@@ -468,39 +468,39 @@ static noinline struct btrfs_fs_devices *find_fsid(
468
468
469
469
static int
470
470
btrfs_get_bdev_and_sb (const char * device_path , blk_mode_t flags , void * holder ,
471
- int flush , struct bdev_handle * * bdev_handle ,
471
+ int flush , struct file * * bdev_file ,
472
472
struct btrfs_super_block * * disk_super )
473
473
{
474
474
struct block_device * bdev ;
475
475
int ret ;
476
476
477
- * bdev_handle = bdev_open_by_path (device_path , flags , holder , NULL );
477
+ * bdev_file = bdev_file_open_by_path (device_path , flags , holder , NULL );
478
478
479
- if (IS_ERR (* bdev_handle )) {
480
- ret = PTR_ERR (* bdev_handle );
479
+ if (IS_ERR (* bdev_file )) {
480
+ ret = PTR_ERR (* bdev_file );
481
481
goto error ;
482
482
}
483
- bdev = ( * bdev_handle ) -> bdev ;
483
+ bdev = file_bdev ( * bdev_file ) ;
484
484
485
485
if (flush )
486
486
sync_blockdev (bdev );
487
487
ret = set_blocksize (bdev , BTRFS_BDEV_BLOCKSIZE );
488
488
if (ret ) {
489
- bdev_release ( * bdev_handle );
489
+ fput ( * bdev_file );
490
490
goto error ;
491
491
}
492
492
invalidate_bdev (bdev );
493
493
* disk_super = btrfs_read_dev_super (bdev );
494
494
if (IS_ERR (* disk_super )) {
495
495
ret = PTR_ERR (* disk_super );
496
- bdev_release ( * bdev_handle );
496
+ fput ( * bdev_file );
497
497
goto error ;
498
498
}
499
499
500
500
return 0 ;
501
501
502
502
error :
503
- * bdev_handle = NULL ;
503
+ * bdev_file = NULL ;
504
504
return ret ;
505
505
}
506
506
@@ -643,7 +643,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
643
643
struct btrfs_device * device , blk_mode_t flags ,
644
644
void * holder )
645
645
{
646
- struct bdev_handle * bdev_handle ;
646
+ struct file * bdev_file ;
647
647
struct btrfs_super_block * disk_super ;
648
648
u64 devid ;
649
649
int ret ;
@@ -654,7 +654,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
654
654
return - EINVAL ;
655
655
656
656
ret = btrfs_get_bdev_and_sb (device -> name -> str , flags , holder , 1 ,
657
- & bdev_handle , & disk_super );
657
+ & bdev_file , & disk_super );
658
658
if (ret )
659
659
return ret ;
660
660
@@ -678,20 +678,20 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
678
678
clear_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state );
679
679
fs_devices -> seeding = true;
680
680
} else {
681
- if (bdev_read_only (bdev_handle -> bdev ))
681
+ if (bdev_read_only (file_bdev ( bdev_file ) ))
682
682
clear_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state );
683
683
else
684
684
set_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state );
685
685
}
686
686
687
- if (!bdev_nonrot (bdev_handle -> bdev ))
687
+ if (!bdev_nonrot (file_bdev ( bdev_file ) ))
688
688
fs_devices -> rotating = true;
689
689
690
- if (bdev_max_discard_sectors (bdev_handle -> bdev ))
690
+ if (bdev_max_discard_sectors (file_bdev ( bdev_file ) ))
691
691
fs_devices -> discardable = true;
692
692
693
- device -> bdev_handle = bdev_handle ;
694
- device -> bdev = bdev_handle -> bdev ;
693
+ device -> bdev_file = bdev_file ;
694
+ device -> bdev = file_bdev ( bdev_file ) ;
695
695
clear_bit (BTRFS_DEV_STATE_IN_FS_METADATA , & device -> dev_state );
696
696
697
697
fs_devices -> open_devices ++ ;
@@ -706,7 +706,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
706
706
707
707
error_free_page :
708
708
btrfs_release_disk_super (disk_super );
709
- bdev_release ( bdev_handle );
709
+ fput ( bdev_file );
710
710
711
711
return - EINVAL ;
712
712
}
@@ -1015,10 +1015,10 @@ static void __btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices,
1015
1015
if (device -> devid == BTRFS_DEV_REPLACE_DEVID )
1016
1016
continue ;
1017
1017
1018
- if (device -> bdev_handle ) {
1019
- bdev_release (device -> bdev_handle );
1018
+ if (device -> bdev_file ) {
1019
+ fput (device -> bdev_file );
1020
1020
device -> bdev = NULL ;
1021
- device -> bdev_handle = NULL ;
1021
+ device -> bdev_file = NULL ;
1022
1022
fs_devices -> open_devices -- ;
1023
1023
}
1024
1024
if (test_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state )) {
@@ -1063,7 +1063,7 @@ static void btrfs_close_bdev(struct btrfs_device *device)
1063
1063
invalidate_bdev (device -> bdev );
1064
1064
}
1065
1065
1066
- bdev_release (device -> bdev_handle );
1066
+ fput (device -> bdev_file );
1067
1067
}
1068
1068
1069
1069
static void btrfs_close_one_device (struct btrfs_device * device )
@@ -1316,7 +1316,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
1316
1316
struct btrfs_super_block * disk_super ;
1317
1317
bool new_device_added = false;
1318
1318
struct btrfs_device * device = NULL ;
1319
- struct bdev_handle * bdev_handle ;
1319
+ struct file * bdev_file ;
1320
1320
u64 bytenr , bytenr_orig ;
1321
1321
int ret ;
1322
1322
@@ -1339,18 +1339,18 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
1339
1339
* values temporarily, as the device paths of the fsid are the only
1340
1340
* required information for assembling the volume.
1341
1341
*/
1342
- bdev_handle = bdev_open_by_path (path , flags , NULL , NULL );
1343
- if (IS_ERR (bdev_handle ))
1344
- return ERR_CAST (bdev_handle );
1342
+ bdev_file = bdev_file_open_by_path (path , flags , NULL , NULL );
1343
+ if (IS_ERR (bdev_file ))
1344
+ return ERR_CAST (bdev_file );
1345
1345
1346
1346
bytenr_orig = btrfs_sb_offset (0 );
1347
- ret = btrfs_sb_log_location_bdev (bdev_handle -> bdev , 0 , READ , & bytenr );
1347
+ ret = btrfs_sb_log_location_bdev (file_bdev ( bdev_file ) , 0 , READ , & bytenr );
1348
1348
if (ret ) {
1349
1349
device = ERR_PTR (ret );
1350
1350
goto error_bdev_put ;
1351
1351
}
1352
1352
1353
- disk_super = btrfs_read_disk_super (bdev_handle -> bdev , bytenr ,
1353
+ disk_super = btrfs_read_disk_super (file_bdev ( bdev_file ) , bytenr ,
1354
1354
bytenr_orig );
1355
1355
if (IS_ERR (disk_super )) {
1356
1356
device = ERR_CAST (disk_super );
@@ -1381,7 +1381,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
1381
1381
btrfs_release_disk_super (disk_super );
1382
1382
1383
1383
error_bdev_put :
1384
- bdev_release ( bdev_handle );
1384
+ fput ( bdev_file );
1385
1385
1386
1386
return device ;
1387
1387
}
@@ -2057,7 +2057,7 @@ void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
2057
2057
2058
2058
int btrfs_rm_device (struct btrfs_fs_info * fs_info ,
2059
2059
struct btrfs_dev_lookup_args * args ,
2060
- struct bdev_handle * * bdev_handle )
2060
+ struct file * * bdev_file )
2061
2061
{
2062
2062
struct btrfs_trans_handle * trans ;
2063
2063
struct btrfs_device * device ;
@@ -2166,7 +2166,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
2166
2166
2167
2167
btrfs_assign_next_active_device (device , NULL );
2168
2168
2169
- if (device -> bdev_handle ) {
2169
+ if (device -> bdev_file ) {
2170
2170
cur_devices -> open_devices -- ;
2171
2171
/* remove sysfs entry */
2172
2172
btrfs_sysfs_remove_device (device );
@@ -2182,9 +2182,9 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
2182
2182
* free the device.
2183
2183
*
2184
2184
* We cannot call btrfs_close_bdev() here because we're holding the sb
2185
- * write lock, and bdev_release () will pull in the ->open_mutex on
2186
- * the block device and it's dependencies. Instead just flush the
2187
- * device and let the caller do the final bdev_release.
2185
+ * write lock, and fput () on the block device will pull in the
2186
+ * ->open_mutex on the block device and it's dependencies. Instead
2187
+ * just flush the device and let the caller do the final bdev_release.
2188
2188
*/
2189
2189
if (test_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state )) {
2190
2190
btrfs_scratch_superblocks (fs_info , device -> bdev ,
@@ -2195,7 +2195,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
2195
2195
}
2196
2196
}
2197
2197
2198
- * bdev_handle = device -> bdev_handle ;
2198
+ * bdev_file = device -> bdev_file ;
2199
2199
synchronize_rcu ();
2200
2200
btrfs_free_device (device );
2201
2201
@@ -2332,7 +2332,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
2332
2332
const char * path )
2333
2333
{
2334
2334
struct btrfs_super_block * disk_super ;
2335
- struct bdev_handle * bdev_handle ;
2335
+ struct file * bdev_file ;
2336
2336
int ret ;
2337
2337
2338
2338
if (!path || !path [0 ])
@@ -2350,7 +2350,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
2350
2350
}
2351
2351
2352
2352
ret = btrfs_get_bdev_and_sb (path , BLK_OPEN_READ , NULL , 0 ,
2353
- & bdev_handle , & disk_super );
2353
+ & bdev_file , & disk_super );
2354
2354
if (ret ) {
2355
2355
btrfs_put_dev_args_from_path (args );
2356
2356
return ret ;
@@ -2363,7 +2363,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
2363
2363
else
2364
2364
memcpy (args -> fsid , disk_super -> fsid , BTRFS_FSID_SIZE );
2365
2365
btrfs_release_disk_super (disk_super );
2366
- bdev_release ( bdev_handle );
2366
+ fput ( bdev_file );
2367
2367
return 0 ;
2368
2368
}
2369
2369
@@ -2583,7 +2583,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
2583
2583
struct btrfs_root * root = fs_info -> dev_root ;
2584
2584
struct btrfs_trans_handle * trans ;
2585
2585
struct btrfs_device * device ;
2586
- struct bdev_handle * bdev_handle ;
2586
+ struct file * bdev_file ;
2587
2587
struct super_block * sb = fs_info -> sb ;
2588
2588
struct btrfs_fs_devices * fs_devices = fs_info -> fs_devices ;
2589
2589
struct btrfs_fs_devices * seed_devices = NULL ;
@@ -2596,12 +2596,12 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
2596
2596
if (sb_rdonly (sb ) && !fs_devices -> seeding )
2597
2597
return - EROFS ;
2598
2598
2599
- bdev_handle = bdev_open_by_path (device_path , BLK_OPEN_WRITE ,
2599
+ bdev_file = bdev_file_open_by_path (device_path , BLK_OPEN_WRITE ,
2600
2600
fs_info -> bdev_holder , NULL );
2601
- if (IS_ERR (bdev_handle ))
2602
- return PTR_ERR (bdev_handle );
2601
+ if (IS_ERR (bdev_file ))
2602
+ return PTR_ERR (bdev_file );
2603
2603
2604
- if (!btrfs_check_device_zone_type (fs_info , bdev_handle -> bdev )) {
2604
+ if (!btrfs_check_device_zone_type (fs_info , file_bdev ( bdev_file ) )) {
2605
2605
ret = - EINVAL ;
2606
2606
goto error ;
2607
2607
}
@@ -2613,11 +2613,11 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
2613
2613
locked = true;
2614
2614
}
2615
2615
2616
- sync_blockdev (bdev_handle -> bdev );
2616
+ sync_blockdev (file_bdev ( bdev_file ) );
2617
2617
2618
2618
rcu_read_lock ();
2619
2619
list_for_each_entry_rcu (device , & fs_devices -> devices , dev_list ) {
2620
- if (device -> bdev == bdev_handle -> bdev ) {
2620
+ if (device -> bdev == file_bdev ( bdev_file ) ) {
2621
2621
ret = - EEXIST ;
2622
2622
rcu_read_unlock ();
2623
2623
goto error ;
@@ -2633,8 +2633,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
2633
2633
}
2634
2634
2635
2635
device -> fs_info = fs_info ;
2636
- device -> bdev_handle = bdev_handle ;
2637
- device -> bdev = bdev_handle -> bdev ;
2636
+ device -> bdev_file = bdev_file ;
2637
+ device -> bdev = file_bdev ( bdev_file ) ;
2638
2638
ret = lookup_bdev (device_path , & device -> devt );
2639
2639
if (ret )
2640
2640
goto error_free_device ;
@@ -2817,7 +2817,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
2817
2817
error_free_device :
2818
2818
btrfs_free_device (device );
2819
2819
error :
2820
- bdev_release ( bdev_handle );
2820
+ fput ( bdev_file );
2821
2821
if (locked ) {
2822
2822
mutex_unlock (& uuid_mutex );
2823
2823
up_write (& sb -> s_umount );
0 commit comments