Skip to contentSkip to conversation

Target updates for June 28

PATCH In review Andy Grover 2 participants 26 messages Jun 28, 2011

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Target updates for June 28

Hi nab,

These updates comprise four major changes, and some small ones. (Please see individual patch changelogs for rationales.) First, it makes all control cdbs scatter-gather. Second, it removes struct se_mem. Third, it quiets dmesg output by using pr_debug and friends instead of bare printks, and removes the custom debug infrastructure. Fourth, it removes direct ramdisk code.

I look forward to hear your (and everyone's) comments on these changes.

Thanks -- Regards -- Andy

The following changes since commit 2a940ce682163cd41670243c3c10b47dbb206cfd:

tcm_fc: Fix transport_lookup_tmr_lun failure usage (2011-06-22 19:51:27 -0700)

are available in the git repository at:
git://fedorapeople.org/home/fedora/grover/public_git/linux-2.6.git for-nab

Andy Grover (15):
target: Remove ifdeffed code in t_g_process_write
target: Pass 2nd param of transport_split_cdb by value
target: Make all control CDBs scatter-gather
target: Disable rd_dr
target: Eliminate usage of struct se_mem
target: Rename task_sg_num to task_sg_nents
target: Remove custom debug macros for pr_debug. Use pr_err().
target: Remove custom debug macros in non-iscsi fabrics target/iscsi: Remove iscsi_target_debug.h and usage of TRACE() & printk() target/iscsi: Remove SE_CMD macro
target: WRITE_SAME_16 and WRITE_SAME_32 should be DATA_SG_IO cdbs
target: Set WSNZ=1 in block limits VPD. Abort if WRITE_SAME sectors = 0
target: Enforce 1 page max for control cdb buffer sizes
target: Remove direct ramdisk code
target: Remove transport do_se_mem_map callback

 drivers/infiniband/ulp/srpt/ib_srpt.c             |    7 -
 drivers/scsi/qla2xxx/qla_target.c                 |    3 -
 drivers/target/iscsi/Kconfig                      |    9 -
 drivers/target/iscsi/iscsi_target.c               |  489 +++----
 drivers/target/iscsi/iscsi_target_auth.c          |   84 +-
 drivers/target/iscsi/iscsi_target_configfs.c      |   76 +-
 drivers/target/iscsi/iscsi_target_core.h          |    3 -
 drivers/target/iscsi/iscsi_target_datain_values.c |   13 +-
 drivers/target/iscsi/iscsi_target_debug.h         |  113 --
 drivers/target/iscsi/iscsi_target_device.c        |    7 +-
 drivers/target/iscsi/iscsi_target_erl0.c          |   71 +-
 drivers/target/iscsi/iscsi_target_erl1.c          |   67 +-
 drivers/target/iscsi/iscsi_target_erl2.c          |   86 +-
 drivers/target/iscsi/iscsi_target_login.c         |  105 +-
 drivers/target/iscsi/iscsi_target_nego.c          |   89 +-
 drivers/target/iscsi/iscsi_target_nodeattrib.c    |   41 +-
 drivers/target/iscsi/iscsi_target_parameters.c    |  259 ++--
 drivers/target/iscsi/iscsi_target_seq_pdu_list.c  |   43 +-
 drivers/target/iscsi/iscsi_target_tmr.c           |   63 +-
 drivers/target/iscsi/iscsi_target_tpg.c           |   77 +-
 drivers/target/iscsi/iscsi_target_tq.c            |   27 +-
 drivers/target/iscsi/iscsi_target_util.c          |  141 +-
 drivers/target/loopback/Kconfig                   |    6 -
 drivers/target/loopback/tcm_loop.c                |   99 +-
 drivers/target/loopback/tcm_loop.h                |    6 -
 drivers/target/target_core_alua.c                 |  120 +-
 drivers/target/target_core_cdb.c                  |   91 +-
 drivers/target/target_core_configfs.c             |  258 ++--
 drivers/target/target_core_device.c               |  175 ++--
 drivers/target/target_core_fabric_configfs.c      |   40 +-
 drivers/target/target_core_fabric_lib.c           |    6 +-
 drivers/target/target_core_file.c                 |   78 +-
 drivers/target/target_core_hba.c                  |   10 +-
 drivers/target/target_core_iblock.c               |   93 +-
 drivers/target/target_core_pr.c                   |  317 +++--
 drivers/target/target_core_pscsi.c                |  144 +--
 drivers/target/target_core_rd.c                   |  420 +-----
 drivers/target/target_core_scdb.c                 |   20 +-
 drivers/target/target_core_scdb.h                 |   10 +-
 drivers/target/target_core_stgt.c                 |   52 +-
 drivers/target/target_core_tmr.c                  |   39 +-
 drivers/target/target_core_tpg.c                  |   42 +-
 drivers/target/target_core_transport.c            | 1614 ++++++---------------
 drivers/target/target_core_ua.c                   |    8 +-
 drivers/target/tcm_fc/tcm_fc.h                    |   24 -
 drivers/target/tcm_fc/tfc_cmd.c                   |   57 +-
 drivers/target/tcm_fc/tfc_conf.c                  |   33 +-
 drivers/target/tcm_fc/tfc_io.c                    |  125 +-
 drivers/target/tcm_fc/tfc_sess.c                  |   18 +-
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_base.h     |    6 -
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c |  190 ++--
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c   |   41 +-
 drivers/target/tcm_vhost/tcm_vhost_configfs.c     |   50 +-
 drivers/target/tcm_vhost/tcm_vhost_fabric.c       |   16 +-
 drivers/target/tcm_vhost/tcm_vhost_scsi.c         |   15 +-
 include/target/target_core_base.h                 |   19 +-
 include/target/target_core_transport.h            |   11 +-
 57 files changed, 2407 insertions(+), 3719 deletions(-)
 delete mode 100644 drivers/target/iscsi/iscsi_target_debug.h
#1 lore raw

PATCH 1/15 target: Remove ifdeffed code in t_g_process_write

---
 drivers/target/target_core_transport.c |   58 --------------------------------
 1 files changed, 0 insertions(+), 58 deletions(-)
drivers/target/target_core_transport.c +0 -58
index 3288cef..9d02f86 100644
@@ -4945,64 +4945,6 @@ EXPORT_SYMBOL(transport_generic_new_cmd);
  */
 void transport_generic_process_write(struct se_cmd *cmd)
 {
-#if 0
-	/*
-	 * Copy SCSI Presented DTL sector(s) from received buffers allocated to
-	 * original EDTL
-	 */
-	if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
-		if (!cmd->t_tasks_se_num) {
-			unsigned char *dst, *buf =
-				(unsigned char *)cmd->t_task_buf;
-
-			dst = kzalloc(cmd->cmd_spdtl), GFP_KERNEL);
-			if (!(dst)) {
-				printk(KERN_ERR "Unable to allocate memory for"
-						" WRITE underflow\n");
-				transport_generic_request_failure(cmd, NULL,
-					PYX_TRANSPORT_REQ_TOO_MANY_SECTORS, 1);
-				return;
-			}
-			memcpy(dst, buf, cmd->cmd_spdtl);
-
-			kfree(cmd->t_task_buf);
-			cmd->t_task_buf = dst;
-		} else {
-			struct scatterlist *sg =
-				(struct scatterlist *sg)cmd->t_task_buf;
-			struct scatterlist *orig_sg;
-
-			orig_sg = kzalloc(sizeof(struct scatterlist) *
-					cmd->t_tasks_se_num,
-					GFP_KERNEL))) {
-			if (!(orig_sg)) {
-				printk(KERN_ERR "Unable to allocate memory"
-						" for WRITE underflow\n");
-				transport_generic_request_failure(cmd, NULL,
-					PYX_TRANSPORT_REQ_TOO_MANY_SECTORS, 1);
-				return;
-			}
-
-			memcpy(orig_sg, cmd->t_task_buf,
-					sizeof(struct scatterlist) *
-					cmd->t_tasks_se_num);
-
-			cmd->data_length = cmd->cmd_spdtl;
-			/*
-			 * FIXME, clear out original struct se_task and state
-			 * information.
-			 */
-			if (transport_generic_new_cmd(cmd) < 0) {
-				transport_generic_request_failure(cmd, NULL,
-					PYX_TRANSPORT_REQ_TOO_MANY_SECTORS, 1);
-				kfree(orig_sg);
-				return;
-			}
-
-			transport_memcpy_write_sg(cmd, orig_sg);
-		}
-	}
-#endif
 	transport_execute_tasks(cmd);
 }
 EXPORT_SYMBOL(transport_generic_process_write);
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 01/15] target: Remove ifdeffed code in t_g_process_write

Quoted 3 lines

void transport_generic_process_write(struct se_cmd *cmd) {
-#if 0

...

drivers/target/target_core_transport.c EXPORT_SYMBOL(transport_generic_new_cmd); · line 4950

Quoted 4 lines
drivers/target/target_core_transport.c +0 -1
-#endif
 	transport_execute_tasks(cmd);
 }
 EXPORT_SYMBOL(transport_generic_process_write);

How about just killing transport_generic_process_write and calling transport_execute_tasks directly?

#3 lore raw

Re: [PATCH 01/15] target: Remove ifdeffed code in t_g_process_write

Quoted 6 lines · Christoph Hellwig
Quoted 3 lines

void transport_generic_process_write(struct se_cmd *cmd) {
-#if 0

...

Quoted 7 lines

drivers/target/target_core_transport.c EXPORT_SYMBOL(transport_generic_new_cmd); · line 4950

Quoted 4 lines
drivers/target/target_core_transport.c +0 -1
-#endif
 	transport_execute_tasks(cmd);
 }
 EXPORT_SYMBOL(transport_generic_process_write);

How about just killing transport_generic_process_write and calling transport_execute_tasks directly?

Thanks for reviewing the set. I'm going to wait a day or two to see if more comments come in, then I'll repost. I'm inclined to agree with all your comments, except I'll probably save the change mentioned above for a follow-on patchset, unless it's fixed in the meantime.

Thanks again -- Regards -- Andy

#4 lore raw

PATCH 2/15 target: Pass 2nd param of transport_split_cdb by value

In reply to Andy Grover

Since sectors is not modified, it's more straightforward to do this.

---
 drivers/target/target_core_scdb.c      |   20 ++++++++++----------
 drivers/target/target_core_scdb.h      |   10 +++++-----
 drivers/target/target_core_transport.c |    3 +--
 include/target/target_core_base.h      |    2 +-
 4 files changed, 17 insertions(+), 18 deletions(-)
drivers/target/target_core_scdb.c +10 -10
index dc6fed0..7284344 100644
@@ -42,13 +42,13 @@
  */
 void split_cdb_XX_6(
 	unsigned long long lba,
-	u32 *sectors,
+	u32 sectors,
 	unsigned char *cdb)
 {
 	cdb[1] = (lba >> 16) & 0x1f;
 	cdb[2] = (lba >> 8) & 0xff;
 	cdb[3] = lba & 0xff;
-	cdb[4] = *sectors & 0xff;
+	cdb[4] = sectors & 0xff;
 }
 
 /*	split_cdb_XX_10():
@@ -57,11 +57,11 @@ void split_cdb_XX_6(
  */
 void split_cdb_XX_10(
 	unsigned long long lba,
-	u32 *sectors,
+	u32 sectors,
 	unsigned char *cdb)
 {
 	put_unaligned_be32(lba, &cdb[2]);
-	put_unaligned_be16(*sectors, &cdb[7]);
+	put_unaligned_be16(sectors, &cdb[7]);
 }
 
 /*	split_cdb_XX_12():
@@ -70,11 +70,11 @@ void split_cdb_XX_10(
  */
 void split_cdb_XX_12(
 	unsigned long long lba,
-	u32 *sectors,
+	u32 sectors,
 	unsigned char *cdb)
 {
 	put_unaligned_be32(lba, &cdb[2]);
-	put_unaligned_be32(*sectors, &cdb[6]);
+	put_unaligned_be32(sectors, &cdb[6]);
 }
 
 /*	split_cdb_XX_16():
@@ -83,11 +83,11 @@ void split_cdb_XX_12(
  */
 void split_cdb_XX_16(
 	unsigned long long lba,
-	u32 *sectors,
+	u32 sectors,
 	unsigned char *cdb)
 {
 	put_unaligned_be64(lba, &cdb[2]);
-	put_unaligned_be32(*sectors, &cdb[10]);
+	put_unaligned_be32(sectors, &cdb[10]);
 }
 
 /*
@@ -97,9 +97,9 @@ void split_cdb_XX_16(
  */
 void split_cdb_XX_32(
 	unsigned long long lba,
-	u32 *sectors,
+	u32 sectors,
 	unsigned char *cdb)
 {
 	put_unaligned_be64(lba, &cdb[12]);
-	put_unaligned_be32(*sectors, &cdb[28]);
+	put_unaligned_be32(sectors, &cdb[28]);
 }
drivers/target/target_core_scdb.h +5 -5
index 98cd1c0..48e9ccc 100644
@@ -1,10 +1,10 @@
 #ifndef TARGET_CORE_SCDB_H
 #define TARGET_CORE_SCDB_H
 
-extern void split_cdb_XX_6(unsigned long long, u32 *, unsigned char *);
-extern void split_cdb_XX_10(unsigned long long, u32 *, unsigned char *);
-extern void split_cdb_XX_12(unsigned long long, u32 *, unsigned char *);
-extern void split_cdb_XX_16(unsigned long long, u32 *, unsigned char *);
-extern void split_cdb_XX_32(unsigned long long, u32 *, unsigned char *);
+extern void split_cdb_XX_6(unsigned long long, u32, unsigned char *);
+extern void split_cdb_XX_10(unsigned long long, u32, unsigned char *);
+extern void split_cdb_XX_12(unsigned long long, u32, unsigned char *);
+extern void split_cdb_XX_16(unsigned long long, u32, unsigned char *);
+extern void split_cdb_XX_32(unsigned long long, u32, unsigned char *);
 
 #endif /* TARGET_CORE_SCDB_H */
drivers/target/target_core_transport.c +1 -2
index 9d02f86..b98f6ff 100644
@@ -4762,8 +4762,7 @@ static u32 transport_allocate_tasks(
 		       scsi_command_size(cmd->t_task_cdb));
 
 		/* Update new cdb with updated lba/sectors */
-		cmd->transport_split_cdb(task->task_lba,
-					 &task->task_sectors, cdb);
+		cmd->transport_split_cdb(task->task_lba, task->task_sectors, cdb);
 
 		/*
 		 * Perform the SE OBJ plugin and/or Transport plugin specific
include/target/target_core_base.h +1 -1
index 380b4c8..464ecd2 100644
@@ -480,7 +480,7 @@ struct se_cmd {
 	struct list_head	se_queue_node;
 	struct target_core_fabric_ops *se_tfo;
 	int (*transport_emulate_cdb)(struct se_cmd *);
-	void (*transport_split_cdb)(unsigned long long, u32 *, unsigned char *);
+	void (*transport_split_cdb)(unsigned long long, u32, unsigned char *);
 	void (*transport_wait_for_tasks)(struct se_cmd *, int, int);
 	void (*transport_complete_callback)(struct se_cmd *);
 	int (*transport_qf_callback)(struct se_cmd *);
Signature · 1 line
1.7.1
#5 lore raw

Re: [PATCH 02/15] target: Pass 2nd param of transport_split_cdb by value

Quoted 1 line · Andy Grover

Since sectors is not modified, it's more straightforward to do this.

Looks fine, although long-term we should really nuke this helper, or move them into target_core_pscsi.c

#6 lore raw

PATCH 3/15 target: Make all control CDBs scatter-gather

In reply to Andy Grover

Previously, some control CDBs did not allocate memory in pages for their data buffer, but just did a kmalloc. This patch makes all cdbs allocate pages.

This has the benefit of streamlining some paths that had to behave differently when we used two allocation methods. The downside is that all accesses to the data buffer need to kmap it before use, and need to handle data in page-sized chunks if more than a page is needed for a given command's data buffer.

---
 drivers/infiniband/ulp/srpt/ib_srpt.c           |    7 -
 drivers/scsi/qla2xxx/qla_target.c               |    3 -
 drivers/target/iscsi/iscsi_target.c             |   74 ++---------
 drivers/target/iscsi/iscsi_target_core.h        |    1 -
 drivers/target/iscsi/iscsi_target_util.c        |   11 +-
 drivers/target/target_core_alua.c               |   24 +++-
 drivers/target/target_core_cdb.c                |   49 ++++++-
 drivers/target/target_core_device.c             |    5 +-
 drivers/target/target_core_pr.c                 |   53 +++++++-
 drivers/target/target_core_pscsi.c              |   32 +----
 drivers/target/target_core_transport.c          |  158 ++++++++---------------
 drivers/target/tcm_fc/tfc_cmd.c                 |    4 +-
 drivers/target/tcm_fc/tfc_io.c                  |   61 +++-------
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c |   21 ---
 include/target/target_core_base.h               |    4 +-
 include/target/target_core_transport.h          |    6 +-
 16 files changed, 207 insertions(+), 306 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +0 -7
index b64b653..60415e1 100644
@@ -1131,13 +1131,6 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch,
 		transport_do_task_sg_chain(cmd);
 		sg = sg_orig = cmd->t_tasks_sg_chained;
 		sg_cnt = cmd->t_tasks_sg_chained_no;
-	} else if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_NONSG_IO_CDB) {
-		/* Use task->t_tasks_sg_bounce for control CDBs. */
-		sg_init_table(&cmd->t_tasks_sg_bounce, 1);
-		sg_set_buf(&cmd->t_tasks_sg_bounce, cmd->t_task_buf,
-			   cmd->data_length);
-		sg = sg_orig = &cmd->t_tasks_sg_bounce;
-		sg_cnt = 1;
 	} else {
 		pr_debug("?? sg == NULL\n");
 		ioctx->mapped_sg_count = 0;
drivers/scsi/qla2xxx/qla_target.c +0 -3
index 4d54872..360abab 100644
@@ -3890,9 +3890,6 @@ restart:
 		    (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB)) {
 			cmd->sg_cnt = se_cmd->t_tasks_sg_chained_no;
 			cmd->sg = se_cmd->t_tasks_sg_chained;
-		} else if (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_NONSG_IO_CDB) {
-			cmd->sg_cnt = 1;
-			cmd->sg = &se_cmd->t_tasks_sg_bounce;
 		}
 
 		DEBUG22(qla_printk(KERN_INFO, ha, "SRR cmd %p (se_cmd %p, tag %d, op %x), "
drivers/target/iscsi/iscsi_target.c +13 -61

92 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_core.h +0 -1
index 5bf2f7a..c66a259 100644
@@ -470,7 +470,6 @@ struct iscsi_cmd {
 #define ISCSI_SENSE_BUFFER_LEN          (TRANSPORT_SENSE_BUFFER + 2)
 	unsigned char		sense_buffer[ISCSI_SENSE_BUFFER_LEN];
 
-	void			*t_mem;
 	struct scatterlist	*t_mem_sg;
 	u32			t_mem_sg_nents;
 
drivers/target/iscsi/iscsi_target_util.c +3 -8
index e677fa0..4260888 100644
@@ -801,6 +801,7 @@ void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn)
 void iscsit_release_cmd(struct iscsi_cmd *cmd)
 {
 	struct iscsi_conn *conn = cmd->conn;
+	int i;
 
 	iscsit_free_r2ts_from_list(cmd);
 	iscsit_free_all_datain_reqs(cmd);
@@ -811,15 +812,9 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd)
 	kfree(cmd->tmr_req);
 	kfree(cmd->iov_data);
 
-	/* see iscsit_alloc_buffs */
-	if (cmd->t_mem) {
-		kfree(cmd->t_mem);
-	} else {
-		int i;
+	for (i = 0; i < cmd->t_mem_sg_nents; i++)
+		__free_page(sg_page(&cmd->t_mem_sg[i]));
 
-		for (i = 0; i < cmd->t_mem_sg_nents; i++)
-			__free_page(sg_page(&cmd->t_mem_sg[i]));
-	}
 	kfree(cmd->t_mem_sg);
 
 	if (conn) {
drivers/target/target_core_alua.c +19 -5
index 2dca8d7..3f307dd 100644
@@ -65,10 +65,12 @@ int core_emulate_report_target_port_groups(struct se_cmd *cmd)
 	struct se_port *port;
 	struct t10_alua_tg_pt_gp *tg_pt_gp;
 	struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
-	unsigned char *buf = (unsigned char *)cmd->t_task_buf;
+	unsigned char *buf;
 	u32 rd_len = 0, off = 4; /* Skip over RESERVED area to first
 				    Target port group descriptor */
 
+	buf = transport_kmap_first_data_page(cmd);
+
 	spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
 	list_for_each_entry(tg_pt_gp, &su_dev->t10_alua.tg_pt_gps_list,
 			tg_pt_gp_list) {
@@ -141,6 +143,8 @@ int core_emulate_report_target_port_groups(struct se_cmd *cmd)
 	buf[2] = ((rd_len >> 8) & 0xff);
 	buf[3] = (rd_len & 0xff);
 
+	transport_kunmap_first_data_page(cmd);
+
 	return 0;
 }
 
@@ -157,8 +161,8 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
 	struct se_node_acl *nacl = cmd->se_sess->se_node_acl;
 	struct t10_alua_tg_pt_gp *tg_pt_gp = NULL, *l_tg_pt_gp;
 	struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, *l_tg_pt_gp_mem;
-	unsigned char *buf = (unsigned char *)cmd->t_task_buf;
-	unsigned char *ptr = &buf[4]; /* Skip over RESERVED area in header */
+	unsigned char *buf;
+	unsigned char *ptr;
 	u32 len = 4; /* Skip over RESERVED area in header */
 	int alua_access_state, primary = 0, rc;
 	u16 tg_pt_id, rtpi;
@@ -190,6 +194,9 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
 		return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 	}
 
+	buf = transport_kmap_first_data_page(cmd);
+	ptr = &buf[4]; /* Skip over RESERVED area in header */
+
 	while (len < cmd->data_length) {
 		alua_access_state = (ptr[0] & 0x0f);
 		/*
@@ -209,6 +216,7 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
 			 * REQUEST, and the additional sense code set to INVALID
 			 * FIELD IN PARAMETER LIST.
 			 */
+			transport_kunmap_first_data_page(cmd);
 			return PYX_TRANSPORT_INVALID_PARAMETER_LIST;
 		}
 		rc = -1;
@@ -260,8 +268,10 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
 			 * If not matching target port group ID can be located
 			 * throw an exception with ASCQ: INVALID_PARAMETER_LIST
 			 */
-			if (rc != 0)
+			if (rc != 0) {
+				transport_kunmap_first_data_page(cmd);
 				return PYX_TRANSPORT_INVALID_PARAMETER_LIST;
+			}
 		} else {
 			/*
 			 * Extact the RELATIVE TARGET PORT IDENTIFIER to identify
@@ -295,14 +305,18 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
 			 * be located, throw an exception with ASCQ:
 			 * INVALID_PARAMETER_LIST
 			 */
-			if (rc != 0)
+			if (rc != 0) {
+				transport_kunmap_first_data_page(cmd);
 				return PYX_TRANSPORT_INVALID_PARAMETER_LIST;
+			}
 		}
 
 		ptr += 4;
 		len += 4;
 	}
 
+	transport_kunmap_first_data_page(cmd);
+
 	return 0;
 }
 
drivers/target/target_core_cdb.c +42 -7

187 lines not on this page · raw message

drivers/target/target_core_device.c +4 -1
index ebf05db..fcd312b 100644
@@ -658,7 +658,7 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
 	struct se_lun *se_lun;
 	struct se_session *se_sess = se_cmd->se_sess;
 	struct se_task *se_task;
-	unsigned char *buf = se_cmd->t_task_buf;
+	unsigned char *buf;
 	u32 cdb_offset = 0, lun_count = 0, offset = 8, i;
 
 	list_for_each_entry(se_task, &se_cmd->t_task_list, t_list)
@@ -669,6 +669,8 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
 		return PYX_TRANSPORT_LU_COMM_FAILURE;
 	}
 
+	buf = transport_kmap_first_data_page(se_cmd);
+
 	/*
 	 * If no struct se_session pointer is present, this struct se_cmd is
 	 * coming via a target_core_mod PASSTHROUGH op, and not through
@@ -705,6 +707,7 @@ int transport_core_report_lun_response(struct se_cmd *se_cmd)
 	 * See SPC3 r07, page 159.
 	 */
 done:
+	transport_kunmap_first_data_page(se_cmd);
 	lun_count *= 8;
 	buf[0] = ((lun_count >> 24) & 0xff);
 	buf[1] = ((lun_count >> 16) & 0xff);
drivers/target/target_core_pr.c +46 -7

217 lines not on this page · raw message

drivers/target/target_core_pscsi.c +3 -29
index 3574c52..d956924 100644
@@ -695,7 +695,7 @@ static int pscsi_transport_complete(struct se_task *task)
 
 		if (task->task_se_cmd->se_deve->lun_flags &
 				TRANSPORT_LUNFLAGS_READ_ONLY) {
-			unsigned char *buf = task->task_se_cmd->t_task_buf;
+			unsigned char *buf = transport_kmap_first_data_page(task->task_se_cmd);
 
 			if (cdb[0] == MODE_SENSE_10) {
 				if (!(buf[3] & 0x80))
@@ -704,6 +704,8 @@ static int pscsi_transport_complete(struct se_task *task)
 				if (!(buf[2] & 0x80))
 					buf[2] |= 0x80;
 			}
+
+			transport_kunmap_first_data_page(task->task_se_cmd);
 		}
 	}
 after_mode_sense:
@@ -1246,33 +1248,6 @@ static int pscsi_map_task_SG(struct se_task *task)
 	return 0;
 }
 
-/*	pscsi_map_task_non_SG():
- *
- *
- */
-static int pscsi_map_task_non_SG(struct se_task *task)
-{
-	struct se_cmd *cmd = task->task_se_cmd;
-	struct pscsi_plugin_task *pt = PSCSI_TASK(task);
-	struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr;
-	int ret = 0;
-
-	if (pscsi_blk_get_request(task) < 0)
-		return PYX_TRANSPORT_LU_COMM_FAILURE;
-
-	if (!task->task_size)
-		return 0;
-
-	ret = blk_rq_map_kern(pdv->pdv_sd->request_queue,
-			pt->pscsi_req, cmd->t_task_buf,
-			task->task_size, GFP_KERNEL);
-	if (ret < 0) {
-		printk(KERN_ERR "PSCSI: blk_rq_map_kern() failed: %d\n", ret);
-		return PYX_TRANSPORT_LU_COMM_FAILURE;
-	}
-	return 0;
-}
-
 static int pscsi_CDB_none(struct se_task *task)
 {
 	return pscsi_blk_get_request(task);
@@ -1392,7 +1367,6 @@ static struct se_subsystem_api pscsi_template = {
 	.owner			= THIS_MODULE,
 	.transport_type		= TRANSPORT_PLUGIN_PHBA_PDEV,
 	.cdb_none		= pscsi_CDB_none,
-	.map_task_non_SG	= pscsi_map_task_non_SG,
 	.map_task_SG		= pscsi_map_task_SG,
 	.attach_hba		= pscsi_attach_hba,
 	.detach_hba		= pscsi_detach_hba,
drivers/target/target_core_transport.c +55 -103

318 lines not on this page · raw message

drivers/target/tcm_fc/tfc_cmd.c +2 -2
index 1f2e9f5..1f8477f 100644
@@ -71,9 +71,9 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
 		caller, cmd, cmd->cdb);
 	printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun);
 
-	printk(KERN_INFO "%s: cmd %p se_num %u buf %p len %u se_cmd_flags <0x%x>\n",
+	printk(KERN_INFO "%s: cmd %p se_num %u len %u se_cmd_flags <0x%x>\n",
 	       caller, cmd, se_cmd->t_tasks_se_num,
-	       se_cmd->t_task_buf, se_cmd->data_length, se_cmd->se_cmd_flags);
+	       se_cmd->data_length, se_cmd->se_cmd_flags);
 
 	list_for_each_entry(mem, &se_cmd->t_mem_list, se_list)
 		printk(KERN_INFO "%s: cmd %p mem %p page %p "
drivers/target/tcm_fc/tfc_io.c +17 -44

109 lines not on this page · raw message

drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c +0 -21
index 1271d4e..4dacc1d 100644
@@ -517,16 +517,6 @@ int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd)
 
 		cmd->sg_cnt = se_cmd->t_tasks_sg_chained_no;
 		cmd->sg = se_cmd->t_tasks_sg_chained;
-	} else if (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_NONSG_IO_CDB) {
-		/*
-		 * Use se_cmd->t_task->t_tasks_sg_bounce for control CDBs
-		 * using a contiguous buffer
-		 */
-		sg_init_table(&se_cmd->t_tasks_sg_bounce, 1);
-		sg_set_buf(&se_cmd->t_tasks_sg_bounce,
-			se_cmd->t_task_buf, se_cmd->data_length);
-		cmd->sg_cnt = 1;
-		cmd->sg = &se_cmd->t_tasks_sg_bounce;
 	} else {
 		printk(KERN_ERR "Unknown se_cmd_flags: 0x%08x in"
 			" tcm_qla2xxx_write_pending()\n", se_cmd->se_cmd_flags);
@@ -729,17 +719,6 @@ int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd)
 
 		cmd->sg_cnt = se_cmd->t_tasks_sg_chained_no;
 		cmd->sg = se_cmd->t_tasks_sg_chained;
-	} else if (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_NONSG_IO_CDB) {
-		/*
-		 * Use se_cmd->t_task->t_tasks_sg_bounce for control CDBs
-		 * using a contigious buffer
-		 */
-		sg_init_table(&se_cmd->t_tasks_sg_bounce, 1);
-		sg_set_buf(&se_cmd->t_tasks_sg_bounce,
-			se_cmd->t_task_buf, se_cmd->data_length);
-
-		cmd->sg_cnt = 1;
-		cmd->sg = &se_cmd->t_tasks_sg_bounce;
 	} else {
 		cmd->sg_cnt = 0;
 		cmd->sg = NULL;
include/target/target_core_base.h +1 -3
index 464ecd2..91a1d93 100644
@@ -109,7 +109,6 @@ enum se_cmd_flags_table {
 	SCF_EMULATED_TASK_SENSE		= 0x00000004,
 	SCF_SCSI_DATA_SG_IO_CDB		= 0x00000008,
 	SCF_SCSI_CONTROL_SG_IO_CDB	= 0x00000010,
-	SCF_SCSI_CONTROL_NONSG_IO_CDB	= 0x00000020,
 	SCF_SCSI_NON_DATA_CDB		= 0x00000040,
 	SCF_SCSI_CDB_EXCEPTION		= 0x00000080,
 	SCF_SCSI_RESERVATION_CONFLICT	= 0x00000100,
@@ -516,8 +515,7 @@ struct se_cmd {
 	struct completion	transport_lun_fe_stop_comp;
 	struct completion	transport_lun_stop_comp;
 	struct scatterlist	*t_tasks_sg_chained;
-	struct scatterlist	t_tasks_sg_bounce;
-	void			*t_task_buf;
+
 	/*
 	 * Used for pre-registered fabric SGL passthrough WRITE and READ
 	 * with the special SCF_PASSTHROUGH_CONTIG_TO_SG case for TCM_Loop
include/target/target_core_transport.h +2 -4
index 2aae764..7d10fb5 100644
@@ -163,6 +163,8 @@ extern void transport_init_se_cmd(struct se_cmd *,
 					struct target_core_fabric_ops *,
 					struct se_session *, u32, int, int,
 					unsigned char *);
+void *transport_kmap_first_data_page(struct se_cmd *cmd);
+void transport_kunmap_first_data_page(struct se_cmd *cmd);
 extern void transport_free_se_cmd(struct se_cmd *);
 extern int transport_generic_allocate_tasks(struct se_cmd *, unsigned char *);
 extern int transport_generic_handle_cdb(struct se_cmd *);
@@ -235,10 +237,6 @@ struct se_subsystem_api {
 	 */
 	int (*cdb_none)(struct se_task *);
 	/*
-	 * For SCF_SCSI_CONTROL_NONSG_IO_CDB
-	 */
-	int (*map_task_non_SG)(struct se_task *);
-	/*
 	 * For SCF_SCSI_DATA_SG_IO_CDB and SCF_SCSI_CONTROL_SG_IO_CDB
 	 */
 	int (*map_task_SG)(struct se_task *);
Signature · 1 line
1.7.1
#7 lore raw

Re: [PATCH 03/15] target: Make all control CDBs scatter-gather

Quoted 9 lines
drivers/target/target_core_alua.c +1 -0
@@ -209,6 +216,7 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
 			 * REQUEST, and the additional sense code set to INVALID
 			 * FIELD IN PARAMETER LIST.
 			 */
+			transport_kunmap_first_data_page(cmd);
 			return PYX_TRANSPORT_INVALID_PARAMETER_LIST;
 		}
 		rc = -1;

drivers/target/target_core_alua.c int core_emulate_set_target_port_groups(struct se_cmd *cmd) · line 274

Quoted 8 lines
drivers/target/target_core_alua.c +3 -1
@@ -260,8 +268,10 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
 			 * If not matching target port group ID can be located
 			 * throw an exception with ASCQ: INVALID_PARAMETER_LIST
 			 */
-			if (rc != 0)
+			if (rc != 0) {
+				transport_kunmap_first_data_page(cmd);
 				return PYX_TRANSPORT_INVALID_PARAMETER_LIST;
+			}

It would be good to use goto unwinding here and in all other control CDB handlers that may return errors.

#8 lore raw

PATCH 4/15 target: Disable rd_dr

In reply to Andy Grover

The rd_dr ramdisk implementation is closely tied with struct se_mem. Disable it before removing struct se_mem. I'm not sure if we want to fix up and re-enable it, or maybe just decide we can live without it and remove it entirely.

---
 drivers/target/target_core_device.c |    2 +-
 drivers/target/target_core_rd.c     |   17 +++++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/target/target_core_device.c +1 -1
index fcd312b..875d64f 100644
@@ -1563,7 +1563,7 @@ int core_dev_setup_virtual_lun0(void)
 	char buf[16];
 	int ret;
 
-	hba = core_alloc_hba("rd_dr", 0, HBA_FLAGS_INTERNAL_USE);
+	hba = core_alloc_hba("rd_mcp", 0, HBA_FLAGS_INTERNAL_USE);
 	if (IS_ERR(hba))
 		return PTR_ERR(hba);
 
drivers/target/target_core_rd.c +15 -2
index 4f9416d..a30c02e 100644
@@ -44,7 +44,7 @@
 
 #include "target_core_rd.h"
 
-static struct se_subsystem_api rd_dr_template;
+//static struct se_subsystem_api rd_dr_template;
 static struct se_subsystem_api rd_mcp_template;
 
 /* #define DEBUG_RAMDISK_MCP */
@@ -226,10 +226,12 @@ static void *rd_allocate_virtdevice(
 	return rd_dev;
 }
 
+#if 0
 static void *rd_DIRECT_allocate_virtdevice(struct se_hba *hba, const char *name)
 {
 	return rd_allocate_virtdevice(hba, name, 1);
 }
+#endif
 
 static void *rd_MEMCPY_allocate_virtdevice(struct se_hba *hba, const char *name)
 {
@@ -270,7 +272,6 @@ static struct se_device *rd_create_virtdevice(
 	dev_limits.queue_depth = RD_DEVICE_QUEUE_DEPTH;
 
 	dev = transport_add_device_to_core_hba(hba,
-			(rd_dev->rd_direct) ? &rd_dr_template :
 			&rd_mcp_template, se_dev, dev_flags, rd_dev,
 			&dev_limits, prod, rev);
 	if (!(dev))
@@ -293,6 +294,7 @@ fail:
 	return ERR_PTR(ret);
 }
 
+#if 0
 static struct se_device *rd_DIRECT_create_virtdevice(
 	struct se_hba *hba,
 	struct se_subsystem_dev *se_dev,
@@ -300,6 +302,7 @@ static struct se_device *rd_DIRECT_create_virtdevice(
 {
 	return rd_create_virtdevice(hba, se_dev, p, 1);
 }
+#endif
 
 static struct se_device *rd_MEMCPY_create_virtdevice(
 	struct se_hba *hba,
@@ -641,6 +644,7 @@ static int rd_MEMCPY_do_task(struct se_task *task)
 	return PYX_TRANSPORT_SENT_TO_TRANSPORT;
 }
 
+#if 0
 /*	rd_DIRECT_with_offset():
  *
  *
@@ -907,6 +911,7 @@ static int rd_DIRECT_do_task(struct se_task *task)
 
 	return PYX_TRANSPORT_SENT_TO_TRANSPORT;
 }
+#endif
 
 /*	rd_free_task(): (Part of se_subsystem_api_t template)
  *
@@ -1022,6 +1027,7 @@ static sector_t rd_get_blocks(struct se_device *dev)
 	return blocks_long;
 }
 
+#if 0
 static struct se_subsystem_api rd_dr_template = {
 	.name			= "rd_dr",
 	.transport_type		= TRANSPORT_PLUGIN_VHBA_VDEV,
@@ -1042,6 +1048,7 @@ static struct se_subsystem_api rd_dr_template = {
 	.get_blocks		= rd_get_blocks,
 	.do_se_mem_map		= rd_DIRECT_do_se_mem_map,
 };
+#endif
 
 static struct se_subsystem_api rd_mcp_template = {
 	.name			= "rd_mcp",
@@ -1067,13 +1074,17 @@ int __init rd_module_init(void)
 {
 	int ret;
 
+#if 0
 	ret = transport_subsystem_register(&rd_dr_template);
 	if (ret < 0)
 		return ret;
+#endif
 
 	ret = transport_subsystem_register(&rd_mcp_template);
 	if (ret < 0) {
+#if 0
 		transport_subsystem_release(&rd_dr_template);
+#endif
 		return ret;
 	}
 
@@ -1082,6 +1093,8 @@ int __init rd_module_init(void)
 
 void rd_module_exit(void)
 {
+#if 0
 	transport_subsystem_release(&rd_dr_template);
+#endif
 	transport_subsystem_release(&rd_mcp_template);
 }
Signature · 1 line
1.7.1
#9 lore raw

PATCH 5/15 target: Eliminate usage of struct se_mem

In reply to Andy Grover

Both backstores and fabrics use arrays of struct scatterlist to describe data buffers. However TCM used struct se_mems, basically a linked list of scatterlist entries. We are able to simplify the code by eliminating this intermediate data structure and just using struct scatterlist[] throughout.

---
 drivers/target/iscsi/iscsi_target.c         |    6 +-
 drivers/target/loopback/tcm_loop.c          |    5 +-
 drivers/target/target_core_iblock.c         |    2 +-
 drivers/target/target_core_pscsi.c          |    2 +-
 drivers/target/target_core_transport.c      |  984 +++++++--------------------
 drivers/target/tcm_fc/tfc_cmd.c             |   22 +-
 drivers/target/tcm_fc/tfc_io.c              |   46 +-
 drivers/target/tcm_vhost/tcm_vhost_fabric.c |    6 +-
 drivers/target/tcm_vhost/tcm_vhost_scsi.c   |    7 +-
 include/target/target_core_base.h           |   10 +-
 10 files changed, 301 insertions(+), 789 deletions(-)
drivers/target/iscsi/iscsi_target.c +3 -3
index 425caef..fd83beb 100644
@@ -762,8 +762,8 @@ static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn)
 
 static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd)
 {
-	u32 iov_count = (cmd->se_cmd.t_tasks_se_num == 0) ? 1 :
-				cmd->se_cmd.t_tasks_se_num;
+	u32 iov_count = (cmd->se_cmd.t_data_nents == 0) ? 1 :
+				cmd->se_cmd.t_data_nents;
 
 	iov_count += TRANSPORT_IOV_DATA_BUFFER;
 
@@ -815,7 +815,7 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd)
 
 	/* BIDI ops not supported */
 
-	/* make se_mem list from the memory */
+	/* Tell the core about our preallocated memory */
 	transport_generic_map_mem_to_cmd(&cmd->se_cmd, sgl, nents, NULL, 0);
 	/*
 	 * Allocate iovecs for SCSI payload after transport_generic_map_mem_to_cmd
drivers/target/loopback/tcm_loop.c +1 -4
index 5075e9b..9e9a3a8 100644
@@ -175,10 +175,7 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd)
 		sgl_bidi_count = sdb->table.nents;
 	}
 
-	/*
-	 * Map the SG memory into struct se_mem->page linked list using the same
-	 * physical memory at sg->page_link.
-	 */
+	/* Tell the core about our preallocated memory */
 	ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc),
 			scsi_sg_count(sc), sgl_bidi, sgl_bidi_count);
 	if (ret < 0)
drivers/target/target_core_iblock.c +1 -1
index d43fc91..c65a83a 100644
@@ -642,7 +642,7 @@ static int iblock_map_task_SG(struct se_task *task)
 	hbio = tbio = bio;
 	/*
 	 * Use fs/bio.c:bio_add_pages() to setup the bio_vec maplist
-	 * from TCM struct se_mem -> task->task_sg -> struct scatterlist memory.
+	 * from task->task_sg -> struct scatterlist memory.
 	 */
 	for_each_sg(task->task_sg, sg, task->task_sg_num, i) {
 		DEBUG_IBLOCK("task: %p bio: %p Calling bio_add_page(): page:"
drivers/target/target_core_pscsi.c +1 -1
index d956924..318ef14 100644
@@ -1097,7 +1097,7 @@ static int __pscsi_map_task_SG(
 		return 0;
 	/*
 	 * For SCF_SCSI_DATA_SG_IO_CDB, Use fs/bio.c:bio_add_page() to setup
-	 * the bio_vec maplist from TC< struct se_mem -> task->task_sg ->
+	 * the bio_vec maplist from task->task_sg ->
 	 * struct scatterlist memory.  The struct se_task->task_sg[] currently needs
 	 * to be attached to struct bios for submission to Linux/SCSI using
 	 * struct request to struct scsi_device->request_queue.
drivers/target/target_core_transport.c +255 -729

1,295 lines not on this page · raw message

drivers/target/tcm_fc/tfc_cmd.c +11 -11
index 1f8477f..c45f4c2 100644
@@ -59,7 +59,8 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
 	struct fc_exch *ep;
 	struct fc_seq *sp;
 	struct se_cmd *se_cmd;
-	struct se_mem *mem;
+	struct scatterlist *sg;
+	int count;
 
 	if (!(ft_debug_logging & FT_DEBUG_IO))
 		return;
@@ -71,15 +72,15 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
 		caller, cmd, cmd->cdb);
 	printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun);
 
-	printk(KERN_INFO "%s: cmd %p se_num %u len %u se_cmd_flags <0x%x>\n",
-	       caller, cmd, se_cmd->t_tasks_se_num,
+	printk(KERN_INFO "%s: cmd %p data_nents %u len %u se_cmd_flags <0x%x>\n",
+	       caller, cmd, se_cmd->t_data_nents,
 	       se_cmd->data_length, se_cmd->se_cmd_flags);
 
-	list_for_each_entry(mem, &se_cmd->t_mem_list, se_list)
-		printk(KERN_INFO "%s: cmd %p mem %p page %p "
+	for_each_sg(se_cmd->t_data_sg, sg, se_cmd->t_data_nents, count)
+		printk(KERN_INFO "%s: cmd %p sg %p page %p "
 		       "len 0x%x off 0x%x\n",
-		       caller, cmd, mem,
-		       mem->se_page, mem->se_len, mem->se_off);
+		       caller, cmd, sg,
+		       sg_page(sg), sg->length, sg->offset);
 
 	sp = cmd->seq;
 	if (sp) {
@@ -257,10 +258,9 @@ int ft_write_pending(struct se_cmd *se_cmd)
 		    (fh->fh_r_ctl == FC_RCTL_DD_DATA_DESC)) {
 			if (se_cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {
 				/*
-				 * Map se_mem list to scatterlist, so that
-				 * DDP can be setup. DDP setup function require
-				 * scatterlist. se_mem_list is internal to
-				 * TCM/LIO target
+				 * cmd may have been broken up into multiple
+				 * tasks. Link their sgs together so we can
+				 * operate on them all at once.
 				 */
 				transport_do_task_sg_chain(se_cmd);
 				cmd->sg = se_cmd->t_tasks_sg_chained;
drivers/target/tcm_fc/tfc_io.c +20 -26

82 lines not on this page · raw message

drivers/target/tcm_vhost/tcm_vhost_fabric.c +2 -4
index 6dba519..e9e0e6a 100644
@@ -278,10 +278,8 @@ int tcm_vhost_new_cmd_map(struct se_cmd *se_cmd)
 		 */
 		sg_ptr = NULL;
 	}
-	/*
-	 * Map the SG memory into struct se_mem->page linked list using the same
-	 * physical memory at sg->page_link.
-	 */
+
+	/* Tell the core about our preallocated memory */
 	ret = transport_generic_map_mem_to_cmd(se_cmd, sg_ptr,
 				tv_cmd->tvc_sgl_count, sg_bidi_ptr,
 				sg_no_bidi);
drivers/target/tcm_vhost/tcm_vhost_scsi.c +1 -6
index 7553052..45e4dd7 100644
@@ -160,12 +160,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs)
 		 * transport_generic_allocate_tasks()
 		 */
 		memcpy(tv_cmd->tvc_cdb, cdb, scsi_command_size(cdb));
-		/*
-		 * Now set the virtio-scsi SGL memory + SGL counter values in
-		 * tv_cmd for use in tcm_vhost_new_cmd_map() and down into
-		 * transport_generic_map_mem_to_cmd() code to setup the
-		 * virtio-scsi SGL  -> TCM struct se_mem mapping.
-		 */
+
 #warning FIXME: Setup tv_cmd->tvc_sgl and tv_cmd->tvc_sgl_count
 		tv_cmd->tvc_sgl = NULL;
 		tv_cmd->tvc_sgl_count = 0;
include/target/target_core_base.h +6 -4
index 91a1d93..b483591 100644
@@ -490,8 +490,6 @@ struct se_cmd {
 	int			t_tasks_failed;
 	int			t_tasks_fua;
 	bool			t_tasks_bidi;
-	u32			t_tasks_se_num;
-	u32			t_tasks_se_bidi_num;
 	u32			t_tasks_sg_chained_no;
 	atomic_t		t_fe_count;
 	atomic_t		t_se_count;
@@ -523,9 +521,13 @@ struct se_cmd {
 	 */
 	struct scatterlist	*t_task_pt_sgl;
 	u32			t_task_pt_sgl_num;
-	struct list_head	t_mem_list;
+
+	struct scatterlist	*t_data_sg;
+	unsigned int		t_data_nents;
+	struct scatterlist	*t_bidi_data_sg;
+	unsigned int		t_bidi_data_nents;
+
 	/* Used for BIDI READ */
-	struct list_head	t_mem_bidi_list;
 	struct list_head	t_task_list;
 	u32			t_task_list_num;
 
Signature · 1 line
1.7.1
#10 lore raw

Re: [PATCH 05/15] target: Eliminate usage of struct se_mem

Quoted 5 lines · Andy Grover

Both backstores and fabrics use arrays of struct scatterlist to describe data buffers. However TCM used struct se_mems, basically a linked list of scatterlist entries. We are able to simplify the code by eliminating this intermediate data structure and just using struct scatterlist[] throughout.

Nice!

Quoted 16 lines
drivers/target/target_core_transport.c +9 -0
+	for_each_sg(cmd->t_data_sg, sg, cmd->t_data_nents, count) {
 		/*
+		 * Only called if
 		 * SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC is NOT in use,
 		 */
 		if (free_page)
+			__free_page(sg_page(sg));
 
+	if (free_page)
+		kfree(cmd->t_data_sg);
+	cmd->t_data_sg = NULL;
+	cmd->t_data_nents = 0;
 
+	for_each_sg(cmd->t_bidi_data_sg, sg, cmd->t_bidi_data_nents, count) {
 		/*
+		 * Only called if

drivers/target/target_core_transport.c static void transport_free_dev_tasks(struct se_cmd *cmd) · line 3885

Quoted 10 lines
drivers/target/target_core_transport.c +5 -0
 		 * SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC is NOT in use,
 		 */
 		if (free_page)
+			__free_page(sg_page(sg));
 
 	}
+	if (free_page)
+		kfree(cmd->t_bidi_data_sg);
+	cmd->t_bidi_data_sg = NULL;
+	cmd->t_bidi_data_nents = 0;

Why bother going through the loops if we're not going to free anything? Might be worth to split this into a function doin the clearing, which only gets condtionally called, and one zeroing out the members, that also conditionally calls the low-level helper.

Quoted 15 lines
drivers/target/target_core_transport.c +8 -0
@@ -4167,160 +4095,28 @@ transport_generic_get_mem(struct se_cmd *cmd)
 	if (cmd->se_dev->transport->do_se_mem_map)
 		return 0;
 
+	if (!length)
+		return 0;
 
+	nents = DIV_ROUND_UP(length, PAGE_SIZE);
+	cmd->t_data_sg = kmalloc(sizeof(struct scatterlist) * nents, GFP_KERNEL);
+	if (!cmd->t_data_sg)
+		return -ENOMEM;
 
+	cmd->t_data_nents = nents;
+	sg_init_table(cmd->t_data_sg, nents);
 

drivers/target/target_core_transport.c transport_generic_get_mem(struct se_cmd *cmd) · line 4118

Quoted 10 lines
drivers/target/target_core_transport.c +8 -0
+	while (length) {
+		u32 page_len = min_t(u32, length, PAGE_SIZE);
+		page = alloc_page(GFP_KERNEL);
+		if (!page)
+			return -ENOMEM;
 
+		sg_set_page(&cmd->t_data_sg[i], page, page_len, 0);
+		length -= page_len;
+		i++;
 	}

This code pretty much is exactly the same as allocation in iscsit_alloc_buffs. If we can't switch iscsi to use internal buffers directly we should at least export this helper so it can use it.

That also means killing the superflous t_mem_sg/t_mem_sg_nents members in favour of t_data/t_data_nents.

drivers/target/target_core_transport.c transport_map_control_cmd_to_task(struct se_cmd *cmd) · line 4363

Quoted 5 lines
drivers/target/target_core_transport.c +5 -0
+		ret = transport_allocate_control_task(cmd);
+		if (ret < 0)
+			return ret;
+		else
+			return 1;

What about making transport_allocate_control_task return the expected value directly?

Quoted 14 lines
drivers/target/target_core_transport.c +0 -10
@@ -4863,19 +4395,13 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
 	if (ret < 0)
 		return ret;
 
-	if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {
-		list_for_each_entry(task, &cmd->t_task_list, t_list) {
-			if (atomic_read(&task->task_sent))
-				continue;
-			if (!dev->transport->map_task_SG)
-				continue;
-
-			ret = dev->transport->map_task_SG(task);
-			if (ret < 0)
-				return ret;

drivers/target/target_core_transport.c int transport_generic_new_cmd(struct se_cmd *cmd) · line 4404

Quoted 10 lines
drivers/target/target_core_transport.c +7 -3
-		}
-	} else {
-		ret = transport_map_control_cmd_to_task(cmd);
+	list_for_each_entry(task, &cmd->t_task_list, t_list) {
+		if (atomic_read(&task->task_sent))
+			continue;
+		if (!dev->transport->map_task_SG)
+			continue;
+  
+		ret = dev->transport->map_task_SG(task);

transport_map_control_cmd_to_task might have called ->cdb_none before. While I'd love to kill that method I haven't seen any work towards actually making that happen. So for now I suspect you'll still need the conditionally call to ->cdb_none.

#11 lore raw

Re: [PATCH 05/15] target: Eliminate usage of struct se_mem

Quoted 6 lines · Christoph Hellwig

This code pretty much is exactly the same as allocation in iscsit_alloc_buffs. If we can't switch iscsi to use internal buffers directly we should at least export this helper so it can use it.

That also means killing the superflous t_mem_sg/t_mem_sg_nents members in favour of t_data/t_data_nents.

Yeah I think iscsi can go back to relying on the core to allocate. I know it's a little weird to change it to self-allocation and then back, but what the move to self-allocation *really* was about was getting se_mem out of iscsi. Now that core no longer has se_mem, and allocating data buffs doesn't involve task switches, having core allocate data buffs sounds good again.

Quoted 8 lines

drivers/target/target_core_transport.c transport_map_control_cmd_to_task(struct se_cmd *cmd) · line 4363

Quoted 5 lines
drivers/target/target_core_transport.c +5 -0
+		ret = transport_allocate_control_task(cmd);
+		if (ret < 0)
+			return ret;
+		else
+			return 1;

What about making transport_allocate_control_task return the expected value directly?

Yeah you're right.

Quoted 21 lines
Quoted 21 lines
drivers/target/target_core_transport.c +4 -13
@@ -4863,19 +4395,13 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
 	if (ret < 0)
 		return ret;
 
-	if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {
-		list_for_each_entry(task, &cmd->t_task_list, t_list) {
-			if (atomic_read(&task->task_sent))
-				continue;
-			if (!dev->transport->map_task_SG)
-				continue;
-
-			ret = dev->transport->map_task_SG(task);
-			if (ret < 0)
-				return ret;
-		}
-	} else {
-		ret = transport_map_control_cmd_to_task(cmd);
+	list_for_each_entry(task, &cmd->t_task_list, t_list) {
+		if (atomic_read(&task->task_sent))
+			continue;
+		if (!dev->transport->map_task_SG)
Quoted 8 lines

drivers/target/target_core_transport.c int transport_generic_new_cmd(struct se_cmd *cmd) · line 4404

Quoted 3 lines
drivers/target/target_core_transport.c +3 -0
+			continue;
+  
+		ret = dev->transport->map_task_SG(task);

transport_map_control_cmd_to_task might have called ->cdb_none before. While I'd love to kill that method I haven't seen any work towards actually making that happen. So for now I suspect you'll still need the conditionally call to ->cdb_none.

Whups, ok.

Regards -- Andy

#12 lore raw

PATCH 6/15 target: Rename task_sg_num to task_sg_nents

In reply to Andy Grover
---
 drivers/target/target_core_file.c      |   12 ++++++------
 drivers/target/target_core_iblock.c    |    4 ++--
 drivers/target/target_core_pscsi.c     |    8 ++++----
 drivers/target/target_core_transport.c |   18 +++++++++---------
 include/target/target_core_base.h      |    2 +-
 5 files changed, 22 insertions(+), 22 deletions(-)
drivers/target/target_core_file.c +6 -6
index 5c47f42..55c7de6 100644
@@ -295,20 +295,20 @@ static int fd_do_readv(struct se_task *task)
 		      task->se_dev->se_sub_dev->se_dev_attrib.block_size);
 	int ret = 0, i;
 
-	iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL);
+	iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL);
 	if (!(iov)) {
 		printk(KERN_ERR "Unable to allocate fd_do_readv iov[]\n");
 		return -ENOMEM;
 	}
 
-	for (i = 0; i < task->task_sg_num; i++) {
+	for (i = 0; i < task->task_sg_nents; i++) {
 		iov[i].iov_len = sg[i].length;
 		iov[i].iov_base = sg_virt(&sg[i]);
 	}
 
 	old_fs = get_fs();
 	set_fs(get_ds());
-	ret = vfs_readv(fd, &iov[0], task->task_sg_num, &pos);
+	ret = vfs_readv(fd, &iov[0], task->task_sg_nents, &pos);
 	set_fs(old_fs);
 
 	kfree(iov);
@@ -346,20 +346,20 @@ static int fd_do_writev(struct se_task *task)
 		      task->se_dev->se_sub_dev->se_dev_attrib.block_size);
 	int ret, i = 0;
 
-	iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL);
+	iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL);
 	if (!(iov)) {
 		printk(KERN_ERR "Unable to allocate fd_do_writev iov[]\n");
 		return -ENOMEM;
 	}
 
-	for (i = 0; i < task->task_sg_num; i++) {
+	for (i = 0; i < task->task_sg_nents; i++) {
 		iov[i].iov_len = sg[i].length;
 		iov[i].iov_base = sg_virt(&sg[i]);
 	}
 
 	old_fs = get_fs();
 	set_fs(get_ds());
-	ret = vfs_writev(fd, &iov[0], task->task_sg_num, &pos);
+	ret = vfs_writev(fd, &iov[0], task->task_sg_nents, &pos);
 	set_fs(old_fs);
 
 	kfree(iov);
drivers/target/target_core_iblock.c +2 -2
index c65a83a..86d2601 100644
@@ -614,7 +614,7 @@ static int iblock_map_task_SG(struct se_task *task)
 	struct bio *bio = NULL, *hbio = NULL, *tbio = NULL;
 	struct scatterlist *sg;
 	int ret = 0;
-	u32 i, sg_num = task->task_sg_num;
+	u32 i, sg_num = task->task_sg_nents;
 	sector_t block_lba;
 	/*
 	 * Do starting conversion up from non 512-byte blocksize with
@@ -644,7 +644,7 @@ static int iblock_map_task_SG(struct se_task *task)
 	 * Use fs/bio.c:bio_add_pages() to setup the bio_vec maplist
 	 * from task->task_sg -> struct scatterlist memory.
 	 */
-	for_each_sg(task->task_sg, sg, task->task_sg_num, i) {
+	for_each_sg(task->task_sg, sg, task->task_sg_nents, i) {
 		DEBUG_IBLOCK("task: %p bio: %p Calling bio_add_page(): page:"
 			" %p len: %u offset: %u\n", task, bio, sg_page(sg),
 				sg->length, sg->offset);
drivers/target/target_core_pscsi.c +4 -4
index 318ef14..2c82b0a 100644
@@ -1200,7 +1200,7 @@ static int __pscsi_map_task_SG(
 		 */
 		pscsi_blk_init_request(task, pt, pt->pscsi_req, 0);
 
-		return task->task_sg_num;
+		return task->task_sg_nents;
 	}
 	/*
 	 * Setup the secondary pt->pscsi_req->next_rq used for the extra BIDI-COMMAND
@@ -1214,7 +1214,7 @@ static int __pscsi_map_task_SG(
 	}
 	pscsi_blk_init_request(task, pt, pt->pscsi_req->next_rq, 1);
 
-	return task->task_sg_num;
+	return task->task_sg_nents;
 fail:
 	while (hbio) {
 		bio = hbio;
@@ -1233,14 +1233,14 @@ static int pscsi_map_task_SG(struct se_task *task)
 	 * Setup the main struct request for the task->task_sg[] payload
 	 */
 
-	ret = __pscsi_map_task_SG(task, task->task_sg, task->task_sg_num, 0);
+	ret = __pscsi_map_task_SG(task, task->task_sg, task->task_sg_nents, 0);
 	if (ret >= 0 && task->task_sg_bidi) {
 		/*
 		 * If present, set up the extra BIDI-COMMAND SCSI READ
 		 * struct request and payload.
 		 */
 		ret = __pscsi_map_task_SG(task, task->task_sg_bidi,
-					task->task_sg_num, 1);
+					task->task_sg_nents, 1);
 	}
 
 	if (ret < 0)
drivers/target/target_core_transport.c +9 -9
index 536b679..bf3039d 100644
@@ -4165,14 +4165,14 @@ void transport_do_task_sg_chain(struct se_cmd *cmd)
 
 		if (!sg_first) {
 			sg_first = task->task_sg;
-			chained_nents = task->task_sg_num;
+			chained_nents = task->task_sg_nents;
 		} else {
 			sg_chain(sg_prev, sg_prev_nents, task->task_sg);
-			chained_nents += task->task_sg_num;
+			chained_nents += task->task_sg_nents;
 		}
 
 		sg_prev = task->task_sg;
-		sg_prev_nents = task->task_sg_num;
+		sg_prev_nents = task->task_sg_nents;
 	}
 	/*
 	 * Setup the starting pointer and total t_tasks_sg_linked_no including
@@ -4255,25 +4255,25 @@ static int transport_allocate_data_tasks(
 		 * It's so much easier and only a waste when task_count > 1.
 		 * That is extremely rare.
 		 */
-		task->task_sg_num = sgl_nents;
+		task->task_sg_nents = sgl_nents;
 		if (cmd->se_tfo->task_sg_chaining) {
-			task->task_sg_num++;
+			task->task_sg_nents++;
 			task->task_padded_sg = 1;
 		}
 
 		task->task_sg = kmalloc(sizeof(struct scatterlist) * \
-					task->task_sg_num, GFP_KERNEL);
+					task->task_sg_nents, GFP_KERNEL);
 		if (!task->task_sg) {
 			cmd->se_dev->transport->free_task(task);
 			return -ENOMEM;
 		}
 
-		sg_init_table(task->task_sg, task->task_sg_num);
+		sg_init_table(task->task_sg, task->task_sg_nents);
 
 		task_size = task->task_size;
 
 		/* Build new sgl, only up to task_size */
-		for_each_sg(task->task_sg, sg, task->task_sg_num, count) {
+		for_each_sg(task->task_sg, sg, task->task_sg_nents, count) {
 			if (cmd_sg->length > task_size)
 				break;
 
@@ -4320,7 +4320,7 @@ transport_allocate_control_task(struct se_cmd *cmd)
 	memcpy(task->task_sg, cmd->t_data_sg,
 	       sizeof(struct scatterlist) * cmd->t_data_nents);
 	task->task_size = cmd->data_length;
-	task->task_sg_num = cmd->t_data_nents;
+	task->task_sg_nents = cmd->t_data_nents;
 
 	atomic_inc(&cmd->t_fe_count);
 	atomic_inc(&cmd->t_se_count);
include/target/target_core_base.h +1 -1
index b483591..2c5a748 100644
@@ -403,7 +403,7 @@ struct se_queue_obj {
 struct se_task {
 	unsigned char	task_sense;
 	struct scatterlist *task_sg;
-	u32		task_sg_num;
+	u32		task_sg_nents;
 	struct scatterlist *task_sg_bidi;
 	u8		task_scsi_status;
 	u8		task_flags;
Signature · 1 line
1.7.1
#13 lore raw

PATCH 7/15 target: Remove custom debug macros for pr_debug. Use pr_err().

In reply to Andy Grover

pr_debug and dynamic debug can give us the flexibility to choose debugprints in a more standard way than these macros.

Since these debug statements were seldom enabled, there was some bitrot in their parameters, so those are also corrected.

Use pr_err etc. macros instead of printk(KERN_ERR..).

---
 drivers/target/target_core_alua.c            |   96 +++---
 drivers/target/target_core_cdb.c             |   39 ++--
 drivers/target/target_core_configfs.c        |  258 ++++++++--------
 drivers/target/target_core_device.c          |  168 +++++-----
 drivers/target/target_core_fabric_configfs.c |   40 ++--
 drivers/target/target_core_fabric_lib.c      |    6 +-
 drivers/target/target_core_file.c            |   66 ++---
 drivers/target/target_core_hba.c             |   10 +-
 drivers/target/target_core_iblock.c          |   87 +++---
 drivers/target/target_core_pr.c              |  264 ++++++++--------
 drivers/target/target_core_pscsi.c           |  102 +++----
 drivers/target/target_core_rd.c              |  169 +++++------
 drivers/target/target_core_stgt.c            |   52 ++--
 drivers/target/target_core_tmr.c             |   39 +--
 drivers/target/target_core_tpg.c             |   42 ++--
 drivers/target/target_core_transport.c       |  427 +++++++++-----------------
 drivers/target/target_core_ua.c              |    8 +-
 17 files changed, 847 insertions(+), 1026 deletions(-)
drivers/target/target_core_alua.c +48 -48
index 3f307dd..99fac95 100644
@@ -175,21 +175,21 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
 	 */
 	l_tg_pt_gp_mem = l_port->sep_alua_tg_pt_gp_mem;
 	if (!(l_tg_pt_gp_mem)) {
-		printk(KERN_ERR "Unable to access l_port->sep_alua_tg_pt_gp_mem\n");
+		pr_err("Unable to access l_port->sep_alua_tg_pt_gp_mem\n");
 		return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 	}
 	spin_lock(&l_tg_pt_gp_mem->tg_pt_gp_mem_lock);
 	l_tg_pt_gp = l_tg_pt_gp_mem->tg_pt_gp;
 	if (!(l_tg_pt_gp)) {
 		spin_unlock(&l_tg_pt_gp_mem->tg_pt_gp_mem_lock);
-		printk(KERN_ERR "Unable to access *l_tg_pt_gp_mem->tg_pt_gp\n");
+		pr_err("Unable to access *l_tg_pt_gp_mem->tg_pt_gp\n");
 		return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 	}
 	rc = (l_tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICT_ALUA);
 	spin_unlock(&l_tg_pt_gp_mem->tg_pt_gp_mem_lock);
 
 	if (!(rc)) {
-		printk(KERN_INFO "Unable to process SET_TARGET_PORT_GROUPS"
+		pr_debug("Unable to process SET_TARGET_PORT_GROUPS"
 				" while TPGS_EXPLICT_ALUA is disabled\n");
 		return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 	}
@@ -500,7 +500,7 @@ static int core_alua_state_check(
 	 */
 	if (atomic_read(&port->sep_tg_pt_secondary_offline)) {
 		*alua_ascq = ASCQ_04H_ALUA_OFFLINE;
-		printk(KERN_INFO "ALUA: Got secondary offline status for local"
+		pr_debug("ALUA: Got secondary offline status for local"
 				" target port\n");
 		*alua_ascq = ASCQ_04H_ALUA_OFFLINE;
 		return 1;
@@ -542,7 +542,7 @@ static int core_alua_state_check(
 	 */
 	case ALUA_ACCESS_STATE_OFFLINE:
 	default:
-		printk(KERN_ERR "Unknown ALUA access state: 0x%02x\n",
+		pr_err("Unknown ALUA access state: 0x%02x\n",
 				out_alua_state);
 		return -EINVAL;
 	}
@@ -574,7 +574,7 @@ static int core_alua_check_transition(int state, int *primary)
 		*primary = 0;
 		break;
 	default:
-		printk(KERN_ERR "Unknown ALUA access state: 0x%02x\n", state);
+		pr_err("Unknown ALUA access state: 0x%02x\n", state);
 		return -EINVAL;
 	}
 
@@ -661,7 +661,7 @@ static int core_alua_write_tpg_metadata(
 
 	file = filp_open(path, flags, 0600);
 	if (IS_ERR(file) || !file || !file->f_dentry) {
-		printk(KERN_ERR "filp_open(%s) for ALUA metadata failed\n",
+		pr_err("filp_open(%s) for ALUA metadata failed\n",
 			path);
 		return -ENODEV;
 	}
@@ -675,7 +675,7 @@ static int core_alua_write_tpg_metadata(
 	set_fs(old_fs);
 
 	if (ret < 0) {
-		printk(KERN_ERR "Error writing ALUA metadata file: %s\n", path);
+		pr_err("Error writing ALUA metadata file: %s\n", path);
 		filp_close(file, NULL);
 		return -EIO;
 	}
@@ -814,7 +814,7 @@ static int core_alua_do_transition_tg_pt(
 	 */
 	atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state, new_state);
 
-	printk(KERN_INFO "Successful %s ALUA transition TG PT Group: %s ID: %hu"
+	pr_debug("Successful %s ALUA transition TG PT Group: %s ID: %hu"
 		" from primary access state %s to %s\n", (explict) ? "explict" :
 		"implict", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item),
 		tg_pt_gp->tg_pt_gp_id, core_alua_dump_state(old_state),
@@ -846,7 +846,7 @@ int core_alua_do_port_transition(
 
 	md_buf = kzalloc(l_tg_pt_gp->tg_pt_gp_md_buf_len, GFP_KERNEL);
 	if (!(md_buf)) {
-		printk("Unable to allocate buf for ALUA metadata\n");
+		pr_err("Unable to allocate buf for ALUA metadata\n");
 		return -ENOMEM;
 	}
 
@@ -935,7 +935,7 @@ int core_alua_do_port_transition(
 	}
 	spin_unlock(&lu_gp->lu_gp_lock);
 
-	printk(KERN_INFO "Successfully processed LU Group: %s all ALUA TG PT"
+	pr_debug("Successfully processed LU Group: %s all ALUA TG PT"
 		" Group IDs: %hu %s transition to primary state: %s\n",
 		config_item_name(&lu_gp->lu_gp_group.cg_item),
 		l_tg_pt_gp->tg_pt_gp_id, (explict) ? "explict" : "implict",
@@ -997,7 +997,7 @@ static int core_alua_set_tg_pt_secondary_state(
 	tg_pt_gp = tg_pt_gp_mem->tg_pt_gp;
 	if (!(tg_pt_gp)) {
 		spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
-		printk(KERN_ERR "Unable to complete secondary state"
+		pr_err("Unable to complete secondary state"
 				" transition\n");
 		return -EINVAL;
 	}
@@ -1016,7 +1016,7 @@ static int core_alua_set_tg_pt_secondary_state(
 			ALUA_STATUS_ALTERED_BY_EXPLICT_STPG :
 			ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA;
 
-	printk(KERN_INFO "Successful %s ALUA transition TG PT Group: %s ID: %hu"
+	pr_debug("Successful %s ALUA transition TG PT Group: %s ID: %hu"
 		" to secondary access state: %s\n", (explict) ? "explict" :
 		"implict", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item),
 		tg_pt_gp->tg_pt_gp_id, (offline) ? "OFFLINE" : "ONLINE");
@@ -1035,7 +1035,7 @@ static int core_alua_set_tg_pt_secondary_state(
 	if (port->sep_tg_pt_secondary_write_md) {
 		md_buf = kzalloc(md_buf_len, GFP_KERNEL);
 		if (!(md_buf)) {
-			printk(KERN_ERR "Unable to allocate md_buf for"
+			pr_err("Unable to allocate md_buf for"
 				" secondary ALUA access metadata\n");
 			return -ENOMEM;
 		}
@@ -1057,7 +1057,7 @@ core_alua_allocate_lu_gp(const char *name, int def_group)
 
 	lu_gp = kmem_cache_zalloc(t10_alua_lu_gp_cache, GFP_KERNEL);
 	if (!(lu_gp)) {
-		printk(KERN_ERR "Unable to allocate struct t10_alua_lu_gp\n");
+		pr_err("Unable to allocate struct t10_alua_lu_gp\n");
 		return ERR_PTR(-ENOMEM);
 	}
 	INIT_LIST_HEAD(&lu_gp->lu_gp_node);
@@ -1082,14 +1082,14 @@ int core_alua_set_lu_gp_id(struct t10_alua_lu_gp *lu_gp, u16 lu_gp_id)
 	 * The lu_gp->lu_gp_id may only be set once..
 	 */
 	if (lu_gp->lu_gp_valid_id) {
-		printk(KERN_WARNING "ALUA LU Group already has a valid ID,"
+		pr_warn("ALUA LU Group already has a valid ID,"
 			" ignoring request\n");
 		return -EINVAL;
 	}
 
 	spin_lock(&lu_gps_lock);
 	if (alua_lu_gps_count == 0x0000ffff) {
-		printk(KERN_ERR "Maximum ALUA alua_lu_gps_count:"
+		pr_err("Maximum ALUA alua_lu_gps_count:"
 				" 0x0000ffff reached\n");
 		spin_unlock(&lu_gps_lock);
 		kmem_cache_free(t10_alua_lu_gp_cache, lu_gp);
@@ -1104,7 +1104,7 @@ again:
 			if (!(lu_gp_id))
 				goto again;
 
-			printk(KERN_WARNING "ALUA Logical Unit Group ID: %hu"
+			pr_warn("ALUA Logical Unit Group ID: %hu"
 				" already exists, ignoring request\n",
 				lu_gp_id);
 			spin_unlock(&lu_gps_lock);
@@ -1128,7 +1128,7 @@ core_alua_allocate_lu_gp_mem(struct se_device *dev)
 
 	lu_gp_mem = kmem_cache_zalloc(t10_alua_lu_gp_mem_cache, GFP_KERNEL);
 	if (!(lu_gp_mem)) {
-		printk(KERN_ERR "Unable to allocate struct t10_alua_lu_gp_member\n");
+		pr_err("Unable to allocate struct t10_alua_lu_gp_member\n");
 		return ERR_PTR(-ENOMEM);
 	}
 	INIT_LIST_HEAD(&lu_gp_mem->lu_gp_mem_list);
@@ -1302,7 +1302,7 @@ struct t10_alua_tg_pt_gp *core_alua_allocate_tg_pt_gp(
 
 	tg_pt_gp = kmem_cache_zalloc(t10_alua_tg_pt_gp_cache, GFP_KERNEL);
 	if (!(tg_pt_gp)) {
-		printk(KERN_ERR "Unable to allocate struct t10_alua_tg_pt_gp\n");
+		pr_err("Unable to allocate struct t10_alua_tg_pt_gp\n");
 		return NULL;
 	}
 	INIT_LIST_HEAD(&tg_pt_gp->tg_pt_gp_list);
@@ -1350,14 +1350,14 @@ int core_alua_set_tg_pt_gp_id(
 	 * The tg_pt_gp->tg_pt_gp_id may only be set once..
 	 */
 	if (tg_pt_gp->tg_pt_gp_valid_id) {
-		printk(KERN_WARNING "ALUA TG PT Group already has a valid ID,"
+		pr_warn("ALUA TG PT Group already has a valid ID,"
 			" ignoring request\n");
 		return -EINVAL;
 	}
 
 	spin_lock(&su_dev->t10_alua.tg_pt_gps_lock);
 	if (su_dev->t10_alua.alua_tg_pt_gps_count == 0x0000ffff) {
-		printk(KERN_ERR "Maximum ALUA alua_tg_pt_gps_count:"
+		pr_err("Maximum ALUA alua_tg_pt_gps_count:"
 			" 0x0000ffff reached\n");
 		spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
 		kmem_cache_free(t10_alua_tg_pt_gp_cache, tg_pt_gp);
@@ -1373,7 +1373,7 @@ again:
 			if (!(tg_pt_gp_id))
 				goto again;
 
-			printk(KERN_ERR "ALUA Target Port Group ID: %hu already"
+			pr_err("ALUA Target Port Group ID: %hu already"
 				" exists, ignoring request\n", tg_pt_gp_id);
 			spin_unlock(&su_dev->t10_alua.tg_pt_gps_lock);
 			return -EINVAL;
@@ -1398,7 +1398,7 @@ struct t10_alua_tg_pt_gp_member *core_alua_allocate_tg_pt_gp_mem(
 	tg_pt_gp_mem = kmem_cache_zalloc(t10_alua_tg_pt_gp_mem_cache,
 				GFP_KERNEL);
 	if (!(tg_pt_gp_mem)) {
-		printk(KERN_ERR "Unable to allocate struct t10_alua_tg_pt_gp_member\n");
+		pr_err("Unable to allocate struct t10_alua_tg_pt_gp_member\n");
 		return ERR_PTR(-ENOMEM);
 	}
 	INIT_LIST_HEAD(&tg_pt_gp_mem->tg_pt_gp_mem_list);
@@ -1628,7 +1628,7 @@ ssize_t core_alua_store_tg_pt_gp_info(
 	lun = port->sep_lun;
 
 	if (su_dev->t10_alua.alua_type != SPC3_ALUA_EMULATED) {
-		printk(KERN_WARNING "SPC3_ALUA_EMULATED not enabled for"
+		pr_warn("SPC3_ALUA_EMULATED not enabled for"
 			" %s/tpgt_%hu/%s\n", tpg->se_tpg_tfo->tpg_get_wwn(tpg),
 			tpg->se_tpg_tfo->tpg_get_tag(tpg),
 			config_item_name(&lun->lun_group.cg_item));
@@ -1636,7 +1636,7 @@ ssize_t core_alua_store_tg_pt_gp_info(
 	}
 
 	if (count > TG_PT_GROUP_NAME_BUF) {
-		printk(KERN_ERR "ALUA Target Port Group alias too large!\n");
+		pr_err("ALUA Target Port Group alias too large!\n");
 		return -EINVAL;
 	}
 	memset(buf, 0, TG_PT_GROUP_NAME_BUF);
@@ -1660,7 +1660,7 @@ ssize_t core_alua_store_tg_pt_gp_info(
 	if (!(tg_pt_gp_mem)) {
 		if (tg_pt_gp_new)
 			core_alua_put_tg_pt_gp_from_name(tg_pt_gp_new);
-		printk(KERN_ERR "NULL struct se_port->sep_alua_tg_pt_gp_mem pointer\n");
+		pr_err("NULL struct se_port->sep_alua_tg_pt_gp_mem pointer\n");
 		return -EINVAL;
 	}
 
@@ -1672,7 +1672,7 @@ ssize_t core_alua_store_tg_pt_gp_info(
 		 * with the default_tg_pt_gp.
 		 */
 		if (!(tg_pt_gp_new)) {
-			printk(KERN_INFO "Target_Core_ConfigFS: Moving"
+			pr_debug("Target_Core_ConfigFS: Moving"
 				" %s/tpgt_%hu/%s from ALUA Target Port Group:"
 				" alua/%s, ID: %hu back to"
 				" default_tg_pt_gp\n",
@@ -1701,7 +1701,7 @@ ssize_t core_alua_store_tg_pt_gp_info(
 	 */
 	__core_alua_attach_tg_pt_gp_mem(tg_pt_gp_mem, tg_pt_gp_new);
 	spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
-	printk(KERN_INFO "Target_Core_ConfigFS: %s %s/tpgt_%hu/%s to ALUA"
+	pr_debug("Target_Core_ConfigFS: %s %s/tpgt_%hu/%s to ALUA"
 		" Target Port Group: alua/%s, ID: %hu\n", (move) ?
 		"Moving" : "Adding", tpg->se_tpg_tfo->tpg_get_wwn(tpg),
 		tpg->se_tpg_tfo->tpg_get_tag(tpg),
@@ -1738,11 +1738,11 @@ ssize_t core_alua_store_access_type(
 
 	ret = strict_strtoul(page, 0, &tmp);
 	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract alua_access_type\n");
+		pr_err("Unable to extract alua_access_type\n");
 		return -EINVAL;
 	}
 	if ((tmp != 0) && (tmp != 1) && (tmp != 2) && (tmp != 3)) {
-		printk(KERN_ERR "Illegal value for alua_access_type:"
+		pr_err("Illegal value for alua_access_type:"
 				" %lu\n", tmp);
 		return -EINVAL;
 	}
@@ -1776,11 +1776,11 @@ ssize_t core_alua_store_nonop_delay_msecs(
 
 	ret = strict_strtoul(page, 0, &tmp);
 	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract nonop_delay_msecs\n");
+		pr_err("Unable to extract nonop_delay_msecs\n");
 		return -EINVAL;
 	}
 	if (tmp > ALUA_MAX_NONOP_DELAY_MSECS) {
-		printk(KERN_ERR "Passed nonop_delay_msecs: %lu, exceeds"
+		pr_err("Passed nonop_delay_msecs: %lu, exceeds"
 			" ALUA_MAX_NONOP_DELAY_MSECS: %d\n", tmp,
 			ALUA_MAX_NONOP_DELAY_MSECS);
 		return -EINVAL;
@@ -1807,11 +1807,11 @@ ssize_t core_alua_store_trans_delay_msecs(
 
 	ret = strict_strtoul(page, 0, &tmp);
 	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract trans_delay_msecs\n");
+		pr_err("Unable to extract trans_delay_msecs\n");
 		return -EINVAL;
 	}
 	if (tmp > ALUA_MAX_TRANS_DELAY_MSECS) {
-		printk(KERN_ERR "Passed trans_delay_msecs: %lu, exceeds"
+		pr_err("Passed trans_delay_msecs: %lu, exceeds"
 			" ALUA_MAX_TRANS_DELAY_MSECS: %d\n", tmp,
 			ALUA_MAX_TRANS_DELAY_MSECS);
 		return -EINVAL;
@@ -1838,11 +1838,11 @@ ssize_t core_alua_store_preferred_bit(
 
 	ret = strict_strtoul(page, 0, &tmp);
 	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract preferred ALUA value\n");
+		pr_err("Unable to extract preferred ALUA value\n");
 		return -EINVAL;
 	}
 	if ((tmp != 0) && (tmp != 1)) {
-		printk(KERN_ERR "Illegal value for preferred ALUA: %lu\n", tmp);
+		pr_err("Illegal value for preferred ALUA: %lu\n", tmp);
 		return -EINVAL;
 	}
 	tg_pt_gp->tg_pt_gp_pref = (int)tmp;
@@ -1873,17 +1873,17 @@ ssize_t core_alua_store_offline_bit(
 
 	ret = strict_strtoul(page, 0, &tmp);
 	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract alua_tg_pt_offline value\n");
+		pr_err("Unable to extract alua_tg_pt_offline value\n");
 		return -EINVAL;
 	}
 	if ((tmp != 0) && (tmp != 1)) {
-		printk(KERN_ERR "Illegal value for alua_tg_pt_offline: %lu\n",
+		pr_err("Illegal value for alua_tg_pt_offline: %lu\n",
 				tmp);
 		return -EINVAL;
 	}
 	tg_pt_gp_mem = lun->lun_sep->sep_alua_tg_pt_gp_mem;
 	if (!(tg_pt_gp_mem)) {
-		printk(KERN_ERR "Unable to locate *tg_pt_gp_mem\n");
+		pr_err("Unable to locate *tg_pt_gp_mem\n");
 		return -EINVAL;
 	}
 
@@ -1912,13 +1912,13 @@ ssize_t core_alua_store_secondary_status(
 
 	ret = strict_strtoul(page, 0, &tmp);
 	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract alua_tg_pt_status\n");
+		pr_err("Unable to extract alua_tg_pt_status\n");
 		return -EINVAL;
 	}
 	if ((tmp != ALUA_STATUS_NONE) &&
 	    (tmp != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) &&
 	    (tmp != ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA)) {
-		printk(KERN_ERR "Illegal value for alua_tg_pt_status: %lu\n",
+		pr_err("Illegal value for alua_tg_pt_status: %lu\n",
 				tmp);
 		return -EINVAL;
 	}
@@ -1945,11 +1945,11 @@ ssize_t core_alua_store_secondary_write_metadata(
 
 	ret = strict_strtoul(page, 0, &tmp);
 	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract alua_tg_pt_write_md\n");
+		pr_err("Unable to extract alua_tg_pt_write_md\n");
 		return -EINVAL;
 	}
 	if ((tmp != 0) && (tmp != 1)) {
-		printk(KERN_ERR "Illegal value for alua_tg_pt_write_md:"
+		pr_err("Illegal value for alua_tg_pt_write_md:"
 				" %lu\n", tmp);
 		return -EINVAL;
 	}
@@ -1973,7 +1973,7 @@ int core_setup_alua(struct se_device *dev, int force_pt)
 	    !(dev->se_sub_dev->se_dev_attrib.emulate_alua)) || force_pt) {
 		alua->alua_type = SPC_ALUA_PASSTHROUGH;
 		alua->alua_state_check = &core_alua_state_check_nop;
-		printk(KERN_INFO "%s: Using SPC_ALUA_PASSTHROUGH, no ALUA"
+		pr_debug("%s: Using SPC_ALUA_PASSTHROUGH, no ALUA"
 			" emulation\n", dev->transport->name);
 		return 0;
 	}
@@ -1982,7 +1982,7 @@ int core_setup_alua(struct se_device *dev, int force_pt)
 	 * use emulated ALUA.
 	 */
 	if (dev->transport->get_device_rev(dev) >= SCSI_3) {
-		printk(KERN_INFO "%s: Enabling ALUA Emulation for SPC-3"
+		pr_debug("%s: Enabling ALUA Emulation for SPC-3"
 			" device\n", dev->transport->name);
 		/*
 		 * Associate this struct se_device with the default ALUA
@@ -1999,13 +1999,13 @@ int core_setup_alua(struct se_device *dev, int force_pt)
 				default_lu_gp);
 		spin_unlock(&lu_gp_mem->lu_gp_mem_lock);
 
-		printk(KERN_INFO "%s: Adding to default ALUA LU Group:"
+		pr_debug("%s: Adding to default ALUA LU Group:"
 			" core/alua/lu_gps/default_lu_gp\n",
 			dev->transport->name);
 	} else {
 		alua->alua_type = SPC2_ALUA_DISABLED;
 		alua->alua_state_check = &core_alua_state_check_nop;
-		printk(KERN_INFO "%s: Disabling ALUA Emulation for SPC-2"
+		pr_debug("%s: Disabling ALUA Emulation for SPC-2"
 			" device\n", dev->transport->name);
 	}
 
drivers/target/target_core_cdb.c +19 -20
index 6c9e53f..9511a9e 100644
@@ -73,7 +73,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
 	 * payload going back for EVPD=0
 	 */
 	if (cmd->data_length < 6) {
-		printk(KERN_ERR "SCSI Inquiry payload length: %u"
+		pr_err("SCSI Inquiry payload length: %u"
 			" too small for EVPD=0\n", cmd->data_length);
 		return -EINVAL;
 	}
@@ -503,14 +503,14 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
 		have_tp = 1;
 
 	if (cmd->data_length < (0x10 + 4)) {
-		printk(KERN_INFO "Received data_length: %u"
+		pr_debug("Received data_length: %u"
 			" too small for EVPD 0xb0\n",
 			cmd->data_length);
 		return -EINVAL;
 	}
 
 	if (have_tp && cmd->data_length < (0x3c + 4)) {
-		printk(KERN_INFO "Received data_length: %u"
+		pr_debug("Received data_length: %u"
 			" too small for TPE=1 EVPD 0xb0\n",
 			cmd->data_length);
 		have_tp = 0;
@@ -640,7 +640,7 @@ target_emulate_inquiry(struct se_cmd *cmd)
 	 * payload length left for the next outgoing EVPD metadata
 	 */
 	if (cmd->data_length < 4) {
-		printk(KERN_ERR "SCSI Inquiry payload length: %u"
+		pr_err("SCSI Inquiry payload length: %u"
 			" too small for EVPD=1\n", cmd->data_length);
 		return -EINVAL;
 	}
@@ -663,7 +663,7 @@ target_emulate_inquiry(struct se_cmd *cmd)
 	case 0xb2:
 		return target_emulate_evpd_b2(cmd, buf);
 	default:
-		printk(KERN_ERR "Unknown VPD Code: 0x%02x\n", cdb[2]);
+		pr_err("Unknown VPD Code: 0x%02x\n", cdb[2]);
 		transport_kunmap_first_data_page(cmd);
 		return -EINVAL;
 	}
@@ -875,7 +875,7 @@ target_emulate_modesense(struct se_cmd *cmd, int ten)
 		length += target_modesense_control(dev, &buf[offset+length]);
 		break;
 	default:
-		printk(KERN_ERR "Got Unknown Mode Page: 0x%02x\n",
+		pr_err("Got Unknown Mode Page: 0x%02x\n",
 				cdb[2] & 0x3f);
 		return PYX_TRANSPORT_UNKNOWN_MODE_PAGE;
 	}
@@ -930,7 +930,7 @@ target_emulate_request_sense(struct se_cmd *cmd)
 	u8 ua_asc = 0, ua_ascq = 0;
 
 	if (cdb[1] & 0x01) {
-		printk(KERN_ERR "REQUEST_SENSE description emulation not"
+		pr_err("REQUEST_SENSE description emulation not"
 			" supported\n");
 		return PYX_TRANSPORT_INVALID_CDB_FIELD;
 	}
@@ -1010,18 +1010,18 @@ target_emulate_unmap(struct se_task *task)
 	buf = transport_kmap_first_data_page(cmd);
 
 	ptr = &buf[offset];
-	printk(KERN_INFO "UNMAP: Sub: %s Using dl: %hu bd_dl: %hu size: %hu"
+	pr_debug("UNMAP: Sub: %s Using dl: %hu bd_dl: %hu size: %hu"
 		" ptr: %p\n", dev->transport->name, dl, bd_dl, size, ptr);
 
 	while (size) {
 		lba = get_unaligned_be64(&ptr[0]);
 		range = get_unaligned_be32(&ptr[8]);
-		printk(KERN_INFO "UNMAP: Using lba: %llu and range: %u\n",
+		pr_debug("UNMAP: Using lba: %llu and range: %u\n",
 				 (unsigned long long)lba, range);
 
 		ret = dev->transport->do_discard(dev, lba, range);
 		if (ret < 0) {
-			printk(KERN_ERR "blkdev_issue_discard() failed: %d\n",
+			pr_err("blkdev_issue_discard() failed: %d\n",
 					ret);
 			transport_kunmap_first_data_page(cmd);
 			return ret;
@@ -1066,12 +1066,12 @@ target_emulate_write_same(struct se_task *task, int write_same32)
 	else
 		range = (dev->transport->get_blocks(dev) - lba);
 
-	printk(KERN_INFO "WRITE_SAME UNMAP: LBA: %llu Range: %llu\n",
+	pr_debug("WRITE_SAME UNMAP: LBA: %llu Range: %llu\n",
 		 (unsigned long long)lba, (unsigned long long)range);
 
 	ret = dev->transport->do_discard(dev, lba, range);
 	if (ret < 0) {
-		printk(KERN_INFO "blkdev_issue_discard() failed for WRITE_SAME\n");
+		pr_debug("blkdev_issue_discard() failed for WRITE_SAME\n");
 		return ret;
 	}
 
@@ -1107,7 +1107,7 @@ transport_emulate_control_cdb(struct se_task *task)
 			ret = target_emulate_readcapacity_16(cmd);
 			break;
 		default:
-			printk(KERN_ERR "Unsupported SA: 0x%02x\n",
+			pr_err("Unsupported SA: 0x%02x\n",
 				cmd->t_task_cdb[1] & 0x1f);
 			return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 		}
@@ -1117,7 +1117,7 @@ transport_emulate_control_cdb(struct se_task *task)
 		break;
 	case UNMAP:
 		if (!dev->transport->do_discard) {
-			printk(KERN_ERR "UNMAP emulation not supported for: %s\n",
+			pr_err("UNMAP emulation not supported for: %s\n",
 					dev->transport->name);
 			return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 		}
@@ -1125,7 +1125,7 @@ transport_emulate_control_cdb(struct se_task *task)
 		break;
 	case WRITE_SAME_16:
 		if (!dev->transport->do_discard) {
-			printk(KERN_ERR "WRITE_SAME_16 emulation not supported"
+			pr_err("WRITE_SAME_16 emulation not supported"
 					" for: %s\n", dev->transport->name);
 			return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 		}
@@ -1137,7 +1137,7 @@ transport_emulate_control_cdb(struct se_task *task)
 		switch (service_action) {
 		case WRITE_SAME_32:
 			if (!dev->transport->do_discard) {
-				printk(KERN_ERR "WRITE_SAME_32 SA emulation not"
+				pr_err("WRITE_SAME_32 SA emulation not"
 					" supported for: %s\n",
 					dev->transport->name);
 				return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
@@ -1145,7 +1145,7 @@ transport_emulate_control_cdb(struct se_task *task)
 			ret = target_emulate_write_same(task, 1);
 			break;
 		default:
-			printk(KERN_ERR "Unsupported VARIABLE_LENGTH_CMD SA:"
+			pr_err("Unsupported VARIABLE_LENGTH_CMD SA:"
 					" 0x%02x\n", service_action);
 			break;
 		}
@@ -1153,8 +1153,7 @@ transport_emulate_control_cdb(struct se_task *task)
 	case SYNCHRONIZE_CACHE:
 	case 0x91: /* SYNCHRONIZE_CACHE_16: */
 		if (!dev->transport->do_sync_cache) {
-			printk(KERN_ERR
-				"SYNCHRONIZE_CACHE emulation not supported"
+			pr_err("SYNCHRONIZE_CACHE emulation not supported"
 				" for: %s\n", dev->transport->name);
 			return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 		}
@@ -1171,7 +1170,7 @@ transport_emulate_control_cdb(struct se_task *task)
 	case WRITE_FILEMARKS:
 		break;
 	default:
-		printk(KERN_ERR "Unsupported SCSI Opcode: 0x%02x for %s\n",
+		pr_err("Unsupported SCSI Opcode: 0x%02x for %s\n",
 			cmd->t_task_cdb[0], dev->transport->name);
 		return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
 	}
drivers/target/target_core_configfs.c +129 -129

879 lines not on this page · raw message

drivers/target/target_core_device.c +84 -84

615 lines not on this page · raw message

drivers/target/target_core_fabric_configfs.c +20 -20
index 9183c86..38aec62 100644
@@ -60,7 +60,7 @@ static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf)
 	cit->ct_group_ops = _group_ops;					\
 	cit->ct_attrs = _attrs;						\
 	cit->ct_owner = tf->tf_module;					\
-	printk("Setup generic %s\n", __stringify(_name));		\
+	pr_debug("Setup generic %s\n", __stringify(_name));		\
 }
 
 /* Start of tfc_tpg_mappedlun_cit */
@@ -81,7 +81,7 @@ static int target_fabric_mappedlun_link(
 	 * Ensure that the source port exists
 	 */
 	if (!(lun->lun_sep) || !(lun->lun_sep->sep_tpg)) {
-		printk(KERN_ERR "Source se_lun->lun_sep or lun->lun_sep->sep"
+		pr_err("Source se_lun->lun_sep or lun->lun_sep->sep"
 				"_tpg does not exist\n");
 		return -EINVAL;
 	}
@@ -96,12 +96,12 @@ static int target_fabric_mappedlun_link(
 	 * Make sure the SymLink is going to the same $FABRIC/$WWN/tpgt_$TPGT
 	 */
 	if (strcmp(config_item_name(wwn_ci), config_item_name(wwn_ci_s))) {
-		printk(KERN_ERR "Illegal Initiator ACL SymLink outside of %s\n",
+		pr_err("Illegal Initiator ACL SymLink outside of %s\n",
 			config_item_name(wwn_ci));
 		return -EINVAL;
 	}
 	if (strcmp(config_item_name(tpg_ci), config_item_name(tpg_ci_s))) {
-		printk(KERN_ERR "Illegal Initiator ACL Symlink outside of %s"
+		pr_err("Illegal Initiator ACL Symlink outside of %s"
 			" TPGT: %s\n", config_item_name(wwn_ci),
 			config_item_name(tpg_ci));
 		return -EINVAL;
@@ -202,7 +202,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
 			TRANSPORT_LUNFLAGS_READ_WRITE,
 			lacl->se_lun_nacl);
 
-	printk(KERN_INFO "%s_ConfigFS: Changed Initiator ACL: %s"
+	pr_debug("%s_ConfigFS: Changed Initiator ACL: %s"
 		" Mapped LUN: %u Write Protect bit to %s\n",
 		se_tpg->se_tpg_tfo->get_fabric_name(),
 		lacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
@@ -328,13 +328,13 @@ static struct config_group *target_fabric_make_mappedlun(
 
 	acl_ci = &group->cg_item;
 	if (!(acl_ci)) {
-		printk(KERN_ERR "Unable to locatel acl_ci\n");
+		pr_err("Unable to locatel acl_ci\n");
 		return NULL;
 	}
 
 	buf = kzalloc(strlen(name) + 1, GFP_KERNEL);
 	if (!(buf)) {
-		printk(KERN_ERR "Unable to allocate memory for name buf\n");
+		pr_err("Unable to allocate memory for name buf\n");
 		return ERR_PTR(-ENOMEM);
 	}
 	snprintf(buf, strlen(name) + 1, "%s", name);
@@ -342,7 +342,7 @@ static struct config_group *target_fabric_make_mappedlun(
 	 * Make sure user is creating iscsi/$IQN/$TPGT/acls/$INITIATOR/lun_$ID.
 	 */
 	if (strstr(buf, "lun_") != buf) {
-		printk(KERN_ERR "Unable to locate \"lun_\" from buf: %s"
+		pr_err("Unable to locate \"lun_\" from buf: %s"
 			" name: %s\n", buf, name);
 		ret = -EINVAL;
 		goto out;
@@ -367,7 +367,7 @@ static struct config_group *target_fabric_make_mappedlun(
 	lacl_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
 				GFP_KERNEL);
 	if (!lacl_cg->default_groups) {
-		printk(KERN_ERR "Unable to allocate lacl_cg->default_groups\n");
+		pr_err("Unable to allocate lacl_cg->default_groups\n");
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -383,7 +383,7 @@ static struct config_group *target_fabric_make_mappedlun(
 	ml_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3,
 				GFP_KERNEL);
 	if (!ml_stat_grp->default_groups) {
-		printk(KERN_ERR "Unable to allocate ml_stat_grp->default_groups\n");
+		pr_err("Unable to allocate ml_stat_grp->default_groups\n");
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -477,7 +477,7 @@ static struct config_group *target_fabric_make_nodeacl(
 	struct config_group *nacl_cg;
 
 	if (!(tf->tf_ops.fabric_make_nodeacl)) {
-		printk(KERN_ERR "tf->tf_ops.fabric_make_nodeacl is NULL\n");
+		pr_err("tf->tf_ops.fabric_make_nodeacl is NULL\n");
 		return ERR_PTR(-ENOSYS);
 	}
 
@@ -575,7 +575,7 @@ static struct config_group *target_fabric_make_np(
 	struct se_tpg_np *se_tpg_np;
 
 	if (!(tf->tf_ops.fabric_make_np)) {
-		printk(KERN_ERR "tf->tf_ops.fabric_make_np is NULL\n");
+		pr_err("tf->tf_ops.fabric_make_np is NULL\n");
 		return ERR_PTR(-ENOSYS);
 	}
 
@@ -783,13 +783,13 @@ static int target_fabric_port_link(
 	tf = se_tpg->se_tpg_wwn->wwn_tf;
 
 	if (lun->lun_se_dev !=  NULL) {
-		printk(KERN_ERR "Port Symlink already exists\n");
+		pr_err("Port Symlink already exists\n");
 		return -EEXIST;
 	}
 
 	dev = se_dev->se_dev_ptr;
 	if (!(dev)) {
-		printk(KERN_ERR "Unable to locate struct se_device pointer from"
+		pr_err("Unable to locate struct se_device pointer from"
 			" %s\n", config_item_name(se_dev_ci));
 		ret = -ENODEV;
 		goto out;
@@ -798,7 +798,7 @@ static int target_fabric_port_link(
 	lun_p = core_dev_add_lun(se_tpg, dev->se_hba, dev,
 				lun->unpacked_lun);
 	if ((IS_ERR(lun_p)) || !(lun_p)) {
-		printk(KERN_ERR "core_dev_add_lun() failed\n");
+		pr_err("core_dev_add_lun() failed\n");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -890,7 +890,7 @@ static struct config_group *target_fabric_make_lun(
 	int errno;
 
 	if (strstr(name, "lun_") != name) {
-		printk(KERN_ERR "Unable to locate \'_\" in"
+		pr_err("Unable to locate \'_\" in"
 				" \"lun_$LUN_NUMBER\"\n");
 		return ERR_PTR(-EINVAL);
 	}
@@ -905,7 +905,7 @@ static struct config_group *target_fabric_make_lun(
 	lun_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
 				GFP_KERNEL);
 	if (!lun_cg->default_groups) {
-		printk(KERN_ERR "Unable to allocate lun_cg->default_groups\n");
+		pr_err("Unable to allocate lun_cg->default_groups\n");
 		return ERR_PTR(-ENOMEM);
 	}
 
@@ -920,7 +920,7 @@ static struct config_group *target_fabric_make_lun(
 	port_stat_grp->default_groups =  kzalloc(sizeof(struct config_group) * 3,
 				GFP_KERNEL);
 	if (!port_stat_grp->default_groups) {
-		printk(KERN_ERR "Unable to allocate port_stat_grp->default_groups\n");
+		pr_err("Unable to allocate port_stat_grp->default_groups\n");
 		errno = -ENOMEM;
 		goto out;
 	}
@@ -1034,7 +1034,7 @@ static struct config_group *target_fabric_make_tpg(
 	struct se_portal_group *se_tpg;
 
 	if (!(tf->tf_ops.fabric_make_tpg)) {
-		printk(KERN_ERR "tf->tf_ops.fabric_make_tpg is NULL\n");
+		pr_err("tf->tf_ops.fabric_make_tpg is NULL\n");
 		return ERR_PTR(-ENOSYS);
 	}
 
@@ -1133,7 +1133,7 @@ static struct config_group *target_fabric_make_wwn(
 	struct se_wwn *wwn;
 
 	if (!(tf->tf_ops.fabric_make_wwn)) {
-		printk(KERN_ERR "tf->tf_ops.fabric_make_wwn is NULL\n");
+		pr_err("tf->tf_ops.fabric_make_wwn is NULL\n");
 		return ERR_PTR(-ENOSYS);
 	}
 
drivers/target/target_core_fabric_lib.c +3 -3
index 1e193f3..ec40a33 100644
@@ -386,7 +386,7 @@ char *iscsi_parse_pr_out_transport_id(
 	 *            Reserved
 	 */
 	if ((format_code != 0x00) && (format_code != 0x40)) {
-		printk(KERN_ERR "Illegal format code: 0x%02x for iSCSI"
+		pr_err("Illegal format code: 0x%02x for iSCSI"
 			" Initiator Transport ID\n", format_code);
 		return NULL;
 	}
@@ -406,7 +406,7 @@ char *iscsi_parse_pr_out_transport_id(
 			tid_len += padding;
 
 		if ((add_len + 4) != tid_len) {
-			printk(KERN_INFO "LIO-Target Extracted add_len: %hu "
+			pr_debug("LIO-Target Extracted add_len: %hu "
 				"does not match calculated tid_len: %u,"
 				" using tid_len instead\n", add_len+4, tid_len);
 			*out_tid_len = tid_len;
@@ -421,7 +421,7 @@ char *iscsi_parse_pr_out_transport_id(
 	if (format_code == 0x40) {
 		p = strstr((char *)&buf[4], ",i,0x");
 		if (!(p)) {
-			printk(KERN_ERR "Unable to locate \",i,0x\" seperator"
+			pr_err("Unable to locate \",i,0x\" seperator"
 				" for Initiator port identifier: %s\n",
 				(char *)&buf[4]);
 			return NULL;
drivers/target/target_core_file.c +27 -39

220 lines not on this page · raw message

drivers/target/target_core_hba.c +5 -5
index a83263d..9f133a8 100644
@@ -60,7 +60,7 @@ int transport_subsystem_register(struct se_subsystem_api *sub_api)
 	mutex_lock(&subsystem_mutex);
 	list_for_each_entry(s, &subsystem_list, sub_api_list) {
 		if (!(strcmp(s->name, sub_api->name))) {
-			printk(KERN_ERR "%p is already registered with"
+			pr_err("%p is already registered with"
 				" duplicate name %s, unable to process"
 				" request\n", s, s->name);
 			mutex_unlock(&subsystem_mutex);
@@ -70,7 +70,7 @@ int transport_subsystem_register(struct se_subsystem_api *sub_api)
 	list_add_tail(&sub_api->sub_api_list, &subsystem_list);
 	mutex_unlock(&subsystem_mutex);
 
-	printk(KERN_INFO "TCM: Registered subsystem plugin: %s struct module:"
+	pr_debug("TCM: Registered subsystem plugin: %s struct module:"
 			" %p\n", sub_api->name, sub_api->owner);
 	return 0;
 }
@@ -110,7 +110,7 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags)
 
 	hba = kzalloc(sizeof(*hba), GFP_KERNEL);
 	if (!hba) {
-		printk(KERN_ERR "Unable to allocate struct se_hba\n");
+		pr_err("Unable to allocate struct se_hba\n");
 		return ERR_PTR(-ENOMEM);
 	}
 
@@ -136,7 +136,7 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags)
 	list_add_tail(&hba->hba_node, &hba_list);
 	spin_unlock(&hba_lock);
 
-	printk(KERN_INFO "CORE_HBA[%d] - Attached HBA to Generic Target"
+	pr_debug("CORE_HBA[%d] - Attached HBA to Generic Target"
 			" Core\n", hba->hba_id);
 
 	return hba;
@@ -162,7 +162,7 @@ core_delete_hba(struct se_hba *hba)
 	list_del(&hba->hba_node);
 	spin_unlock(&hba_lock);
 
-	printk(KERN_INFO "CORE_HBA[%d] - Detached HBA from Generic Target"
+	pr_debug("CORE_HBA[%d] - Detached HBA from Generic Target"
 			" Core\n", hba->hba_id);
 
 	if (hba->transport->owner)
drivers/target/target_core_iblock.c +41 -46

251 lines not on this page · raw message

drivers/target/target_core_pr.c +132 -132

304 lines not on this page · raw message

drivers/target/target_core_pscsi.c +48 -54

102 lines not on this page · raw message

drivers/target/target_core_rd.c +77 -92

169 lines not on this page · raw message

drivers/target/target_core_stgt.c +26 -26

52 lines not on this page · raw message

drivers/target/target_core_tmr.c +16 -23
index b95f090..219dbc8 100644

Lines of this file are not shown. View the raw message.

drivers/target/target_core_tpg.c +21 -21

42 lines not on this page · raw message

drivers/target/target_core_transport.c +147 -280

427 lines not on this page · raw message

drivers/target/target_core_ua.c +4 -4
index d28e9c4..dfa5664 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.1

Part of the diff is not shown here. View the raw message.

#14 lore raw

PATCH 8/15 target: Remove custom debug macros in non-iscsi fabrics

In reply to Andy Grover

pr_debug and dynamic debug messages are cool, we don't need specialized debug infrastructure.

Use pr_err etc. instead of printk(KERN_ERR...).

---
 drivers/target/loopback/Kconfig                   |    6 -
 drivers/target/loopback/tcm_loop.c                |   94 +++++-----
 drivers/target/loopback/tcm_loop.h                |    6 -
 drivers/target/tcm_fc/tcm_fc.h                    |   24 ---
 drivers/target/tcm_fc/tfc_cmd.c                   |   37 ++---
 drivers/target/tcm_fc/tfc_conf.c                  |   33 ++--
 drivers/target/tcm_fc/tfc_io.c                    |   22 ++--
 drivers/target/tcm_fc/tfc_sess.c                  |   18 +-
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_base.h     |    6 -
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c |  190 ++++++++++----------
 drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c   |   20 +-
 drivers/target/tcm_vhost/tcm_vhost_configfs.c     |   50 +++---
 drivers/target/tcm_vhost/tcm_vhost_fabric.c       |   10 +-
 drivers/target/tcm_vhost/tcm_vhost_scsi.c         |    8 +-
 14 files changed, 239 insertions(+), 285 deletions(-)
drivers/target/loopback/Kconfig +0 -6
index 57dcbc2..abe8ecb 100644
@@ -3,9 +3,3 @@ config LOOPBACK_TARGET
 	help
 	  Say Y here to enable the TCM Virtual SAS target and Linux/SCSI LLD
 	  fabric loopback module.
-
-config LOOPBACK_TARGET_CDB_DEBUG
-	bool "TCM loopback fabric module CDB debug code"
-	depends on LOOPBACK_TARGET
-	help
-	  Say Y here to enable the TCM loopback fabric module CDB debug code
drivers/target/loopback/tcm_loop.c +47 -47

369 lines not on this page · raw message

drivers/target/loopback/tcm_loop.h +0 -6
index 7e9f7ab..6b76c7a 100644
@@ -16,12 +16,6 @@
  */
 #define TL_SCSI_MAX_CMD_LEN		32
 
-#ifdef CONFIG_LOOPBACK_TARGET_CDB_DEBUG
-# define TL_CDB_DEBUG(x...)		printk(KERN_INFO x)
-#else
-# define TL_CDB_DEBUG(x...)
-#endif
-
 struct tcm_loop_cmd {
 	/* State of Linux/SCSI CDB+Data descriptor */
 	u32 sc_cmd_state;
drivers/target/tcm_fc/tcm_fc.h +0 -24
index d0405e0..334d3b2 100644
@@ -23,30 +23,6 @@
 #define FT_TPG_NAMELEN 32	/* max length of TPG name */
 #define FT_LUN_NAMELEN 32	/* max length of LUN name */
 
-/*
- * Debug options.
- */
-#define FT_DEBUG_CONF	0x01	/* configuration messages */
-#define	FT_DEBUG_SESS	0x02	/* session messages */
-#define	FT_DEBUG_TM	0x04	/* TM operations */
-#define	FT_DEBUG_IO	0x08	/* I/O commands */
-#define	FT_DEBUG_DATA	0x10	/* Data transfer */
-
-extern unsigned int ft_debug_logging;	/* debug options */
-
-#define FT_DEBUG(mask, fmt, args...) 					\
-	do {								\
-		if (ft_debug_logging & (mask))				\
-			printk(KERN_INFO "tcm_fc: %s: " fmt, 		\
-			       __func__, ##args);			\
-	} while (0)
-
-#define	FT_CONF_DBG(fmt, args...)	FT_DEBUG(FT_DEBUG_CONF, fmt, ##args)
-#define	FT_SESS_DBG(fmt, args...)	FT_DEBUG(FT_DEBUG_SESS, fmt, ##args)
-#define	FT_TM_DBG(fmt, args...)		FT_DEBUG(FT_DEBUG_TM, fmt, ##args)
-#define	FT_IO_DBG(fmt, args...)		FT_DEBUG(FT_DEBUG_IO, fmt, ##args)
-#define	FT_DATA_DBG(fmt, args...)	FT_DEBUG(FT_DEBUG_DATA, fmt, ##args)
-
 struct ft_transport_id {
 	__u8	format;
 	__u8	__resvd1[7];
drivers/target/tcm_fc/tfc_cmd.c +17 -20
index c45f4c2..cbb3858 100644
@@ -62,22 +62,19 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
 	struct scatterlist *sg;
 	int count;
 
-	if (!(ft_debug_logging & FT_DEBUG_IO))
-		return;
-
 	se_cmd = &cmd->se_cmd;
-	printk(KERN_INFO "%s: cmd %p state %d sess %p seq %p se_cmd %p\n",
+	pr_debug("%s: cmd %p state %d sess %p seq %p se_cmd %p\n",
 		caller, cmd, cmd->state, cmd->sess, cmd->seq, se_cmd);
-	printk(KERN_INFO "%s: cmd %p cdb %p\n",
+	pr_debug("%s: cmd %p cdb %p\n",
 		caller, cmd, cmd->cdb);
-	printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun);
+	pr_debug("%s: cmd %p lun %d\n", caller, cmd, cmd->lun);
 
-	printk(KERN_INFO "%s: cmd %p data_nents %u len %u se_cmd_flags <0x%x>\n",
+	pr_debug("%s: cmd %p data_nents %u len %u se_cmd_flags <0x%x>\n",
 	       caller, cmd, se_cmd->t_data_nents,
 	       se_cmd->data_length, se_cmd->se_cmd_flags);
 
 	for_each_sg(se_cmd->t_data_sg, sg, se_cmd->t_data_nents, count)
-		printk(KERN_INFO "%s: cmd %p sg %p page %p "
+		pr_debug("%s: cmd %p sg %p page %p "
 		       "len 0x%x off 0x%x\n",
 		       caller, cmd, sg,
 		       sg_page(sg), sg->length, sg->offset);
@@ -85,7 +82,7 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
 	sp = cmd->seq;
 	if (sp) {
 		ep = fc_seq_exch(sp);
-		printk(KERN_INFO "%s: cmd %p sid %x did %x "
+		pr_debug("%s: cmd %p sid %x did %x "
 			"ox_id %x rx_id %x seq_id %x e_stat %x\n",
 			caller, cmd, ep->sid, ep->did, ep->oxid, ep->rxid,
 			sp->id, ep->esb_stat);
@@ -321,7 +318,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
 	case FC_RCTL_DD_SOL_CTL:	/* transfer ready */
 	case FC_RCTL_DD_DATA_DESC:	/* transfer ready */
 	default:
-		printk(KERN_INFO "%s: unhandled frame r_ctl %x\n",
+		pr_debug("%s: unhandled frame r_ctl %x\n",
 		       __func__, fh->fh_r_ctl);
 		fc_frame_free(fp);
 		transport_generic_free_cmd(&cmd->se_cmd, 0, 0);
@@ -346,7 +343,7 @@ static void ft_send_resp_status(struct fc_lport *lport,
 	struct fcp_resp_rsp_info *info;
 
 	fh = fc_frame_header_get(rx_fp);
-	FT_IO_DBG("FCP error response: did %x oxid %x status %x code %x\n",
+	pr_debug("FCP error response: did %x oxid %x status %x code %x\n",
 		  ntoh24(fh->fh_s_id), ntohs(fh->fh_ox_id), status, code);
 	len = sizeof(*fcp);
 	if (status == SAM_STAT_GOOD)
@@ -405,7 +402,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
 			 * since "unable to  handle TMR request because failed
 			 * to get to LUN"
 			 */
-			FT_TM_DBG("Failed to get LUN for TMR func %d, "
+			pr_debug("Failed to get LUN for TMR func %d, "
 				"se_cmd %p, unpacked_lun %d\n",
 				tm_func, &cmd->se_cmd, cmd->lun);
 			ft_dump_cmd(cmd, __func__);
@@ -434,15 +431,15 @@ static void ft_send_tm(struct ft_cmd *cmd)
 		 * FCP4r01 indicates having a combination of
 		 * tm_flags set is invalid.
 		 */
-		FT_TM_DBG("invalid FCP tm_flags %x\n", fcp->fc_tm_flags);
+		pr_debug("invalid FCP tm_flags %x\n", fcp->fc_tm_flags);
 		ft_send_resp_code(cmd, FCP_CMND_FIELDS_INVALID);
 		return;
 	}
 
-	FT_TM_DBG("alloc tm cmd fn %d\n", tm_func);
+	pr_debug("alloc tm cmd fn %d\n", tm_func);
 	tmr = core_tmr_alloc_req(&cmd->se_cmd, cmd, tm_func);
 	if (!tmr) {
-		FT_TM_DBG("alloc failed\n");
+		pr_debug("alloc failed\n");
 		ft_send_resp_code(cmd, FCP_TMF_FAILED);
 		return;
 	}
@@ -478,7 +475,7 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd)
 		code = FCP_TMF_FAILED;
 		break;
 	}
-	FT_TM_DBG("tmr fn %d resp %d fcp code %d\n",
+	pr_debug("tmr fn %d resp %d fcp code %d\n",
 		  tmr->function, tmr->response, code);
 	ft_send_resp_code(cmd, code);
 	return 0;
@@ -506,7 +503,7 @@ static void ft_recv_cmd(struct ft_sess *sess, struct fc_frame *fp)
 	return;
 
 busy:
-	FT_IO_DBG("cmd or seq allocation failure - sending BUSY\n");
+	pr_debug("cmd or seq allocation failure - sending BUSY\n");
 	ft_send_resp_status(lport, fp, SAM_STAT_BUSY, 0);
 	fc_frame_free(fp);
 	ft_sess_put(sess);		/* undo get from lookup */
@@ -531,7 +528,7 @@ void ft_recv_req(struct ft_sess *sess, struct fc_frame *fp)
 	case FC_RCTL_DD_DATA_DESC:	/* transfer ready */
 	case FC_RCTL_ELS4_REQ:		/* SRR, perhaps */
 	default:
-		printk(KERN_INFO "%s: unhandled frame r_ctl %x\n",
+		pr_debug("%s: unhandled frame r_ctl %x\n",
 		       __func__, fh->fh_r_ctl);
 		fc_frame_free(fp);
 		ft_sess_put(sess);	/* undo get from lookup */
@@ -626,7 +623,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
 
 	ret = transport_generic_allocate_tasks(se_cmd, cmd->cdb);
 
-	FT_IO_DBG("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret);
+	pr_debug("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret);
 	ft_dump_cmd(cmd, __func__);
 
 	if (ret == -ENOMEM) {
@@ -657,7 +654,7 @@ err:
  */
 static void ft_exec_req(struct ft_cmd *cmd)
 {
-	FT_IO_DBG("cmd state %x\n", cmd->state);
+	pr_debug("cmd state %x\n", cmd->state);
 	switch (cmd->state) {
 	case FC_CMD_ST_NEW:
 		ft_send_cmd(cmd);
drivers/target/tcm_fc/tfc_conf.c +16 -17
index e47e7e7..98eb96c 100644
@@ -106,7 +106,7 @@ static ssize_t ft_parse_wwn(const char *name, u64 *wwn, int strict)
 	}
 	err = 4;
 fail:
-	FT_CONF_DBG("err %u len %zu pos %u byte %u\n",
+	pr_debug("err %u len %zu pos %u byte %u\n",
 		    err, cp - name, pos, byte);
 	return -1;
 }
@@ -216,7 +216,7 @@ static struct se_node_acl *ft_add_acl(
 	u64 wwpn;
 	u32 q_depth;
 
-	FT_CONF_DBG("add acl %s\n", name);
+	pr_debug("add acl %s\n", name);
 	tpg = container_of(se_tpg, struct ft_tpg, se_tpg);
 
 	if (ft_parse_wwn(name, &wwpn, 1) < 0)
@@ -239,11 +239,11 @@ static void ft_del_acl(struct se_node_acl *se_acl)
 	struct ft_node_acl *acl = container_of(se_acl,
 				struct ft_node_acl, se_node_acl);
 
-	FT_CONF_DBG("del acl %s\n",
+	pr_debug("del acl %s\n",
 		config_item_name(&se_acl->acl_group.cg_item));
 
 	tpg = container_of(se_tpg, struct ft_tpg, se_tpg);
-	FT_CONF_DBG("del acl %p se_acl %p tpg %p se_tpg %p\n",
+	pr_debug("del acl %p se_acl %p tpg %p se_tpg %p\n",
 		    acl, se_acl, tpg, &tpg->se_tpg);
 
 	core_tpg_del_initiator_node_acl(&tpg->se_tpg, se_acl, 1);
@@ -260,11 +260,11 @@ struct ft_node_acl *ft_acl_get(struct ft_tpg *tpg, struct fc_rport_priv *rdata)
 	spin_lock_bh(&se_tpg->acl_node_lock);
 	list_for_each_entry(se_acl, &se_tpg->acl_node_list, acl_list) {
 		acl = container_of(se_acl, struct ft_node_acl, se_node_acl);
-		FT_CONF_DBG("acl %p port_name %llx\n",
+		pr_debug("acl %p port_name %llx\n",
 			acl, (unsigned long long)acl->node_auth.port_name);
 		if (acl->node_auth.port_name == rdata->ids.port_name ||
 		    acl->node_auth.node_name == rdata->ids.node_name) {
-			FT_CONF_DBG("acl %p port_name %llx matched\n", acl,
+			pr_debug("acl %p port_name %llx matched\n", acl,
 				    (unsigned long long)rdata->ids.port_name);
 			found = acl;
 			/* XXX need to hold onto ACL */
@@ -281,10 +281,10 @@ struct se_node_acl *ft_tpg_alloc_fabric_acl(struct se_portal_group *se_tpg)
 
 	acl = kzalloc(sizeof(*acl), GFP_KERNEL);
 	if (!acl) {
-		printk(KERN_ERR "Unable to allocate struct ft_node_acl\n");
+		pr_err("Unable to allocate struct ft_node_acl\n");
 		return NULL;
 	}
-	FT_CONF_DBG("acl %p\n", acl);
+	pr_debug("acl %p\n", acl);
 	return &acl->se_node_acl;
 }
 
@@ -294,7 +294,7 @@ static void ft_tpg_release_fabric_acl(struct se_portal_group *se_tpg,
 	struct ft_node_acl *acl = container_of(se_acl,
 				struct ft_node_acl, se_node_acl);
 
-	FT_CONF_DBG(KERN_INFO "acl %p\n", acl);
+	pr_debug("acl %p\n", acl);
 	kfree(acl);
 }
 
@@ -311,7 +311,7 @@ static struct se_portal_group *ft_add_tpg(
 	unsigned long index;
 	int ret;
 
-	FT_CONF_DBG("tcm_fc: add tpg %s\n", name);
+	pr_debug("tcm_fc: add tpg %s\n", name);
 
 	/*
 	 * Name must be "tpgt_" followed by the index.
@@ -354,7 +354,7 @@ static void ft_del_tpg(struct se_portal_group *se_tpg)
 {
 	struct ft_tpg *tpg = container_of(se_tpg, struct ft_tpg, se_tpg);
 
-	FT_CONF_DBG("del tpg %s\n",
+	pr_debug("del tpg %s\n",
 		config_item_name(&tpg->se_tpg.tpg_group.cg_item));
 
 	kthread_stop(tpg->thread);
@@ -412,7 +412,7 @@ static struct se_wwn *ft_add_lport(
 	struct ft_lport_acl *old_lacl;
 	u64 wwpn;
 
-	FT_CONF_DBG("add lport %s\n", name);
+	pr_debug("add lport %s\n", name);
 	if (ft_parse_wwn(name, &wwpn, 1) < 0)
 		return NULL;
 	lacl = kzalloc(sizeof(*lacl), GFP_KERNEL);
@@ -441,7 +441,7 @@ static void ft_del_lport(struct se_wwn *wwn)
 	struct ft_lport_acl *lacl = container_of(wwn,
 				struct ft_lport_acl, fc_lport_wwn);
 
-	FT_CONF_DBG("del lport %s\n",
+	pr_debug("del lport %s\n",
 			config_item_name(&wwn->wwn_group.cg_item));
 	mutex_lock(&ft_lport_lock);
 	list_del(&lacl->list);
@@ -580,7 +580,7 @@ int ft_register_configfs(void)
 	 */
 	fabric = target_fabric_configfs_init(THIS_MODULE, "fc");
 	if (IS_ERR(fabric)) {
-		printk(KERN_INFO "%s: target_fabric_configfs_init() failed!\n",
+		pr_debug("%s: target_fabric_configfs_init() failed!\n",
 		       __func__);
 		return PTR_ERR(fabric);
 	}
@@ -607,10 +607,9 @@ int ft_register_configfs(void)
 	 */
 	ret = target_fabric_configfs_register(fabric);
 	if (ret < 0) {
-		FT_CONF_DBG("target_fabric_configfs_register() for"
+		pr_debug("target_fabric_configfs_register() for"
 			    " FC Target failed!\n");
-		printk(KERN_INFO
-		       "%s: target_fabric_configfs_register() failed!\n",
+		pr_debug("%s: target_fabric_configfs_register() failed!\n",
 		       __func__);
 		target_fabric_configfs_free(fabric);
 		return -1;
drivers/target/tcm_fc/tfc_io.c +11 -11
index c1552cf..a8ef64a 100644
@@ -39,6 +39,7 @@
 #include <linux/configfs.h>
 #include <linux/ctype.h>
 #include <linux/hash.h>
+#include <linux/ratelimit.h>
 #include <asm/unaligned.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
@@ -176,12 +177,11 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
 		error = lport->tt.seq_send(lport, cmd->seq, fp);
 		if (error) {
 			/* XXX For now, initiator will retry */
-			if (printk_ratelimit())
-				printk(KERN_ERR "%s: Failed to send frame %p, "
-						"xid <0x%x>, remaining <0x%zx>, "
-						"lso_max <0x%x>\n",
-						__func__, fp, ep->xid,
-						remaining, lport->lso_max);
+			pr_err_ratelimited("%s: Failed to send frame %p, "
+					   "xid <0x%x>, remaining <0x%zx>, "
+					   "lso_max <0x%x>\n",
+					   __func__, fp, ep->xid,
+					   remaining, lport->lso_max);
 		}
 	}
 	return ft_queue_status(se_cmd);
@@ -222,10 +222,10 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
 	 */
 	buf = fc_frame_payload_get(fp, 1);
 	if (cmd->was_ddp_setup && buf) {
-		printk(KERN_INFO "%s: When DDP was setup, not expected to"
-				 "receive frame with payload, Payload shall be"
-				 "copied directly to buffer instead of coming "
-				 "via. legacy receive queues\n", __func__);
+		pr_err("%s: When DDP was setup, not expected to"
+		       "receive frame with payload, Payload shall be"
+		       "copied directly to buffer instead of coming "
+		       "via. legacy receive queues\n", __func__);
 		BUG_ON(buf);
 	}
 
@@ -260,7 +260,7 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp)
 			 * this point, but just in case if required in future
 			 * for debugging or any other purpose
 			 */
-			printk(KERN_ERR "%s: Received frame with TSI bit not"
+			pr_err("%s: Received frame with TSI bit not"
 					" being SET, dropping the frame, "
 					"cmd->sg <%p>, cmd->sg_cnt <0x%x>\n",
 					__func__, cmd->sg, cmd->sg_cnt);
drivers/target/tcm_fc/tfc_sess.c +9 -9
index 7491e21..fbcbb3d 100644
@@ -198,13 +198,13 @@ static struct ft_sess *ft_sess_get(struct fc_lport *lport, u32 port_id)
 		if (sess->port_id == port_id) {
 			kref_get(&sess->kref);
 			rcu_read_unlock();
-			FT_SESS_DBG("port_id %x found %p\n", port_id, sess);
+			pr_debug("port_id %x found %p\n", port_id, sess);
 			return sess;
 		}
 	}
 out:
 	rcu_read_unlock();
-	FT_SESS_DBG("port_id %x not found\n", port_id);
+	pr_debug("port_id %x not found\n", port_id);
 	return NULL;
 }
 
@@ -240,7 +240,7 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
 	hlist_add_head_rcu(&sess->hash, head);
 	tport->sess_count++;
 
-	FT_SESS_DBG("port_id %x sess %p\n", port_id, sess);
+	pr_debug("port_id %x sess %p\n", port_id, sess);
 
 	transport_register_session(&tport->tpg->se_tpg, &acl->se_node_acl,
 				   sess->se_sess, sess);
@@ -314,7 +314,7 @@ int ft_sess_shutdown(struct se_session *se_sess)
 {
 	struct ft_sess *sess = se_sess->fabric_sess_ptr;
 
-	FT_SESS_DBG("port_id %x\n", sess->port_id);
+	pr_debug("port_id %x\n", sess->port_id);
 	return 1;
 }
 
@@ -335,7 +335,7 @@ void ft_sess_close(struct se_session *se_sess)
 		mutex_unlock(&ft_lport_lock);
 		return;
 	}
-	FT_SESS_DBG("port_id %x\n", port_id);
+	pr_debug("port_id %x\n", port_id);
 	ft_sess_unhash(sess);
 	mutex_unlock(&ft_lport_lock);
 	transport_deregister_session_configfs(se_sess);
@@ -348,7 +348,7 @@ void ft_sess_stop(struct se_session *se_sess, int sess_sleep, int conn_sleep)
 {
 	struct ft_sess *sess = se_sess->fabric_sess_ptr;
 
-	FT_SESS_DBG("port_id %x\n", sess->port_id);
+	pr_debug("port_id %x\n", sess->port_id);
 }
 
 int ft_sess_logged_in(struct se_session *se_sess)
@@ -458,7 +458,7 @@ static int ft_prli(struct fc_rport_priv *rdata, u32 spp_len,
 	mutex_lock(&ft_lport_lock);
 	ret = ft_prli_locked(rdata, spp_len, rspp, spp);
 	mutex_unlock(&ft_lport_lock);
-	FT_SESS_DBG("port_id %x flags %x ret %x\n",
+	pr_debug("port_id %x flags %x ret %x\n",
 	       rdata->ids.port_id, rspp ? rspp->spp_flags : 0, ret);
 	return ret;
 }
@@ -518,11 +518,11 @@ static void ft_recv(struct fc_lport *lport, struct fc_frame *fp)
 	struct ft_sess *sess;
 	u32 sid = fc_frame_sid(fp);
 
-	FT_SESS_DBG("sid %x\n", sid);
+	pr_debug("sid %x\n", sid);
 
 	sess = ft_sess_get(lport, sid);
 	if (!sess) {
-		FT_SESS_DBG("sid %x sess lookup failed\n", sid);
+		pr_debug("sid %x sess lookup failed\n", sid);
 		/* TBD XXX - if FCP_CMND, send PRLO */
 		fc_frame_free(fp);
 		return;
drivers/target/tcm_qla2xxx/tcm_qla2xxx_base.h +0 -6
index a89a567..bb7c497 100644
@@ -8,12 +8,6 @@
 
 #include "qla_target.h"
 
-#if 0
-#define DEBUG_QLA_TGT_SESS_MAP(x...)	printk(KERN_INFO x)
-#else
-#define DEBUG_QLA_TGT_SESS_MAP(x...)
-#endif
-
 struct tcm_qla2xxx_nacl {
 	/* From libfc struct fc_rport->port_id */
 	u16 nport_id;
drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c +95 -95

575 lines not on this page · raw message

drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c +10 -10
index 4dacc1d..9055366 100644
@@ -106,7 +106,7 @@ ssize_t tcm_qla2xxx_parse_wwn(const char *name, u64 *wwn, int strict)
 	}
 	err = 4;
 fail:
-	printk(KERN_INFO "err %u len %zu pos %u byte %u\n",
+	pr_debug("err %u len %zu pos %u byte %u\n",
 			err, cp - name, pos, byte);
 	return -1;
 }
@@ -358,7 +358,7 @@ struct se_node_acl *tcm_qla2xxx_alloc_fabric_acl(struct se_portal_group *se_tpg)
 
 	nacl = kzalloc(sizeof(struct tcm_qla2xxx_nacl), GFP_KERNEL);
 	if (!(nacl)) {
-		printk(KERN_ERR "Unable to alocate struct tcm_qla2xxx_nacl\n");
+		pr_err("Unable to alocate struct tcm_qla2xxx_nacl\n");
 		return NULL;
 	}
 
@@ -427,7 +427,7 @@ void tcm_qla2xxx_release_cmd(struct se_cmd *se_cmd)
 		return;
 
 	while (atomic_read(&cmd->cmd_stop_free) != 1) {
-		printk(KERN_WARNING "Hit atomic_read(&cmd->cmd_stop_free)=1"
+		pr_warn("Hit atomic_read(&cmd->cmd_stop_free)=1"
 				" in tcm_qla2xxx_release_cmd\n");
 		cpu_relax();
 	}
@@ -440,7 +440,7 @@ int tcm_qla2xxx_shutdown_session(struct se_session *se_sess)
 	struct qla_tgt_sess *sess = se_sess->fabric_sess_ptr;
 
 	if (!sess) {
-		printk("se_sess->fabric_sess_ptr is NULL\n");
+		pr_err("se_sess->fabric_sess_ptr is NULL\n");
 		dump_stack();
 		return 0;
 	}
@@ -457,7 +457,7 @@ void tcm_qla2xxx_close_session(struct se_session *se_sess)
 	unsigned long flags;
 
 	if (!sess) {
-		printk(KERN_ERR "se_sess->fabric_sess_ptr is NULL\n");
+		pr_err("se_sess->fabric_sess_ptr is NULL\n");
 		dump_stack();
 		return;
 	}
@@ -476,7 +476,7 @@ void tcm_qla2xxx_stop_session(struct se_session *se_sess, int sess_sleep , int c
 	unsigned long flags;
 
 	if (!sess) {
-		printk(KERN_ERR "se_sess->fabric_sess_ptr is NULL\n");
+		pr_err("se_sess->fabric_sess_ptr is NULL\n");
 		dump_stack();
 		return;
 	}
@@ -518,7 +518,7 @@ int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd)
 		cmd->sg_cnt = se_cmd->t_tasks_sg_chained_no;
 		cmd->sg = se_cmd->t_tasks_sg_chained;
 	} else {
-		printk(KERN_ERR "Unknown se_cmd_flags: 0x%08x in"
+		pr_err("Unknown se_cmd_flags: 0x%08x in"
 			" tcm_qla2xxx_write_pending()\n", se_cmd->se_cmd_flags);
 		BUG();
 	}
@@ -566,13 +566,13 @@ int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
 
 	sess = cmd->sess;
 	if (!sess) {
-		printk(KERN_ERR "Unable to locate struct qla_tgt_sess from qla_tgt_cmd\n");
+		pr_err("Unable to locate struct qla_tgt_sess from qla_tgt_cmd\n");
 		return -EINVAL;
 	}
 
 	se_sess = sess->se_sess;
 	if (!se_sess) {
-		printk(KERN_ERR "Unable to locate active struct se_session\n");
+		pr_err("Unable to locate active struct se_session\n");
 		return -EINVAL;
 	}
 	se_tpg = se_sess->se_tpg;
@@ -756,7 +756,7 @@ int tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
 	struct qla_tgt_mgmt_cmd *mcmd = container_of(se_cmd,
 				struct qla_tgt_mgmt_cmd, se_cmd);
 
-	printk("queue_tm_rsp: mcmd: %p func: 0x%02x response: 0x%02x\n",
+	pr_debug("queue_tm_rsp: mcmd: %p func: 0x%02x response: 0x%02x\n",
 			mcmd, se_tmr->function, se_tmr->response);
 	/*
 	 * Do translation between TCM TM response codes and
drivers/target/tcm_vhost/tcm_vhost_configfs.c +25 -25

198 lines not on this page · raw message

drivers/target/tcm_vhost/tcm_vhost_fabric.c +5 -5
index e9e0e6a..286c719 100644
@@ -76,7 +76,7 @@ u8 tcm_vhost_get_fabric_proto_ident(struct se_portal_group *se_tpg)
 	case SCSI_PROTOCOL_ISCSI:
 		return iscsi_get_fabric_proto_ident(se_tpg);
 	default:
-		printk(KERN_ERR "Unknown tport_proto_id: 0x%02x, using"
+		pr_err("Unknown tport_proto_id: 0x%02x, using"
 			" SAS emulation\n", tport->tport_proto_id);
 		break;
 	}
@@ -127,7 +127,7 @@ u32 tcm_vhost_get_pr_transport_id(
 		return iscsi_get_pr_transport_id(se_tpg, se_nacl, pr_reg,
 					format_code, buf);
 	default:
-		printk(KERN_ERR "Unknown tport_proto_id: 0x%02x, using"
+		pr_err("Unknown tport_proto_id: 0x%02x, using"
 			" SAS emulation\n", tport->tport_proto_id);
 		break;	
 	}
@@ -157,7 +157,7 @@ u32 tcm_vhost_get_pr_transport_id_len(
 		return iscsi_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,
 					format_code);
 	default:
-		printk(KERN_ERR "Unknown tport_proto_id: 0x%02x, using"
+		pr_err("Unknown tport_proto_id: 0x%02x, using"
 			" SAS emulation\n", tport->tport_proto_id);
 		break;
 	}
@@ -187,7 +187,7 @@ char *tcm_vhost_parse_pr_out_transport_id(
 		return iscsi_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,
 					port_nexus_ptr);
 	default:
-		printk(KERN_ERR "Unknown tport_proto_id: 0x%02x, using"
+		pr_err("Unknown tport_proto_id: 0x%02x, using"
 			" SAS emulation\n", tport->tport_proto_id);
 		break;
 	}
@@ -202,7 +202,7 @@ struct se_node_acl *tcm_vhost_alloc_fabric_acl(struct se_portal_group *se_tpg)
 
 	nacl = kzalloc(sizeof(struct tcm_vhost_nacl), GFP_KERNEL);
 	if (!(nacl)) {
-		printk(KERN_ERR "Unable to alocate struct tcm_vhost_nacl\n");
+		pr_err("Unable to alocate struct tcm_vhost_nacl\n");
 		return NULL;
 	}
 
drivers/target/tcm_vhost/tcm_vhost_scsi.c +4 -4
index 45e4dd7..691c45b 100644
@@ -52,14 +52,14 @@ static struct tcm_vhost_cmd *vhost_scsi_allocate_cmd(
 
 	tv_nexus = tv_tpg->tpg_nexus;
 	if (!tv_nexus) {
-		printk(KERN_ERR "Unable to locate active struct tcm_vhost_nexus\n");
+		pr_err("Unable to locate active struct tcm_vhost_nexus\n");
 		return ERR_PTR(-EIO);
 	}
 	se_sess = tv_nexus->tvn_se_sess;
 
 	tv_cmd = kzalloc(sizeof(struct tcm_vhost_cmd), GFP_ATOMIC);
 	if (!tv_cmd) {
-		printk(KERN_ERR "Unable to allocate struct tcm_vhost_cmd\n");
+		pr_err("Unable to allocate struct tcm_vhost_cmd\n");
 		return ERR_PTR(-ENOMEM);
 	}
 	tv_cmd->tvc_tag = v_header->tag;
@@ -144,7 +144,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs)
 		 * hardcoded max for t
 		 */
 		if (scsi_command_size(cdb) > TCM_VHOST_MAX_CDB_SIZE) {
-			printk(KERN_ERR "Received SCSI CDB with command_size:"
+			pr_err("Received SCSI CDB with command_size:"
 				" %d that exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n",
 				scsi_command_size(cdb), TCM_VHOST_MAX_CDB_SIZE);
 			break;
@@ -294,7 +294,7 @@ static int vhost_scsi_clear_endpoint(
 	if (strcmp(tv_tport->tport_name, t->vhost_wwpn) ||
 	    (tv_tpg->tport_tpgt != t->vhost_tpgt)) {
 		mutex_unlock(&vq->mutex);
-		printk(KERN_WARNING "tv_tport->tport_name: %s, tv_tpg->tport_tpgt: %hu"
+		pr_warn("tv_tport->tport_name: %s, tv_tpg->tport_tpgt: %hu"
 			" does not match t->vhost_wwpn: %s, t->vhost_tpgt: %hu\n",
 			tv_tport->tport_name, tv_tpg->tport_tpgt,
 			t->vhost_wwpn, t->vhost_tpgt);
Signature · 1 line
1.7.1
#15 lore raw

PATCH 9/15 target/iscsi: Remove iscsi_target_debug.h and usage of TRACE() & printk()

In reply to Andy Grover

This should have the effect of quieting dmesg output when there are no issues, and yet still allow these messages to be enabled during a debugging session if needs be.

Replaced all printk(KERN_ERR) with pr_err()

Replaced all printk(KERN_INFO) with pr_debug()

Replaced all uses of TRACE() with pr_debug()

Moved PRINT_BUFF macro to iscsi_target_util.c, only place it's used

Remove iscsi debug config option

---
 drivers/target/iscsi/Kconfig                      |    9 -
 drivers/target/iscsi/iscsi_target.c               |  319 ++++++++++-----------
 drivers/target/iscsi/iscsi_target_auth.c          |   84 +++---
 drivers/target/iscsi/iscsi_target_configfs.c      |   76 +++---
 drivers/target/iscsi/iscsi_target_datain_values.c |   13 +-
 drivers/target/iscsi/iscsi_target_debug.h         |  113 --------
 drivers/target/iscsi/iscsi_target_device.c        |    3 +-
 drivers/target/iscsi/iscsi_target_erl0.c          |   67 +++---
 drivers/target/iscsi/iscsi_target_erl1.c          |   65 ++---
 drivers/target/iscsi/iscsi_target_erl2.c          |   25 +-
 drivers/target/iscsi/iscsi_target_login.c         |  105 ++++----
 drivers/target/iscsi/iscsi_target_nego.c          |   89 +++---
 drivers/target/iscsi/iscsi_target_nodeattrib.c    |   41 ++--
 drivers/target/iscsi/iscsi_target_parameters.c    |  259 +++++++++---------
 drivers/target/iscsi/iscsi_target_seq_pdu_list.c  |   43 ++--
 drivers/target/iscsi/iscsi_target_tmr.c           |   49 ++--
 drivers/target/iscsi/iscsi_target_tpg.c           |   77 +++---
 drivers/target/iscsi/iscsi_target_tq.c            |   27 +-
 drivers/target/iscsi/iscsi_target_util.c          |  128 +++++----
 19 files changed, 731 insertions(+), 861 deletions(-)
 delete mode 100644 drivers/target/iscsi/iscsi_target_debug.h
drivers/target/iscsi/Kconfig +0 -9
index b927796..564ff4e 100644
@@ -6,12 +6,3 @@ config ISCSI_TARGET
 	help
 	Say M here to enable the ConfigFS enabled Linux-iSCSI.org iSCSI
 	Target Mode Stack.
-
-if ISCSI_TARGET
-
-config ISCSI_TARGET_DEBUG
-	bool "LIO-Target iscsi_debug.h ring buffer messages"
-	help
-	Say Y here to enable the legacy DEBUG_ISCSI macros in iscsi_debug.h
-
-endif
drivers/target/iscsi/iscsi_target.c +157 -162

1,218 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_auth.c +39 -45

283 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_configfs.c +38 -38

284 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_datain_values.c +6 -7
index 92a134b..97b459f 100644
@@ -20,7 +20,6 @@
 
 #include <scsi/iscsi_proto.h>
 
-#include "iscsi_target_debug.h"
 #include "iscsi_target_core.h"
 #include "iscsi_target_seq_pdu_list.h"
 #include "iscsi_target_erl1.h"
@@ -34,7 +33,7 @@ struct iscsi_datain_req *iscsit_allocate_datain_req(void)
 
 	dr = kmem_cache_zalloc(lio_dr_cache, GFP_ATOMIC);
 	if (!dr) {
-		printk(KERN_ERR "Unable to allocate memory for"
+		pr_err("Unable to allocate memory for"
 				" struct iscsi_datain_req\n");
 		return NULL;
 	}
@@ -76,7 +75,7 @@ struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd)
 	struct iscsi_datain_req *dr;
 
 	if (list_empty(&cmd->datain_list)) {
-		printk(KERN_ERR "cmd->datain_list is empty for ITT:"
+		pr_err("cmd->datain_list is empty for ITT:"
 			" 0x%08x\n", cmd->init_task_tag);
 		return NULL;
 	}
@@ -116,7 +115,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes(
 
 	read_data_left = (cmd->data_length - read_data_done);
 	if (!read_data_left) {
-		printk(KERN_ERR "ITT: 0x%08x read_data_left is zero!\n",
+		pr_err("ITT: 0x%08x read_data_left is zero!\n",
 				cmd->init_task_tag);
 		return NULL;
 	}
@@ -215,7 +214,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes(
 
 	read_data_left = (cmd->data_length - read_data_done);
 	if (!read_data_left) {
-		printk(KERN_ERR "ITT: 0x%08x read_data_left is zero!\n",
+		pr_err("ITT: 0x%08x read_data_left is zero!\n",
 				cmd->init_task_tag);
 		return NULL;
 	}
@@ -336,7 +335,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no(
 
 	read_data_left = (cmd->data_length - read_data_done);
 	if (!read_data_left) {
-		printk(KERN_ERR "ITT: 0x%08x read_data_left is zero!\n",
+		pr_err("ITT: 0x%08x read_data_left is zero!\n",
 				cmd->init_task_tag);
 		return dr;
 	}
@@ -436,7 +435,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no(
 
 	read_data_left = (cmd->data_length - read_data_done);
 	if (!read_data_left) {
-		printk(KERN_ERR "ITT: 0x%08x read_data_left is zero!\n",
+		pr_err("ITT: 0x%08x read_data_left is zero!\n",
 				cmd->init_task_tag);
 		return NULL;
 	}
drivers/target/iscsi/iscsi_target_debug.h deleted +0 -113

113 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_device.c +1 -2
index b855c68..40975df 100644
@@ -24,7 +24,6 @@
 #include <target/target_core_device.h>
 #include <target/target_core_transport.h>
 
-#include "iscsi_target_debug.h"
 #include "iscsi_target_core.h"
 #include "iscsi_target_device.h"
 #include "iscsi_target_tpg.h"
@@ -83,6 +82,6 @@ void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess
 
 	mutex_lock(&sess->cmdsn_mutex);
 	sess->max_cmd_sn += 1;
-	TRACE(TRACE_ISCSI, "Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn);
+	pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn);
 	mutex_unlock(&sess->cmdsn_mutex);
 }
drivers/target/iscsi/iscsi_target_erl0.c +33 -34

266 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_erl1.c +32 -33

261 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_erl2.c +12 -13
index a810e59..fcbc861 100644
@@ -23,7 +23,6 @@
 #include <target/target_core_base.h>
 #include <target/target_core_transport.h>
 
-#include "iscsi_target_debug.h"
 #include "iscsi_target_core.h"
 #include "iscsi_target_datain_values.h"
 #include "iscsi_target_util.h"
@@ -102,7 +101,7 @@ static int iscsit_attach_inactive_connection_recovery_entry(
 	list_add_tail(&cr->cr_list, &sess->cr_inactive_list);
 
 	sess->conn_recovery_count++;
-	TRACE(TRACE_ERL2, "Incremented connection recovery count to %u for"
+	pr_debug("Incremented connection recovery count to %u for"
 		" SID: %u\n", sess->conn_recovery_count, sess->sid);
 	spin_unlock(&sess->cr_i_lock);
 
@@ -197,7 +196,7 @@ int iscsit_remove_active_connection_recovery_entry(
 	list_del(&cr->cr_list);
 
 	sess->conn_recovery_count--;
-	TRACE(TRACE_ERL2, "Decremented connection recovery count to %u for"
+	pr_debug("Decremented connection recovery count to %u for"
 		" SID: %u\n", sess->conn_recovery_count, sess->sid);
 	spin_unlock(&sess->cr_a_lock);
 
@@ -227,7 +226,7 @@ int iscsit_remove_cmd_from_connection_recovery(
 	struct iscsi_conn_recovery *cr;
 
 	if (!cmd->cr) {
-		printk(KERN_ERR "struct iscsi_conn_recovery pointer for ITT: 0x%08x"
+		pr_err("struct iscsi_conn_recovery pointer for ITT: 0x%08x"
 			" is NULL!\n", cmd->init_task_tag);
 		BUG();
 	}
@@ -256,7 +255,7 @@ void iscsit_discard_cr_cmds_by_expstatsn(
 		}
 
 		dropped_count++;
-		TRACE(TRACE_ERL2, "Dropping Acknowledged ITT: 0x%08x, StatSN:"
+		pr_debug("Dropping Acknowledged ITT: 0x%08x, StatSN:"
 			" 0x%08x, CID: %hu.\n", cmd->init_task_tag,
 				cmd->stat_sn, cr->cid);
 
@@ -274,17 +273,17 @@ void iscsit_discard_cr_cmds_by_expstatsn(
 	}
 	spin_unlock(&cr->conn_recovery_cmd_lock);
 
-	TRACE(TRACE_ERL2, "Dropped %u total acknowledged commands on"
+	pr_debug("Dropped %u total acknowledged commands on"
 		" CID: %hu less than old ExpStatSN: 0x%08x\n",
 			dropped_count, cr->cid, exp_statsn);
 
 	if (!cr->cmd_count) {
-		TRACE(TRACE_ERL2, "No commands to be reassigned for failed"
+		pr_debug("No commands to be reassigned for failed"
 			" connection CID: %hu on SID: %u\n",
 			cr->cid, sess->sid);
 		iscsit_remove_inactive_connection_recovery_entry(cr, sess);
 		iscsit_attach_active_connection_recovery_entry(sess, cr);
-		printk(KERN_INFO "iSCSI connection recovery successful for CID:"
+		pr_debug("iSCSI connection recovery successful for CID:"
 			" %hu on SID: %u\n", cr->cid, sess->sid);
 		iscsit_remove_active_connection_recovery_entry(cr, sess);
 	} else {
@@ -308,7 +307,7 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn)
 			continue;
 
 		dropped_count++;
-		TRACE(TRACE_ERL2, "Dropping unacknowledged CmdSN:"
+		pr_debug("Dropping unacknowledged CmdSN:"
 		" 0x%08x during connection recovery on CID: %hu\n",
 			ooo_cmdsn->cmdsn, conn->cid);
 		iscsit_remove_ooo_cmdsn(sess, ooo_cmdsn);
@@ -334,7 +333,7 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn)
 	}
 	spin_unlock_bh(&conn->cmd_lock);
 
-	TRACE(TRACE_ERL2, "Dropped %u total unacknowledged commands on CID:"
+	pr_debug("Dropped %u total unacknowledged commands on CID:"
 		" %hu for ExpCmdSN: 0x%08x.\n", dropped_count, conn->cid,
 				sess->exp_cmd_sn);
 	return 0;
@@ -354,7 +353,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
 	 */
 	cr = kzalloc(sizeof(struct iscsi_conn_recovery), GFP_KERNEL);
 	if (!cr) {
-		printk(KERN_ERR "Unable to allocate memory for"
+		pr_err("Unable to allocate memory for"
 			" struct iscsi_conn_recovery.\n");
 		return -1;
 	}
@@ -375,7 +374,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
 
 		if ((cmd->iscsi_opcode != ISCSI_OP_SCSI_CMD) &&
 		    (cmd->iscsi_opcode != ISCSI_OP_NOOP_OUT)) {
-			TRACE(TRACE_ERL2, "Not performing realligence on"
+			pr_debug("Not performing realligence on"
 				" Opcode: 0x%02x, ITT: 0x%08x, CmdSN: 0x%08x,"
 				" CID: %hu\n", cmd->iscsi_opcode,
 				cmd->init_task_tag, cmd->cmd_sn, conn->cid);
@@ -422,7 +421,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn)
 		}
 
 		cmd_count++;
-		TRACE(TRACE_ERL2, "Preparing Opcode: 0x%02x, ITT: 0x%08x,"
+		pr_debug("Preparing Opcode: 0x%02x, ITT: 0x%08x,"
 			" CmdSN: 0x%08x, StatSN: 0x%08x, CID: %hu for"
 			" realligence.\n", cmd->iscsi_opcode,
 			cmd->init_task_tag, cmd->cmd_sn, cmd->stat_sn,
drivers/target/iscsi/iscsi_target_login.c +52 -53

395 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_nego.c +44 -45

89 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_nodeattrib.c +20 -21

41 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_parameters.c +129 -130

259 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_seq_pdu_list.c +21 -22

43 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_tmr.c +24 -25

49 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_tpg.c +38 -39

77 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_tq.c +13 -14
index 8f8a4ca..0ecd22f 100644

Lines of this file are not shown. View the raw message.

drivers/target/iscsi/iscsi_target_util.c +72 -56

128 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.1

Part of the diff is not shown here. View the raw message.

#16 lore raw

PATCH 10/15 target/iscsi: Remove SE_CMD macro

In reply to Andy Grover

Similar to macros that were in the core, we can remove this macro and help make the code a little more straightforward.

---
 drivers/target/iscsi/iscsi_target.c        |   90 ++++++++++++++--------------
 drivers/target/iscsi/iscsi_target_core.h   |    2 -
 drivers/target/iscsi/iscsi_target_device.c |    4 +-
 drivers/target/iscsi/iscsi_target_erl0.c   |    4 +-
 drivers/target/iscsi/iscsi_target_erl1.c   |    2 +-
 drivers/target/iscsi/iscsi_target_erl2.c   |   61 ++++++++-----------
 drivers/target/iscsi/iscsi_target_tmr.c    |   14 ++--
 drivers/target/iscsi/iscsi_target_util.c   |    2 +-
 8 files changed, 85 insertions(+), 94 deletions(-)
drivers/target/iscsi/iscsi_target.c +45 -45
index f0681ca..3007956 100644
@@ -1008,7 +1008,7 @@ done:
 	ret = iscsit_get_lun_for_cmd(cmd, hdr->cdb,
 				get_unaligned_le64(&hdr->lun[0]));
 	if (ret < 0) {
-		if (SE_CMD(cmd)->scsi_sense_reason == TCM_NON_EXISTENT_LUN) {
+		if (cmd->se_cmd.scsi_sense_reason == TCM_NON_EXISTENT_LUN) {
 			pr_debug("Responding to non-acl'ed,"
 				" non-existent or non-exported iSCSI LUN:"
 				" 0x%016Lx\n", get_unaligned_le64(&hdr->lun[0]));
@@ -1027,7 +1027,7 @@ done:
 	 * allocate 1->N transport tasks (depending on sector count and
 	 * maximum request size the physical HBA(s) can handle.
 	 */
-	transport_ret = transport_generic_allocate_tasks(SE_CMD(cmd), hdr->cdb);
+	transport_ret = transport_generic_allocate_tasks(&cmd->se_cmd, hdr->cdb);
 	if (transport_ret == -ENOMEM) {
 		return iscsit_add_reject_from_cmd(
 				ISCSI_REASON_BOOKMARK_NO_RESOURCES,
@@ -1054,7 +1054,7 @@ attach_cmd:
 	 * Check if we need to delay processing because of ALUA
 	 * Active/NonOptimized primary access state..
 	 */
-	core_alua_check_nonop_delay(SE_CMD(cmd));
+	core_alua_check_nonop_delay(&cmd->se_cmd);
 	/*
 	 * Allocate and setup SGL used with transport_generic_map_mem_to_cmd().
 	 * also call iscsit_allocate_iovecs()
@@ -1117,7 +1117,7 @@ attach_cmd:
 	 * the backend memory allocation.
 	 */
 	ret = transport_generic_new_cmd(&cmd->se_cmd);
-	if ((ret < 0) || (SE_CMD(cmd)->se_cmd_flags & SCF_SE_CMD_FAILED)) {
+	if ((ret < 0) || (cmd->se_cmd.se_cmd_flags & SCF_SE_CMD_FAILED)) {
 		immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION;
 		dump_immediate_data = 1;
 		goto after_immediate_data;
@@ -1301,7 +1301,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)
 		return iscsit_add_reject_from_cmd(ISCSI_REASON_PROTOCOL_ERROR,
 				1, 0, buf, cmd);
 	}
-	se_cmd = SE_CMD(cmd);
+	se_cmd = &cmd->se_cmd;
 	iscsit_mod_dataout_timer(cmd);
 
 	if ((hdr->offset + payload_length) > cmd->data_length) {
@@ -1318,7 +1318,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)
 		if (conn->sess->sess_ops->InitialR2T) {
 			pr_err("Received unexpected unsolicited data"
 				" while InitialR2T=Yes, protocol error.\n");
-			transport_send_check_condition_and_sense(SE_CMD(cmd),
+			transport_send_check_condition_and_sense(&cmd->se_cmd,
 					TCM_UNEXPECTED_UNSOLICITED_DATA, 0);
 			return -1;
 		}
@@ -1457,7 +1457,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)
 
 		iscsit_stop_dataout_timer(cmd);
 		return (!ooo_cmdsn) ? transport_generic_handle_data(
-					SE_CMD(cmd)) : 0;
+					&cmd->se_cmd) : 0;
 	} else /* DATAOUT_CANNOT_RECOVER */
 		return -1;
 
@@ -1740,7 +1740,7 @@ static int iscsit_handle_task_mgt_cmd(
 	cmd->targ_xfer_tag	= 0xFFFFFFFF;
 	cmd->cmd_sn		= hdr->cmdsn;
 	cmd->exp_stat_sn	= hdr->exp_statsn;
-	se_tmr			= SE_CMD(cmd)->se_tmr_req;
+	se_tmr			= cmd->se_cmd.se_tmr_req;
 	tmr_req			= cmd->tmr_req;
 	/*
 	 * Locate the struct se_lun for all TMRs not related to ERL=2 TASK_REASSIGN
@@ -1749,7 +1749,7 @@ static int iscsit_handle_task_mgt_cmd(
 		ret = iscsit_get_lun_for_tmr(cmd,
 				get_unaligned_le64(&hdr->lun[0]));
 		if (ret < 0) {
-			SE_CMD(cmd)->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
+			cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
 			se_tmr->response = ISCSI_TMF_RSP_NO_LUN;
 			goto attach;
 		}
@@ -1759,7 +1759,7 @@ static int iscsit_handle_task_mgt_cmd(
 	case ISCSI_TM_FUNC_ABORT_TASK:
 		se_tmr->response = iscsit_tmr_abort_task(cmd, buf);
 		if (se_tmr->response != ISCSI_TMF_RSP_COMPLETE) {
-			SE_CMD(cmd)->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
+			cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
 			goto attach;
 		}
 		break;
@@ -1770,14 +1770,14 @@ static int iscsit_handle_task_mgt_cmd(
 		break;
 	case ISCSI_TM_FUNC_TARGET_WARM_RESET:
 		if (iscsit_tmr_task_warm_reset(conn, tmr_req, buf) < 0) {
-			SE_CMD(cmd)->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
+			cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
 			se_tmr->response = ISCSI_TMF_RSP_AUTH_FAILED;
 			goto attach;
 		}
 		break;
 	case ISCSI_TM_FUNC_TARGET_COLD_RESET:
 		if (iscsit_tmr_task_cold_reset(conn, tmr_req, buf) < 0) {
-			SE_CMD(cmd)->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
+			cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
 			se_tmr->response = ISCSI_TMF_RSP_AUTH_FAILED;
 			goto attach;
 		}
@@ -1799,7 +1799,7 @@ static int iscsit_handle_task_mgt_cmd(
 	default:
 		pr_err("Unknown TMR function: 0x%02x, protocol"
 			" error.\n", function);
-		SE_CMD(cmd)->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
+		cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
 		se_tmr->response = ISCSI_TMF_RSP_NOT_SUPPORTED;
 		goto attach;
 	}
@@ -1832,7 +1832,7 @@ attach:
 	 * Found the referenced task, send to transport for processing.
 	 */
 	if (se_tmr->call_transport)
-		return transport_generic_handle_tmr(SE_CMD(cmd));
+		return transport_generic_handle_tmr(&cmd->se_cmd);
 
 	/*
 	 * Could not find the referenced LUN, task, or Task Management
@@ -2489,7 +2489,7 @@ static int iscsit_send_data_in(
 	 * and Sense Data.
 	 */
 	if ((datain.flags & ISCSI_FLAG_DATA_STATUS) &&
-	    (SE_CMD(cmd)->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE))
+	    (cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE))
 		datain.flags &= ~ISCSI_FLAG_DATA_STATUS;
 	else {
 		if ((dr->dr_complete == DATAIN_COMPLETE_NORMAL) ||
@@ -2507,17 +2507,17 @@ static int iscsit_send_data_in(
 	hdr->opcode		= ISCSI_OP_SCSI_DATA_IN;
 	hdr->flags		= datain.flags;
 	if (hdr->flags & ISCSI_FLAG_DATA_STATUS) {
-		if (SE_CMD(cmd)->se_cmd_flags & SCF_OVERFLOW_BIT) {
+		if (cmd->se_cmd.se_cmd_flags & SCF_OVERFLOW_BIT) {
 			hdr->flags |= ISCSI_FLAG_DATA_OVERFLOW;
 			hdr->residual_count = cpu_to_be32(cmd->residual_count);
-		} else if (SE_CMD(cmd)->se_cmd_flags & SCF_UNDERFLOW_BIT) {
+		} else if (cmd->se_cmd.se_cmd_flags & SCF_UNDERFLOW_BIT) {
 			hdr->flags |= ISCSI_FLAG_DATA_UNDERFLOW;
 			hdr->residual_count = cpu_to_be32(cmd->residual_count);
 		}
 	}
 	hton24(hdr->dlength, datain.length);
 	if (hdr->flags & ISCSI_FLAG_DATA_ACK)
-		int_to_scsilun(SE_CMD(cmd)->orig_fe_lun,
+		int_to_scsilun(cmd->se_cmd.orig_fe_lun,
 				(struct scsi_lun *)&hdr->lun[0]);
 	else
 		put_unaligned_le64(0xFFFFFFFFFFFFFFFFULL, &hdr->lun[0]);
@@ -2589,7 +2589,7 @@ static int iscsit_send_data_in(
 		ntohl(hdr->offset), datain.length, conn->cid);
 
 	if (dr->dr_complete) {
-		*eodr = (SE_CMD(cmd)->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ?
+		*eodr = (cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ?
 				2 : 1;
 		iscsit_free_datain_req(cmd, dr);
 	}
@@ -2864,7 +2864,7 @@ int iscsit_send_r2t(
 	memset(hdr, 0, ISCSI_HDR_LEN);
 	hdr->opcode		= ISCSI_OP_R2T;
 	hdr->flags		|= ISCSI_FLAG_CMD_FINAL;
-	int_to_scsilun(SE_CMD(cmd)->orig_fe_lun,
+	int_to_scsilun(cmd->se_cmd.orig_fe_lun,
 			(struct scsi_lun *)&hdr->lun[0]);
 	hdr->itt		= cpu_to_be32(cmd->init_task_tag);
 	spin_lock_bh(&conn->sess->ttt_lock);
@@ -3012,15 +3012,15 @@ static int iscsit_send_status(
 	memset(hdr, 0, ISCSI_HDR_LEN);
 	hdr->opcode		= ISCSI_OP_SCSI_CMD_RSP;
 	hdr->flags		|= ISCSI_FLAG_CMD_FINAL;
-	if (SE_CMD(cmd)->se_cmd_flags & SCF_OVERFLOW_BIT) {
+	if (cmd->se_cmd.se_cmd_flags & SCF_OVERFLOW_BIT) {
 		hdr->flags |= ISCSI_FLAG_CMD_OVERFLOW;
 		hdr->residual_count = cpu_to_be32(cmd->residual_count);
-	} else if (SE_CMD(cmd)->se_cmd_flags & SCF_UNDERFLOW_BIT) {
+	} else if (cmd->se_cmd.se_cmd_flags & SCF_UNDERFLOW_BIT) {
 		hdr->flags |= ISCSI_FLAG_CMD_UNDERFLOW;
 		hdr->residual_count = cpu_to_be32(cmd->residual_count);
 	}
 	hdr->response		= cmd->iscsi_response;
-	hdr->cmd_status		= SE_CMD(cmd)->scsi_status;
+	hdr->cmd_status		= cmd->se_cmd.scsi_status;
 	hdr->itt		= cpu_to_be32(cmd->init_task_tag);
 	hdr->statsn		= cpu_to_be32(cmd->stat_sn);
 
@@ -3036,19 +3036,19 @@ static int iscsit_send_status(
 	/*
 	 * Attach SENSE DATA payload to iSCSI Response PDU
 	 */
-	if (SE_CMD(cmd)->sense_buffer &&
-	   ((SE_CMD(cmd)->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ||
-	    (SE_CMD(cmd)->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) {
-		padding		= -(SE_CMD(cmd)->scsi_sense_length) & 3;
-		hton24(hdr->dlength, SE_CMD(cmd)->scsi_sense_length);
-		iov[iov_count].iov_base	= SE_CMD(cmd)->sense_buffer;
+	if (cmd->se_cmd.sense_buffer &&
+	   ((cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ||
+	    (cmd->se_cmd.se_cmd_flags & SCF_EMULATED_TASK_SENSE))) {
+		padding		= -(cmd->se_cmd.scsi_sense_length) & 3;
+		hton24(hdr->dlength, cmd->se_cmd.scsi_sense_length);
+		iov[iov_count].iov_base	= cmd->se_cmd.sense_buffer;
 		iov[iov_count++].iov_len =
-				(SE_CMD(cmd)->scsi_sense_length + padding);
-		tx_size += SE_CMD(cmd)->scsi_sense_length;
+				(cmd->se_cmd.scsi_sense_length + padding);
+		tx_size += cmd->se_cmd.scsi_sense_length;
 
 		if (padding) {
-			memset(SE_CMD(cmd)->sense_buffer +
-				SE_CMD(cmd)->scsi_sense_length, 0, padding);
+			memset(cmd->se_cmd.sense_buffer +
+				cmd->se_cmd.scsi_sense_length, 0, padding);
 			tx_size += padding;
 			pr_debug("Adding %u bytes of padding to"
 				" SENSE.\n", padding);
@@ -3056,8 +3056,8 @@ static int iscsit_send_status(
 
 		if (conn->conn_ops->DataDigest) {
 			iscsit_do_crypto_hash_buf(&conn->conn_tx_hash,
-				SE_CMD(cmd)->sense_buffer,
-				(SE_CMD(cmd)->scsi_sense_length + padding),
+				cmd->se_cmd.sense_buffer,
+				(cmd->se_cmd.scsi_sense_length + padding),
 				0, NULL, (u8 *)&cmd->data_crc);
 
 			iov[iov_count].iov_base    = &cmd->data_crc;
@@ -3066,13 +3066,13 @@ static int iscsit_send_status(
 
 			pr_debug("Attaching CRC32 DataDigest for"
 				" SENSE, %u bytes CRC 0x%08x\n",
-				(SE_CMD(cmd)->scsi_sense_length + padding),
+				(cmd->se_cmd.scsi_sense_length + padding),
 				cmd->data_crc);
 		}
 
 		pr_debug("Attaching SENSE DATA: %u bytes to iSCSI"
 				" Response PDU\n",
-				SE_CMD(cmd)->scsi_sense_length);
+				cmd->se_cmd.scsi_sense_length);
 	}
 
 	if (conn->conn_ops->HeaderDigest) {
@@ -3122,7 +3122,7 @@ static int iscsit_send_task_mgt_rsp(
 	struct iscsi_cmd *cmd,
 	struct iscsi_conn *conn)
 {
-	struct se_tmr_req *se_tmr = SE_CMD(cmd)->se_tmr_req;
+	struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
 	struct iscsi_tm_rsp *hdr;
 	u32 tx_size = 0;
 
@@ -3535,11 +3535,11 @@ get_immediate:
 				 * Determine if a struct se_cmd is assoicated with
 				 * this struct iscsi_cmd.
 				 */
-				if (!(SE_CMD(cmd)->se_cmd_flags & SCF_SE_LUN_CMD) &&
+				if (!(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD) &&
 				    !(cmd->tmr_req))
 					iscsit_release_cmd(cmd);
 				else
-					transport_generic_free_cmd(SE_CMD(cmd),
+					transport_generic_free_cmd(&cmd->se_cmd,
 								1, 0);
 				goto get_immediate;
 			case ISTATE_SEND_NOPIN_WANT_RESPONSE:
@@ -3941,13 +3941,13 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
 	 */
 	spin_lock_bh(&conn->cmd_lock);
 	list_for_each_entry_safe(cmd, cmd_tmp, &conn->conn_cmd_list, i_list) {
-		if (!(SE_CMD(cmd)) ||
-		    !(SE_CMD(cmd)->se_cmd_flags & SCF_SE_LUN_CMD)) {
+		if (!(&cmd->se_cmd) ||
+		    !(cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)) {
 
 			list_del(&cmd->i_list);
 			spin_unlock_bh(&conn->cmd_lock);
 			iscsit_increment_maxcmdsn(cmd, sess);
-			se_cmd = SE_CMD(cmd);
+			se_cmd = &cmd->se_cmd;
 			/*
 			 * Special cases for active iSCSI TMR, and
 			 * transport_lookup_cmd_lun() failing from
@@ -3955,7 +3955,7 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
 			 */
 			if (cmd->tmr_req && se_cmd->transport_wait_for_tasks)
 				se_cmd->transport_wait_for_tasks(se_cmd, 1, 1);
-			else if (SE_CMD(cmd)->se_cmd_flags & SCF_SE_LUN_CMD)
+			else if (cmd->se_cmd.se_cmd_flags & SCF_SE_LUN_CMD)
 				transport_release_cmd(se_cmd);
 			else
 				iscsit_release_cmd(cmd);
@@ -3967,7 +3967,7 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
 		spin_unlock_bh(&conn->cmd_lock);
 
 		iscsit_increment_maxcmdsn(cmd, sess);
-		se_cmd = SE_CMD(cmd);
+		se_cmd = &cmd->se_cmd;
 
 		if (se_cmd->transport_wait_for_tasks)
 			se_cmd->transport_wait_for_tasks(se_cmd, 1, 1);
drivers/target/iscsi/iscsi_target_core.h +0 -2
index c66a259..470ed55 100644
@@ -482,8 +482,6 @@ struct iscsi_cmd {
 
 }  ____cacheline_aligned;
 
-#define SE_CMD(cmd)		(&(cmd)->se_cmd)
-
 struct iscsi_tmr_req {
 	bool			task_reassign:1;
 	u32			ref_cmd_sn;
drivers/target/iscsi/iscsi_target_device.c +2 -2
index 40975df..9e356de 100644
@@ -35,7 +35,7 @@ int iscsit_get_lun_for_tmr(
 {
 	u32 unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun);
 
-	return transport_lookup_tmr_lun(SE_CMD(cmd), unpacked_lun);
+	return transport_lookup_tmr_lun(&cmd->se_cmd, unpacked_lun);
 }
 
 int iscsit_get_lun_for_cmd(
@@ -45,7 +45,7 @@ int iscsit_get_lun_for_cmd(
 {
 	u32 unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun);
 
-	return transport_lookup_cmd_lun(SE_CMD(cmd), unpacked_lun);
+	return transport_lookup_cmd_lun(&cmd->se_cmd, unpacked_lun);
 }
 
 void iscsit_determine_maxcmdsn(struct iscsi_session *sess)
drivers/target/iscsi/iscsi_target_erl0.c +2 -2
index 863a29c..1999bf8 100644
@@ -164,7 +164,7 @@ static int iscsit_dataout_check_unsolicited_sequence(
 		pr_err("Total %u bytes exceeds FirstBurstLength: %u"
 			" for this Unsolicited DataOut Burst.\n",
 			first_burst_len, conn->sess->sess_ops->FirstBurstLength);
-		transport_send_check_condition_and_sense(SE_CMD(cmd),
+		transport_send_check_condition_and_sense(&cmd->se_cmd,
 				TCM_INCORRECT_AMOUNT_OF_DATA, 0);
 		return DATAOUT_CANNOT_RECOVER;
 	}
@@ -189,7 +189,7 @@ static int iscsit_dataout_check_unsolicited_sequence(
 			" does not equal ExpXferLen %u.\n", first_burst_len,
 				conn->sess->sess_ops->FirstBurstLength,
 				cmd->data_length);
-			transport_send_check_condition_and_sense(SE_CMD(cmd),
+			transport_send_check_condition_and_sense(&cmd->se_cmd,
 					TCM_INCORRECT_AMOUNT_OF_DATA, 0);
 			return DATAOUT_CANNOT_RECOVER;
 		}
drivers/target/iscsi/iscsi_target_erl1.c +1 -1
index 8db9377..9fd3e9c 100644
@@ -1027,7 +1027,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo)
 		}
 		spin_unlock_bh(&cmd->istate_lock);
 
-		return transport_generic_handle_tmr(SE_CMD(cmd));
+		return transport_generic_handle_tmr(&cmd->se_cmd);
 	case ISCSI_OP_LOGOUT:
 		spin_unlock_bh(&cmd->istate_lock);
 		switch (cmd->logout_reason) {
drivers/target/iscsi/iscsi_target_erl2.c +27 -34

115 lines not on this page · raw message

drivers/target/iscsi/iscsi_target_tmr.c +7 -7
index 1183c04..dc90366 100644
@@ -42,7 +42,7 @@ u8 iscsit_tmr_abort_task(
 	struct iscsi_cmd *ref_cmd;
 	struct iscsi_conn *conn = cmd->conn;
 	struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
-	struct se_tmr_req *se_tmr = SE_CMD(cmd)->se_tmr_req;
+	struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
 	struct iscsi_tm *hdr = (struct iscsi_tm *) buf;
 
 	ref_cmd = iscsit_find_cmd_from_itt(conn, hdr->rtt);
@@ -122,7 +122,7 @@ u8 iscsit_tmr_task_reassign(
 	struct iscsi_conn *conn = cmd->conn;
 	struct iscsi_conn_recovery *cr = NULL;
 	struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
-	struct se_tmr_req *se_tmr = SE_CMD(cmd)->se_tmr_req;
+	struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
 	struct iscsi_tm *hdr = (struct iscsi_tm *) buf;
 	int ret;
 
@@ -231,7 +231,7 @@ static int iscsit_task_reassign_complete_write(
 	int no_build_r2ts = 0;
 	u32 length = 0, offset = 0;
 	struct iscsi_conn *conn = cmd->conn;
-	struct se_cmd *se_cmd = SE_CMD(cmd);
+	struct se_cmd *se_cmd = &cmd->se_cmd;
 	/*
 	 * The Initiator must not send a R2T SNACK with a Begrun less than
 	 * the TMR TASK_REASSIGN's ExpDataSN.
@@ -301,7 +301,7 @@ static int iscsit_task_reassign_complete_read(
 {
 	struct iscsi_conn *conn = cmd->conn;
 	struct iscsi_datain_req *dr;
-	struct se_cmd *se_cmd = SE_CMD(cmd);
+	struct se_cmd *se_cmd = &cmd->se_cmd;
 	/*
 	 * The Initiator must not send a Data SNACK with a BegRun less than
 	 * the TMR TASK_REASSIGN's ExpDataSN.
@@ -317,7 +317,7 @@ static int iscsit_task_reassign_complete_read(
 	if (!atomic_read(&cmd->transport_sent)) {
 		pr_debug("READ ITT: 0x%08x: t_state: %d never sent to"
 			" transport\n", cmd->init_task_tag,
-			SE_CMD(cmd)->t_state);
+			cmd->se_cmd.t_state);
 		transport_generic_handle_cdb(se_cmd);
 		return 0;
 	}
@@ -325,7 +325,7 @@ static int iscsit_task_reassign_complete_read(
 	if (!atomic_read(&se_cmd->t_transport_complete)) {
 		pr_err("READ ITT: 0x%08x: t_state: %d, never returned"
 			" from transport\n", cmd->init_task_tag,
-			SE_CMD(cmd)->t_state);
+			cmd->se_cmd.t_state);
 		return -1;
 	}
 
@@ -459,7 +459,7 @@ static int iscsit_task_reassign_complete(
 extern int iscsit_tmr_post_handler(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
 {
 	struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
-	struct se_tmr_req *se_tmr = SE_CMD(cmd)->se_tmr_req;
+	struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
 
 	if (tmr_req->task_reassign &&
 	   (se_tmr->response == ISCSI_TMF_RSP_COMPLETE))
drivers/target/iscsi/iscsi_target_util.c +1 -1
index 8568d0a..842df2e 100644
@@ -480,7 +480,7 @@ int iscsit_sequence_cmd(
 int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf)
 {
 	struct iscsi_conn *conn = cmd->conn;
-	struct se_cmd *se_cmd = SE_CMD(cmd);
+	struct se_cmd *se_cmd = &cmd->se_cmd;
 	struct iscsi_data *hdr = (struct iscsi_data *) buf;
 	u32 payload_length = ntoh24(hdr->dlength);
 
Signature · 1 line
1.7.1
#17 lore raw

PATCH 11/15 target: WRITE_SAME_16 and WRITE_SAME_32 should be DATA_SG_IO cdbs

In reply to Andy Grover

The definition of what's a data and what's a control CDB is not totally clear, but both of these set t_task_lba, so I'm inclined to call them data CDBs.

---
 drivers/target/target_core_transport.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/target/target_core_transport.c +2 -2
index 3dec696..fff099a 100644
@@ -3078,7 +3078,7 @@ static int transport_generic_cmd_sequencer(
 				size = dev->se_sub_dev->se_dev_attrib.block_size;
 
 			cmd->t_task_lba = get_unaligned_be64(&cdb[12]);
-			cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
+			cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
 
 			/*
 			 * Skip the remaining assignments for TCM/PSCSI passthrough
@@ -3381,7 +3381,7 @@ static int transport_generic_cmd_sequencer(
 				goto out_invalid_cdb_field;
 			}
 		}
-		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
+		cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
 		break;
 	case ALLOW_MEDIUM_REMOVAL:
 	case GPCMD_CLOSE_TRACK:
Signature · 1 line
1.7.1
#18 lore raw

Re: [PATCH 11/15] target: WRITE_SAME_16 and WRITE_SAME_32 should be DATA_SG_IO cdbs

Quoted 3 lines · Andy Grover

The definition of what's a data and what's a control CDB is not totally clear, but both of these set t_task_lba, so I'm inclined to call them data CDBs.

Currently DATA cdbs are those that get passes through to the backend (except for pscsi which gets all of them). As the backends can't handle WRITE_SAME this patch is incorrect.

I have a nice prototype to kill that whole DATA vs CONTROL flag thing, which will be much nicer after your series. Once the guts of your patches hit the tree I'll resubmit them.

#19 lore raw

Re: [PATCH 11/15] target: WRITE_SAME_16 and WRITE_SAME_32 should be DATA_SG_IO cdbs

Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Andy Grover

The definition of what's a data and what's a control CDB is not totally clear, but both of these set t_task_lba, so I'm inclined to call them data CDBs.

Currently DATA cdbs are those that get passes through to the backend (except for pscsi which gets all of them). As the backends can't handle WRITE_SAME this patch is incorrect.

Ah yes that makes sense, I'll delete this patch.

Quoted 3 lines

I have a nice prototype to kill that whole DATA vs CONTROL flag thing, which will be much nicer after your series. Once the guts of your patches hit the tree I'll resubmit them.

Sounds really good. I was pondering if that was possible.

Thanks -- Regards -- Andy

#20 lore raw

PATCH 12/15 target: Set WSNZ=1 in block limits VPD. Abort if WRITE_SAME sectors = 0

In reply to Andy Grover

According to sbc3r27, WRITE SAME with sectors=0 either writes to the end of the lun, or returns an error, depending on if WSNZ was set to 0 or 1 in the block limits VPD (0xB0). This patch sets that bit, and returns the error. Previously we used the block size, I don't know why, but it seems wrong.

---
 drivers/target/target_core_cdb.c       |    3 +++
 drivers/target/target_core_transport.c |   17 +++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/target/target_core_cdb.c +3 -0
index 9511a9e..f0779f1 100644
@@ -520,6 +520,9 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
 	buf[1] = 0xb0;
 	buf[3] = have_tp ? 0x3c : 0x10;
 
+	/* Set WSNZ to 1 */
+	buf[4] = 0x01;
+
 	/*
 	 * Set OPTIMAL TRANSFER LENGTH GRANULARITY
 	 */
drivers/target/target_core_transport.c +11 -6
index fff099a..c647e1f 100644
@@ -3072,10 +3072,13 @@ static int transport_generic_cmd_sequencer(
 			if (sector_ret)
 				goto out_unsupported_cdb;
 			
-			if (sectors != 0)
+			if (sectors)
 				size = transport_get_size(sectors, cdb, cmd);
-			else
-				size = dev->se_sub_dev->se_dev_attrib.block_size;
+			else {
+				pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not"
+				       " supported\n");
+				goto out_invalid_cdb_field;
+			}
 
 			cmd->t_task_lba = get_unaligned_be64(&cdb[12]);
 			cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB;
@@ -3349,10 +3352,12 @@ static int transport_generic_cmd_sequencer(
 		if (sector_ret)
 			goto out_unsupported_cdb;
 
-		if (sectors != 0)
+		if (sectors)
 			size = transport_get_size(sectors, cdb, cmd);
-		else
-			size = dev->se_sub_dev->se_dev_attrib.block_size;
+		else {
+			pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not supported\n");
+			goto out_invalid_cdb_field;
+		}
 
 		cmd->t_task_lba = get_unaligned_be16(&cdb[2]);
 		passthrough = (dev->transport->transport_type ==
Signature · 1 line
1.7.1
#21 lore raw

PATCH 13/15 target: Enforce 1 page max for control cdb buffer sizes

In reply to Andy Grover

Due to all cdbs' data buffers being referenced by scatterlists, buffers of more than a page are not contiguous. Instead of handling this in all control command handlers, we may be able to get away with just limiting control cdb data buffers to one page. The only control CDBs we handle that have potentially large data buffers are REPORT LUNS and UNMAP, so if we didn't want to live with this limitation, they would need to be modified to walk the pages in the data buffer's sgl.

---
 drivers/target/target_core_transport.c |    5 +++++
 include/target/target_core_base.h      |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)
drivers/target/target_core_transport.c +5 -0
index c647e1f..a6b7a46 100644
@@ -3459,6 +3459,11 @@ static int transport_generic_cmd_sequencer(
 		cmd->data_length = size;
 	}
 
+	/* Let's limit control cdbs to a page, for simplicity's sake. */
+	if ((cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB)
+	    && size > PAGE_SIZE)
+		goto out_invalid_cdb_field;
+
 	transport_set_supported_SAM_opcode(cmd);
 	return ret;
 
include/target/target_core_base.h +1 -0
index 2c5a748..32a1a48 100644
@@ -15,6 +15,7 @@
 /* Used by transport_generic_allocate_iovecs() */
 #define TRANSPORT_IOV_DATA_BUFFER		5
 /* Maximum Number of LUNs per Target Portal Group */
+/* Don't raise above 511 or REPORT_LUNS needs to handle >1 page */
 #define TRANSPORT_MAX_LUNS_PER_TPG		256
 /*
  * By default we use 32-byte CDBs in TCM Core and subsystem plugin code.
Signature · 1 line
1.7.1
#22 lore raw

Re: [PATCH 13/15] target: Enforce 1 page max for control cdb buffer sizes

Quoted 7 lines · Andy Grover

Due to all cdbs' data buffers being referenced by scatterlists, buffers of more than a page are not contiguous. Instead of handling this in all control command handlers, we may be able to get away with just limiting control cdb data buffers to one page. The only control CDBs we handle that have potentially large data buffers are REPORT LUNS and UNMAP, so if we didn't want to live with this limitation, they would need to be modified to walk the pages in the data buffer's sgl.

I think this should be moved earlier in the series, that is before making all control CDBs use SG lists.

#23 lore raw

PATCH 14/15 target: Remove direct ramdisk code

In reply to Andy Grover

Instead of converting rd_dr to be se_mem-free, maybe we should just remove it. Do we really need *two* private ramdisk implementations, especially when the kernel already has its own ramdisk code, that we could access via the iblock backstore?

This also lets us remove hooks like do_se_mem_map, that are in the common path but only implemented by rd_dr.

---
 drivers/target/target_core_rd.c |  316 ---------------------------------------
 1 files changed, 0 insertions(+), 316 deletions(-)
drivers/target/target_core_rd.c +0 -316
index f507c99..d9be7b4 100644
@@ -44,7 +44,6 @@
 
 #include "target_core_rd.h"
 
-//static struct se_subsystem_api rd_dr_template;
 static struct se_subsystem_api rd_mcp_template;
 
 /*	rd_attach_hba(): (Part of se_subsystem_api_t template)
@@ -223,13 +222,6 @@ static void *rd_allocate_virtdevice(
 	return rd_dev;
 }
 
-#if 0
-static void *rd_DIRECT_allocate_virtdevice(struct se_hba *hba, const char *name)
-{
-	return rd_allocate_virtdevice(hba, name, 1);
-}
-#endif
-
 static void *rd_MEMCPY_allocate_virtdevice(struct se_hba *hba, const char *name)
 {
 	return rd_allocate_virtdevice(hba, name, 0);
@@ -291,16 +283,6 @@ fail:
 	return ERR_PTR(ret);
 }
 
-#if 0
-static struct se_device *rd_DIRECT_create_virtdevice(
-	struct se_hba *hba,
-	struct se_subsystem_dev *se_dev,
-	void *p)
-{
-	return rd_create_virtdevice(hba, se_dev, p, 1);
-}
-#endif
-
 static struct se_device *rd_MEMCPY_create_virtdevice(
 	struct se_hba *hba,
 	struct se_subsystem_dev *se_dev,
@@ -635,269 +617,6 @@ static int rd_MEMCPY_do_task(struct se_task *task)
 	return PYX_TRANSPORT_SENT_TO_TRANSPORT;
 }
 
-#if 0
-/*	rd_DIRECT_with_offset():
- *
- *
- */
-static int rd_DIRECT_with_offset(
-	struct se_task *task,
-	struct list_head *se_mem_list,
-	u32 *se_mem_cnt,
-	u32 *task_offset)
-{
-	struct rd_request *req = RD_REQ(task);
-	struct rd_dev *dev = req->rd_dev;
-	struct rd_dev_sg_table *table;
-	struct se_mem *se_mem;
-	struct scatterlist *sg_s;
-	u32 j = 0, set_offset = 1;
-	u32 get_next_table = 0, offset_length, table_sg_end;
-
-	table = rd_get_sg_table(dev, req->rd_page);
-	if (!(table))
-		return -EINVAL;
-
-	table_sg_end = (table->page_end_offset - req->rd_page);
-	sg_s = &table->sg_table[req->rd_page - table->page_start_offset];
-
-	pr_debug("%s DIRECT LBA: %llu, Size: %u Page: %u, Offset: %u\n",
-		(task->task_data_direction == DMA_TO_DEVICE) ?
-			"Write" : "Read",
-		task->task_lba, req->rd_size, req->rd_page, req->rd_offset);
-
-	while (req->rd_size) {
-		se_mem = kmem_cache_zalloc(se_mem_cache, GFP_KERNEL);
-		if (!(se_mem)) {
-			pr_err("Unable to allocate struct se_mem\n");
-			return -ENOMEM;
-		}
-		INIT_LIST_HEAD(&se_mem->se_list);
-
-		if (set_offset) {
-			offset_length = sg_s[j].length - req->rd_offset;
-			if (offset_length > req->rd_size)
-				offset_length = req->rd_size;
-
-			se_mem->se_page = sg_page(&sg_s[j++]);
-			se_mem->se_off = req->rd_offset;
-			se_mem->se_len = offset_length;
-
-			set_offset = 0;
-			get_next_table = (j > table_sg_end);
-			goto check_eot;
-		}
-
-		offset_length = (req->rd_size < req->rd_offset) ?
-			req->rd_size : req->rd_offset;
-
-		se_mem->se_page = sg_page(&sg_s[j]);
-		se_mem->se_len = offset_length;
-
-		set_offset = 1;
-
-check_eot:
-		pr_debug("page: %u, size: %u, offset_length: %u, j: %u"
-			" se_mem: %p, se_page: %p se_off: %u se_len: %u\n",
-			req->rd_page, req->rd_size, offset_length, j, se_mem,
-			se_mem->se_page, se_mem->se_off, se_mem->se_len);
-
-		list_add_tail(&se_mem->se_list, se_mem_list);
-		(*se_mem_cnt)++;
-
-		req->rd_size -= offset_length;
-		if (!(req->rd_size))
-			goto out;
-
-		if (!set_offset && !get_next_table)
-			continue;
-
-		if (++req->rd_page <= table->page_end_offset) {
-			pr_debug("page: %u in same page table\n",
-					req->rd_page);
-			continue;
-		}
-
-		pr_debug("getting new page table for page: %u\n",
-				req->rd_page);
-
-		table = rd_get_sg_table(dev, req->rd_page);
-		if (!(table))
-			return -EINVAL;
-
-		sg_s = &table->sg_table[j = 0];
-	}
-
-out:
-	task->task_se_cmd->t_tasks_se_num += *se_mem_cnt;
-
-	pr_debug("RD_DR - Allocated %u struct se_mem segments for task\n",
-			*se_mem_cnt);
-
-	return 0;
-}
-
-/*	rd_DIRECT_without_offset():
- *
- *
- */
-static int rd_DIRECT_without_offset(
-	struct se_task *task,
-	struct list_head *se_mem_list,
-	u32 *se_mem_cnt,
-	u32 *task_offset)
-{
-	struct rd_request *req = RD_REQ(task);
-	struct rd_dev *dev = req->rd_dev;
-	struct rd_dev_sg_table *table;
-	struct se_mem *se_mem;
-	struct scatterlist *sg_s;
-	u32 length, j = 0;
-
-	table = rd_get_sg_table(dev, req->rd_page);
-	if (!(table))
-		return -EINVAL;
-
-	sg_s = &table->sg_table[req->rd_page - table->page_start_offset];
-
-	pr_debug("%s DIRECT LBA: %llu, Size: %u, Page: %u\n",
-		(task->task_data_direction == DMA_TO_DEVICE) ?
-			"Write" : "Read",
-		task->task_lba, req->rd_size, req->rd_page);
-
-	while (req->rd_size) {
-		se_mem = kmem_cache_zalloc(se_mem_cache, GFP_KERNEL);
-		if (!(se_mem)) {
-			pr_err("Unable to allocate struct se_mem\n");
-			return -ENOMEM;
-		}
-		INIT_LIST_HEAD(&se_mem->se_list);
-
-		length = (req->rd_size < sg_s[j].length) ?
-			req->rd_size : sg_s[j].length;
-
-		se_mem->se_page = sg_page(&sg_s[j++]);
-		se_mem->se_len = length;
-
-		pr_debug("page: %u, size: %u, j: %u se_mem: %p,"
-			" se_page: %p se_off: %u se_len: %u\n", req->rd_page,
-			req->rd_size, j, se_mem, se_mem->se_page,
-			se_mem->se_off, se_mem->se_len);
-
-		list_add_tail(&se_mem->se_list, se_mem_list);
-		(*se_mem_cnt)++;
-
-		req->rd_size -= length;
-		if (!(req->rd_size))
-			goto out;
-
-		if (++req->rd_page <= table->page_end_offset) {
-			printk("page: %u in same page table\n",
-				req->rd_page);
-			continue;
-		}
-
-		pr_debug("getting new page table for page: %u\n",
-				req->rd_page);
-
-		table = rd_get_sg_table(dev, req->rd_page);
-		if (!(table))
-			return -EINVAL;
-
-		sg_s = &table->sg_table[j = 0];
-	}
-
-out:
-	task->task_se_cmd->t_tasks_se_num += *se_mem_cnt;
-
-	pr_debug("RD_DR - Allocated %u struct se_mem segments for task\n",
-			*se_mem_cnt);
-
-	return 0;
-}
-
-/*	rd_DIRECT_do_se_mem_map():
- *
- *
- */
-static int rd_DIRECT_do_se_mem_map(
-	struct se_task *task,
-	struct list_head *se_mem_list,
-	void *in_mem,
-	struct se_mem *in_se_mem,
-	struct se_mem **out_se_mem,
-	u32 *se_mem_cnt,
-	u32 *task_offset_in)
-{
-	struct se_cmd *cmd = task->task_se_cmd;
-	struct rd_request *req = RD_REQ(task);
-	u32 task_offset = *task_offset_in;
-	unsigned long long lba;
-	int ret;
-	int block_size = task->se_dev->se_sub_dev->se_dev_attrib.block_size;
-
-	lba = task->task_lba;
-	req->rd_page = ((task->task_lba * block_size) /	PAGE_SIZE);
-	req->rd_offset = (do_div(lba, (PAGE_SIZE / block_size))) * block_size;
-	req->rd_size = task->task_size;
-
-	if (req->rd_offset)
-		ret = rd_DIRECT_with_offset(task, se_mem_list, se_mem_cnt,
-				task_offset_in);
-	else
-		ret = rd_DIRECT_without_offset(task, se_mem_list, se_mem_cnt,
-				task_offset_in);
-
-	if (ret < 0)
-		return ret;
-
-	if (cmd->se_tfo->task_sg_chaining == 0)
-		return 0;
-	/*
-	 * Currently prevent writers from multiple HW fabrics doing
-	 * pci_map_sg() to RD_DR's internal scatterlist memory.
-	 */
-	if (cmd->data_direction == DMA_TO_DEVICE) {
-		pr_err("DMA_TO_DEVICE not supported for"
-				" RAMDISK_DR with task_sg_chaining=1\n");
-		return -ENOSYS;
-	}
-	/*
-	 * Special case for if task_sg_chaining is enabled, then
-	 * we setup struct se_task->task_sg[], as it will be used by
-	 * transport_do_task_sg_chain() for creating chainged SGLs
-	 * across multiple struct se_task->task_sg[].
-	 */
-	ret = transport_init_task_sg(task,
-			list_first_entry(&cmd->t_mem_list,
-				   struct se_mem, se_list),
-			task_offset);
-	if (ret <= 0)
-		return ret;
-
-	return transport_map_mem_to_sg(task, se_mem_list, task->task_sg,
-			list_first_entry(&cmd->t_mem_list,
-				   struct se_mem, se_list),
-			out_se_mem, se_mem_cnt, task_offset_in);
-}
-
-/*	rd_DIRECT_do_task(): (Part of se_subsystem_api_t template)
- *
- *
- */
-static int rd_DIRECT_do_task(struct se_task *task)
-{
-	/*
-	 * At this point the locally allocated RD tables have been mapped
-	 * to struct se_mem elements in rd_DIRECT_do_se_mem_map().
-	 */
-	task->task_scsi_status = GOOD;
-	transport_complete_task(task, 1);
-
-	return PYX_TRANSPORT_SENT_TO_TRANSPORT;
-}
-#endif
-
 /*	rd_free_task(): (Part of se_subsystem_api_t template)
  *
  *
@@ -1012,29 +731,6 @@ static sector_t rd_get_blocks(struct se_device *dev)
 	return blocks_long;
 }
 
-#if 0
-static struct se_subsystem_api rd_dr_template = {
-	.name			= "rd_dr",
-	.transport_type		= TRANSPORT_PLUGIN_VHBA_VDEV,
-	.attach_hba		= rd_attach_hba,
-	.detach_hba		= rd_detach_hba,
-	.allocate_virtdevice	= rd_DIRECT_allocate_virtdevice,
-	.create_virtdevice	= rd_DIRECT_create_virtdevice,
-	.free_device		= rd_free_device,
-	.alloc_task		= rd_alloc_task,
-	.do_task		= rd_DIRECT_do_task,
-	.free_task		= rd_free_task,
-	.check_configfs_dev_params = rd_check_configfs_dev_params,
-	.set_configfs_dev_params = rd_set_configfs_dev_params,
-	.show_configfs_dev_params = rd_show_configfs_dev_params,
-	.get_cdb		= rd_get_cdb,
-	.get_device_rev		= rd_get_device_rev,
-	.get_device_type	= rd_get_device_type,
-	.get_blocks		= rd_get_blocks,
-	.do_se_mem_map		= rd_DIRECT_do_se_mem_map,
-};
-#endif
-
 static struct se_subsystem_api rd_mcp_template = {
 	.name			= "rd_mcp",
 	.transport_type		= TRANSPORT_PLUGIN_VHBA_VDEV,
@@ -1059,17 +755,8 @@ int __init rd_module_init(void)
 {
 	int ret;
 
-#if 0
-	ret = transport_subsystem_register(&rd_dr_template);
-	if (ret < 0)
-		return ret;
-#endif
-
 	ret = transport_subsystem_register(&rd_mcp_template);
 	if (ret < 0) {
-#if 0
-		transport_subsystem_release(&rd_dr_template);
-#endif
 		return ret;
 	}
 
@@ -1078,8 +765,5 @@ int __init rd_module_init(void)
 
 void rd_module_exit(void)
 {
-#if 0
-	transport_subsystem_release(&rd_dr_template);
-#endif
 	transport_subsystem_release(&rd_mcp_template);
 }
Signature · 1 line
1.7.1
#24 lore raw

Re: [PATCH 14/15] target: Remove direct ramdisk code

Quoted 7 lines · Andy Grover

Instead of converting rd_dr to be se_mem-free, maybe we should just remove it. Do we really need *two* private ramdisk implementations, especially when the kernel already has its own ramdisk code, that we could access via the iblock backstore?

This also lets us remove hooks like do_se_mem_map, that are in the common path but only implemented by rd_dr.

I always hated the hooks the direct ramdisk code had to the core code, so I'm absolutely in favour of it. The indirect ramdisk currently is used for things like the virtual lun0 handling, which requires it to be just there instead of setting up a block device. I think keeping the simple internal ramdisk around for that and benchmarking is fine.

#25 lore raw

PATCH 15/15 target: Remove transport do_se_mem_map callback

In reply to Andy Grover

This callback was only used by the direct ramdisk driver, which is no longer present.

---
 drivers/target/target_core_transport.c |    8 --------
 include/target/target_core_transport.h |    5 -----
 2 files changed, 0 insertions(+), 13 deletions(-)
drivers/target/target_core_transport.c +0 -8
index a6b7a46..bc440d6 100644
@@ -3737,8 +3737,6 @@ static inline void transport_free_pages(struct se_cmd *cmd)
 
 	if (cmd->se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC)
 		free_page = 0;
-	if (cmd->se_dev->transport->do_se_mem_map)
-		free_page = 0;
 
 	for_each_sg(cmd->t_data_sg, sg, cmd->t_data_nents, count) {
 		/*
@@ -3973,12 +3971,6 @@ transport_generic_get_mem(struct se_cmd *cmd)
 	struct page *page;
 	int i = 0;
 
-	/*
-	 * If the device uses memory mapping this is enough.
-	 */
-	if (cmd->se_dev->transport->do_se_mem_map)
-		return 0;
-
 	if (!length)
 		return 0;
 
include/target/target_core_transport.h +0 -5
index 7d10fb5..b9f7766 100644
@@ -340,11 +340,6 @@ struct se_subsystem_api {
 	 */
 	sector_t (*get_blocks)(struct se_device *);
 	/*
-	 * do_se_mem_map():
-	 */
-	int (*do_se_mem_map)(struct se_task *, struct list_head *, void *,
-				struct se_mem *, struct se_mem **, u32 *, u32 *);
-	/*
 	 * get_sense_buffer():
 	 */
 	unsigned char *(*get_sense_buffer)(struct se_task *);
Signature · 1 line
1.7.1