Documentation: add initial iomap kdoc
Subsystems (4)
PATCH 1/1 Documentation: add initial iomap kdoc
To help with iomap adoption / porting I set out the goal to try to help improve the iomap documentation and get general guidance for filesystem conversions over from buffer-head in time for this year's LSFMM. The end results thanks to the review of Darrick, Christoph and others is on the kernelnewbies wiki [0].
This brings this forward a relevant subset of that documentation to the kernel in kdoc format and also kdoc'ifies the existing documentation on iomap.h.
Tested with:
make htmldocs SPHINXDIRS="filesystems"
Then looking at the docs produced on:
Documentation/output/filesystems/iomap.html
[0] https://kernelnewbies.org/KernelProjects/iomap
--- Documentation/filesystems/index.rst | 1 + Documentation/filesystems/iomap.rst | 234 ++++++++++++++++++++ include/linux/iomap.h | 324 +++++++++++++++++----------- 3 files changed, 437 insertions(+), 122 deletions(-) create mode 100644 Documentation/filesystems/iomap.rst
Documentation/filesystems/index.rst +1 -0
@@ -34,6 +34,7 @@ algorithms work. seq_file sharedsubtree idmappings + iomap automount-support
Documentation/filesystems/iomap.rst new file +234 -0
234 lines not on this page · raw message
include/linux/iomap.h +202 -122
421 lines not on this page · raw message
Signature · 1 line
2.39.2
Documentation/filesystems/iomap.rst line 29
Quoted 2 lines
Documentation/filesystems/iomap.rst new file +2
-0+**iomap** allows filesystems to query storage media for data using *byte ranges*. Since block +mapping are provided for a *byte ranges* for cache data in memory, in the page cache, naturally
Without fixing your line length I can't even read this mess..
Quoted 4 lines · Christoph Hellwig
Documentation/filesystems/iomap.rst line 29
Quoted 2 lines
Documentation/filesystems/iomap.rst new file +2
-0+**iomap** allows filesystems to query storage media for data using *byte ranges*. Since block +mapping are provided for a *byte ranges* for cache data in memory, in the page cache, naturallyWithout fixing your line length I can't even read this mess..
I thought we are at 100?
Luis
Quoted 7 lines · Luis Chamberlain
Quoted 4 lines · Christoph Hellwig
Documentation/filesystems/iomap.rst line 29
Quoted 2 lines
Documentation/filesystems/iomap.rst new file +2
-0+**iomap** allows filesystems to query storage media for data using *byte ranges*. Since block +mapping are provided for a *byte ranges* for cache data in memory, in the page cache, naturallyWithout fixing your line length I can't even read this mess..
I thought we are at 100?
Ony for individual lines and when it improves readability (whatever that means). But multiple to long lines, especially full of text are completely unreadable in a terminal.
Jonathan Corbet
maintainerQuoted 7 lines · Christoph Hellwig
Quoted 6 lines · Luis Chamberlain
Quoted 4 lines · Christoph Hellwig
Documentation/filesystems/iomap.rst line 29
Quoted 2 lines
Documentation/filesystems/iomap.rst new file +2
-0+**iomap** allows filesystems to query storage media for data using *byte ranges*. Since block +mapping are provided for a *byte ranges* for cache data in memory, in the page cache, naturallyWithout fixing your line length I can't even read this mess..
Quoted 5 lines
Quoted 1 line
I thought we are at 100?
Ony for individual lines and when it improves readability (whatever that means). But multiple to long lines, especially full of text are completely unreadable in a terminal.
Long text lines are definitely unfriendly to readers in general, so I think we should absolutely avoid them in text - where they are unnecessary to begin with. Something to fix for the next iteration.
I'm glad to see this document, though; it's definitely a big gap in our current coverage.
Thanks,
jon
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Luis Chamberlain
Quoted 4 lines · Christoph Hellwig
Documentation/filesystems/iomap.rst line 29
Quoted 2 lines
Documentation/filesystems/iomap.rst new file +2
-0+**iomap** allows filesystems to query storage media for data using *byte ranges*. Since block +mapping are provided for a *byte ranges* for cache data in memory, in the page cache, naturallyWithout fixing your line length I can't even read this mess..
Quoted 5 lines
Quoted 1 line
I thought we are at 100?
Ony for individual lines and when it improves readability (whatever that means). But multiple to long lines, especially full of text are completely unreadable in a terminal.
For C code, if you have really deeply nested code, sometimes it's better to have some lines which are longer than to have gratuitous line break just to keep everything under 72-76 characters.
But if you are writing a block of text, and you are expecting people to read it in a terminal window, I think it is adviseable to wrap at 72 characters. In fact, some will advise wrapping earlier than that, to better aid comprehension. For example:
"Optimal line length or column width for body text is 40–70 characters. When people read, their eyes jump across a line of text, pausing momentarily to take in groups of three or four words. Studies have shown that readers can make only three or four of these jumps (or saccades) per line before reading becomes tiring.
Too long lines with too many words also make it harder for the eyes to find the correct spot when they sweep back to the left to pick up the next line of text. To maintain readability, it is imperative to use moderate line lengths within the range of 40–70 characters.
Do not set normally sized body text in a single column across a 8.5 by 11 inch page. If you do that, the result will greatly exceed 70 characters, reading efficiency will be significantly reduced, and your readers’ attention will be easily lost.
Two column layouts are the best solution for achieving optimal body text column widths on American letter size paper. If that is not practical and using only one column is necessary, then be sure to use large side margins in order to bring the line length as close as possible to 70 characters or less."
Cheers,
- Ted
Review
Quoted 9 lines · Luis Chamberlain
+..
(quoted diff) +8
-0+ Mapping of heading styles within this document: + Heading 1 uses "====" above and below + Heading 2 uses "====" + Heading 3 uses "----" + Heading 4 uses "````" + Heading 5 uses "^^^^" + Heading 6 uses "~~~~" + Heading 7 uses "...."
Everyone can distinguished those heading levels without telling them.
Review
Quoted 3 lines
(quoted diff) +3
-0+ + Sections are manually numbered because apparently that's what everyone + does in the kernel.
I don't see any section numbering here (forget to add one?).
Quoted 2 lines
+.. contents:: Table of Contents
+ :local:
I see the toctree before actual doc title. Maybe move down toctree below it?
Review
Quoted 5 lines
(quoted diff) +5
-0+You can call into **iomap** for reading, ie, dealing with the filesystems's +``struct file_operations``: + + * ``struct file_operations.read_iter()``: note that depending on the type of read your filesystem + might use ``iomap_dio_rw()`` for direct IO, generic_file_read_iter() for buffered IO and
Try to be consistent on inlining code keywords (identifiers, function names, etc).
Review
Quoted 9 lines
(quoted diff) +9
-0+Testing Direct IO +================= + +Other than fstests you can use LTP's dio, however this tests is limited as it does not test stale +data. + +{{{ +./runltp -f dio -d /mnt1/scratch/tmp/ +}}}
Use literal code block for above shell snippet:
---- >8 ----
Documentation/filesystems/iomap.rst +3 -3
@@ -213,9 +213,9 @@ Testing Direct IO Other than fstests you can use LTP's dio, however this tests is limited as it does not test stale data. -{{{ -./runltp -f dio -d /mnt1/scratch/tmp/ -}}} +:: + + ./runltp -f dio -d /mnt1/scratch/tmp/ Known issues and future improvements ====================================
Review
Quoted 5 lines
(quoted diff) +5
-0+References +========== + + * `Presentation on iomap evolution`<https://docs.google.com/presentation/d/e/2PACX-1vSN4TmhiTu1c6HNv6_gJZFqbFZpbF7GkABllSwJw5iLnSYKkkO-etQJ3AySYEbgJA/pub?start=true&loop=false&delayms=3000&slide=id.g189cfd05063_0_185>` + * `LWN review on deprecating buffer-heads <https://lwn.net/Articles/930173/>`
I don't see clickable hyperlinks on above external references, so I have to fix them up:
---- >8 ----
Documentation/filesystems/iomap.rst +2 -2
@@ -230,5 +230,5 @@ We try to document known issues that folks should be aware of with **iomap** her References ========== - * `Presentation on iomap evolution`<https://docs.google.com/presentation/d/e/2PACX-1vSN4TmhiTu1c6HNv6_gJZFqbFZpbF7GkABllSwJw5iLnSYKkkO-etQJ3AySYEbgJA/pub?start=true&loop=false&delayms=3000&slide=id.g189cfd05063_0_185>` - * `LWN review on deprecating buffer-heads <https://lwn.net/Articles/930173/>` + * `Presentation on iomap evolution <https://docs.google.com/presentation/d/e/2PACX-1vSN4TmhiTu1c6HNv6_gJZFqbFZpbF7GkABllSwJw5iLnSYKkkO-etQJ3AySYEbgJA/pub?start=true&loop=false&delayms=3000&slide=id.g189cfd05063_0_185>`_ + * `LWN review on deprecating buffer-heads <https://lwn.net/Articles/930173/>`_
include/linux/iomap.h +1 -1
@@ -25,7 +25,7 @@* * Block mapping provides a mapping between data cached in memory and the location on persistent * storage where that data lives. `LWN has an great review of the old buffer-heads block-mapping and -* why they are inefficient <https://lwn.net/Articles/930173/>`, since the inception of Linux. +* why they are inefficient <https://lwn.net/Articles/930173/>`_, since the inception of Linux. * Since **buffer-heads** work on a 512-byte block based paradigm, it creates an overhead for modern * storage media which no longer necessarily works only on 512-blocks. iomap is flexible * providing block ranges in *bytes*. iomap, with the support of folios, provides a modern
Quoted 29 lines
(quoted diff) +12
-12-/* - * Flags reported by the file system from iomap_begin: +/** + * DOC: Flags reported by the file system from iomap_begin * - * IOMAP_F_NEW indicates that the blocks have been newly allocated and need - * zeroing for areas that no data is copied to. + * * IOMAP_F_NEW: indicates that the blocks have been newly allocated and need + * zeroing for areas that no data is copied to. * - * IOMAP_F_DIRTY indicates the inode has uncommitted metadata needed to access - * written data and requires fdatasync to commit them to persistent storage. - * This needs to take into account metadata changes that *may* be made at IO - * completion, such as file size updates from direct IO. + * * IOMAP_F_DIRTY: indicates the inode has uncommitted metadata needed to access + * written data and requires fdatasync to commit them to persistent storage. + * This needs to take into account metadata changes that *may* be made at IO + * completion, such as file size updates from direct IO. * - * IOMAP_F_SHARED indicates that the blocks are shared, and will need to be - * unshared as part a write. + * * IOMAP_F_SHARED: indicates that the blocks are shared, and will need to be + * unshared as part a write. * - * IOMAP_F_MERGED indicates that the iomap contains the merge of multiple block - * mappings. + * * IOMAP_F_MERGED: indicates that the iomap contains the merge of multiple block + * mappings. *
Review
Quoted 10 lines
(quoted diff) +4
-4- * IOMAP_F_BUFFER_HEAD indicates that the file system requires the use of - * buffer heads for this mapping. + * * IOMAP_F_BUFFER_HEAD: indicates that the file system requires the use of + * buffer heads for this mapping. * - * IOMAP_F_XATTR indicates that the iomap is for an extended attribute extent - * rather than a file data extent. + * * IOMAP_F_XATTR: indicates that the iomap is for an extended attribute extent + * rather than a file data extent. */
Why don't use kernel-doc comments to describe flags?
Quoted 17 lines
+/**
+ * structiomap_folio_ops- buffered writes folio folio reference count helpers
+ *
+ * A filesystem can optionally setfolio_opsin a &struct iomap mapping it returns to
+ * override the defaultget_folioandput_foliofor each folio written to. This only applies
+ * to buffered writes as unbuffered writes will not typically have folios associated with them.
+ *
+ * @get_folio: iomap defaults toiomap_get_folio()(which calls__filemap_get_folio()) if the
+ * filesystem did not provide a get folio op.
+ *
+ * @put_folio: whenget_foliosucceeds,put_foliowill always be called to do any cleanup work
+ * necessary.put_foliois responsible for unlocking and putting @folio.
+ *
+ * @iomap_valid: check that the cached iomap still maps correctly to the filesystem's internal
+ * extent map. FS internal extent maps can change while iomap is iterating a cached iomap, so
+ * this hook allows iomap to detect that the iomap needs to be refreshed during a long running
+ * write operation.
Quoted 8 lines
+ *
+ * The filesystem can store internal state (e.g. a sequence number) iniomap->validity_cookie
+ * when the iomap is first mapped to be able to detect changes between mapping time and whenever
+ * .iomap_valid() is called.
+ *
+ * This is called with the folio over the specified file position held locked by the iomap code.
+ * This is useful for filesystems that have dynamic mappings (e.g. anything other than zonefs).
+ * An example reason as to why this is necessary is writeback doesn't take the vfs locks.
Nice, this one has kernel-doc.
Thanks for review.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Randy Dunlap
reviewerQuoted 37 lines · Bagas Sanjaya
Quoted 29 lines
+/**
+ * DOC: Flags reported by the file system fromiomap_begin
*
- *IOMAP_F_NEWindicates that the blocks have been newly allocated and need
- * zeroing for areas that no data is copied to.
+ * *IOMAP_F_NEW: indicates that the blocks have been newly allocated and need
+ * zeroing for areas that no data is copied to.
*
- *IOMAP_F_DIRTYindicates the inode has uncommitted metadata needed to access
- * written data and requires fdatasync to commit them to persistent storage.
- * This needs to take into account metadata changes that *may* be made at IO
- * completion, such as file size updates from direct IO.
+ * *IOMAP_F_DIRTY: indicates the inode has uncommitted metadata needed to access
+ * written data and requires fdatasync to commit them to persistent storage.
+ * This needs to take into account metadata changes that *may* be made at IO
+ * completion, such as file size updates from direct IO.
*
- *IOMAP_F_SHAREDindicates that the blocks are shared, and will need to be
- * unshared as part a write.
+ * *IOMAP_F_SHARED: indicates that the blocks are shared, and will need to be
+ * unshared as part a write.
*
- *IOMAP_F_MERGEDindicates that the iomap contains the merge of multiple block
- * mappings.
+ * *IOMAP_F_MERGED: indicates that the iomap contains the merge of multiple block
+ * mappings.
*
- *IOMAP_F_BUFFER_HEADindicates that the file system requires the use of
- * buffer heads for this mapping.Quoted 8 lines
+ * *
IOMAP_F_BUFFER_HEAD: indicates that the file system requires the use of
+ * buffer heads for this mapping.
*
- *IOMAP_F_XATTRindicates that the iomap is for an extended attribute extent
- * rather than a file data extent.
+ * *IOMAP_F_XATTR: indicates that the iomap is for an extended attribute extent
+ * rather than a file data extent.
*/
Quoted 2 lines
Why don't use kernel-doc comments to describe flags?
Because kernel-doc handles functions, structs, unions, and enums. Not defines.
Signature · 1 line
~Randy
Quoted 40 lines · Randy Dunlap
Quoted 37 lines · Bagas Sanjaya
Quoted 37 lines
+/**
+ * DOC: Flags reported by the file system fromiomap_begin
*
- *IOMAP_F_NEWindicates that the blocks have been newly allocated and need
- * zeroing for areas that no data is copied to.
+ * *IOMAP_F_NEW: indicates that the blocks have been newly allocated and need
+ * zeroing for areas that no data is copied to.
*
- *IOMAP_F_DIRTYindicates the inode has uncommitted metadata needed to access
- * written data and requires fdatasync to commit them to persistent storage.
- * This needs to take into account metadata changes that *may* be made at IO
- * completion, such as file size updates from direct IO.
+ * *IOMAP_F_DIRTY: indicates the inode has uncommitted metadata needed to access
+ * written data and requires fdatasync to commit them to persistent storage.
+ * This needs to take into account metadata changes that *may* be made at IO
+ * completion, such as file size updates from direct IO.
*
- *IOMAP_F_SHAREDindicates that the blocks are shared, and will need to be
- * unshared as part a write.
+ * *IOMAP_F_SHARED: indicates that the blocks are shared, and will need to be
+ * unshared as part a write.
*
- *IOMAP_F_MERGEDindicates that the iomap contains the merge of multiple block
- * mappings.
+ * *IOMAP_F_MERGED: indicates that the iomap contains the merge of multiple block
+ * mappings.
*
- *IOMAP_F_BUFFER_HEADindicates that the file system requires the use of
- * buffer heads for this mapping.
+ * *IOMAP_F_BUFFER_HEAD: indicates that the file system requires the use of
+ * buffer heads for this mapping.
*
- *IOMAP_F_XATTRindicates that the iomap is for an extended attribute extent
- * rather than a file data extent.
+ * *IOMAP_F_XATTR: indicates that the iomap is for an extended attribute extent
+ * rather than a file data extent.
*/
Quoted 5 lines
Quoted 2 lines
Why don't use kernel-doc comments to describe flags?
Because kernel-doc handles functions, structs, unions, and enums. Not defines.
So perhaps that should be fixed first?
I seriously dislike the implication here that we should accept poorly/inconsistently written comments and code just to work around deficiencies in documentation tooling.
Either modify the code to work cleanly and consistently with the tooling (e.g. change the code to use enums rather than #defines), or fix the tools that don't work with macro definitions in a way that matches the existing code documentation standards.
Forcing developers, reviewers and maintainers to understand, accept and then maintain inconsistent crap in the code just because some tool they never use is deficient is pretty much my definition of an unacceptible engineering process.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Randy Dunlap
reviewerHi Dave,
Quoted 58 lines · Dave Chinner
Quoted 40 lines · Randy Dunlap
Quoted 37 lines · Bagas Sanjaya
Quoted 37 lines
+/**
+ * DOC: Flags reported by the file system fromiomap_begin
*
- *IOMAP_F_NEWindicates that the blocks have been newly allocated and need
- * zeroing for areas that no data is copied to.
+ * *IOMAP_F_NEW: indicates that the blocks have been newly allocated and need
+ * zeroing for areas that no data is copied to.
*
- *IOMAP_F_DIRTYindicates the inode has uncommitted metadata needed to access
- * written data and requires fdatasync to commit them to persistent storage.
- * This needs to take into account metadata changes that *may* be made at IO
- * completion, such as file size updates from direct IO.
+ * *IOMAP_F_DIRTY: indicates the inode has uncommitted metadata needed to access
+ * written data and requires fdatasync to commit them to persistent storage.
+ * This needs to take into account metadata changes that *may* be made at IO
+ * completion, such as file size updates from direct IO.
*
- *IOMAP_F_SHAREDindicates that the blocks are shared, and will need to be
- * unshared as part a write.
+ * *IOMAP_F_SHARED: indicates that the blocks are shared, and will need to be
+ * unshared as part a write.
*
- *IOMAP_F_MERGEDindicates that the iomap contains the merge of multiple block
- * mappings.
+ * *IOMAP_F_MERGED: indicates that the iomap contains the merge of multiple block
+ * mappings.
*
- *IOMAP_F_BUFFER_HEADindicates that the file system requires the use of
- * buffer heads for this mapping.
+ * *IOMAP_F_BUFFER_HEAD: indicates that the file system requires the use of
+ * buffer heads for this mapping.
*
- *IOMAP_F_XATTRindicates that the iomap is for an extended attribute extent
- * rather than a file data extent.
+ * *IOMAP_F_XATTR: indicates that the iomap is for an extended attribute extent
+ * rather than a file data extent.
*/Quoted 5 lines
Quoted 2 lines
Why don't use kernel-doc comments to describe flags?
Because kernel-doc handles functions, structs, unions, and enums. Not defines.
So perhaps that should be fixed first?
I seriously dislike the implication here that we should accept poorly/inconsistently written comments and code just to work around deficiencies in documentation tooling.
Either modify the code to work cleanly and consistently with the tooling (e.g. change the code to use enums rather than #defines), or fix the tools that don't work with macro definitions in a way that matches the existing code documentation standards.
Quoted 4 lines
Forcing developers, reviewers and maintainers to understand, accept and then maintain inconsistent crap in the code just because some tool they never use is deficient is pretty much my definition of an unacceptible engineering process.
I started looking into this. It looks like Mauro added more support to scripts/kernel-doc for typedefs and macros while I wasn't looking. I don't know how well it works, but it's not clear to me how we would want this to look.
For example, take the first set of defines from <linux/iomap.h> that Luis modified:
/*
* Types of block ranges for iomap mappings:
*/
#define IOMAP_HOLE 0 /* no blocks allocated, need allocation */
#define IOMAP_DELALLOC 1 /* delayed allocation blocks */
#define IOMAP_MAPPED 2 /* blocks allocated at @addr */
#define IOMAP_UNWRITTEN 3 /* blocks allocated at @addr in unwritten state */
#define IOMAP_INLINE 4 /* data inline in the inode */
and Luis changed that to:
/**
* DOC: iomap block ranges types
*
* * IOMAP_HOLE - no blocks allocated, need allocation
* * IOMAP_DELALLOC - delayed allocation blocks
* * IOMAP_MAPPED - blocks allocated at @addr
* * IOMAP_UNWRITTEN - blocks allocated at @addr in unwritten state
* * IOMAP_INLINE - data inline in the inode
*/
How would we want that to look? How would we express it in kernel-doc format? Currently it would have to be one macro at a time I think.
/*
* Types of block ranges for iomap mappings:
*/
/**
* IOMAP_HOLE - no blocks allocated, need allocation
*/
#define IOMAP_HOLE 0
/**
* IOMAP_DELALLOC - delayed allocation blocks
*/
#define IOMAP_DELALLOC 1
/**
* IOMAP_MAPPED - blocks allocated at @addr
*/
#define IOMAP_MAPPED 2
/**
* IOMAP_UNWRITTEN - blocks allocated at @addr in unwritten state */
#define IOMAP_UNWRITTEN 3
/**
* IOMAP_INLINE - data inline in the inode
*/
#define IOMAP_INLINE 4
That's ugly to my eyes. And it doesn't collect the set of macros together in any manner.
The modification that Luis made looks pretty good to me ATM.
Signature · 1 line
~Randy