[PATCH v2 20/34] ocfs2: don't set SB_RDONLY after filesystem errors
Joseph Qi
joseph.qi at linux.alibaba.com
Thu Oct 29 20:01:58 PDT 2026
On 10/30/26 12:07 AM, Christian Brauner wrote:
> With errors=remount-ro, the default, ocfs2_handle_error() sets SB_RDONLY
> without holding s_umount. If that happens while the filesystem is frozen
> through bdev_freeze() thaw_super() leaves the s_writers rwsems locked.
> Writers hang and so does umount because ocfs2_shutdown_local_alloc()
> needs sb_start_intwrite().
>
> The soft read-only state doesn't stop modifications on its own. Every
> read-only mount sets it and those still need transactions for recovery,
> the local alloc and the truncate log. Everything else was stopped by the
> VFS because of SB_RDONLY. So call sb_set_emergency_ro() instead which
> keeps it that way, and keep setting SOFT_RO for the existing
> ocfs2_emergency_state() checks.
>
> The xattr and ACL setters get a check of their own because ecryptfs
> calls them without write access on the lower mount. It sits in the xattr
> handlers and not in ocfs2_xattr_set() because chmod and setfacl store
> the ACL through it after the new mode was already committed.
>
> Quotas aren't enabled at mount in the error state because that writes
> the quota files. ocfs2_sync_fs() doesn't flush anything anymore and a
> remount to read-only doesn't suspend quotas. Q_GETQUOTA, Q_GETNEXTQUOTA
> and Q_SYNC can still start transactions. I've left that alone.
>
> Writes through file descriptors opened before the error fail with EROFS
> and umount completes instead of hanging.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>
Looks fine.
Reviewed-by: Joseph Qi <joseph.qi at linux.alibaba.com>
More information about the linux-mtd
mailing list