diff options
author | Christoph Hellwig <hch@lst.de> | 2014-09-05 21:20:23 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-11-24 13:56:55 -0500 |
commit | 3c356bde19e9a728b26a231a23099c8057dbe881 (patch) | |
tree | 5c36f956e9f8a15de22dfca057b07c63818eeeda | |
parent | bb3ec62a179922b501535d5bd210cb8ba2ad069b (diff) |
scsi: stop passing a gfp_mask argument down the command setup path
There is no reason for ULDs to pass in a flag on how to allocate the S/G
lists. While we don't need GFP_ATOMIC for the blk-mq case because we
don't hold locks, that decision can be made way down the chain without
having to pass a pointless gfp_mask argument.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
-rw-r--r-- | drivers/scsi/scsi_lib.c | 20 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sr.c | 2 | ||||
-rw-r--r-- | include/scsi/scsi_cmnd.h | 2 |
4 files changed, 14 insertions, 16 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 2179851cdaf3..fcdc585278bf 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -588,10 +588,10 @@ static void scsi_free_sgtable(struct scsi_data_buffer *sdb, bool mq) | |||
588 | __sg_free_table(&sdb->table, SCSI_MAX_SG_SEGMENTS, mq, scsi_sg_free); | 588 | __sg_free_table(&sdb->table, SCSI_MAX_SG_SEGMENTS, mq, scsi_sg_free); |
589 | } | 589 | } |
590 | 590 | ||
591 | static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, | 591 | static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq) |
592 | gfp_t gfp_mask, bool mq) | ||
593 | { | 592 | { |
594 | struct scatterlist *first_chunk = NULL; | 593 | struct scatterlist *first_chunk = NULL; |
594 | gfp_t gfp_mask = mq ? GFP_NOIO : GFP_ATOMIC; | ||
595 | int ret; | 595 | int ret; |
596 | 596 | ||
597 | BUG_ON(!nents); | 597 | BUG_ON(!nents); |
@@ -1077,8 +1077,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, | 1080 | static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb) |
1081 | gfp_t gfp_mask) | ||
1082 | { | 1081 | { |
1083 | int count; | 1082 | int count; |
1084 | 1083 | ||
@@ -1086,7 +1085,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, | |||
1086 | * If sg table allocation fails, requeue request later. | 1085 | * If sg table allocation fails, requeue request later. |
1087 | */ | 1086 | */ |
1088 | if (unlikely(scsi_alloc_sgtable(sdb, req->nr_phys_segments, | 1087 | if (unlikely(scsi_alloc_sgtable(sdb, req->nr_phys_segments, |
1089 | gfp_mask, req->mq_ctx != NULL))) | 1088 | req->mq_ctx != NULL))) |
1090 | return BLKPREP_DEFER; | 1089 | return BLKPREP_DEFER; |
1091 | 1090 | ||
1092 | /* | 1091 | /* |
@@ -1111,7 +1110,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, | |||
1111 | * BLKPREP_DEFER if the failure is retryable | 1110 | * BLKPREP_DEFER if the failure is retryable |
1112 | * BLKPREP_KILL if the failure is fatal | 1111 | * BLKPREP_KILL if the failure is fatal |
1113 | */ | 1112 | */ |
1114 | int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) | 1113 | int scsi_init_io(struct scsi_cmnd *cmd) |
1115 | { | 1114 | { |
1116 | struct scsi_device *sdev = cmd->device; | 1115 | struct scsi_device *sdev = cmd->device; |
1117 | struct request *rq = cmd->request; | 1116 | struct request *rq = cmd->request; |
@@ -1120,7 +1119,7 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
1120 | 1119 | ||
1121 | BUG_ON(!rq->nr_phys_segments); | 1120 | BUG_ON(!rq->nr_phys_segments); |
1122 | 1121 | ||
1123 | error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask); | 1122 | error = scsi_init_sgtable(rq, &cmd->sdb); |
1124 | if (error) | 1123 | if (error) |
1125 | goto err_exit; | 1124 | goto err_exit; |
1126 | 1125 | ||
@@ -1136,8 +1135,7 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
1136 | rq->next_rq->special = bidi_sdb; | 1135 | rq->next_rq->special = bidi_sdb; |
1137 | } | 1136 | } |
1138 | 1137 | ||
1139 | error = scsi_init_sgtable(rq->next_rq, rq->next_rq->special, | 1138 | error = scsi_init_sgtable(rq->next_rq, rq->next_rq->special); |
1140 | GFP_ATOMIC); | ||
1141 | if (error) | 1139 | if (error) |
1142 | goto err_exit; | 1140 | goto err_exit; |
1143 | } | 1141 | } |
@@ -1149,7 +1147,7 @@ int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
1149 | BUG_ON(prot_sdb == NULL); | 1147 | BUG_ON(prot_sdb == NULL); |
1150 | ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); | 1148 | ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio); |
1151 | 1149 | ||
1152 | if (scsi_alloc_sgtable(prot_sdb, ivecs, gfp_mask, is_mq)) { | 1150 | if (scsi_alloc_sgtable(prot_sdb, ivecs, is_mq)) { |
1153 | error = BLKPREP_DEFER; | 1151 | error = BLKPREP_DEFER; |
1154 | goto err_exit; | 1152 | goto err_exit; |
1155 | } | 1153 | } |
@@ -1218,7 +1216,7 @@ static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) | |||
1218 | * submit a request without an attached bio. | 1216 | * submit a request without an attached bio. |
1219 | */ | 1217 | */ |
1220 | if (req->bio) { | 1218 | if (req->bio) { |
1221 | int ret = scsi_init_io(cmd, GFP_ATOMIC); | 1219 | int ret = scsi_init_io(cmd); |
1222 | if (unlikely(ret)) | 1220 | if (unlikely(ret)) |
1223 | return ret; | 1221 | return ret; |
1224 | } else { | 1222 | } else { |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 95bfb7bfbb9d..f2e9b1dad574 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -786,7 +786,7 @@ static int sd_setup_discard_cmnd(struct scsi_cmnd *cmd) | |||
786 | * amount of blocks described by the request. | 786 | * amount of blocks described by the request. |
787 | */ | 787 | */ |
788 | blk_add_request_payload(rq, page, len); | 788 | blk_add_request_payload(rq, page, len); |
789 | ret = scsi_init_io(cmd, GFP_ATOMIC); | 789 | ret = scsi_init_io(cmd); |
790 | rq->__data_len = nr_bytes; | 790 | rq->__data_len = nr_bytes; |
791 | 791 | ||
792 | out: | 792 | out: |
@@ -880,7 +880,7 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) | |||
880 | * knows how much to actually write. | 880 | * knows how much to actually write. |
881 | */ | 881 | */ |
882 | rq->__data_len = sdp->sector_size; | 882 | rq->__data_len = sdp->sector_size; |
883 | ret = scsi_init_io(cmd, GFP_ATOMIC); | 883 | ret = scsi_init_io(cmd); |
884 | rq->__data_len = nr_bytes; | 884 | rq->__data_len = nr_bytes; |
885 | return ret; | 885 | return ret; |
886 | } | 886 | } |
@@ -914,7 +914,7 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) | |||
914 | int ret; | 914 | int ret; |
915 | unsigned char protect; | 915 | unsigned char protect; |
916 | 916 | ||
917 | ret = scsi_init_io(SCpnt, GFP_ATOMIC); | 917 | ret = scsi_init_io(SCpnt); |
918 | if (ret != BLKPREP_OK) | 918 | if (ret != BLKPREP_OK) |
919 | goto out; | 919 | goto out; |
920 | SCpnt = rq->special; | 920 | SCpnt = rq->special; |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 3d5399e341af..5ebadc2ace9b 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -387,7 +387,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt) | |||
387 | struct request *rq = SCpnt->request; | 387 | struct request *rq = SCpnt->request; |
388 | int ret; | 388 | int ret; |
389 | 389 | ||
390 | ret = scsi_init_io(SCpnt, GFP_ATOMIC); | 390 | ret = scsi_init_io(SCpnt); |
391 | if (ret != BLKPREP_OK) | 391 | if (ret != BLKPREP_OK) |
392 | goto out; | 392 | goto out; |
393 | SCpnt = rq->special; | 393 | SCpnt = rq->special; |
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index e119142e565e..9fc1aecfc813 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h | |||
@@ -163,7 +163,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, | |||
163 | size_t *offset, size_t *len); | 163 | size_t *offset, size_t *len); |
164 | extern void scsi_kunmap_atomic_sg(void *virt); | 164 | extern void scsi_kunmap_atomic_sg(void *virt); |
165 | 165 | ||
166 | extern int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask); | 166 | extern int scsi_init_io(struct scsi_cmnd *cmd); |
167 | 167 | ||
168 | extern int scsi_dma_map(struct scsi_cmnd *cmd); | 168 | extern int scsi_dma_map(struct scsi_cmnd *cmd); |
169 | extern void scsi_dma_unmap(struct scsi_cmnd *cmd); | 169 | extern void scsi_dma_unmap(struct scsi_cmnd *cmd); |