Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

target: port block device access to file

Link: https://lore.kernel.org/r/20240123-vfs-bdev-file-v2-17-adbd023e19cc@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+22 -22
+9 -9
drivers/target/target_core_iblock.c
··· 91 91 { 92 92 struct iblock_dev *ib_dev = IBLOCK_DEV(dev); 93 93 struct request_queue *q; 94 - struct bdev_handle *bdev_handle; 94 + struct file *bdev_file; 95 95 struct block_device *bd; 96 96 struct blk_integrity *bi; 97 97 blk_mode_t mode = BLK_OPEN_READ; ··· 117 117 else 118 118 dev->dev_flags |= DF_READ_ONLY; 119 119 120 - bdev_handle = bdev_open_by_path(ib_dev->ibd_udev_path, mode, ib_dev, 120 + bdev_file = bdev_file_open_by_path(ib_dev->ibd_udev_path, mode, ib_dev, 121 121 NULL); 122 - if (IS_ERR(bdev_handle)) { 123 - ret = PTR_ERR(bdev_handle); 122 + if (IS_ERR(bdev_file)) { 123 + ret = PTR_ERR(bdev_file); 124 124 goto out_free_bioset; 125 125 } 126 - ib_dev->ibd_bdev_handle = bdev_handle; 127 - ib_dev->ibd_bd = bd = bdev_handle->bdev; 126 + ib_dev->ibd_bdev_file = bdev_file; 127 + ib_dev->ibd_bd = bd = file_bdev(bdev_file); 128 128 129 129 q = bdev_get_queue(bd); 130 130 ··· 180 180 return 0; 181 181 182 182 out_blkdev_put: 183 - bdev_release(ib_dev->ibd_bdev_handle); 183 + fput(ib_dev->ibd_bdev_file); 184 184 out_free_bioset: 185 185 bioset_exit(&ib_dev->ibd_bio_set); 186 186 out: ··· 205 205 { 206 206 struct iblock_dev *ib_dev = IBLOCK_DEV(dev); 207 207 208 - if (ib_dev->ibd_bdev_handle) 209 - bdev_release(ib_dev->ibd_bdev_handle); 208 + if (ib_dev->ibd_bdev_file) 209 + fput(ib_dev->ibd_bdev_file); 210 210 bioset_exit(&ib_dev->ibd_bio_set); 211 211 } 212 212
+1 -1
drivers/target/target_core_iblock.h
··· 32 32 u32 ibd_flags; 33 33 struct bio_set ibd_bio_set; 34 34 struct block_device *ibd_bd; 35 - struct bdev_handle *ibd_bdev_handle; 35 + struct file *ibd_bdev_file; 36 36 bool ibd_readonly; 37 37 struct iblock_dev_plug *ibd_plug; 38 38 } ____cacheline_aligned;
+11 -11
drivers/target/target_core_pscsi.c
··· 352 352 struct pscsi_hba_virt *phv = dev->se_hba->hba_ptr; 353 353 struct pscsi_dev_virt *pdv = PSCSI_DEV(dev); 354 354 struct Scsi_Host *sh = sd->host; 355 - struct bdev_handle *bdev_handle; 355 + struct file *bdev_file; 356 356 int ret; 357 357 358 358 if (scsi_device_get(sd)) { ··· 366 366 * Claim exclusive struct block_device access to struct scsi_device 367 367 * for TYPE_DISK and TYPE_ZBC using supplied udev_path 368 368 */ 369 - bdev_handle = bdev_open_by_path(dev->udev_path, 369 + bdev_file = bdev_file_open_by_path(dev->udev_path, 370 370 BLK_OPEN_WRITE | BLK_OPEN_READ, pdv, NULL); 371 - if (IS_ERR(bdev_handle)) { 371 + if (IS_ERR(bdev_file)) { 372 372 pr_err("pSCSI: bdev_open_by_path() failed\n"); 373 373 scsi_device_put(sd); 374 - return PTR_ERR(bdev_handle); 374 + return PTR_ERR(bdev_file); 375 375 } 376 - pdv->pdv_bdev_handle = bdev_handle; 376 + pdv->pdv_bdev_file = bdev_file; 377 377 378 378 ret = pscsi_add_device_to_list(dev, sd); 379 379 if (ret) { 380 - bdev_release(bdev_handle); 380 + fput(bdev_file); 381 381 scsi_device_put(sd); 382 382 return ret; 383 383 } ··· 564 564 * from pscsi_create_type_disk() 565 565 */ 566 566 if ((sd->type == TYPE_DISK || sd->type == TYPE_ZBC) && 567 - pdv->pdv_bdev_handle) { 568 - bdev_release(pdv->pdv_bdev_handle); 569 - pdv->pdv_bdev_handle = NULL; 567 + pdv->pdv_bdev_file) { 568 + fput(pdv->pdv_bdev_file); 569 + pdv->pdv_bdev_file = NULL; 570 570 } 571 571 /* 572 572 * For HBA mode PHV_LLD_SCSI_HOST_NO, release the reference ··· 994 994 { 995 995 struct pscsi_dev_virt *pdv = PSCSI_DEV(dev); 996 996 997 - if (pdv->pdv_bdev_handle) 998 - return bdev_nr_sectors(pdv->pdv_bdev_handle->bdev); 997 + if (pdv->pdv_bdev_file) 998 + return bdev_nr_sectors(file_bdev(pdv->pdv_bdev_file)); 999 999 return 0; 1000 1000 } 1001 1001
+1 -1
drivers/target/target_core_pscsi.h
··· 37 37 int pdv_channel_id; 38 38 int pdv_target_id; 39 39 int pdv_lun_id; 40 - struct bdev_handle *pdv_bdev_handle; 40 + struct file *pdv_bdev_file; 41 41 struct scsi_device *pdv_sd; 42 42 struct Scsi_Host *pdv_lld_host; 43 43 } ____cacheline_aligned;