@@ -468,39 +468,39 @@ static noinline struct btrfs_fs_devices *find_fsid(
468468
469469static int
470470btrfs_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 ,
472472 struct btrfs_super_block * * disk_super )
473473{
474474 struct block_device * bdev ;
475475 int ret ;
476476
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 );
478478
479- if (IS_ERR (* bdev_handle )) {
480- ret = PTR_ERR (* bdev_handle );
479+ if (IS_ERR (* bdev_file )) {
480+ ret = PTR_ERR (* bdev_file );
481481 goto error ;
482482 }
483- bdev = ( * bdev_handle ) -> bdev ;
483+ bdev = file_bdev ( * bdev_file ) ;
484484
485485 if (flush )
486486 sync_blockdev (bdev );
487487 ret = set_blocksize (bdev , BTRFS_BDEV_BLOCKSIZE );
488488 if (ret ) {
489- bdev_release ( * bdev_handle );
489+ fput ( * bdev_file );
490490 goto error ;
491491 }
492492 invalidate_bdev (bdev );
493493 * disk_super = btrfs_read_dev_super (bdev );
494494 if (IS_ERR (* disk_super )) {
495495 ret = PTR_ERR (* disk_super );
496- bdev_release ( * bdev_handle );
496+ fput ( * bdev_file );
497497 goto error ;
498498 }
499499
500500 return 0 ;
501501
502502error :
503- * bdev_handle = NULL ;
503+ * bdev_file = NULL ;
504504 return ret ;
505505}
506506
@@ -643,7 +643,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
643643 struct btrfs_device * device , blk_mode_t flags ,
644644 void * holder )
645645{
646- struct bdev_handle * bdev_handle ;
646+ struct file * bdev_file ;
647647 struct btrfs_super_block * disk_super ;
648648 u64 devid ;
649649 int ret ;
@@ -654,7 +654,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
654654 return - EINVAL ;
655655
656656 ret = btrfs_get_bdev_and_sb (device -> name -> str , flags , holder , 1 ,
657- & bdev_handle , & disk_super );
657+ & bdev_file , & disk_super );
658658 if (ret )
659659 return ret ;
660660
@@ -678,20 +678,20 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
678678 clear_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state );
679679 fs_devices -> seeding = true;
680680 } else {
681- if (bdev_read_only (bdev_handle -> bdev ))
681+ if (bdev_read_only (file_bdev ( bdev_file ) ))
682682 clear_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state );
683683 else
684684 set_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state );
685685 }
686686
687- if (!bdev_nonrot (bdev_handle -> bdev ))
687+ if (!bdev_nonrot (file_bdev ( bdev_file ) ))
688688 fs_devices -> rotating = true;
689689
690- if (bdev_max_discard_sectors (bdev_handle -> bdev ))
690+ if (bdev_max_discard_sectors (file_bdev ( bdev_file ) ))
691691 fs_devices -> discardable = true;
692692
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 ) ;
695695 clear_bit (BTRFS_DEV_STATE_IN_FS_METADATA , & device -> dev_state );
696696
697697 fs_devices -> open_devices ++ ;
@@ -706,7 +706,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
706706
707707error_free_page :
708708 btrfs_release_disk_super (disk_super );
709- bdev_release ( bdev_handle );
709+ fput ( bdev_file );
710710
711711 return - EINVAL ;
712712}
@@ -1015,10 +1015,10 @@ static void __btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices,
10151015 if (device -> devid == BTRFS_DEV_REPLACE_DEVID )
10161016 continue ;
10171017
1018- if (device -> bdev_handle ) {
1019- bdev_release (device -> bdev_handle );
1018+ if (device -> bdev_file ) {
1019+ fput (device -> bdev_file );
10201020 device -> bdev = NULL ;
1021- device -> bdev_handle = NULL ;
1021+ device -> bdev_file = NULL ;
10221022 fs_devices -> open_devices -- ;
10231023 }
10241024 if (test_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state )) {
@@ -1063,7 +1063,7 @@ static void btrfs_close_bdev(struct btrfs_device *device)
10631063 invalidate_bdev (device -> bdev );
10641064 }
10651065
1066- bdev_release (device -> bdev_handle );
1066+ fput (device -> bdev_file );
10671067}
10681068
10691069static 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,
13161316 struct btrfs_super_block * disk_super ;
13171317 bool new_device_added = false;
13181318 struct btrfs_device * device = NULL ;
1319- struct bdev_handle * bdev_handle ;
1319+ struct file * bdev_file ;
13201320 u64 bytenr , bytenr_orig ;
13211321 int ret ;
13221322
@@ -1339,18 +1339,18 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
13391339 * values temporarily, as the device paths of the fsid are the only
13401340 * required information for assembling the volume.
13411341 */
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 );
13451345
13461346 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 );
13481348 if (ret ) {
13491349 device = ERR_PTR (ret );
13501350 goto error_bdev_put ;
13511351 }
13521352
1353- disk_super = btrfs_read_disk_super (bdev_handle -> bdev , bytenr ,
1353+ disk_super = btrfs_read_disk_super (file_bdev ( bdev_file ) , bytenr ,
13541354 bytenr_orig );
13551355 if (IS_ERR (disk_super )) {
13561356 device = ERR_CAST (disk_super );
@@ -1381,7 +1381,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
13811381 btrfs_release_disk_super (disk_super );
13821382
13831383error_bdev_put :
1384- bdev_release ( bdev_handle );
1384+ fput ( bdev_file );
13851385
13861386 return device ;
13871387}
@@ -2057,7 +2057,7 @@ void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
20572057
20582058int btrfs_rm_device (struct btrfs_fs_info * fs_info ,
20592059 struct btrfs_dev_lookup_args * args ,
2060- struct bdev_handle * * bdev_handle )
2060+ struct file * * bdev_file )
20612061{
20622062 struct btrfs_trans_handle * trans ;
20632063 struct btrfs_device * device ;
@@ -2166,7 +2166,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
21662166
21672167 btrfs_assign_next_active_device (device , NULL );
21682168
2169- if (device -> bdev_handle ) {
2169+ if (device -> bdev_file ) {
21702170 cur_devices -> open_devices -- ;
21712171 /* remove sysfs entry */
21722172 btrfs_sysfs_remove_device (device );
@@ -2182,9 +2182,9 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
21822182 * free the device.
21832183 *
21842184 * 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.
21882188 */
21892189 if (test_bit (BTRFS_DEV_STATE_WRITEABLE , & device -> dev_state )) {
21902190 btrfs_scratch_superblocks (fs_info , device -> bdev ,
@@ -2195,7 +2195,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
21952195 }
21962196 }
21972197
2198- * bdev_handle = device -> bdev_handle ;
2198+ * bdev_file = device -> bdev_file ;
21992199 synchronize_rcu ();
22002200 btrfs_free_device (device );
22012201
@@ -2332,7 +2332,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
23322332 const char * path )
23332333{
23342334 struct btrfs_super_block * disk_super ;
2335- struct bdev_handle * bdev_handle ;
2335+ struct file * bdev_file ;
23362336 int ret ;
23372337
23382338 if (!path || !path [0 ])
@@ -2350,7 +2350,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
23502350 }
23512351
23522352 ret = btrfs_get_bdev_and_sb (path , BLK_OPEN_READ , NULL , 0 ,
2353- & bdev_handle , & disk_super );
2353+ & bdev_file , & disk_super );
23542354 if (ret ) {
23552355 btrfs_put_dev_args_from_path (args );
23562356 return ret ;
@@ -2363,7 +2363,7 @@ int btrfs_get_dev_args_from_path(struct btrfs_fs_info *fs_info,
23632363 else
23642364 memcpy (args -> fsid , disk_super -> fsid , BTRFS_FSID_SIZE );
23652365 btrfs_release_disk_super (disk_super );
2366- bdev_release ( bdev_handle );
2366+ fput ( bdev_file );
23672367 return 0 ;
23682368}
23692369
@@ -2583,7 +2583,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
25832583 struct btrfs_root * root = fs_info -> dev_root ;
25842584 struct btrfs_trans_handle * trans ;
25852585 struct btrfs_device * device ;
2586- struct bdev_handle * bdev_handle ;
2586+ struct file * bdev_file ;
25872587 struct super_block * sb = fs_info -> sb ;
25882588 struct btrfs_fs_devices * fs_devices = fs_info -> fs_devices ;
25892589 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
25962596 if (sb_rdonly (sb ) && !fs_devices -> seeding )
25972597 return - EROFS ;
25982598
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 ,
26002600 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 );
26032603
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 ) )) {
26052605 ret = - EINVAL ;
26062606 goto error ;
26072607 }
@@ -2613,11 +2613,11 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
26132613 locked = true;
26142614 }
26152615
2616- sync_blockdev (bdev_handle -> bdev );
2616+ sync_blockdev (file_bdev ( bdev_file ) );
26172617
26182618 rcu_read_lock ();
26192619 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 ) ) {
26212621 ret = - EEXIST ;
26222622 rcu_read_unlock ();
26232623 goto error ;
@@ -2633,8 +2633,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
26332633 }
26342634
26352635 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 ) ;
26382638 ret = lookup_bdev (device_path , & device -> devt );
26392639 if (ret )
26402640 goto error_free_device ;
@@ -2817,7 +2817,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
28172817error_free_device :
28182818 btrfs_free_device (device );
28192819error :
2820- bdev_release ( bdev_handle );
2820+ fput ( bdev_file );
28212821 if (locked ) {
28222822 mutex_unlock (& uuid_mutex );
28232823 up_write (& sb -> s_umount );
0 commit comments