]> git.ipfire.org Git - thirdparty/linux.git/commit
block: allow making a block device unfreezable
authorChristian Brauner <brauner@kernel.org>
Tue, 16 Jun 2026 11:58:14 +0000 (13:58 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 29 Jun 2026 08:31:49 +0000 (10:31 +0200)
commitea4e4cc263011910eb7c62f3bb4fa094a1573c61
tree9e99938b22316fcc6a58850aa15ebb2a25908843
parentdc59e4fea9d83f03bad6bddf3fa2e52491777482
block: allow making a block device unfreezable

Add bdev_deny_freeze() and bdev_allow_freeze(), modeled on
deny_write_access()/allow_write_access().  bd_fsfreeze_count becomes a
signed counter: > 0 counts active freezes, < 0 counts deniers, and the
two regimes are mutually exclusive.  bdev_freeze() refuses with -EBUSY
while a deny is held, and bdev_deny_freeze() refuses while the device is
frozen.

A filesystem that mutates a device's membership (a btrfs device add,
remove or replace) denies freezing on the device for the duration, so a
claim a freeze walk might act on is never added or torn down behind the
freezer's back.

The deny/allow helpers are a single atomic on bd_fsfreeze_count and take
no lock, so they can be called while holding s_umount without inverting
against bdev_freeze()'s bd_fsfreeze_mutex -> s_umount order.

Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260616-work-super-freeze_deny_upstream-v2-1-b3567c7f994b@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
block/bdev.c
include/linux/blk_types.h
include/linux/blkdev.h