Skip to content

Commit d24fa5c

Browse files
asjkdave
authored andcommitted
btrfs: convert latest_bdev type to btrfs_device and rename
In preparation to fix a bug in btrfs_show_devname(). Convert fs_devices::latest_bdev type from struct block_device to struct btrfs_device and, rename the member to fs_devices::latest_dev. So that btrfs_show_devname() can use fs_devices::latest_dev::name. Tested-by: Su Yue <[email protected]> Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 7ae9bd1 commit d24fa5c

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

fs/btrfs/disk-io.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,12 +3231,12 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
32313231
mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
32323232
btrfs_init_btree_inode(fs_info);
32333233

3234-
invalidate_bdev(fs_devices->latest_bdev);
3234+
invalidate_bdev(fs_devices->latest_dev->bdev);
32353235

32363236
/*
32373237
* Read super block and check the signature bytes only
32383238
*/
3239-
disk_super = btrfs_read_dev_super(fs_devices->latest_bdev);
3239+
disk_super = btrfs_read_dev_super(fs_devices->latest_dev->bdev);
32403240
if (IS_ERR(disk_super)) {
32413241
err = PTR_ERR(disk_super);
32423242
goto fail_alloc;
@@ -3473,7 +3473,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
34733473
* below in btrfs_init_dev_replace().
34743474
*/
34753475
btrfs_free_extra_devids(fs_devices);
3476-
if (!fs_devices->latest_bdev) {
3476+
if (!fs_devices->latest_dev->bdev) {
34773477
btrfs_err(fs_info, "failed to read devices");
34783478
goto fail_tree_roots;
34793479
}

fs/btrfs/extent_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3327,7 +3327,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,
33273327
if (wbc) {
33283328
struct block_device *bdev;
33293329

3330-
bdev = fs_info->fs_devices->latest_bdev;
3330+
bdev = fs_info->fs_devices->latest_dev->bdev;
33313331
bio_set_dev(bio, bdev);
33323332
wbc_init_bio(wbc, bio);
33333333
}

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7965,7 +7965,7 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
79657965
iomap->type = IOMAP_MAPPED;
79667966
}
79677967
iomap->offset = start;
7968-
iomap->bdev = fs_info->fs_devices->latest_bdev;
7968+
iomap->bdev = fs_info->fs_devices->latest_dev->bdev;
79697969
iomap->length = len;
79707970

79717971
if (write && btrfs_use_zone_append(BTRFS_I(inode), em->block_start))

fs/btrfs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
17051705
goto error_close_devices;
17061706
}
17071707

1708-
bdev = fs_devices->latest_bdev;
1708+
bdev = fs_devices->latest_dev->bdev;
17091709
s = sget(fs_type, btrfs_test_super, btrfs_set_super, flags | SB_NOSEC,
17101710
fs_info);
17111711
if (IS_ERR(s)) {

fs/btrfs/volumes.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices)
10911091
list_for_each_entry(seed_dev, &fs_devices->seed_list, seed_list)
10921092
__btrfs_free_extra_devids(seed_dev, &latest_dev);
10931093

1094-
fs_devices->latest_bdev = latest_dev->bdev;
1094+
fs_devices->latest_dev = latest_dev;
10951095

10961096
mutex_unlock(&uuid_mutex);
10971097
}
@@ -1222,7 +1222,7 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices,
12221222
return -EINVAL;
12231223

12241224
fs_devices->opened = 1;
1225-
fs_devices->latest_bdev = latest_dev->bdev;
1225+
fs_devices->latest_dev = latest_dev;
12261226
fs_devices->total_rw_bytes = 0;
12271227
fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR;
12281228
fs_devices->read_policy = BTRFS_READ_POLICY_PID;
@@ -1986,7 +1986,7 @@ static struct btrfs_device * btrfs_find_next_active_device(
19861986
}
19871987

19881988
/*
1989-
* Helper function to check if the given device is part of s_bdev / latest_bdev
1989+
* Helper function to check if the given device is part of s_bdev / latest_dev
19901990
* and replace it with the provided or the next active device, in the context
19911991
* where this function called, there should be always be another device (or
19921992
* this_dev) which is active.
@@ -2005,8 +2005,8 @@ void __cold btrfs_assign_next_active_device(struct btrfs_device *device,
20052005
(fs_info->sb->s_bdev == device->bdev))
20062006
fs_info->sb->s_bdev = next_device->bdev;
20072007

2008-
if (fs_info->fs_devices->latest_bdev == device->bdev)
2009-
fs_info->fs_devices->latest_bdev = next_device->bdev;
2008+
if (fs_info->fs_devices->latest_dev->bdev == device->bdev)
2009+
fs_info->fs_devices->latest_dev = next_device;
20102010
}
20112011

20122012
/*

fs/btrfs/volumes.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,11 @@ struct btrfs_fs_devices {
246246
/* Highest generation number of seen devices */
247247
u64 latest_generation;
248248

249-
struct block_device *latest_bdev;
249+
/*
250+
* The mount device or a device with highest generation after removal
251+
* or replace.
252+
*/
253+
struct btrfs_device *latest_dev;
250254

251255
/* all of the devices in the FS, protected by a mutex
252256
* so we can safely walk it to write out the supers without

0 commit comments

Comments
 (0)