[PATCH v4 1/6] fs: add write-stream management ioctls
Kanchan Joshi <[email protected]>
| Newsgroups | org.kernel.vger.linux-xfs,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <[email protected]> |
From: Anuj Gupta <[email protected]> Wire up the userspace interface for write stream management via four ioctls: FS_IOC_WRITE_STREAM_GET_MAX query the max streams supported FS_IOC_WRITE_STREAM_OPEN open a stream id, returns a stream fd FS_IOC_WRITE_STREAM_SET attach the stream fd to an open file FS_IOC_WRITE_STREAM_GET query the stream id value set on a file Application should query the available streams by using FS_IOC_WRITE_STREAM_GET_MAX. If returned value is N, valid stream id for the file are 1 to N. Application calls FS_IOC_WRITE_STREAM_OPEN to get fd for a stream-id. By default, kernel picks an available stream-id and returns the fd for it. The flag FS_WRITE_STREAM_OPEN_EXACT can be used to request a specific stream_id. This is useful if application cares about keeping a stable stream-id-to-spatial-isolation-bucket mapping across restarts. Suggested-by: Christoph Hellwig <[email protected]> Co-developed-by: Kanchan Joshi <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> Signed-off-by: Kanchan Joshi <[email protected]> --- include/uapi/linux/fs.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index bd87262f2e34..a756d27bdf84 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -345,6 +345,22 @@ struct file_attr { /* Get logical block metadata capability details */ #define FS_IOC_GETLBMD_CAP _IOWR(0x15, 2, struct logical_block_metadata_cap) +struct fs_write_stream_open { + __u32 stream_id; /* IN: requested id if OPEN_EXACT set; OUT: assigned id */ + __u32 flags; /* IN: FS_WRITE_STREAM_OPEN_* */ +}; + +/* + * Flag to ask for specific stream_id, otherwise kernel can return any. + * Fails with -EBUSY if that stream_id is already held + */ +#define FS_WRITE_STREAM_OPEN_EXACT (1 << 0) + +#define FS_IOC_WRITE_STREAM_GET_MAX _IOR('f', 135, __u32) +#define FS_IOC_WRITE_STREAM_OPEN _IOWR('f', 136, struct fs_write_stream_open) +#define FS_IOC_WRITE_STREAM_SET _IOW('f', 137, __s32) +#define FS_IOC_WRITE_STREAM_GET _IOR('f', 138, __u32) + /* * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS) * -- 2.25.1