Skip to contentSkip to conversation

sparse fixes for nvme/fc

PATCH New Christoph Hellwig 3 participants 20 messages Apr 21, 2017 – Apr 23, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Christoph Hellwig

author maintainer
#0 lore raw

[sorry for the double post, the first series got the linux-nvme
address wrong]

This fixes a couple ?parse warnings in the FC code, missing statics, missing endianess annotations and incorrect byte swaps.

author maintainer
#1 lore raw

PATCH 1/7 nvme/fc: mark two symbols static

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/fc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/fc.c +2 -2
index 596b3a453b54..63819b12c1da 100644
@@ -1183,7 +1183,7 @@ nvme_fc_exit_aen_ops(struct nvme_fc_ctrl *ctrl)
 	}
 }
 
-void
+static void
 nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
 {
 	struct nvme_fc_fcp_op *op = fcp_req_to_fcp_op(req);
@@ -1671,7 +1671,7 @@ __nvme_fc_abort_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_fcp_op *op)
 	return 0;
 }
 
-enum blk_eh_timer_return
+static enum blk_eh_timer_return
 nvme_fc_timeout(struct request *rq, bool reserved)
 {
 	struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(rq);
Signature · 1 line
2.11.0
#2 lore raw

PATCH 1/7 nvme/fc: mark two symbols static

Quoted 4 lines · Christoph Hellwig

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>

---

Reviewed-by Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
author maintainer
#4 lore raw

PATCH 2/7 nvme/fc: don't byte swap command_id

In reply to Christoph Hellwig

The command ID is a field for host only use and thus always is in native endian.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/fc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/fc.c +2 -2
index 63819b12c1da..68887818801e 100644
@@ -1274,7 +1274,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
 			     be32_to_cpu(op->rsp_iu.xfrd_len) !=
 					freq->transferred_length ||
 			     op->rsp_iu.status_code ||
-			     op->rqno != le16_to_cpu(cqe->command_id))) {
+			     op->rqno != cqe->command_id)) {
 			status = cpu_to_le16(NVME_SC_FC_TRANSPORT_ERROR << 1);
 			goto done;
 		}
@@ -1830,7 +1830,7 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
 	sqe->rw.dptr.sgl.addr = 0;
 
 	/* odd that we set the command_id - should come from nvme-fabrics */
-	WARN_ON_ONCE(sqe->common.command_id != cpu_to_le16(op->rqno));
+	WARN_ON_ONCE(sqe->common.command_id != op->rqno);
 
 	if (op->rq) {				/* skipped on aens */
 		ret = nvme_fc_map_data(ctrl, op->rq, op);
Signature · 1 line
2.11.0
#5 lore raw

PATCH 2/7 nvme/fc: don't byte swap command_id

Quoted 7 lines · Christoph Hellwig

The command ID is a field for host only use and thus always is in native endian.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>

---

Reviewed-by Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#6 lore raw

PATCH 2/7 nvme/fc: don't byte swap command_id

In reply to Christoph Hellwig
Quoted 15 lines · Christoph Hellwig

The command ID is a field for host only use and thus always is in native endian.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
  drivers/nvme/host/fc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/fc.c +0 -0
index 63819b12c1da..68887818801e 100644

drivers/nvme/host/fc.c nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) · line 1280

Quoted 8 lines
drivers/nvme/host/fc.c +1 -1
@@ -1274,7 +1274,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
  			     be32_to_cpu(op->rsp_iu.xfrd_len) !=
  					freq->transferred_length ||
  			     op->rsp_iu.status_code ||
-			     op->rqno != le16_to_cpu(cqe->command_id))) {
+			     op->rqno != cqe->command_id)) {
  			status = cpu_to_le16(NVME_SC_FC_TRANSPORT_ERROR << 1);
  			goto done;
  		}

This check was replaced in the following patch, obsoleting this change:
http://lists.infradead.org/pipermail/linux-nvme/2017-April/009259.html

drivers/nvme/host/fc.c nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, · line 1836

Quoted 9 lines
drivers/nvme/host/fc.c +1 -1
@@ -1830,7 +1830,7 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
  	sqe->rw.dptr.sgl.addr = 0;
 
  	/* odd that we set the command_id - should come from nvme-fabrics */
-	WARN_ON_ONCE(sqe->common.command_id != cpu_to_le16(op->rqno));
+	WARN_ON_ONCE(sqe->common.command_id != op->rqno);
 
  	if (op->rq) {				/* skipped on aens */
  		ret = nvme_fc_map_data(ctrl, op->rq, op);

This line was removed by the following patch, obsoleting this change:
http://lists.infradead.org/pipermail/linux-nvme/2017-April/009260.html

-- james

author maintainer
#7 lore raw

PATCH 2/7 nvme/fc: don't byte swap command_id

Quoted 11 lines · James Smart
Quoted 10 lines · Christoph Hellwig

The command ID is a field for host only use and thus always is in native endian.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
  drivers/nvme/host/fc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines

drivers/nvme/host/fc.c nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) · line 1280

Quoted 13 lines
drivers/nvme/host/fc.c +1 -1
index 63819b12c1da..68887818801e 100644
@@ -1274,7 +1274,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
  			     be32_to_cpu(op->rsp_iu.xfrd_len) !=
  					freq->transferred_length ||
  			     op->rsp_iu.status_code ||
-			     op->rqno != le16_to_cpu(cqe->command_id))) {
+			     op->rqno != cqe->command_id)) {
  			status = cpu_to_le16(NVME_SC_FC_TRANSPORT_ERROR << 1);
  			goto done;
  		}

This check was replaced in the following patch, obsoleting this change:
http://lists.infradead.org/pipermail/linux-nvme/2017-April/009259.html

Can you please resend this and the two patches related to it? They had non-trivial conflicts with the error status rework.

#8 lore raw

PATCH 2/7 nvme/fc: don't byte swap command_id

Quoted 27 lines · Christoph Hellwig
Quoted 11 lines · James Smart
Quoted 10 lines · Christoph Hellwig

The command ID is a field for host only use and thus always is in native endian.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
   drivers/nvme/host/fc.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines

drivers/nvme/host/fc.c nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) · line 1280

Quoted 13 lines
drivers/nvme/host/fc.c +1 -1
index 63819b12c1da..68887818801e 100644
@@ -1274,7 +1274,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
   			     be32_to_cpu(op->rsp_iu.xfrd_len) !=
   					freq->transferred_length ||
   			     op->rsp_iu.status_code ||
-			     op->rqno != le16_to_cpu(cqe->command_id))) {
+			     op->rqno != cqe->command_id)) {
   			status = cpu_to_le16(NVME_SC_FC_TRANSPORT_ERROR << 1);
   			goto done;
   		}

This check was replaced in the following patch, obsoleting this change:
http://lists.infradead.org/pipermail/linux-nvme/2017-April/009259.html

Quoted 2 lines

Can you please resend this and the two patches related to it? They had non-trivial conflicts with the error status rework.

Resent: As your patch had been merged, the new patches layer on top.

-- james

author maintainer
#9 lore raw

PATCH 3/7 nvmet/fc: mark nvmet_fc_handle_fcp_rqst static

In reply to Christoph Hellwig

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/target/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fc.c +1 -1
index 074bd3743b5f..3626dd8cc8a1 100644
@@ -2055,7 +2055,7 @@ nvmet_fc_fcp_nvme_cmd_done(struct nvmet_req *nvme_req)
 /*
  * Actual processing routine for received FC-NVME LS Requests from the LLD
  */
-void
+static void
 nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,
 			struct nvmet_fc_fcp_iod *fod)
 {
Signature · 1 line
2.11.0
#10 lore raw

PATCH 3/7 nvmet/fc: mark nvmet_fc_handle_fcp_rqst static

Quoted 4 lines · Christoph Hellwig

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>

---

Reviewed-by Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
author maintainer
#11 lore raw

PATCH 4/7 nvmet/fc: fix endianess annoations for nvmet_fc_format_rsp_hdr

In reply to Christoph Hellwig

The passed in desc_len is a big endian value, so mark it as such.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/target/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fc.c +1 -1
index 3626dd8cc8a1..d504c52ac9cb 100644
@@ -1058,7 +1058,7 @@ EXPORT_SYMBOL_GPL(nvmet_fc_unregister_targetport);
 
 
 static void
-nvmet_fc_format_rsp_hdr(void *buf, u8 ls_cmd, u32 desc_len, u8 rqst_ls_cmd)
+nvmet_fc_format_rsp_hdr(void *buf, u8 ls_cmd, __be32 desc_len, u8 rqst_ls_cmd)
 {
 	struct fcnvme_ls_acc_hdr *acc = buf;
 
Signature · 1 line
2.11.0
#12 lore raw

PATCH 4/7 nvmet/fc: fix endianess annoations for nvmet_fc_format_rsp_hdr

Quoted 6 lines · Christoph Hellwig

The passed in desc_len is a big endian value, so mark it as such.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>

---

Reviewed-by Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
author maintainer
#13 lore raw

PATCH 5/7 nvmet/fc: mark the sqhd field as __le16

In reply to Christoph Hellwig

That's what it's used as.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/target/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fc.c +1 -1
index d504c52ac9cb..4392b514725b 100644
@@ -119,7 +119,7 @@ struct nvmet_fc_tgt_queue {
 	u16				qid;
 	u16				sqsize;
 	u16				ersp_ratio;
-	u16				sqhd;
+	__le16				sqhd;
 	int				cpu;
 	atomic_t			connected;
 	atomic_t			sqtail;
Signature · 1 line
2.11.0
#14 lore raw

PATCH 5/7 nvmet/fc: mark the sqhd field as __le16

Quoted 6 lines · Christoph Hellwig

That's what it's used as.

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>

---

Reviewed-by Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

A message that is not in the archive (sent off-list or not yet received): [email protected]

author maintainer
#16 lore raw

PATCH 5/7 nvmet/fc: mark the sqhd field as __le16

Quoted 3 lines · James Smart

This is fine, but this also highlights several different areas where sqhd is referenced and endianness wasn't accounted for. So I'll need to make a complimentary patch.

All the assignments to/from it are already to __le16 values.

author maintainer
#17 lore raw

PATCH 6/7 nvmet/fc: properly endian swap sq_head

In reply to Christoph Hellwig

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/target/fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fc.c +1 -1
index 4392b514725b..62eba29c85fb 100644
@@ -1700,7 +1700,7 @@ nvmet_fc_prep_fcp_rsp(struct nvmet_fc_tgtport *tgtport,
 	    xfr_length != fod->total_length ||
 	    (le16_to_cpu(cqe->status) & 0xFFFE) || cqewd[0] || cqewd[1] ||
 	    (sqe->flags & (NVME_CMD_FUSE_FIRST | NVME_CMD_FUSE_SECOND)) ||
-	    queue_90percent_full(fod->queue, cqe->sq_head))
+	    queue_90percent_full(fod->queue, le16_to_cpu(cqe->sq_head)))
 		send_ersp = true;
 
 	/* re-set the fields */
Signature · 1 line
2.11.0
#18 lore raw

PATCH 6/7 nvmet/fc: properly endian swap sq_head

Quoted 4 lines · Christoph Hellwig

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>

---

Reviewed-by Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
author maintainer
#19 lore raw

PATCH 7/7 nvmet/fcloop: mark two symbols static

In reply to Christoph Hellwig

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/target/fcloop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/target/fcloop.c +2 -2
index aaa3dbe22bd5..15551ef79c8c 100644
@@ -666,7 +666,7 @@ fcloop_targetport_delete(struct nvmet_fc_target_port *targetport)
 #define	FCLOOP_SGL_SEGS			256
 #define FCLOOP_DMABOUND_4G		0xFFFFFFFF
 
-struct nvme_fc_port_template fctemplate = {
+static struct nvme_fc_port_template fctemplate = {
 	.localport_delete	= fcloop_localport_delete,
 	.remoteport_delete	= fcloop_remoteport_delete,
 	.create_queue		= fcloop_create_queue,
@@ -686,7 +686,7 @@ struct nvme_fc_port_template fctemplate = {
 	.fcprqst_priv_sz	= sizeof(struct fcloop_ini_fcpreq),
 };
 
-struct nvmet_fc_target_template tgttemplate = {
+static struct nvmet_fc_target_template tgttemplate = {
 	.targetport_delete	= fcloop_targetport_delete,
 	.xmt_ls_rsp		= fcloop_xmt_ls_rsp,
 	.fcp_op			= fcloop_fcp_op,
Signature · 1 line
2.11.0
#20 lore raw

PATCH 7/7 nvmet/fcloop: mark two symbols static

Quoted 4 lines · Christoph Hellwig

Found by sparse.

Signed-off-by Christoph Hellwig <hch at lst.de>

---

Reviewed-by Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850