[PATCH v6 03/16] fs: add generic FS_IOC_SHUTDOWN definitions

Namjae Jeon posted 16 patches 5 days, 15 hours ago
Only 14 patches received!
There is a newer version of this series
[PATCH v6 03/16] fs: add generic FS_IOC_SHUTDOWN definitions
Posted by Namjae Jeon 5 days, 15 hours ago
Currently, several filesystems (e.g., xfs, ext4, btrfs) implement
a "shutdown" or "going down" ioctl to simulate filesystem force a shutdown.
While they often use the same underlying numeric value, the definition is
duplicated across filesystem headers or private definitions.

This patch adds generic definitions for FS_IOC_SHUTDOWN in uapi/linux/fs.h.
This allows new filesystems (like ntfs) to implement this feature using
a standard VFS definition and paves the way for existing filesystems
to unify their definitions later.

The flag names are standardized as FS_SHUTDOWN_* to be consistent with
the ioctl name, replacing the historical GOING_DOWN naming convention.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 include/uapi/linux/fs.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 66ca526cf786..32e24778c9e5 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -656,4 +656,16 @@ struct procmap_query {
 	__u64 build_id_addr;		/* in */
 };
 
+/*
+ * Shutdown the filesystem.
+ */
+#define FS_IOC_SHUTDOWN _IOR('X', 125, __u32)
+
+/*
+ * Flags for FS_IOC_SHUTDOWN
+ */
+#define FS_SHUTDOWN_FLAGS_DEFAULT	0x0
+#define FS_SHUTDOWN_FLAGS_LOGFLUSH	0x1	/* flush log but not data*/
+#define FS_SHUTDOWN_FLAGS_NOLOGFLUSH	0x2	/* don't flush log nor data */
+
 #endif /* _UAPI_LINUX_FS_H */
-- 
2.25.1
Re: [PATCH v6 03/16] fs: add generic FS_IOC_SHUTDOWN definitions
Posted by Jan Kara 5 days, 4 hours ago
On Tue 03-02-26 07:01:49, Namjae Jeon wrote:
> Currently, several filesystems (e.g., xfs, ext4, btrfs) implement
> a "shutdown" or "going down" ioctl to simulate filesystem force a shutdown.
> While they often use the same underlying numeric value, the definition is
> duplicated across filesystem headers or private definitions.
> 
> This patch adds generic definitions for FS_IOC_SHUTDOWN in uapi/linux/fs.h.
> This allows new filesystems (like ntfs) to implement this feature using
> a standard VFS definition and paves the way for existing filesystems
> to unify their definitions later.
> 
> The flag names are standardized as FS_SHUTDOWN_* to be consistent with
> the ioctl name, replacing the historical GOING_DOWN naming convention.
> 
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

Good idea. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  include/uapi/linux/fs.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
> index 66ca526cf786..32e24778c9e5 100644
> --- a/include/uapi/linux/fs.h
> +++ b/include/uapi/linux/fs.h
> @@ -656,4 +656,16 @@ struct procmap_query {
>  	__u64 build_id_addr;		/* in */
>  };
>  
> +/*
> + * Shutdown the filesystem.
> + */
> +#define FS_IOC_SHUTDOWN _IOR('X', 125, __u32)
> +
> +/*
> + * Flags for FS_IOC_SHUTDOWN
> + */
> +#define FS_SHUTDOWN_FLAGS_DEFAULT	0x0
> +#define FS_SHUTDOWN_FLAGS_LOGFLUSH	0x1	/* flush log but not data*/
> +#define FS_SHUTDOWN_FLAGS_NOLOGFLUSH	0x2	/* don't flush log nor data */
> +
>  #endif /* _UAPI_LINUX_FS_H */
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR
Re: [PATCH v6 03/16] fs: add generic FS_IOC_SHUTDOWN definitions
Posted by Darrick J. Wong 5 days, 14 hours ago
On Tue, Feb 03, 2026 at 07:01:49AM +0900, Namjae Jeon wrote:
> Currently, several filesystems (e.g., xfs, ext4, btrfs) implement
> a "shutdown" or "going down" ioctl to simulate filesystem force a shutdown.
> While they often use the same underlying numeric value, the definition is
> duplicated across filesystem headers or private definitions.
> 
> This patch adds generic definitions for FS_IOC_SHUTDOWN in uapi/linux/fs.h.
> This allows new filesystems (like ntfs) to implement this feature using
> a standard VFS definition and paves the way for existing filesystems
> to unify their definitions later.
> 
> The flag names are standardized as FS_SHUTDOWN_* to be consistent with
> the ioctl name, replacing the historical GOING_DOWN naming convention.
> 
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
> ---
>  include/uapi/linux/fs.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
> index 66ca526cf786..32e24778c9e5 100644
> --- a/include/uapi/linux/fs.h
> +++ b/include/uapi/linux/fs.h
> @@ -656,4 +656,16 @@ struct procmap_query {
>  	__u64 build_id_addr;		/* in */
>  };
>  
> +/*
> + * Shutdown the filesystem.
> + */
> +#define FS_IOC_SHUTDOWN _IOR('X', 125, __u32)
> +
> +/*
> + * Flags for FS_IOC_SHUTDOWN
> + */
> +#define FS_SHUTDOWN_FLAGS_DEFAULT	0x0
> +#define FS_SHUTDOWN_FLAGS_LOGFLUSH	0x1	/* flush log but not data*/
> +#define FS_SHUTDOWN_FLAGS_NOLOGFLUSH	0x2	/* don't flush log nor data */

Hoisting this to reduce the copy-pasting already going on in filesystems
sounds like a good idea to me:

$ git grep '_IOR.*X.*125'
fs/ntfs3/file.c:26:#define NTFS3_IOC_SHUTDOWN _IOR('X', 125, __u32)
fs/smb/client/cifs_ioctl.h:117:#define CIFS_IOC_SHUTDOWN _IOR('X', 125, __u32)
fs/xfs/libxfs/xfs_fs.h:1266:#define XFS_IOC_GOINGDOWN        _IOR ('X', 125, uint32_t)
include/uapi/linux/btrfs.h:1230:#define BTRFS_IOC_SHUTDOWN      _IOR('X', 125, __u32)
include/uapi/linux/exfat.h:15:#define EXFAT_IOC_SHUTDOWN _IOR('X', 125, __u32)
include/uapi/linux/ext4.h:39:#define EXT4_IOC_SHUTDOWN _IOR('X', 125, __u32)
include/uapi/linux/f2fs.h:53:#define F2FS_IOC_SHUTDOWN  _IOR('X', 125, __u32)   /* Shutdown */

Christian: any chance we could get this api cleanup queued for 7.0 even
though we're past -rc8?

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> +
>  #endif /* _UAPI_LINUX_FS_H */
> -- 
> 2.25.1
>
Re: [PATCH v6 03/16] fs: add generic FS_IOC_SHUTDOWN definitions
Posted by Christoph Hellwig 5 days, 7 hours ago
On Mon, Feb 02, 2026 at 02:36:57PM -0800, Darrick J. Wong wrote:
> Christian: any chance we could get this api cleanup queued for 7.0 even
> though we're past -rc8?

I assume the new ntrfs code is still aimed at 7.0, so it would be best
to just merge it with that.

Reviewed-by: Christoph Hellwig <hch@lst.de>