Skip to contentSkip to conversation

scsi: remove last references to scsi_cmnd.tag

PATCH In review Hannes Reinecke 4 participants 10 messages Aug 19, 2021 – Sep 15, 2021

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

cover scsi: remove last references to scsi_cmnd.tag

Hi all,

with commit 4c7b6ea336c1 ("scsi: core: Remove scsi_cmnd.tag") drivers cannot reference the SCSI command tag anymore.
Arguably these drivers would have stopped working since 2010 with the switch to block layer tags in SCSI anyway, so chances are no-one had been using tagging in these drivers.

This patchset fixes up these usage; for fas216 we're just switching to use the appropriate wrapper.
For acornscsi the tagged queue handling is removed altogether as it was broken in the first place, and no-one since the switch to git could be bothered to fix it.
And the patchset has the nice side-effect that we can remove the scsi_device.current_tag field.

As usual, comments and reviews are welcome.

Hannes Reinecke (4):
scsi: Introduct scsi_cmd_to_tag()
fas216: kill scmd->tag
acornscsi: remove tagged queuing vestiges
scsi: remove 'current_tag'

 drivers/scsi/arm/Kconfig     |  11 ----
 drivers/scsi/arm/acornscsi.c | 103 ++++++++---------------------------
 drivers/scsi/arm/fas216.c    |  31 +++--------
 drivers/scsi/arm/queue.c     |   2 +-
 include/scsi/scsi_cmnd.h     |   7 +++
 include/scsi/scsi_device.h   |   1 -
 6 files changed, 38 insertions(+), 117 deletions(-)
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/4 scsi: Introduct scsi_cmd_to_tag()

Introduce a wrapper to get the tag from a SCSI command.

---
 include/scsi/scsi_cmnd.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/scsi/scsi_cmnd.h +7 -0
index eaf04c9a1dfc..f3cc3aa0eb04 100644
@@ -165,6 +165,13 @@ static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
 	return *(struct scsi_driver **)rq->rq_disk->private_data;
 }
 
+static inline u32 scsi_cmd_to_tag(struct scsi_cmnd *cmd)
+{
+	struct request *rq = scsi_cmd_to_rq(cmd);
+
+	return rq->tag;
+}
+
 extern void scsi_finish_command(struct scsi_cmnd *cmd);
 
 extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
Signature · 1 line
2.29.2
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] scsi: Introduct scsi_cmd_to_tag()

Quoted 12 lines · Hannes Reinecke

Introduce a wrapper to get the tag from a SCSI command.

---
  include/scsi/scsi_cmnd.h | 7 +++++++
  1 file changed, 7 insertions(+)
include/scsi/scsi_cmnd.h +0 -0
index eaf04c9a1dfc..f3cc3aa0eb04 100644

include/scsi/scsi_cmnd.h static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd) · line 168

Quoted 4 lines
include/scsi/scsi_cmnd.h +1 -0
@@ -165,6 +165,13 @@ static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
  	return *(struct scsi_driver **)rq->rq_disk->private_data;
  }
 
+static inline u32 scsi_cmd_to_tag(struct scsi_cmnd *cmd)

I'd call it scsi_cmd_to_rq_tag(), especially since scsi_cmnd.tag is hanging for dear life and I assume you want this helper regardless of what happens there, but it's just a name...

include/scsi/scsi_cmnd.h static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd) · line 177

Quoted 9 lines
include/scsi/scsi_cmnd.h +5 -0
+{
+	struct request *rq = scsi_cmd_to_rq(cmd);
+
+	return rq->tag; > +}
+
  extern void scsi_finish_command(struct scsi_cmnd *cmd);
 
  extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
#3 lore raw

Re: [PATCH 1/4] scsi: Introduct scsi_cmd_to_tag()

In reply to Hannes Reinecke

include/scsi/scsi_cmnd.h static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd) · line 173

Quoted 6 lines · Hannes Reinecke
include/scsi/scsi_cmnd.h +6 -0
+static inline u32 scsi_cmd_to_tag(struct scsi_cmnd *cmd)
+{
+	struct request *rq = scsi_cmd_to_rq(cmd);
+
+	return rq->tag;
+}

Do we really need this function? If so, please change "Introduct" in the subject into "Introduce". Additionally, how about renaming this function into scsi_cmd_tag()? How about changing the function body into "return scsi_cmd_to_rq(cmd)->tag"?

Thanks,

Bart.

#4 lore raw

PATCH 2/4 fas216: kill scmd->tag

In reply to Hannes Reinecke

The driver is attempting to allocated a tag internally, which is is no-go with blk-mq. Switch the driver to use the request tag and kill usage of scmd->tag and scmd->device->current_tag.

---
 drivers/scsi/arm/fas216.c | 31 ++++++++-----------------------
 1 file changed, 8 insertions(+), 23 deletions(-)
drivers/scsi/arm/fas216.c +8 -23
index 6baa9b36367d..1752a29fdb3c 100644
@@ -77,7 +77,6 @@
  *  I was thinking that this was a good chip until I found this restriction ;(
  */
 #define SCSI2_SYNC
-#undef  SCSI2_TAG
 
 #undef DEBUG_CONNECT
 #undef DEBUG_MESSAGES
@@ -990,7 +989,7 @@ fas216_reselected_intr(FAS216_Info *info)
 		info->scsi.disconnectable = 0;
 		if (info->SCpnt->device->id  == target &&
 		    info->SCpnt->device->lun == lun &&
-		    info->SCpnt->tag         == tag) {
+		    scsi_cmd_to_tag(info->SCpnt) == tag) {
 			fas216_log(info, LOG_CONNECT, "reconnected previously executing command");
 		} else {
 			queue_add_cmd_tail(&info->queues.disconnected, info->SCpnt);
@@ -1790,8 +1789,9 @@ static void fas216_start_command(FAS216_Info *info, struct scsi_cmnd *SCpnt)
 	/*
 	 * add tag message if required
 	 */
-	if (SCpnt->tag)
-		msgqueue_addmsg(&info->scsi.msgs, 2, SIMPLE_QUEUE_TAG, SCpnt->tag);
+	if (SCpnt->device->simple_tags)
+		msgqueue_addmsg(&info->scsi.msgs, 2, SIMPLE_QUEUE_TAG,
+				scsi_cmd_to_tag(SCpnt));
 
 	do {
 #ifdef SCSI2_SYNC
@@ -1814,20 +1814,8 @@ static void fas216_start_command(FAS216_Info *info, struct scsi_cmnd *SCpnt)
 
 static void fas216_allocate_tag(FAS216_Info *info, struct scsi_cmnd *SCpnt)
 {
-#ifdef SCSI2_TAG
-	/*
-	 * tagged queuing - allocate a new tag to this command
-	 */
-	if (SCpnt->device->simple_tags && SCpnt->cmnd[0] != REQUEST_SENSE &&
-	    SCpnt->cmnd[0] != INQUIRY) {
-	    SCpnt->device->current_tag += 1;
-		if (SCpnt->device->current_tag == 0)
-		    SCpnt->device->current_tag = 1;
-			SCpnt->tag = SCpnt->device->current_tag;
-	} else
-#endif
-		set_bit(SCpnt->device->id * 8 +
-			(u8)(SCpnt->device->lun & 0x7), info->busyluns);
+	set_bit(SCpnt->device->id * 8 +
+		(u8)(SCpnt->device->lun & 0x7), info->busyluns);
 
 	info->stats.removes += 1;
 	switch (SCpnt->cmnd[0]) {
@@ -2116,7 +2104,6 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result)
 	init_SCp(SCpnt);
 	SCpnt->SCp.Message = 0;
 	SCpnt->SCp.Status = 0;
-	SCpnt->tag = 0;
 	SCpnt->host_scribble = (void *)fas216_rq_sns_done;
 
 	/*
@@ -2222,7 +2209,6 @@ static int fas216_queue_command_lck(struct scsi_cmnd *SCpnt,
 	init_SCp(SCpnt);
 
 	info->stats.queues += 1;
-	SCpnt->tag = 0;
 
 	spin_lock(&info->host_lock);
 
@@ -3002,9 +2988,8 @@ void fas216_print_devices(FAS216_Info *info, struct seq_file *m)
 		dev = &info->device[scd->id];
 		seq_printf(m, "     %d/%llu   ", scd->id, scd->lun);
 		if (scd->tagged_supported)
-			seq_printf(m, "%3sabled(%3d) ",
-				     scd->simple_tags ? "en" : "dis",
-				     scd->current_tag);
+			seq_printf(m, "%3sabled ",
+				     scd->simple_tags ? "en" : "dis");
 		else
 			seq_puts(m, "unsupported   ");
 
Signature · 1 line
2.29.2
#5 lore raw

PATCH 3/4 acornscsi: remove tagged queuing vestiges

In reply to Hannes Reinecke

The acornscsi driver has a config option to enable tagged queuing, but this option gets disabled in the driver itself with the comment 'needs to be debugged'.
As this is a _really_ old driver I doubt anyone will be wanting to invest time here, so remove the tagged queue vestiges and make our live easier.

---
 drivers/scsi/arm/Kconfig     |  11 ----
 drivers/scsi/arm/acornscsi.c | 103 ++++++++---------------------------
 drivers/scsi/arm/queue.c     |   2 +-
 3 files changed, 23 insertions(+), 93 deletions(-)
drivers/scsi/arm/Kconfig +0 -11
index f34badc75196..9f64133f976a 100644
@@ -10,17 +10,6 @@ config SCSI_ACORNSCSI_3
 	  This enables support for the Acorn SCSI card (aka30). If you have an
 	  Acorn system with one of these, say Y. If unsure, say N.
 
-config SCSI_ACORNSCSI_TAGGED_QUEUE
-	bool "Support SCSI 2 Tagged queueing"
-	depends on SCSI_ACORNSCSI_3
-	help
-	  Say Y here to enable tagged queuing support on the Acorn SCSI card.
-
-	  This is a feature of SCSI-2 which improves performance: the host
-	  adapter can send several SCSI commands to a device's queue even if
-	  previous commands haven't finished yet. Some SCSI devices don't
-	  implement this properly, so the safe answer is N.
-
 config SCSI_ACORNSCSI_SYNC
 	bool "Support SCSI 2 Synchronous Transfers"
 	depends on SCSI_ACORNSCSI_3
drivers/scsi/arm/acornscsi.c +22 -81

257 lines not on this page · raw message

drivers/scsi/arm/queue.c +1 -1
index e5559f27669d..0d99db7df5d6 100644
@@ -214,7 +214,7 @@ struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target, int lun,
 	list_for_each(l, &queue->head) {
 		QE_t *q = list_entry(l, QE_t, list);
 		if (q->SCpnt->device->id == target && q->SCpnt->device->lun == lun &&
-		    q->SCpnt->tag == tag) {
+		    scsi_cmd_to_tag(q->SCpnt) == tag) {
 			SCpnt = __queue_remove(queue, l);
 			break;
 		}
Signature · 1 line
2.29.2
#6 lore raw

PATCH 4/4 scsi: remove 'current_tag'

In reply to Hannes Reinecke

The 'current_tag' field in struct scsi_device is unused now; remove it.

---
 include/scsi/scsi_device.h | 1 -
 1 file changed, 1 deletion(-)
include/scsi/scsi_device.h +0 -1
index 09a17f6e93a7..b97e142a7ca9 100644
@@ -146,7 +146,6 @@ struct scsi_device {
 	struct scsi_vpd __rcu *vpd_pg83;
 	struct scsi_vpd __rcu *vpd_pg80;
 	struct scsi_vpd __rcu *vpd_pg89;
-	unsigned char current_tag;	/* current tag */
 	struct scsi_target      *sdev_target;
 
 	blist_flags_t		sdev_bflags; /* black/white flags as also found in
Signature · 1 line
2.29.2
#7 lore raw
In reply to Hannes Reinecke

+ Russell

On 19/08/2021 09:40, Hannes Reinecke wrote:

The arm rpc_defconfig build is now broken on mainline.

I suggest resending this series, please.

Thanks

Quoted 32 lines

Hi all,

with commit 4c7b6ea336c1 ("scsi: core: Remove scsi_cmnd.tag") drivers cannot reference the SCSI command tag anymore.
Arguably these drivers would have stopped working since 2010 with the switch to block layer tags in SCSI anyway, so chances are no-one had been using tagging in these drivers.

This patchset fixes up these usage; for fas216 we're just switching to use the appropriate wrapper.
For acornscsi the tagged queue handling is removed altogether as it was broken in the first place, and no-one since the switch to git could be bothered to fix it.
And the patchset has the nice side-effect that we can remove the scsi_device.current_tag field.

As usual, comments and reviews are welcome.

Hannes Reinecke (4):
scsi: Introduct scsi_cmd_to_tag()
fas216: kill scmd->tag
acornscsi: remove tagged queuing vestiges
scsi: remove 'current_tag'

  drivers/scsi/arm/Kconfig     |  11 ----
  drivers/scsi/arm/acornscsi.c | 103 ++++++++---------------------------
  drivers/scsi/arm/fas216.c    |  31 +++--------
  drivers/scsi/arm/queue.c     |   2 +-
  include/scsi/scsi_cmnd.h     |   7 +++
  include/scsi/scsi_device.h   |   1 -
  6 files changed, 38 insertions(+), 117 deletions(-)
#8 lore raw

John,

Quoted 3 lines

The arm rpc_defconfig build is now broken on mainline.

I suggest resending this series, please.

Yes, please!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#9 lore raw
Quoted 4 lines · Martin K. Petersen
Quoted 3 lines

The arm rpc_defconfig build is now broken on mainline.

I suggest resending this series, please.

Yes, please!

I'm going to just do that now.