Thread (28 messages) 28 messages, 4 authors, 2014-07-17

Re: [PATCH 01/10] scsi: move the nr_phys_segments assert into scsi_init_io

From: Hannes Reinecke <hare@suse.de>
Date: 2014-07-11 12:17:12

On 06/29/2014 03:34 PM, Christoph Hellwig wrote:
quoted hunk ↗ jump to hunk
scsi_init_io should only be called for requests that transfer data,
so move the assert that a request has segments from the callers into
scsi_init_io.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
  drivers/scsi/scsi_lib.c |   16 +++++-----------
  1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 37038fb..b505b06 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -996,8 +996,11 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
  {
  	struct scsi_device *sdev = cmd->device;
  	struct request *rq = cmd->request;
+	int error;

-	int error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask);
+	BUG_ON(!rq->nr_phys_segments);
+
+	error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask);
  	if (error)
  		goto err_exit;
@@ -1088,11 +1091,7 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
  	 * submit a request without an attached bio.
  	 */
  	if (req->bio) {
-		int ret;
-
-		BUG_ON(!req->nr_phys_segments);
-
-		ret = scsi_init_io(cmd, GFP_ATOMIC);
+		int ret = scsi_init_io(cmd, GFP_ATOMIC);
  		if (unlikely(ret))
  			return ret;
  	} else {
@@ -1131,11 +1130,6 @@ int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
  			return ret;
  	}

-	/*
-	 * Filesystem requests must transfer data.
-	 */
-	BUG_ON(!req->nr_phys_segments);
-
  	memset(cmd->cmnd, 0, BLK_MAX_CDB);
  	return scsi_init_io(cmd, GFP_ATOMIC);
  }
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help