Skip to content

Commit 135ec43

Browse files
rddunlapbrauner
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: Christoph Hellwig <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jan Kara <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: [email protected] Cc: Matthew Wilcox <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent c717595 commit 135ec43

File tree

3 files changed

+59
-53
lines changed

3 files changed

+59
-53
lines changed

Documentation/filesystems/fiemap.rst

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,10 @@ returns a list of extents.
1212
Request Basics
1313
--------------
1414

15-
A fiemap request is encoded within struct fiemap::
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-
};
15+
A fiemap request is encoded within struct fiemap:
2916

17+
.. kernel-doc:: include/uapi/linux/fiemap.h
18+
:identifiers: fiemap
3019

3120
fm_start, and fm_length specify the logical range within the file
3221
which the process would like mappings for. Extents returned mirror
@@ -60,6 +49,8 @@ FIEMAP_FLAG_XATTR
6049
If this flag is set, the extents returned will describe the inodes
6150
extended attribute lookup tree, instead of its data tree.
6251

52+
FIEMAP_FLAG_CACHE
53+
This flag requests caching of the extents.
6354

6455
Extent Mapping
6556
--------------
@@ -77,18 +68,10 @@ complete the requested range and will not have the FIEMAP_EXTENT_LAST
7768
flag set (see the next section on extent flags).
7869

7970
Each extent is described by a single fiemap_extent structure as
80-
returned in fm_extents::
81-
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-
};
71+
returned in fm_extents:
72+
73+
.. kernel-doc:: include/uapi/linux/fiemap.h
74+
:identifiers: fiemap_extent
9275

9376
All offsets and lengths are in bytes and mirror those on disk. It is valid
9477
for an extents logical offset to start before the request or its logical
@@ -175,6 +158,8 @@ FIEMAP_EXTENT_MERGED
175158
userspace would be highly inefficient, the kernel will try to merge most
176159
adjacent blocks into 'extents'.
177160

161+
FIEMAP_EXTENT_SHARED
162+
This flag is set to request that space be shared with other files.
178163

179164
VFS -> File System Implementation
180165
---------------------------------
@@ -191,14 +176,10 @@ each discovered extent::
191176
u64 len);
192177

193178
->fiemap is passed struct fiemap_extent_info which describes the
194-
fiemap request::
195-
196-
struct fiemap_extent_info {
197-
unsigned int fi_flags; /* Flags as passed from user */
198-
unsigned int fi_extents_mapped; /* Number of mapped extents */
199-
unsigned int fi_extents_max; /* Size of fiemap_extent array */
200-
struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent array */
201-
};
179+
fiemap request:
180+
181+
.. kernel-doc:: include/linux/fiemap.h
182+
:identifiers: fiemap_extent_info
202183

203184
It is intended that the file system should not need to access any of this
204185
structure directly. Filesystem handlers should be tolerant to signals and return

include/linux/fiemap.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55
#include <uapi/linux/fiemap.h>
66
#include <linux/fs.h>
77

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+
*/
815
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;
1420
};
1521

1622
int fiemap_prep(struct inode *inode, struct fiemap_extent_info *fieinfo,

include/uapi/linux/fiemap.h

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,56 @@
1414

1515
#include <linux/types.h>
1616

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+
*/
1724
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: */
2329
__u64 fe_reserved64[2];
24-
__u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
30+
/* public: */
31+
__u32 fe_flags;
32+
/* private: */
2533
__u32 fe_reserved[3];
2634
};
2735

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+
*/
2845
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: */
3652
__u32 fm_reserved;
37-
struct fiemap_extent fm_extents[]; /* array of mapped extents (out) */
53+
/* public: */
54+
struct fiemap_extent fm_extents[];
3855
};
3956

4057
#define FIEMAP_MAX_OFFSET (~0ULL)
4158

59+
/* flags used in fm_flags: */
4260
#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */
4361
#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */
4462
#define FIEMAP_FLAG_CACHE 0x00000004 /* request caching of the extents */
4563

4664
#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
4765

66+
/* flags used in fe_flags: */
4867
#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */
4968
#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */
5069
#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.

0 commit comments

Comments
 (0)