[CHANGELOG] RFC->v1: - Add a new remove_bdev() callback Thanks all the feedback from Christian, Christoph and Jan on this new name. - Add a @surprise parameter to the remove_bdev() callback To keep it the same as the bdev_mark_dead(). - Hide the shutdown ioctl and remove_bdev callback behind experimental With the shutdown ioctl, there are 3 test failures (g/050, g/388, g/508). G/050 may require a test case update. G/388 is related to the error handling with COW fixup. G/508 looks like something related to log replay. And the remove_bdev() doesn't have any btrfs specific test case yet to check the auto-degraded behavior, nor the auto-degraded behavior is fully discussed. So hide both of them behind experimental features. - Do not use btrfs_handle_fs_error() to avoid freeze/thaw behavior change btrfs_handle_fs_error() will flips the fs read-only, which will affect freeze/thaw behavior. And no other fs set the fs read-only when shutting down, so follow the other fs to have a more consistent behavior. The series is based on the fs_holder_ops patchset here: https://lore.kernel.org/linux-btrfs/cover.1750724841.git.wqu@xxxxxxxx/ The full series including the btrfs' support of fs_holder_ops can be found here: https://github.com/adam900710/linux/tree/shutdown Patch 1 is introducing the new remove_bdev() super operation callback, with not only the extra @bdev parameter, but also a @surprise flag to follow bdev_mark_dead(). Patch 2~5 implement the shutdown ioctl so that btrfs can benefit from the existing shutdown test group. Although it's still only enabled for experimental builds, as there are still some minor failures needs to be addressed Patch 6 implements the remove_bdev() callback, so that btrfs can either shutdown the fs or continue degraded. It's still an experimental feature, as we still need more disccussion on the user expectation and possible extra user configurable behaviors. Qu Wenruo (6): fs: add a new remove_bdev() super operations callback btrfs: introduce a new fs state, EMERGENCY_SHUTDOWN btrfs: reject file operations if in shutdown state btrfs: reject delalloc ranges if the fs is shutdown btrfs: implement shutdown ioctl btrfs: implement remove_bdev super operation callback fs/btrfs/file.c | 25 ++++++++++++++++- fs/btrfs/fs.h | 28 +++++++++++++++++++ fs/btrfs/inode.c | 14 +++++++++- fs/btrfs/ioctl.c | 43 +++++++++++++++++++++++++++++ fs/btrfs/messages.c | 1 + fs/btrfs/reflink.c | 3 +++ fs/btrfs/super.c | 55 ++++++++++++++++++++++++++++++++++++++ fs/btrfs/volumes.c | 2 ++ fs/btrfs/volumes.h | 5 ++++ fs/super.c | 4 ++- include/linux/fs.h | 18 +++++++++++++ include/uapi/linux/btrfs.h | 9 +++++++ 12 files changed, 204 insertions(+), 3 deletions(-) -- 2.49.0