Commit 982c3b30 authored by Christian Brauner's avatar Christian Brauner

bdev: rename freeze and thaw helpers

We have bdev_mark_dead() etc and we're going to move block device
freezing to holder ops in the next patch. Make the naming consistent:

* freeze_bdev() -> bdev_freeze()
* thaw_bdev()   -> bdev_thaw()

Also document the return code.

Link: https://lore.kernel.org/r/20231024-vfs-super-freeze-v2-2-599c19f4faac@kernel.orgReviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent f0cd9880
...@@ -207,18 +207,20 @@ int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend) ...@@ -207,18 +207,20 @@ int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend)
EXPORT_SYMBOL(sync_blockdev_range); EXPORT_SYMBOL(sync_blockdev_range);
/** /**
* freeze_bdev - lock a filesystem and force it into a consistent state * bdev_freeze - lock a filesystem and force it into a consistent state
* @bdev: blockdevice to lock * @bdev: blockdevice to lock
* *
* If a superblock is found on this device, we take the s_umount semaphore * If a superblock is found on this device, we take the s_umount semaphore
* on it to make sure nobody unmounts until the snapshot creation is done. * on it to make sure nobody unmounts until the snapshot creation is done.
* The reference counter (bd_fsfreeze_count) guarantees that only the last * The reference counter (bd_fsfreeze_count) guarantees that only the last
* unfreeze process can unfreeze the frozen filesystem actually when multiple * unfreeze process can unfreeze the frozen filesystem actually when multiple
* freeze requests arrive simultaneously. It counts up in freeze_bdev() and * freeze requests arrive simultaneously. It counts up in bdev_freeze() and
* count down in thaw_bdev(). When it becomes 0, thaw_bdev() will unfreeze * count down in bdev_thaw(). When it becomes 0, thaw_bdev() will unfreeze
* actually. * actually.
*
* Return: On success zero is returned, negative error code on failure.
*/ */
int freeze_bdev(struct block_device *bdev) int bdev_freeze(struct block_device *bdev)
{ {
struct super_block *sb; struct super_block *sb;
int error = 0; int error = 0;
...@@ -248,15 +250,17 @@ int freeze_bdev(struct block_device *bdev) ...@@ -248,15 +250,17 @@ int freeze_bdev(struct block_device *bdev)
mutex_unlock(&bdev->bd_fsfreeze_mutex); mutex_unlock(&bdev->bd_fsfreeze_mutex);
return error; return error;
} }
EXPORT_SYMBOL(freeze_bdev); EXPORT_SYMBOL(bdev_freeze);
/** /**
* thaw_bdev - unlock filesystem * bdev_thaw - unlock filesystem
* @bdev: blockdevice to unlock * @bdev: blockdevice to unlock
* *
* Unlocks the filesystem and marks it writeable again after freeze_bdev(). * Unlocks the filesystem and marks it writeable again after bdev_freeze().
*
* Return: On success zero is returned, negative error code on failure.
*/ */
int thaw_bdev(struct block_device *bdev) int bdev_thaw(struct block_device *bdev)
{ {
struct super_block *sb; struct super_block *sb;
int error = -EINVAL; int error = -EINVAL;
...@@ -285,7 +289,7 @@ int thaw_bdev(struct block_device *bdev) ...@@ -285,7 +289,7 @@ int thaw_bdev(struct block_device *bdev)
mutex_unlock(&bdev->bd_fsfreeze_mutex); mutex_unlock(&bdev->bd_fsfreeze_mutex);
return error; return error;
} }
EXPORT_SYMBOL(thaw_bdev); EXPORT_SYMBOL(bdev_thaw);
/* /*
* pseudo-fs * pseudo-fs
......
...@@ -2675,7 +2675,7 @@ static int lock_fs(struct mapped_device *md) ...@@ -2675,7 +2675,7 @@ static int lock_fs(struct mapped_device *md)
WARN_ON(test_bit(DMF_FROZEN, &md->flags)); WARN_ON(test_bit(DMF_FROZEN, &md->flags));
r = freeze_bdev(md->disk->part0); r = bdev_freeze(md->disk->part0);
if (!r) if (!r)
set_bit(DMF_FROZEN, &md->flags); set_bit(DMF_FROZEN, &md->flags);
return r; return r;
...@@ -2685,7 +2685,7 @@ static void unlock_fs(struct mapped_device *md) ...@@ -2685,7 +2685,7 @@ static void unlock_fs(struct mapped_device *md)
{ {
if (!test_bit(DMF_FROZEN, &md->flags)) if (!test_bit(DMF_FROZEN, &md->flags))
return; return;
thaw_bdev(md->disk->part0); bdev_thaw(md->disk->part0);
clear_bit(DMF_FROZEN, &md->flags); clear_bit(DMF_FROZEN, &md->flags);
} }
......
...@@ -291,14 +291,14 @@ static int bch2_ioc_goingdown(struct bch_fs *c, u32 __user *arg) ...@@ -291,14 +291,14 @@ static int bch2_ioc_goingdown(struct bch_fs *c, u32 __user *arg)
switch (flags) { switch (flags) {
case FSOP_GOING_FLAGS_DEFAULT: case FSOP_GOING_FLAGS_DEFAULT:
ret = freeze_bdev(c->vfs_sb->s_bdev); ret = bdev_freeze(c->vfs_sb->s_bdev);
if (ret) if (ret)
goto err; goto err;
bch2_journal_flush(&c->journal); bch2_journal_flush(&c->journal);
c->vfs_sb->s_flags |= SB_RDONLY; c->vfs_sb->s_flags |= SB_RDONLY;
bch2_fs_emergency_read_only(c); bch2_fs_emergency_read_only(c);
thaw_bdev(c->vfs_sb->s_bdev); bdev_thaw(c->vfs_sb->s_bdev);
break; break;
case FSOP_GOING_FLAGS_LOGFLUSH: case FSOP_GOING_FLAGS_LOGFLUSH:
......
...@@ -819,11 +819,11 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags) ...@@ -819,11 +819,11 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags)
switch (flags) { switch (flags) {
case EXT4_GOING_FLAGS_DEFAULT: case EXT4_GOING_FLAGS_DEFAULT:
ret = freeze_bdev(sb->s_bdev); ret = bdev_freeze(sb->s_bdev);
if (ret) if (ret)
return ret; return ret;
set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags);
thaw_bdev(sb->s_bdev); bdev_thaw(sb->s_bdev);
break; break;
case EXT4_GOING_FLAGS_LOGFLUSH: case EXT4_GOING_FLAGS_LOGFLUSH:
set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags);
......
...@@ -2239,11 +2239,11 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) ...@@ -2239,11 +2239,11 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
switch (in) { switch (in) {
case F2FS_GOING_DOWN_FULLSYNC: case F2FS_GOING_DOWN_FULLSYNC:
ret = freeze_bdev(sb->s_bdev); ret = bdev_freeze(sb->s_bdev);
if (ret) if (ret)
goto out; goto out;
f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_SHUTDOWN); f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_SHUTDOWN);
thaw_bdev(sb->s_bdev); bdev_thaw(sb->s_bdev);
break; break;
case F2FS_GOING_DOWN_METASYNC: case F2FS_GOING_DOWN_METASYNC:
/* do checkpoint only */ /* do checkpoint only */
......
...@@ -1224,7 +1224,7 @@ static void do_thaw_all_callback(struct super_block *sb) ...@@ -1224,7 +1224,7 @@ static void do_thaw_all_callback(struct super_block *sb)
if (locked && sb->s_root) { if (locked && sb->s_root) {
if (IS_ENABLED(CONFIG_BLOCK)) if (IS_ENABLED(CONFIG_BLOCK))
while (sb->s_bdev && !thaw_bdev(sb->s_bdev)) while (sb->s_bdev && !bdev_thaw(sb->s_bdev))
pr_warn("Emergency Thaw on %pg\n", sb->s_bdev); pr_warn("Emergency Thaw on %pg\n", sb->s_bdev);
thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE); thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE);
return; return;
...@@ -1532,7 +1532,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, ...@@ -1532,7 +1532,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
/* /*
* Until SB_BORN flag is set, there can be no active superblock * Until SB_BORN flag is set, there can be no active superblock
* references and thus no filesystem freezing. get_active_super() will * references and thus no filesystem freezing. get_active_super() will
* just loop waiting for SB_BORN so even freeze_bdev() cannot proceed. * just loop waiting for SB_BORN so even bdev_freeze() cannot proceed.
* *
* It is enough to check bdev was not frozen before we set s_bdev. * It is enough to check bdev was not frozen before we set s_bdev.
*/ */
......
...@@ -482,9 +482,9 @@ xfs_fs_goingdown( ...@@ -482,9 +482,9 @@ xfs_fs_goingdown(
{ {
switch (inflags) { switch (inflags) {
case XFS_FSOP_GOING_FLAGS_DEFAULT: { case XFS_FSOP_GOING_FLAGS_DEFAULT: {
if (!freeze_bdev(mp->m_super->s_bdev)) { if (!bdev_freeze(mp->m_super->s_bdev)) {
xfs_force_shutdown(mp, SHUTDOWN_FORCE_UMOUNT); xfs_force_shutdown(mp, SHUTDOWN_FORCE_UMOUNT);
thaw_bdev(mp->m_super->s_bdev); bdev_thaw(mp->m_super->s_bdev);
} }
break; break;
} }
......
...@@ -1541,8 +1541,8 @@ static inline int early_lookup_bdev(const char *pathname, dev_t *dev) ...@@ -1541,8 +1541,8 @@ static inline int early_lookup_bdev(const char *pathname, dev_t *dev)
} }
#endif /* CONFIG_BLOCK */ #endif /* CONFIG_BLOCK */
int freeze_bdev(struct block_device *bdev); int bdev_freeze(struct block_device *bdev);
int thaw_bdev(struct block_device *bdev); int bdev_thaw(struct block_device *bdev);
struct io_comp_batch { struct io_comp_batch {
struct request *req_list; struct request *req_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment