[PATCH v2 23/34] btrfs: check BTRFS_FS_STATE_RO instead of SB_RDONLY at runtime

Christian Brauner brauner at kernel.org
Tue Nov 10 13:54:57 PST 2026


On Sun, Nov 01, 2026 at 01:26:22PM +1030, Qu Wenruo wrote:
> I love the idea. This reminds me exactly why for btrfs_force_shutdown(),
> we have to manually set the fs error without marking the fs RO, to avoid
> exactly the same problem.
>
> With that said, can you also a set_bit() call in btrfs_force_shutdown()
> to also set that flag instead of the exsting setting fs_info->fs_error?

I think so. I'd set BTRFS_FS_STATE_RO in addition to fs_error though.
start_transaction(), join_transaction() and btrfs_remount_rw() key off
BTRFS_FS_ERROR().

Note that this changes some error codes after a shutdown.
btrfs_permission() returns EROFS for MAY_WRITE once btrfs_fs_rdonly() is
true so opening a file for writing fails with EROFS instead of the EIO
from btrfs_file_open().



More information about the linux-mtd mailing list