Re: [PATCH v4 3/6] btrfs: reject file operations if in shutdown state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 04, 2025 at 10:12:31AM +0930, Qu Wenruo wrote:
> This includes the following callbacks of file_operations:
> 
> - read_iter()
> - write_iter()
> - mmap()
> - open()
> - remap_file_range()
> - uring_cmd()
> - splice_read()
>   This requires a small wrapper to do the extra shutdown check, then call
>   the regular filemap_splice_read() function
> 
> This should reject most of the file operations on a shutdown btrfs.
> 
> The callback ioctl() is intentionally skipped, as ext4 doesn't do the
> shutdown check on ioctl() either, thus I believe there is some special
> require for ioctl() callback even if the fs is fully shutdown.
> 
> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
> ---
>  fs/btrfs/file.c    | 25 ++++++++++++++++++++++++-
>  fs/btrfs/ioctl.c   |  3 +++
>  fs/btrfs/reflink.c |  3 +++
>  3 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 05b046c6806f..cb7d1d53fc13 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -1419,6 +1419,8 @@ ssize_t btrfs_do_write_iter(struct kiocb *iocb, struct iov_iter *from,
>  	struct btrfs_inode *inode = BTRFS_I(file_inode(file));
>  	ssize_t num_written, num_sync;
>  
> +	if (unlikely(btrfs_is_shutdown(inode->root->fs_info)))

This looks like a repetitive pattern, it would be better to do something
like

#define IS_SHUTDOWN(fs_info) (unlikely(btrfs_is_shutdown(fs_info))

Eventually we can use _Generic to pick the fs_info from the most
commonly used types, like inode or root.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux