Skip to content

Commit 845295f

Browse files
committed
tools/include: Sync filesystem headers with the kernel sources
To pick up changes from: 0f9ca80 fs: Add initial atomic write support info to statx f9af549 fs: export mount options via statmount() 0a3deb1 fs: Allow listmount() in foreign mount namespace 09b3129 fs: export the mount ns id via statmount d04bccd listmount: allow listing in reverse order bfc69fd fs/procfs: add build ID fetching to PROCMAP_QUERY API ed5d583 fs/procfs: implement efficient VMA querying API for /proc/<pid>/maps This should be used to beautify FS syscall arguments and it addresses these tools/perf build warnings: Warning: Kernel ABI header differences: diff -u tools/include/uapi/linux/stat.h include/uapi/linux/stat.h diff -u tools/perf/trace/beauty/include/uapi/linux/fs.h include/uapi/linux/fs.h diff -u tools/perf/trace/beauty/include/uapi/linux/mount.h include/uapi/linux/mount.h diff -u tools/perf/trace/beauty/include/uapi/linux/stat.h include/uapi/linux/stat.h Please see tools/include/uapi/README for details (it's in the first patch of this series). Cc: Alexander Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jan Kara <[email protected]> Cc: [email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent ed86525 commit 845295f

File tree

4 files changed

+189
-8
lines changed

4 files changed

+189
-8
lines changed

tools/include/uapi/linux/stat.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,15 @@ struct statx {
126126
__u64 stx_mnt_id;
127127
__u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */
128128
__u32 stx_dio_offset_align; /* File offset alignment for direct I/O */
129-
__u64 stx_subvol; /* Subvolume identifier */
130129
/* 0xa0 */
131-
__u64 __spare3[11]; /* Spare space for future expansion */
130+
__u64 stx_subvol; /* Subvolume identifier */
131+
__u32 stx_atomic_write_unit_min; /* Min atomic write unit in bytes */
132+
__u32 stx_atomic_write_unit_max; /* Max atomic write unit in bytes */
133+
/* 0xb0 */
134+
__u32 stx_atomic_write_segments_max; /* Max atomic write segment count */
135+
__u32 __spare1[1];
136+
/* 0xb8 */
137+
__u64 __spare3[9]; /* Spare space for future expansion */
132138
/* 0x100 */
133139
};
134140

@@ -157,6 +163,7 @@ struct statx {
157163
#define STATX_DIOALIGN 0x00002000U /* Want/got direct I/O alignment info */
158164
#define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */
159165
#define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */
166+
#define STATX_WRITE_ATOMIC 0x00010000U /* Want/got atomic_write_* fields */
160167

161168
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
162169

@@ -192,6 +199,7 @@ struct statx {
192199
#define STATX_ATTR_MOUNT_ROOT 0x00002000 /* Root of a mount */
193200
#define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */
194201
#define STATX_ATTR_DAX 0x00200000 /* File is currently in DAX state */
202+
#define STATX_ATTR_WRITE_ATOMIC 0x00400000 /* File supports atomic write operations */
195203

196204

197205
#endif /* _UAPI_LINUX_STAT_H */

tools/perf/trace/beauty/include/uapi/linux/fs.h

Lines changed: 161 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,17 @@ typedef int __bitwise __kernel_rwf_t;
329329
/* per-IO negation of O_APPEND */
330330
#define RWF_NOAPPEND ((__force __kernel_rwf_t)0x00000020)
331331

332+
/* Atomic Write */
333+
#define RWF_ATOMIC ((__force __kernel_rwf_t)0x00000040)
334+
332335
/* mask of flags supported by the kernel */
333336
#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
334-
RWF_APPEND | RWF_NOAPPEND)
337+
RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC)
338+
339+
#define PROCFS_IOCTL_MAGIC 'f'
335340

336341
/* Pagemap ioctl */
337-
#define PAGEMAP_SCAN _IOWR('f', 16, struct pm_scan_arg)
342+
#define PAGEMAP_SCAN _IOWR(PROCFS_IOCTL_MAGIC, 16, struct pm_scan_arg)
338343

339344
/* Bitmasks provided in pm_scan_args masks and reported in page_region.categories. */
340345
#define PAGE_IS_WPALLOWED (1 << 0)
@@ -393,4 +398,158 @@ struct pm_scan_arg {
393398
__u64 return_mask;
394399
};
395400

401+
/* /proc/<pid>/maps ioctl */
402+
#define PROCMAP_QUERY _IOWR(PROCFS_IOCTL_MAGIC, 17, struct procmap_query)
403+
404+
enum procmap_query_flags {
405+
/*
406+
* VMA permission flags.
407+
*
408+
* Can be used as part of procmap_query.query_flags field to look up
409+
* only VMAs satisfying specified subset of permissions. E.g., specifying
410+
* PROCMAP_QUERY_VMA_READABLE only will return both readable and read/write VMAs,
411+
* while having PROCMAP_QUERY_VMA_READABLE | PROCMAP_QUERY_VMA_WRITABLE will only
412+
* return read/write VMAs, though both executable/non-executable and
413+
* private/shared will be ignored.
414+
*
415+
* PROCMAP_QUERY_VMA_* flags are also returned in procmap_query.vma_flags
416+
* field to specify actual VMA permissions.
417+
*/
418+
PROCMAP_QUERY_VMA_READABLE = 0x01,
419+
PROCMAP_QUERY_VMA_WRITABLE = 0x02,
420+
PROCMAP_QUERY_VMA_EXECUTABLE = 0x04,
421+
PROCMAP_QUERY_VMA_SHARED = 0x08,
422+
/*
423+
* Query modifier flags.
424+
*
425+
* By default VMA that covers provided address is returned, or -ENOENT
426+
* is returned. With PROCMAP_QUERY_COVERING_OR_NEXT_VMA flag set, closest
427+
* VMA with vma_start > addr will be returned if no covering VMA is
428+
* found.
429+
*
430+
* PROCMAP_QUERY_FILE_BACKED_VMA instructs query to consider only VMAs that
431+
* have file backing. Can be combined with PROCMAP_QUERY_COVERING_OR_NEXT_VMA
432+
* to iterate all VMAs with file backing.
433+
*/
434+
PROCMAP_QUERY_COVERING_OR_NEXT_VMA = 0x10,
435+
PROCMAP_QUERY_FILE_BACKED_VMA = 0x20,
436+
};
437+
438+
/*
439+
* Input/output argument structured passed into ioctl() call. It can be used
440+
* to query a set of VMAs (Virtual Memory Areas) of a process.
441+
*
442+
* Each field can be one of three kinds, marked in a short comment to the
443+
* right of the field:
444+
* - "in", input argument, user has to provide this value, kernel doesn't modify it;
445+
* - "out", output argument, kernel sets this field with VMA data;
446+
* - "in/out", input and output argument; user provides initial value (used
447+
* to specify maximum allowable buffer size), and kernel sets it to actual
448+
* amount of data written (or zero, if there is no data).
449+
*
450+
* If matching VMA is found (according to criterias specified by
451+
* query_addr/query_flags, all the out fields are filled out, and ioctl()
452+
* returns 0. If there is no matching VMA, -ENOENT will be returned.
453+
* In case of any other error, negative error code other than -ENOENT is
454+
* returned.
455+
*
456+
* Most of the data is similar to the one returned as text in /proc/<pid>/maps
457+
* file, but procmap_query provides more querying flexibility. There are no
458+
* consistency guarantees between subsequent ioctl() calls, but data returned
459+
* for matched VMA is self-consistent.
460+
*/
461+
struct procmap_query {
462+
/* Query struct size, for backwards/forward compatibility */
463+
__u64 size;
464+
/*
465+
* Query flags, a combination of enum procmap_query_flags values.
466+
* Defines query filtering and behavior, see enum procmap_query_flags.
467+
*
468+
* Input argument, provided by user. Kernel doesn't modify it.
469+
*/
470+
__u64 query_flags; /* in */
471+
/*
472+
* Query address. By default, VMA that covers this address will
473+
* be looked up. PROCMAP_QUERY_* flags above modify this default
474+
* behavior further.
475+
*
476+
* Input argument, provided by user. Kernel doesn't modify it.
477+
*/
478+
__u64 query_addr; /* in */
479+
/* VMA starting (inclusive) and ending (exclusive) address, if VMA is found. */
480+
__u64 vma_start; /* out */
481+
__u64 vma_end; /* out */
482+
/* VMA permissions flags. A combination of PROCMAP_QUERY_VMA_* flags. */
483+
__u64 vma_flags; /* out */
484+
/* VMA backing page size granularity. */
485+
__u64 vma_page_size; /* out */
486+
/*
487+
* VMA file offset. If VMA has file backing, this specifies offset
488+
* within the file that VMA's start address corresponds to.
489+
* Is set to zero if VMA has no backing file.
490+
*/
491+
__u64 vma_offset; /* out */
492+
/* Backing file's inode number, or zero, if VMA has no backing file. */
493+
__u64 inode; /* out */
494+
/* Backing file's device major/minor number, or zero, if VMA has no backing file. */
495+
__u32 dev_major; /* out */
496+
__u32 dev_minor; /* out */
497+
/*
498+
* If set to non-zero value, signals the request to return VMA name
499+
* (i.e., VMA's backing file's absolute path, with " (deleted)" suffix
500+
* appended, if file was unlinked from FS) for matched VMA. VMA name
501+
* can also be some special name (e.g., "[heap]", "[stack]") or could
502+
* be even user-supplied with prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME).
503+
*
504+
* Kernel will set this field to zero, if VMA has no associated name.
505+
* Otherwise kernel will return actual amount of bytes filled in
506+
* user-supplied buffer (see vma_name_addr field below), including the
507+
* terminating zero.
508+
*
509+
* If VMA name is longer that user-supplied maximum buffer size,
510+
* -E2BIG error is returned.
511+
*
512+
* If this field is set to non-zero value, vma_name_addr should point
513+
* to valid user space memory buffer of at least vma_name_size bytes.
514+
* If set to zero, vma_name_addr should be set to zero as well
515+
*/
516+
__u32 vma_name_size; /* in/out */
517+
/*
518+
* If set to non-zero value, signals the request to extract and return
519+
* VMA's backing file's build ID, if the backing file is an ELF file
520+
* and it contains embedded build ID.
521+
*
522+
* Kernel will set this field to zero, if VMA has no backing file,
523+
* backing file is not an ELF file, or ELF file has no build ID
524+
* embedded.
525+
*
526+
* Build ID is a binary value (not a string). Kernel will set
527+
* build_id_size field to exact number of bytes used for build ID.
528+
* If build ID is requested and present, but needs more bytes than
529+
* user-supplied maximum buffer size (see build_id_addr field below),
530+
* -E2BIG error will be returned.
531+
*
532+
* If this field is set to non-zero value, build_id_addr should point
533+
* to valid user space memory buffer of at least build_id_size bytes.
534+
* If set to zero, build_id_addr should be set to zero as well
535+
*/
536+
__u32 build_id_size; /* in/out */
537+
/*
538+
* User-supplied address of a buffer of at least vma_name_size bytes
539+
* for kernel to fill with matched VMA's name (see vma_name_size field
540+
* description above for details).
541+
*
542+
* Should be set to zero if VMA name should not be returned.
543+
*/
544+
__u64 vma_name_addr; /* in */
545+
/*
546+
* User-supplied address of a buffer of at least build_id_size bytes
547+
* for kernel to fill with matched VMA's ELF build ID, if available
548+
* (see build_id_size field description above for details).
549+
*
550+
* Should be set to zero if build ID should not be returned.
551+
*/
552+
__u64 build_id_addr; /* in */
553+
};
554+
396555
#endif /* _UAPI_LINUX_FS_H */

tools/perf/trace/beauty/include/uapi/linux/mount.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ struct mount_attr {
154154
*/
155155
struct statmount {
156156
__u32 size; /* Total size, including strings */
157-
__u32 __spare1;
157+
__u32 mnt_opts; /* [str] Mount options of the mount */
158158
__u64 mask; /* What results were written */
159159
__u32 sb_dev_major; /* Device ID */
160160
__u32 sb_dev_minor;
@@ -172,7 +172,8 @@ struct statmount {
172172
__u64 propagate_from; /* Propagation from in current namespace */
173173
__u32 mnt_root; /* [str] Root of mount relative to root of fs */
174174
__u32 mnt_point; /* [str] Mountpoint relative to current root */
175-
__u64 __spare2[50];
175+
__u64 mnt_ns_id; /* ID of the mount namespace */
176+
__u64 __spare2[49];
176177
char str[]; /* Variable size part containing strings */
177178
};
178179

@@ -188,10 +189,12 @@ struct mnt_id_req {
188189
__u32 spare;
189190
__u64 mnt_id;
190191
__u64 param;
192+
__u64 mnt_ns_id;
191193
};
192194

193195
/* List of all mnt_id_req versions. */
194196
#define MNT_ID_REQ_SIZE_VER0 24 /* sizeof first published struct */
197+
#define MNT_ID_REQ_SIZE_VER1 32 /* sizeof second published struct */
195198

196199
/*
197200
* @mask bits for statmount(2)
@@ -202,10 +205,13 @@ struct mnt_id_req {
202205
#define STATMOUNT_MNT_ROOT 0x00000008U /* Want/got mnt_root */
203206
#define STATMOUNT_MNT_POINT 0x00000010U /* Want/got mnt_point */
204207
#define STATMOUNT_FS_TYPE 0x00000020U /* Want/got fs_type */
208+
#define STATMOUNT_MNT_NS_ID 0x00000040U /* Want/got mnt_ns_id */
209+
#define STATMOUNT_MNT_OPTS 0x00000080U /* Want/got mnt_opts */
205210

206211
/*
207212
* Special @mnt_id values that can be passed to listmount
208213
*/
209214
#define LSMT_ROOT 0xffffffffffffffff /* root mount */
215+
#define LISTMOUNT_REVERSE (1 << 0) /* List later mounts first */
210216

211217
#endif /* _UAPI_LINUX_MOUNT_H */

tools/perf/trace/beauty/include/uapi/linux/stat.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,15 @@ struct statx {
126126
__u64 stx_mnt_id;
127127
__u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */
128128
__u32 stx_dio_offset_align; /* File offset alignment for direct I/O */
129-
__u64 stx_subvol; /* Subvolume identifier */
130129
/* 0xa0 */
131-
__u64 __spare3[11]; /* Spare space for future expansion */
130+
__u64 stx_subvol; /* Subvolume identifier */
131+
__u32 stx_atomic_write_unit_min; /* Min atomic write unit in bytes */
132+
__u32 stx_atomic_write_unit_max; /* Max atomic write unit in bytes */
133+
/* 0xb0 */
134+
__u32 stx_atomic_write_segments_max; /* Max atomic write segment count */
135+
__u32 __spare1[1];
136+
/* 0xb8 */
137+
__u64 __spare3[9]; /* Spare space for future expansion */
132138
/* 0x100 */
133139
};
134140

@@ -157,6 +163,7 @@ struct statx {
157163
#define STATX_DIOALIGN 0x00002000U /* Want/got direct I/O alignment info */
158164
#define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */
159165
#define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */
166+
#define STATX_WRITE_ATOMIC 0x00010000U /* Want/got atomic_write_* fields */
160167

161168
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
162169

@@ -192,6 +199,7 @@ struct statx {
192199
#define STATX_ATTR_MOUNT_ROOT 0x00002000 /* Root of a mount */
193200
#define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */
194201
#define STATX_ATTR_DAX 0x00200000 /* File is currently in DAX state */
202+
#define STATX_ATTR_WRITE_ATOMIC 0x00400000 /* File supports atomic write operations */
195203

196204

197205
#endif /* _UAPI_LINUX_STAT_H */

0 commit comments

Comments
 (0)