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

docs: filesystems: convert fiemap.txt to ReST

- Add a SPDX header;
- Some whitespace fixes and new line breaks;
- Mark literal blocks as such;
- Add it to filesystems/index.rst.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/9182d49ffca7a0580e32ab24ecf5f8cc8d8924af.1588021877.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
e6f7df74 b31763cf

+69 -65
+68 -65
Documentation/filesystems/fiemap.txt Documentation/filesystems/fiemap.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 1 3 ============ 2 4 Fiemap Ioctl 3 5 ============ ··· 12 10 Request Basics 13 11 -------------- 14 12 15 - A fiemap request is encoded within struct fiemap: 13 + A fiemap request is encoded within struct fiemap:: 16 14 17 - struct fiemap { 15 + struct fiemap { 18 16 __u64 fm_start; /* logical offset (inclusive) at 19 17 * which to start mapping (in) */ 20 18 __u64 fm_length; /* logical length of mapping which ··· 25 23 __u32 fm_extent_count; /* size of fm_extents array (in) */ 26 24 __u32 fm_reserved; 27 25 struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */ 28 - }; 26 + }; 29 27 30 28 31 29 fm_start, and fm_length specify the logical range within the file ··· 53 51 54 52 The following flags can be set in fm_flags: 55 53 56 - * FIEMAP_FLAG_SYNC 57 - If this flag is set, the kernel will sync the file before mapping extents. 54 + FIEMAP_FLAG_SYNC 55 + If this flag is set, the kernel will sync the file before mapping extents. 58 56 59 - * FIEMAP_FLAG_XATTR 60 - If this flag is set, the extents returned will describe the inodes 61 - extended attribute lookup tree, instead of its data tree. 57 + FIEMAP_FLAG_XATTR 58 + If this flag is set, the extents returned will describe the inodes 59 + extended attribute lookup tree, instead of its data tree. 62 60 63 61 64 62 Extent Mapping ··· 77 75 flag set (see the next section on extent flags). 78 76 79 77 Each extent is described by a single fiemap_extent structure as 80 - returned in fm_extents. 78 + returned in fm_extents:: 81 79 82 - struct fiemap_extent { 83 - __u64 fe_logical; /* logical offset in bytes for the start of 84 - * the extent */ 85 - __u64 fe_physical; /* physical offset in bytes for the start 86 - * of the extent */ 87 - __u64 fe_length; /* length in bytes for the extent */ 88 - __u64 fe_reserved64[2]; 89 - __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ 90 - __u32 fe_reserved[3]; 91 - }; 80 + struct fiemap_extent { 81 + __u64 fe_logical; /* logical offset in bytes for the start of 82 + * the extent */ 83 + __u64 fe_physical; /* physical offset in bytes for the start 84 + * of the extent */ 85 + __u64 fe_length; /* length in bytes for the extent */ 86 + __u64 fe_reserved64[2]; 87 + __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ 88 + __u32 fe_reserved[3]; 89 + }; 92 90 93 91 All offsets and lengths are in bytes and mirror those on disk. It is valid 94 92 for an extents logical offset to start before the request or its logical ··· 116 114 data. Note that the opposite is not true - it would be valid for 117 115 FIEMAP_EXTENT_NOT_ALIGNED to appear alone. 118 116 119 - * FIEMAP_EXTENT_LAST 120 - This is generally the last extent in the file. A mapping attempt past 121 - this extent may return nothing. Some implementations set this flag to 122 - indicate this extent is the last one in the range queried by the user 123 - (via fiemap->fm_length). 117 + FIEMAP_EXTENT_LAST 118 + This is generally the last extent in the file. A mapping attempt past 119 + this extent may return nothing. Some implementations set this flag to 120 + indicate this extent is the last one in the range queried by the user 121 + (via fiemap->fm_length). 124 122 125 - * FIEMAP_EXTENT_UNKNOWN 126 - The location of this extent is currently unknown. This may indicate 127 - the data is stored on an inaccessible volume or that no storage has 128 - been allocated for the file yet. 123 + FIEMAP_EXTENT_UNKNOWN 124 + The location of this extent is currently unknown. This may indicate 125 + the data is stored on an inaccessible volume or that no storage has 126 + been allocated for the file yet. 129 127 130 - * FIEMAP_EXTENT_DELALLOC 131 - - This will also set FIEMAP_EXTENT_UNKNOWN. 132 - Delayed allocation - while there is data for this extent, its 133 - physical location has not been allocated yet. 128 + FIEMAP_EXTENT_DELALLOC 129 + This will also set FIEMAP_EXTENT_UNKNOWN. 134 130 135 - * FIEMAP_EXTENT_ENCODED 136 - This extent does not consist of plain filesystem blocks but is 137 - encoded (e.g. encrypted or compressed). Reading the data in this 138 - extent via I/O to the block device will have undefined results. 131 + Delayed allocation - while there is data for this extent, its 132 + physical location has not been allocated yet. 133 + 134 + FIEMAP_EXTENT_ENCODED 135 + This extent does not consist of plain filesystem blocks but is 136 + encoded (e.g. encrypted or compressed). Reading the data in this 137 + extent via I/O to the block device will have undefined results. 139 138 140 139 Note that it is *always* undefined to try to update the data 141 140 in-place by writing to the indicated location without the ··· 148 145 clear; user applications must not try reading or writing to the 149 146 filesystem via the block device under any other circumstances. 150 147 151 - * FIEMAP_EXTENT_DATA_ENCRYPTED 152 - - This will also set FIEMAP_EXTENT_ENCODED 153 - The data in this extent has been encrypted by the file system. 148 + FIEMAP_EXTENT_DATA_ENCRYPTED 149 + This will also set FIEMAP_EXTENT_ENCODED 150 + The data in this extent has been encrypted by the file system. 154 151 155 - * FIEMAP_EXTENT_NOT_ALIGNED 156 - Extent offsets and length are not guaranteed to be block aligned. 152 + FIEMAP_EXTENT_NOT_ALIGNED 153 + Extent offsets and length are not guaranteed to be block aligned. 157 154 158 - * FIEMAP_EXTENT_DATA_INLINE 155 + FIEMAP_EXTENT_DATA_INLINE 159 156 This will also set FIEMAP_EXTENT_NOT_ALIGNED 160 - Data is located within a meta data block. 157 + Data is located within a meta data block. 161 158 162 - * FIEMAP_EXTENT_DATA_TAIL 159 + FIEMAP_EXTENT_DATA_TAIL 163 160 This will also set FIEMAP_EXTENT_NOT_ALIGNED 164 - Data is packed into a block with data from other files. 161 + Data is packed into a block with data from other files. 165 162 166 - * FIEMAP_EXTENT_UNWRITTEN 167 - Unwritten extent - the extent is allocated but its data has not been 168 - initialized. This indicates the extent's data will be all zero if read 169 - through the filesystem but the contents are undefined if read directly from 170 - the device. 163 + FIEMAP_EXTENT_UNWRITTEN 164 + Unwritten extent - the extent is allocated but its data has not been 165 + initialized. This indicates the extent's data will be all zero if read 166 + through the filesystem but the contents are undefined if read directly from 167 + the device. 171 168 172 - * FIEMAP_EXTENT_MERGED 173 - This will be set when a file does not support extents, i.e., it uses a block 174 - based addressing scheme. Since returning an extent for each block back to 175 - userspace would be highly inefficient, the kernel will try to merge most 176 - adjacent blocks into 'extents'. 169 + FIEMAP_EXTENT_MERGED 170 + This will be set when a file does not support extents, i.e., it uses a block 171 + based addressing scheme. Since returning an extent for each block back to 172 + userspace would be highly inefficient, the kernel will try to merge most 173 + adjacent blocks into 'extents'. 177 174 178 175 179 176 VFS -> File System Implementation ··· 182 179 File systems wishing to support fiemap must implement a ->fiemap callback on 183 180 their inode_operations structure. The fs ->fiemap call is responsible for 184 181 defining its set of supported fiemap flags, and calling a helper function on 185 - each discovered extent: 182 + each discovered extent:: 186 183 187 - struct inode_operations { 184 + struct inode_operations { 188 185 ... 189 186 190 187 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, 191 188 u64 len); 192 189 193 190 ->fiemap is passed struct fiemap_extent_info which describes the 194 - fiemap request: 191 + fiemap request:: 195 192 196 - struct fiemap_extent_info { 193 + struct fiemap_extent_info { 197 194 unsigned int fi_flags; /* Flags as passed from user */ 198 195 unsigned int fi_extents_mapped; /* Number of mapped extents */ 199 196 unsigned int fi_extents_max; /* Size of fiemap_extent array */ 200 197 struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent array */ 201 - }; 198 + }; 202 199 203 200 It is intended that the file system should not need to access any of this 204 201 structure directly. Filesystem handlers should be tolerant to signals and return ··· 206 203 207 204 208 205 Flag checking should be done at the beginning of the ->fiemap callback via the 209 - fiemap_check_flags() helper: 206 + fiemap_check_flags() helper:: 210 207 211 - int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags); 208 + int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags); 212 209 213 210 The struct fieinfo should be passed in as received from ioctl_fiemap(). The 214 211 set of fiemap flags which the fs understands should be passed via fs_flags. If ··· 219 216 220 217 221 218 For each extent in the request range, the file system should call 222 - the helper function, fiemap_fill_next_extent(): 219 + the helper function, fiemap_fill_next_extent():: 223 220 224 - int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, 225 - u64 phys, u64 len, u32 flags, u32 dev); 221 + int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, 222 + u64 phys, u64 len, u32 flags, u32 dev); 226 223 227 224 fiemap_fill_next_extent() will use the passed values to populate the 228 225 next free extent in the fm_extents array. 'General' extent flags will
+1
Documentation/filesystems/index.rst
··· 26 26 directory-locking 27 27 devpts 28 28 dnotify 29 + fiemap 29 30 30 31 automount-support 31 32