]> git.baikalelectronics.ru Git - kernel.git/commitdiff
target: pass a block_device to target_configure_unmap_from_queue
authorChristoph Hellwig <hch@lst.de>
Fri, 15 Apr 2022 04:52:33 +0000 (06:52 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 Apr 2022 01:49:58 +0000 (19:49 -0600)
The SCSI target drivers is a consumer of the block layer and shoul
d generally work on struct block_device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220415045258.199825-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/target/target_core_device.c
drivers/target/target_core_file.c
drivers/target/target_core_iblock.c
include/target/target_core_backend.h

index fa866acef5bb2a6c56d6a772f704d3e849f22498..3a1ec705cd80b34133298cdc2059c237ac8163a4 100644 (file)
@@ -834,9 +834,10 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
  * in ATA and we need to set TPE=1
  */
 bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
-                                      struct request_queue *q)
+                                      struct block_device *bdev)
 {
-       int block_size = queue_logical_block_size(q);
+       struct request_queue *q = bdev_get_queue(bdev);
+       int block_size = bdev_logical_block_size(bdev);
 
        if (!blk_queue_discard(q))
                return false;
index 8190b840065f3e9137d6d872dbbdb8c051358e49..8d191fdc33217ab82d00b1ce4b3578b206cc3551 100644 (file)
@@ -134,10 +134,11 @@ static int fd_configure_device(struct se_device *dev)
         */
        inode = file->f_mapping->host;
        if (S_ISBLK(inode->i_mode)) {
-               struct request_queue *q = bdev_get_queue(I_BDEV(inode));
+               struct block_device *bdev = I_BDEV(inode);
+               struct request_queue *q = bdev_get_queue(bdev);
                unsigned long long dev_size;
 
-               fd_dev->fd_block_size = bdev_logical_block_size(I_BDEV(inode));
+               fd_dev->fd_block_size = bdev_logical_block_size(bdev);
                /*
                 * Determine the number of bytes from i_size_read() minus
                 * one (1) logical sector from underlying struct block_device
@@ -150,7 +151,7 @@ static int fd_configure_device(struct se_device *dev)
                        dev_size, div_u64(dev_size, fd_dev->fd_block_size),
                        fd_dev->fd_block_size);
 
-               if (target_configure_unmap_from_queue(&dev->dev_attrib, q))
+               if (target_configure_unmap_from_queue(&dev->dev_attrib, bdev))
                        pr_debug("IFILE: BLOCK Discard support available,"
                                 " disabled by default\n");
                /*
index 87ede165ddba435ef8eeb3912e9368599e87b0c4..b886ce1770bfd04ded43ee8b2722d063f56e6a12 100644 (file)
@@ -119,7 +119,7 @@ static int iblock_configure_device(struct se_device *dev)
        dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q);
        dev->dev_attrib.hw_queue_depth = q->nr_requests;
 
-       if (target_configure_unmap_from_queue(&dev->dev_attrib, q))
+       if (target_configure_unmap_from_queue(&dev->dev_attrib, bd))
                pr_debug("IBLOCK: BLOCK Discard support available,"
                         " disabled by default\n");
 
index 675f3a1fe613944464ab5c14fe841d590f91f17e..773963a1e0b5362d4e5b4423f8534c23dc6d7957 100644 (file)
@@ -14,7 +14,7 @@
 #define TRANSPORT_FLAG_PASSTHROUGH_ALUA                0x2
 #define TRANSPORT_FLAG_PASSTHROUGH_PGR          0x4
 
-struct request_queue;
+struct block_device;
 struct scatterlist;
 
 struct target_backend_ops {
@@ -117,7 +117,7 @@ sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd,
 bool target_sense_desc_format(struct se_device *dev);
 sector_t target_to_linux_sector(struct se_device *dev, sector_t lb);
 bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
-                                      struct request_queue *q);
+                                      struct block_device *bdev);
 
 static inline bool target_dev_configured(struct se_device *se_dev)
 {