[PATCH 2/6] target: remove target_get_task_cdb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that tasks are always the same size as the command there is no need
to rewrite a CDB in common code.  Notw that we keep the separately allocated
CDB in the pscsi and stgt backends for now, to easy reintroducing any
command splitting local to these backends if nessecary.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>

---
 drivers/target/target_core_cdb.c     |   49 -----------------------------------
 drivers/target/target_core_pscsi.c   |    3 +-
 drivers/target/target_core_stgt.c    |    3 +-
 include/target/target_core_backend.h |    2 -
 4 files changed, 4 insertions(+), 53 deletions(-)

Index: lio-core/drivers/target/target_core_cdb.c
===================================================================
--- lio-core.orig/drivers/target/target_core_cdb.c	2012-04-21 10:40:05.847915834 +0200
+++ lio-core/drivers/target/target_core_cdb.c	2012-04-21 14:02:57.643933527 +0200
@@ -1148,52 +1148,3 @@ int target_emulate_noop(struct se_task *
 	transport_complete_task(task, 1);
 	return 0;
 }
-
-/*
- * Write a CDB into @cdb that is based on the one the intiator sent us,
- * but updated to only cover the sectors that the current task handles.
- */
-void target_get_task_cdb(struct se_task *task, unsigned char *cdb)
-{
-	struct se_cmd *cmd = task->task_se_cmd;
-	unsigned int cdb_len = scsi_command_size(cmd->t_task_cdb);
-
-	memcpy(cdb, cmd->t_task_cdb, cdb_len);
-	if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {
-		unsigned long long lba = task->task_lba;
-		u32 sectors = task->task_sectors;
-
-		switch (cdb_len) {
-		case 6:
-			/* 21-bit LBA and 8-bit sectors */
-			cdb[1] = (lba >> 16) & 0x1f;
-			cdb[2] = (lba >> 8) & 0xff;
-			cdb[3] = lba & 0xff;
-			cdb[4] = sectors & 0xff;
-			break;
-		case 10:
-			/* 32-bit LBA and 16-bit sectors */
-			put_unaligned_be32(lba, &cdb[2]);
-			put_unaligned_be16(sectors, &cdb[7]);
-			break;
-		case 12:
-			/* 32-bit LBA and 32-bit sectors */
-			put_unaligned_be32(lba, &cdb[2]);
-			put_unaligned_be32(sectors, &cdb[6]);
-			break;
-		case 16:
-			/* 64-bit LBA and 32-bit sectors */
-			put_unaligned_be64(lba, &cdb[2]);
-			put_unaligned_be32(sectors, &cdb[10]);
-			break;
-		case 32:
-			/* 64-bit LBA and 32-bit sectors, extended CDB */
-			put_unaligned_be64(lba, &cdb[12]);
-			put_unaligned_be32(sectors, &cdb[28]);
-			break;
-		default:
-			BUG();
-		}
-	}
-}
-EXPORT_SYMBOL(target_get_task_cdb);
Index: lio-core/drivers/target/target_core_pscsi.c
===================================================================
--- lio-core.orig/drivers/target/target_core_pscsi.c	2012-04-05 23:02:52.846753598 +0200
+++ lio-core/drivers/target/target_core_pscsi.c	2012-04-21 14:04:12.023930214 +0200
@@ -1070,7 +1070,8 @@ static int pscsi_do_task(struct se_task
 	struct bio *hbio;
 	int ret;
 
-	target_get_task_cdb(task, pt->pscsi_cdb);
+	memcpy(pt->pscsi_cdb, cmd->t_task_cdb,
+		scsi_command_size(cmd->t_task_cdb));
 
 	if (task->task_se_cmd->se_cmd_flags & SCF_SCSI_NON_DATA_CDB) {
 		req = blk_get_request(pdv->pdv_sd->request_queue,
Index: lio-core/drivers/target/target_core_stgt.c
===================================================================
--- lio-core.orig/drivers/target/target_core_stgt.c	2012-04-21 10:37:32.355922690 +0200
+++ lio-core/drivers/target/target_core_stgt.c	2012-04-21 14:04:29.987929238 +0200
@@ -337,7 +337,8 @@ static int stgt_do_task(struct se_task *
 		return -ENOMEM;
 	}
 
-	target_get_task_cdb(task, st->stgt_cdb);
+	memcpy(st->stgt_cdb, cmd->t_task_cdb,
+		scsi_command_size(cmd->t_task_cdb));
 	memcpy(sc->cmnd, st->stgt_cdb, MAX_COMMAND_SIZE);
 	sc->sdb.length = task->task_size;
 	sc->sdb.table.sgl = task->task_sg;
Index: lio-core/include/target/target_core_backend.h
===================================================================
--- lio-core.orig/include/target/target_core_backend.h	2012-03-19 11:08:07.566682828 +0100
+++ lio-core/include/target/target_core_backend.h	2012-04-21 14:04:39.771928962 +0200
@@ -51,8 +51,6 @@ struct se_device *transport_add_device_t
 void	transport_complete_sync_cache(struct se_cmd *, int);
 void	transport_complete_task(struct se_task *, int);
 
-void	target_get_task_cdb(struct se_task *, unsigned char *);
-
 void	transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
 int	transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
 int	transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux