|
@@ -121,29 +121,11 @@ 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;
|
|
|
|
|
|
- /*
|
|
|
- * Check if the underlying struct block_device request_queue supports
|
|
|
- * the QUEUE_FLAG_DISCARD bit for UNMAP/WRITE_SAME in SCSI + TRIM
|
|
|
- * in ATA and we need to set TPE=1
|
|
|
- */
|
|
|
- if (blk_queue_discard(q)) {
|
|
|
- dev->dev_attrib.max_unmap_lba_count =
|
|
|
- q->limits.max_discard_sectors;
|
|
|
-
|
|
|
- /*
|
|
|
- * Currently hardcoded to 1 in Linux/SCSI code..
|
|
|
- */
|
|
|
- dev->dev_attrib.max_unmap_block_desc_count = 1;
|
|
|
- dev->dev_attrib.unmap_granularity =
|
|
|
- q->limits.discard_granularity >> 9;
|
|
|
- dev->dev_attrib.unmap_granularity_alignment =
|
|
|
- q->limits.discard_alignment;
|
|
|
- dev->dev_attrib.unmap_zeroes_data =
|
|
|
- q->limits.discard_zeroes_data;
|
|
|
-
|
|
|
+ if (target_configure_unmap_from_queue(&dev->dev_attrib, q,
|
|
|
+ dev->dev_attrib.hw_block_size))
|
|
|
pr_debug("IBLOCK: BLOCK Discard support available,"
|
|
|
- " disabled by default\n");
|
|
|
- }
|
|
|
+ " disabled by default\n");
|
|
|
+
|
|
|
/*
|
|
|
* Enable write same emulation for IBLOCK and use 0xFFFF as
|
|
|
* the smaller WRITE_SAME(10) only has a two-byte block count.
|
|
@@ -415,9 +397,13 @@ static sense_reason_t
|
|
|
iblock_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
|
|
|
{
|
|
|
struct block_device *bdev = IBLOCK_DEV(cmd->se_dev)->ibd_bd;
|
|
|
+ struct se_device *dev = cmd->se_dev;
|
|
|
int ret;
|
|
|
|
|
|
- ret = blkdev_issue_discard(bdev, lba, nolb, GFP_KERNEL, 0);
|
|
|
+ ret = blkdev_issue_discard(bdev,
|
|
|
+ target_to_linux_sector(dev, lba),
|
|
|
+ target_to_linux_sector(dev, nolb),
|
|
|
+ GFP_KERNEL, 0);
|
|
|
if (ret < 0) {
|
|
|
pr_err("blkdev_issue_discard() failed: %d\n", ret);
|
|
|
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
|
@@ -433,8 +419,10 @@ iblock_execute_write_same(struct se_cmd *cmd)
|
|
|
struct scatterlist *sg;
|
|
|
struct bio *bio;
|
|
|
struct bio_list list;
|
|
|
- sector_t block_lba = cmd->t_task_lba;
|
|
|
- sector_t sectors = sbc_get_write_same_sectors(cmd);
|
|
|
+ struct se_device *dev = cmd->se_dev;
|
|
|
+ sector_t block_lba = target_to_linux_sector(dev, cmd->t_task_lba);
|
|
|
+ sector_t sectors = target_to_linux_sector(dev,
|
|
|
+ sbc_get_write_same_sectors(cmd));
|
|
|
|
|
|
if (cmd->prot_op) {
|
|
|
pr_err("WRITE_SAME: Protection information with IBLOCK"
|
|
@@ -648,12 +636,12 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
|
|
|
enum dma_data_direction data_direction)
|
|
|
{
|
|
|
struct se_device *dev = cmd->se_dev;
|
|
|
+ sector_t block_lba = target_to_linux_sector(dev, cmd->t_task_lba);
|
|
|
struct iblock_req *ibr;
|
|
|
struct bio *bio, *bio_start;
|
|
|
struct bio_list list;
|
|
|
struct scatterlist *sg;
|
|
|
u32 sg_num = sgl_nents;
|
|
|
- sector_t block_lba;
|
|
|
unsigned bio_cnt;
|
|
|
int rw = 0;
|
|
|
int i;
|
|
@@ -679,24 +667,6 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
|
|
|
rw = READ;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * Convert the blocksize advertised to the initiator to the 512 byte
|
|
|
- * units unconditionally used by the Linux block layer.
|
|
|
- */
|
|
|
- if (dev->dev_attrib.block_size == 4096)
|
|
|
- block_lba = (cmd->t_task_lba << 3);
|
|
|
- else if (dev->dev_attrib.block_size == 2048)
|
|
|
- block_lba = (cmd->t_task_lba << 2);
|
|
|
- else if (dev->dev_attrib.block_size == 1024)
|
|
|
- block_lba = (cmd->t_task_lba << 1);
|
|
|
- else if (dev->dev_attrib.block_size == 512)
|
|
|
- block_lba = cmd->t_task_lba;
|
|
|
- else {
|
|
|
- pr_err("Unsupported SCSI -> BLOCK LBA conversion:"
|
|
|
- " %u\n", dev->dev_attrib.block_size);
|
|
|
- return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
|
|
- }
|
|
|
-
|
|
|
ibr = kzalloc(sizeof(struct iblock_req), GFP_KERNEL);
|
|
|
if (!ibr)
|
|
|
goto fail;
|