Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fiemap: use kernel-doc includes in fiemap docbook

Add some kernel-doc notation to structs in fiemap header files
then pull that into Documentation/filesystems/fiemap.rst
instead of duplicating the header file structs in fiemap.rst.
This helps to future-proof fiemap.rst against struct changes.

Add missing flags documentation from header files into fiemap.rst
for FIEMAP_FLAG_CACHE and FIEMAP_EXTENT_SHARED.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20241121011352.201907-1-rdunlap@infradead.org
Cc: Christoph Hellwig <hch@lst.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Randy Dunlap and committed by
Christian Brauner
135ec43e c7175957

+57 -51
+13 -32
Documentation/filesystems/fiemap.rst
··· 12 12 Request Basics 13 13 -------------- 14 14 15 - A fiemap request is encoded within struct fiemap:: 15 + A fiemap request is encoded within struct fiemap: 16 16 17 - struct fiemap { 18 - __u64 fm_start; /* logical offset (inclusive) at 19 - * which to start mapping (in) */ 20 - __u64 fm_length; /* logical length of mapping which 21 - * userspace cares about (in) */ 22 - __u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */ 23 - __u32 fm_mapped_extents; /* number of extents that were 24 - * mapped (out) */ 25 - __u32 fm_extent_count; /* size of fm_extents array (in) */ 26 - __u32 fm_reserved; 27 - struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */ 28 - }; 29 - 17 + .. kernel-doc:: include/uapi/linux/fiemap.h 18 + :identifiers: fiemap 30 19 31 20 fm_start, and fm_length specify the logical range within the file 32 21 which the process would like mappings for. Extents returned mirror ··· 49 60 If this flag is set, the extents returned will describe the inodes 50 61 extended attribute lookup tree, instead of its data tree. 51 62 63 + FIEMAP_FLAG_CACHE 64 + This flag requests caching of the extents. 52 65 53 66 Extent Mapping 54 67 -------------- ··· 68 77 flag set (see the next section on extent flags). 69 78 70 79 Each extent is described by a single fiemap_extent structure as 71 - returned in fm_extents:: 80 + returned in fm_extents: 72 81 73 - struct fiemap_extent { 74 - __u64 fe_logical; /* logical offset in bytes for the start of 75 - * the extent */ 76 - __u64 fe_physical; /* physical offset in bytes for the start 77 - * of the extent */ 78 - __u64 fe_length; /* length in bytes for the extent */ 79 - __u64 fe_reserved64[2]; 80 - __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ 81 - __u32 fe_reserved[3]; 82 - }; 82 + .. kernel-doc:: include/uapi/linux/fiemap.h 83 + :identifiers: fiemap_extent 83 84 84 85 All offsets and lengths are in bytes and mirror those on disk. It is valid 85 86 for an extents logical offset to start before the request or its logical ··· 158 175 userspace would be highly inefficient, the kernel will try to merge most 159 176 adjacent blocks into 'extents'. 160 177 178 + FIEMAP_EXTENT_SHARED 179 + This flag is set to request that space be shared with other files. 161 180 162 181 VFS -> File System Implementation 163 182 --------------------------------- ··· 176 191 u64 len); 177 192 178 193 ->fiemap is passed struct fiemap_extent_info which describes the 179 - fiemap request:: 194 + fiemap request: 180 195 181 - struct fiemap_extent_info { 182 - unsigned int fi_flags; /* Flags as passed from user */ 183 - unsigned int fi_extents_mapped; /* Number of mapped extents */ 184 - unsigned int fi_extents_max; /* Size of fiemap_extent array */ 185 - struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent array */ 186 - }; 196 + .. kernel-doc:: include/linux/fiemap.h 197 + :identifiers: fiemap_extent_info 187 198 188 199 It is intended that the file system should not need to access any of this 189 200 structure directly. Filesystem handlers should be tolerant to signals and return
+11 -5
include/linux/fiemap.h
··· 5 5 #include <uapi/linux/fiemap.h> 6 6 #include <linux/fs.h> 7 7 8 + /** 9 + * struct fiemap_extent_info - fiemap request to a filesystem 10 + * @fi_flags: Flags as passed from user 11 + * @fi_extents_mapped: Number of mapped extents 12 + * @fi_extents_max: Size of fiemap_extent array 13 + * @fi_extents_start: Start of fiemap_extent array 14 + */ 8 15 struct fiemap_extent_info { 9 - unsigned int fi_flags; /* Flags as passed from user */ 10 - unsigned int fi_extents_mapped; /* Number of mapped extents */ 11 - unsigned int fi_extents_max; /* Size of fiemap_extent array */ 12 - struct fiemap_extent __user *fi_extents_start; /* Start of 13 - fiemap_extent array */ 16 + unsigned int fi_flags; 17 + unsigned int fi_extents_mapped; 18 + unsigned int fi_extents_max; 19 + struct fiemap_extent __user *fi_extents_start; 14 20 }; 15 21 16 22 int fiemap_prep(struct inode *inode, struct fiemap_extent_info *fieinfo,
+33 -14
include/uapi/linux/fiemap.h
··· 14 14 15 15 #include <linux/types.h> 16 16 17 + /** 18 + * struct fiemap_extent - description of one fiemap extent 19 + * @fe_logical: byte offset of the extent in the file 20 + * @fe_physical: byte offset of extent on disk 21 + * @fe_length: length in bytes for this extent 22 + * @fe_flags: FIEMAP_EXTENT_* flags for this extent 23 + */ 17 24 struct fiemap_extent { 18 - __u64 fe_logical; /* logical offset in bytes for the start of 19 - * the extent from the beginning of the file */ 20 - __u64 fe_physical; /* physical offset in bytes for the start 21 - * of the extent from the beginning of the disk */ 22 - __u64 fe_length; /* length in bytes for this extent */ 25 + __u64 fe_logical; 26 + __u64 fe_physical; 27 + __u64 fe_length; 28 + /* private: */ 23 29 __u64 fe_reserved64[2]; 24 - __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ 30 + /* public: */ 31 + __u32 fe_flags; 32 + /* private: */ 25 33 __u32 fe_reserved[3]; 26 34 }; 27 35 36 + /** 37 + * struct fiemap - file extent mappings 38 + * @fm_start: byte offset (inclusive) at which to start mapping (in) 39 + * @fm_length: logical length of mapping which userspace wants (in) 40 + * @fm_flags: FIEMAP_FLAG_* flags for request (in/out) 41 + * @fm_mapped_extents: number of extents that were mapped (out) 42 + * @fm_extent_count: size of fm_extents array (in) 43 + * @fm_extents: array of mapped extents (out) 44 + */ 28 45 struct fiemap { 29 - __u64 fm_start; /* logical offset (inclusive) at 30 - * which to start mapping (in) */ 31 - __u64 fm_length; /* logical length of mapping which 32 - * userspace wants (in) */ 33 - __u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */ 34 - __u32 fm_mapped_extents;/* number of extents that were mapped (out) */ 35 - __u32 fm_extent_count; /* size of fm_extents array (in) */ 46 + __u64 fm_start; 47 + __u64 fm_length; 48 + __u32 fm_flags; 49 + __u32 fm_mapped_extents; 50 + __u32 fm_extent_count; 51 + /* private: */ 36 52 __u32 fm_reserved; 37 - struct fiemap_extent fm_extents[]; /* array of mapped extents (out) */ 53 + /* public: */ 54 + struct fiemap_extent fm_extents[]; 38 55 }; 39 56 40 57 #define FIEMAP_MAX_OFFSET (~0ULL) 41 58 59 + /* flags used in fm_flags: */ 42 60 #define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */ 43 61 #define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */ 44 62 #define FIEMAP_FLAG_CACHE 0x00000004 /* request caching of the extents */ 45 63 46 64 #define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR) 47 65 66 + /* flags used in fe_flags: */ 48 67 #define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */ 49 68 #define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */ 50 69 #define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.