Commit 44cab9ba authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: refactor locked condition in btrfs_init_new_device

Invert unlocked to locked and exploit the fact it can only ever be
modified if we are adding a new device to a seed filesystem. This allows
to simplify the check in error: label. No semantics changes.
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f4cfa9bd
...@@ -2497,7 +2497,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path ...@@ -2497,7 +2497,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
u64 orig_super_num_devices; u64 orig_super_num_devices;
int seeding_dev = 0; int seeding_dev = 0;
int ret = 0; int ret = 0;
bool unlocked = false; bool locked = false;
if (sb_rdonly(sb) && !fs_devices->seeding) if (sb_rdonly(sb) && !fs_devices->seeding)
return -EROFS; return -EROFS;
...@@ -2511,6 +2511,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path ...@@ -2511,6 +2511,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
seeding_dev = 1; seeding_dev = 1;
down_write(&sb->s_umount); down_write(&sb->s_umount);
mutex_lock(&uuid_mutex); mutex_lock(&uuid_mutex);
locked = true;
} }
filemap_write_and_wait(bdev->bd_inode->i_mapping); filemap_write_and_wait(bdev->bd_inode->i_mapping);
...@@ -2645,7 +2646,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path ...@@ -2645,7 +2646,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
if (seeding_dev) { if (seeding_dev) {
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
up_write(&sb->s_umount); up_write(&sb->s_umount);
unlocked = true; locked = false;
if (ret) /* transaction commit */ if (ret) /* transaction commit */
return ret; return ret;
...@@ -2706,7 +2707,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path ...@@ -2706,7 +2707,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
btrfs_free_device(device); btrfs_free_device(device);
error: error:
blkdev_put(bdev, FMODE_EXCL); blkdev_put(bdev, FMODE_EXCL);
if (seeding_dev && !unlocked) { if (locked) {
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
up_write(&sb->s_umount); up_write(&sb->s_umount);
} }
......
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