diff options
author | Joe Lawrence <joe.lawrence@stratus.com> | 2014-08-28 10:15:21 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-08-28 12:03:46 -0400 |
commit | a492f075450f3ba87de36e5ffe92a9d0c7af9723 (patch) | |
tree | 61960a71c7fde0eee3d77cda460154d2f7715d2f | |
parent | eb571eeade2598635f813b3284d02c13a380301e (diff) |
block,scsi: fixup blk_get_request dead queue scenarios
The blk_get_request function may fail in low-memory conditions or during
device removal (even if __GFP_WAIT is set). To distinguish between these
errors, modify the blk_get_request call stack to return the appropriate
ERR_PTR. Verify that all callers check the return status and consider
IS_ERR instead of a simple NULL pointer check.
For consistency, make a similar change to the blk_mq_alloc_request leg
of blk_get_request. It may fail if the queue is dead, or the caller was
unwilling to wait.
Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Jiri Kosina <jkosina@suse.cz> [for pktdvd]
Acked-by: Boaz Harrosh <bharrosh@panasas.com> [for osd]
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | block/blk-core.c | 34 | ||||
-rw-r--r-- | block/blk-mq.c | 8 | ||||
-rw-r--r-- | block/bsg.c | 8 | ||||
-rw-r--r-- | block/scsi_ioctl.c | 12 | ||||
-rw-r--r-- | drivers/block/paride/pd.c | 4 | ||||
-rw-r--r-- | drivers/block/pktcdvd.c | 4 | ||||
-rw-r--r-- | drivers/block/sx8.c | 2 | ||||
-rw-r--r-- | drivers/cdrom/cdrom.c | 4 | ||||
-rw-r--r-- | drivers/ide/ide-park.c | 2 | ||||
-rw-r--r-- | drivers/scsi/device_handler/scsi_dh_alua.c | 2 | ||||
-rw-r--r-- | drivers/scsi/device_handler/scsi_dh_emc.c | 2 | ||||
-rw-r--r-- | drivers/scsi/device_handler/scsi_dh_hp_sw.c | 4 | ||||
-rw-r--r-- | drivers/scsi/device_handler/scsi_dh_rdac.c | 2 | ||||
-rw-r--r-- | drivers/scsi/osd/osd_initiator.c | 4 | ||||
-rw-r--r-- | drivers/scsi/osst.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_error.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 4 | ||||
-rw-r--r-- | drivers/scsi/st.c | 2 | ||||
-rw-r--r-- | drivers/target/target_core_pscsi.c | 2 |
20 files changed, 55 insertions, 51 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index c359d72e9d76..93603e6ff479 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -933,9 +933,9 @@ static struct io_context *rq_ioc(struct bio *bio) | |||
933 | * Get a free request from @q. This function may fail under memory | 933 | * Get a free request from @q. This function may fail under memory |
934 | * pressure or if @q is dead. | 934 | * pressure or if @q is dead. |
935 | * | 935 | * |
936 | * Must be callled with @q->queue_lock held and, | 936 | * Must be called with @q->queue_lock held and, |
937 | * Returns %NULL on failure, with @q->queue_lock held. | 937 | * Returns ERR_PTR on failure, with @q->queue_lock held. |
938 | * Returns !%NULL on success, with @q->queue_lock *not held*. | 938 | * Returns request pointer on success, with @q->queue_lock *not held*. |
939 | */ | 939 | */ |
940 | static struct request *__get_request(struct request_list *rl, int rw_flags, | 940 | static struct request *__get_request(struct request_list *rl, int rw_flags, |
941 | struct bio *bio, gfp_t gfp_mask) | 941 | struct bio *bio, gfp_t gfp_mask) |
@@ -949,7 +949,7 @@ static struct request *__get_request(struct request_list *rl, int rw_flags, | |||
949 | int may_queue; | 949 | int may_queue; |
950 | 950 | ||
951 | if (unlikely(blk_queue_dying(q))) | 951 | if (unlikely(blk_queue_dying(q))) |
952 | return NULL; | 952 | return ERR_PTR(-ENODEV); |
953 | 953 | ||
954 | may_queue = elv_may_queue(q, rw_flags); | 954 | may_queue = elv_may_queue(q, rw_flags); |
955 | if (may_queue == ELV_MQUEUE_NO) | 955 | if (may_queue == ELV_MQUEUE_NO) |
@@ -974,7 +974,7 @@ static struct request *__get_request(struct request_list *rl, int rw_flags, | |||
974 | * process is not a "batcher", and not | 974 | * process is not a "batcher", and not |
975 | * exempted by the IO scheduler | 975 | * exempted by the IO scheduler |
976 | */ | 976 | */ |
977 | return NULL; | 977 | return ERR_PTR(-ENOMEM); |
978 | } | 978 | } |
979 | } | 979 | } |
980 | } | 980 | } |
@@ -992,7 +992,7 @@ static struct request *__get_request(struct request_list *rl, int rw_flags, | |||
992 | * allocated with any setting of ->nr_requests | 992 | * allocated with any setting of ->nr_requests |
993 | */ | 993 | */ |
994 | if (rl->count[is_sync] >= (3 * q->nr_requests / 2)) | 994 | if (rl->count[is_sync] >= (3 * q->nr_requests / 2)) |
995 | return NULL; | 995 | return ERR_PTR(-ENOMEM); |
996 | 996 | ||
997 | q->nr_rqs[is_sync]++; | 997 | q->nr_rqs[is_sync]++; |
998 | rl->count[is_sync]++; | 998 | rl->count[is_sync]++; |
@@ -1097,7 +1097,7 @@ fail_alloc: | |||
1097 | rq_starved: | 1097 | rq_starved: |
1098 | if (unlikely(rl->count[is_sync] == 0)) | 1098 | if (unlikely(rl->count[is_sync] == 0)) |
1099 | rl->starved[is_sync] = 1; | 1099 | rl->starved[is_sync] = 1; |
1100 | return NULL; | 1100 | return ERR_PTR(-ENOMEM); |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | /** | 1103 | /** |
@@ -1110,9 +1110,9 @@ rq_starved: | |||
1110 | * Get a free request from @q. If %__GFP_WAIT is set in @gfp_mask, this | 1110 | * Get a free request from @q. If %__GFP_WAIT is set in @gfp_mask, this |
1111 | * function keeps retrying under memory pressure and fails iff @q is dead. | 1111 | * function keeps retrying under memory pressure and fails iff @q is dead. |
1112 | * | 1112 | * |
1113 | * Must be callled with @q->queue_lock held and, | 1113 | * Must be called with @q->queue_lock held and, |
1114 | * Returns %NULL on failure, with @q->queue_lock held. | 1114 | * Returns ERR_PTR on failure, with @q->queue_lock held. |
1115 | * Returns !%NULL on success, with @q->queue_lock *not held*. | 1115 | * Returns request pointer on success, with @q->queue_lock *not held*. |
1116 | */ | 1116 | */ |
1117 | static struct request *get_request(struct request_queue *q, int rw_flags, | 1117 | static struct request *get_request(struct request_queue *q, int rw_flags, |
1118 | struct bio *bio, gfp_t gfp_mask) | 1118 | struct bio *bio, gfp_t gfp_mask) |
@@ -1125,12 +1125,12 @@ static struct request *get_request(struct request_queue *q, int rw_flags, | |||
1125 | rl = blk_get_rl(q, bio); /* transferred to @rq on success */ | 1125 | rl = blk_get_rl(q, bio); /* transferred to @rq on success */ |
1126 | retry: | 1126 | retry: |
1127 | rq = __get_request(rl, rw_flags, bio, gfp_mask); | 1127 | rq = __get_request(rl, rw_flags, bio, gfp_mask); |
1128 | if (rq) | 1128 | if (!IS_ERR(rq)) |
1129 | return rq; | 1129 | return rq; |
1130 | 1130 | ||
1131 | if (!(gfp_mask & __GFP_WAIT) || unlikely(blk_queue_dying(q))) { | 1131 | if (!(gfp_mask & __GFP_WAIT) || unlikely(blk_queue_dying(q))) { |
1132 | blk_put_rl(rl); | 1132 | blk_put_rl(rl); |
1133 | return NULL; | 1133 | return rq; |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | /* wait on @rl and retry */ | 1136 | /* wait on @rl and retry */ |
@@ -1167,7 +1167,7 @@ static struct request *blk_old_get_request(struct request_queue *q, int rw, | |||
1167 | 1167 | ||
1168 | spin_lock_irq(q->queue_lock); | 1168 | spin_lock_irq(q->queue_lock); |
1169 | rq = get_request(q, rw, NULL, gfp_mask); | 1169 | rq = get_request(q, rw, NULL, gfp_mask); |
1170 | if (!rq) | 1170 | if (IS_ERR(rq)) |
1171 | spin_unlock_irq(q->queue_lock); | 1171 | spin_unlock_irq(q->queue_lock); |
1172 | /* q->queue_lock is unlocked at this point */ | 1172 | /* q->queue_lock is unlocked at this point */ |
1173 | 1173 | ||
@@ -1219,8 +1219,8 @@ struct request *blk_make_request(struct request_queue *q, struct bio *bio, | |||
1219 | { | 1219 | { |
1220 | struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask); | 1220 | struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask); |
1221 | 1221 | ||
1222 | if (unlikely(!rq)) | 1222 | if (IS_ERR(rq)) |
1223 | return ERR_PTR(-ENOMEM); | 1223 | return rq; |
1224 | 1224 | ||
1225 | blk_rq_set_block_pc(rq); | 1225 | blk_rq_set_block_pc(rq); |
1226 | 1226 | ||
@@ -1615,8 +1615,8 @@ get_rq: | |||
1615 | * Returns with the queue unlocked. | 1615 | * Returns with the queue unlocked. |
1616 | */ | 1616 | */ |
1617 | req = get_request(q, rw_flags, bio, GFP_NOIO); | 1617 | req = get_request(q, rw_flags, bio, GFP_NOIO); |
1618 | if (unlikely(!req)) { | 1618 | if (IS_ERR(req)) { |
1619 | bio_endio(bio, -ENODEV); /* @q is dead */ | 1619 | bio_endio(bio, PTR_ERR(req)); /* @q is dead */ |
1620 | goto out_unlock; | 1620 | goto out_unlock; |
1621 | } | 1621 | } |
1622 | 1622 | ||
diff --git a/block/blk-mq.c b/block/blk-mq.c index 5189cb1e478a..940aa8a34b70 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -218,9 +218,11 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp, | |||
218 | struct blk_mq_hw_ctx *hctx; | 218 | struct blk_mq_hw_ctx *hctx; |
219 | struct request *rq; | 219 | struct request *rq; |
220 | struct blk_mq_alloc_data alloc_data; | 220 | struct blk_mq_alloc_data alloc_data; |
221 | int ret; | ||
221 | 222 | ||
222 | if (blk_mq_queue_enter(q)) | 223 | ret = blk_mq_queue_enter(q); |
223 | return NULL; | 224 | if (ret) |
225 | return ERR_PTR(ret); | ||
224 | 226 | ||
225 | ctx = blk_mq_get_ctx(q); | 227 | ctx = blk_mq_get_ctx(q); |
226 | hctx = q->mq_ops->map_queue(q, ctx->cpu); | 228 | hctx = q->mq_ops->map_queue(q, ctx->cpu); |
@@ -240,6 +242,8 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp, | |||
240 | ctx = alloc_data.ctx; | 242 | ctx = alloc_data.ctx; |
241 | } | 243 | } |
242 | blk_mq_put_ctx(ctx); | 244 | blk_mq_put_ctx(ctx); |
245 | if (!rq) | ||
246 | return ERR_PTR(-EWOULDBLOCK); | ||
243 | return rq; | 247 | return rq; |
244 | } | 248 | } |
245 | EXPORT_SYMBOL(blk_mq_alloc_request); | 249 | EXPORT_SYMBOL(blk_mq_alloc_request); |
diff --git a/block/bsg.c b/block/bsg.c index ff46addde5d8..73c78fd12cc1 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -270,8 +270,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm, | |||
270 | * map scatter-gather elements separately and string them to request | 270 | * map scatter-gather elements separately and string them to request |
271 | */ | 271 | */ |
272 | rq = blk_get_request(q, rw, GFP_KERNEL); | 272 | rq = blk_get_request(q, rw, GFP_KERNEL); |
273 | if (!rq) | 273 | if (IS_ERR(rq)) |
274 | return ERR_PTR(-ENOMEM); | 274 | return rq; |
275 | blk_rq_set_block_pc(rq); | 275 | blk_rq_set_block_pc(rq); |
276 | 276 | ||
277 | ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd, has_write_perm); | 277 | ret = blk_fill_sgv4_hdr_rq(q, rq, hdr, bd, has_write_perm); |
@@ -285,8 +285,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm, | |||
285 | } | 285 | } |
286 | 286 | ||
287 | next_rq = blk_get_request(q, READ, GFP_KERNEL); | 287 | next_rq = blk_get_request(q, READ, GFP_KERNEL); |
288 | if (!next_rq) { | 288 | if (IS_ERR(next_rq)) { |
289 | ret = -ENOMEM; | 289 | ret = PTR_ERR(next_rq); |
290 | goto out; | 290 | goto out; |
291 | } | 291 | } |
292 | rq->next_rq = next_rq; | 292 | rq->next_rq = next_rq; |
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 29d056782833..a8b0d0208448 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c | |||
@@ -318,8 +318,8 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk, | |||
318 | at_head = 1; | 318 | at_head = 1; |
319 | 319 | ||
320 | rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL); | 320 | rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL); |
321 | if (!rq) | 321 | if (IS_ERR(rq)) |
322 | return -ENOMEM; | 322 | return PTR_ERR(rq); |
323 | blk_rq_set_block_pc(rq); | 323 | blk_rq_set_block_pc(rq); |
324 | 324 | ||
325 | if (blk_fill_sghdr_rq(q, rq, hdr, mode)) { | 325 | if (blk_fill_sghdr_rq(q, rq, hdr, mode)) { |
@@ -448,8 +448,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, | |||
448 | } | 448 | } |
449 | 449 | ||
450 | rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT); | 450 | rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT); |
451 | if (!rq) { | 451 | if (IS_ERR(rq)) { |
452 | err = -ENODEV; | 452 | err = PTR_ERR(rq); |
453 | goto error_free_buffer; | 453 | goto error_free_buffer; |
454 | } | 454 | } |
455 | 455 | ||
@@ -539,8 +539,8 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk, | |||
539 | int err; | 539 | int err; |
540 | 540 | ||
541 | rq = blk_get_request(q, WRITE, __GFP_WAIT); | 541 | rq = blk_get_request(q, WRITE, __GFP_WAIT); |
542 | if (!rq) | 542 | if (IS_ERR(rq)) |
543 | return -ENODEV; | 543 | return PTR_ERR(rq); |
544 | blk_rq_set_block_pc(rq); | 544 | blk_rq_set_block_pc(rq); |
545 | rq->timeout = BLK_DEFAULT_SG_TIMEOUT; | 545 | rq->timeout = BLK_DEFAULT_SG_TIMEOUT; |
546 | rq->cmd[0] = cmd; | 546 | rq->cmd[0] = cmd; |
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index ca831f741d89..d48715b287e6 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c | |||
@@ -722,8 +722,8 @@ static int pd_special_command(struct pd_unit *disk, | |||
722 | int err = 0; | 722 | int err = 0; |
723 | 723 | ||
724 | rq = blk_get_request(disk->gd->queue, READ, __GFP_WAIT); | 724 | rq = blk_get_request(disk->gd->queue, READ, __GFP_WAIT); |
725 | if (!rq) | 725 | if (IS_ERR(rq)) |
726 | return -ENODEV; | 726 | return PTR_ERR(rq); |
727 | 727 | ||
728 | rq->cmd_type = REQ_TYPE_SPECIAL; | 728 | rq->cmd_type = REQ_TYPE_SPECIAL; |
729 | rq->special = func; | 729 | rq->special = func; |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 7fa8c80e8982..09e628dafd9d 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -704,8 +704,8 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * | |||
704 | 704 | ||
705 | rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ? | 705 | rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ? |
706 | WRITE : READ, __GFP_WAIT); | 706 | WRITE : READ, __GFP_WAIT); |
707 | if (!rq) | 707 | if (IS_ERR(rq)) |
708 | return -ENODEV; | 708 | return PTR_ERR(rq); |
709 | blk_rq_set_block_pc(rq); | 709 | blk_rq_set_block_pc(rq); |
710 | 710 | ||
711 | if (cgc->buflen) { | 711 | if (cgc->buflen) { |
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index d5e2d12b9d9e..5d552857de41 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c | |||
@@ -568,7 +568,7 @@ static struct carm_request *carm_get_special(struct carm_host *host) | |||
568 | return NULL; | 568 | return NULL; |
569 | 569 | ||
570 | rq = blk_get_request(host->oob_q, WRITE /* bogus */, GFP_KERNEL); | 570 | rq = blk_get_request(host->oob_q, WRITE /* bogus */, GFP_KERNEL); |
571 | if (!rq) { | 571 | if (IS_ERR(rq)) { |
572 | spin_lock_irqsave(&host->lock, flags); | 572 | spin_lock_irqsave(&host->lock, flags); |
573 | carm_put_request(host, crq); | 573 | carm_put_request(host, crq); |
574 | spin_unlock_irqrestore(&host->lock, flags); | 574 | spin_unlock_irqrestore(&host->lock, flags); |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 898b84bba28a..5d28a45d2960 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -2180,8 +2180,8 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, | |||
2180 | len = nr * CD_FRAMESIZE_RAW; | 2180 | len = nr * CD_FRAMESIZE_RAW; |
2181 | 2181 | ||
2182 | rq = blk_get_request(q, READ, GFP_KERNEL); | 2182 | rq = blk_get_request(q, READ, GFP_KERNEL); |
2183 | if (!rq) { | 2183 | if (IS_ERR(rq)) { |
2184 | ret = -ENOMEM; | 2184 | ret = PTR_ERR(rq); |
2185 | break; | 2185 | break; |
2186 | } | 2186 | } |
2187 | blk_rq_set_block_pc(rq); | 2187 | blk_rq_set_block_pc(rq); |
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c index f41558a0bcd1..ca958604cda2 100644 --- a/drivers/ide/ide-park.c +++ b/drivers/ide/ide-park.c | |||
@@ -46,7 +46,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) | |||
46 | * timeout has expired, so power management will be reenabled. | 46 | * timeout has expired, so power management will be reenabled. |
47 | */ | 47 | */ |
48 | rq = blk_get_request(q, READ, GFP_NOWAIT); | 48 | rq = blk_get_request(q, READ, GFP_NOWAIT); |
49 | if (unlikely(!rq)) | 49 | if (IS_ERR(rq)) |
50 | goto out; | 50 | goto out; |
51 | 51 | ||
52 | rq->cmd[0] = REQ_UNPARK_HEADS; | 52 | rq->cmd[0] = REQ_UNPARK_HEADS; |
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 7bcf67eec921..e99507ed0e3c 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c | |||
@@ -115,7 +115,7 @@ static struct request *get_alua_req(struct scsi_device *sdev, | |||
115 | 115 | ||
116 | rq = blk_get_request(q, rw, GFP_NOIO); | 116 | rq = blk_get_request(q, rw, GFP_NOIO); |
117 | 117 | ||
118 | if (!rq) { | 118 | if (IS_ERR(rq)) { |
119 | sdev_printk(KERN_INFO, sdev, | 119 | sdev_printk(KERN_INFO, sdev, |
120 | "%s: blk_get_request failed\n", __func__); | 120 | "%s: blk_get_request failed\n", __func__); |
121 | return NULL; | 121 | return NULL; |
diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index 6f07f7fe3aa1..84765384c47c 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c | |||
@@ -275,7 +275,7 @@ static struct request *get_req(struct scsi_device *sdev, int cmd, | |||
275 | 275 | ||
276 | rq = blk_get_request(sdev->request_queue, | 276 | rq = blk_get_request(sdev->request_queue, |
277 | (cmd != INQUIRY) ? WRITE : READ, GFP_NOIO); | 277 | (cmd != INQUIRY) ? WRITE : READ, GFP_NOIO); |
278 | if (!rq) { | 278 | if (IS_ERR(rq)) { |
279 | sdev_printk(KERN_INFO, sdev, "get_req: blk_get_request failed"); | 279 | sdev_printk(KERN_INFO, sdev, "get_req: blk_get_request failed"); |
280 | return NULL; | 280 | return NULL; |
281 | } | 281 | } |
diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index e9d9fea9e272..4ee2759f5299 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c | |||
@@ -117,7 +117,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) | |||
117 | 117 | ||
118 | retry: | 118 | retry: |
119 | req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO); | 119 | req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO); |
120 | if (!req) | 120 | if (IS_ERR(req)) |
121 | return SCSI_DH_RES_TEMP_UNAVAIL; | 121 | return SCSI_DH_RES_TEMP_UNAVAIL; |
122 | 122 | ||
123 | blk_rq_set_block_pc(req); | 123 | blk_rq_set_block_pc(req); |
@@ -247,7 +247,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h) | |||
247 | struct request *req; | 247 | struct request *req; |
248 | 248 | ||
249 | req = blk_get_request(h->sdev->request_queue, WRITE, GFP_ATOMIC); | 249 | req = blk_get_request(h->sdev->request_queue, WRITE, GFP_ATOMIC); |
250 | if (!req) | 250 | if (IS_ERR(req)) |
251 | return SCSI_DH_RES_TEMP_UNAVAIL; | 251 | return SCSI_DH_RES_TEMP_UNAVAIL; |
252 | 252 | ||
253 | blk_rq_set_block_pc(req); | 253 | blk_rq_set_block_pc(req); |
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index 826069db9848..1b5bc9293e37 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c | |||
@@ -274,7 +274,7 @@ static struct request *get_rdac_req(struct scsi_device *sdev, | |||
274 | 274 | ||
275 | rq = blk_get_request(q, rw, GFP_NOIO); | 275 | rq = blk_get_request(q, rw, GFP_NOIO); |
276 | 276 | ||
277 | if (!rq) { | 277 | if (IS_ERR(rq)) { |
278 | sdev_printk(KERN_INFO, sdev, | 278 | sdev_printk(KERN_INFO, sdev, |
279 | "get_rdac_req: blk_get_request failed.\n"); | 279 | "get_rdac_req: blk_get_request failed.\n"); |
280 | return NULL; | 280 | return NULL; |
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c index 5f4cbf0c4759..fd19fd8468ac 100644 --- a/drivers/scsi/osd/osd_initiator.c +++ b/drivers/scsi/osd/osd_initiator.c | |||
@@ -1567,8 +1567,8 @@ static struct request *_make_request(struct request_queue *q, bool has_write, | |||
1567 | struct request *req; | 1567 | struct request *req; |
1568 | 1568 | ||
1569 | req = blk_get_request(q, has_write ? WRITE : READ, flags); | 1569 | req = blk_get_request(q, has_write ? WRITE : READ, flags); |
1570 | if (unlikely(!req)) | 1570 | if (IS_ERR(req)) |
1571 | return ERR_PTR(-ENOMEM); | 1571 | return req; |
1572 | 1572 | ||
1573 | blk_rq_set_block_pc(req); | 1573 | blk_rq_set_block_pc(req); |
1574 | return req; | 1574 | return req; |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 0727ea7cc387..dff37a250d79 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -362,7 +362,7 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd, | |||
362 | int write = (data_direction == DMA_TO_DEVICE); | 362 | int write = (data_direction == DMA_TO_DEVICE); |
363 | 363 | ||
364 | req = blk_get_request(SRpnt->stp->device->request_queue, write, GFP_KERNEL); | 364 | req = blk_get_request(SRpnt->stp->device->request_queue, write, GFP_KERNEL); |
365 | if (!req) | 365 | if (IS_ERR(req)) |
366 | return DRIVER_ERROR << 24; | 366 | return DRIVER_ERROR << 24; |
367 | 367 | ||
368 | blk_rq_set_block_pc(req); | 368 | blk_rq_set_block_pc(req); |
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 4c433bf47a06..a2c3d3d255a1 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
@@ -1960,7 +1960,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) | |||
1960 | * request becomes available | 1960 | * request becomes available |
1961 | */ | 1961 | */ |
1962 | req = blk_get_request(sdev->request_queue, READ, GFP_KERNEL); | 1962 | req = blk_get_request(sdev->request_queue, READ, GFP_KERNEL); |
1963 | if (!req) | 1963 | if (IS_ERR(req)) |
1964 | return; | 1964 | return; |
1965 | 1965 | ||
1966 | blk_rq_set_block_pc(req); | 1966 | blk_rq_set_block_pc(req); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ce62e8798cc8..972d0a8adf2e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -221,7 +221,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, | |||
221 | int ret = DRIVER_ERROR << 24; | 221 | int ret = DRIVER_ERROR << 24; |
222 | 222 | ||
223 | req = blk_get_request(sdev->request_queue, write, __GFP_WAIT); | 223 | req = blk_get_request(sdev->request_queue, write, __GFP_WAIT); |
224 | if (!req) | 224 | if (IS_ERR(req)) |
225 | return ret; | 225 | return ret; |
226 | blk_rq_set_block_pc(req); | 226 | blk_rq_set_block_pc(req); |
227 | 227 | ||
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 01cf88888797..60354449d9ed 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1711,9 +1711,9 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) | |||
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | rq = blk_get_request(q, rw, GFP_ATOMIC); | 1713 | rq = blk_get_request(q, rw, GFP_ATOMIC); |
1714 | if (!rq) { | 1714 | if (IS_ERR(rq)) { |
1715 | kfree(long_cmdp); | 1715 | kfree(long_cmdp); |
1716 | return -ENOMEM; | 1716 | return PTR_ERR(rq); |
1717 | } | 1717 | } |
1718 | 1718 | ||
1719 | blk_rq_set_block_pc(rq); | 1719 | blk_rq_set_block_pc(rq); |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index aff9689de0f7..59db5bfc11db 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -490,7 +490,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, | |||
490 | 490 | ||
491 | req = blk_get_request(SRpnt->stp->device->request_queue, write, | 491 | req = blk_get_request(SRpnt->stp->device->request_queue, write, |
492 | GFP_KERNEL); | 492 | GFP_KERNEL); |
493 | if (!req) | 493 | if (IS_ERR(req)) |
494 | return DRIVER_ERROR << 24; | 494 | return DRIVER_ERROR << 24; |
495 | 495 | ||
496 | blk_rq_set_block_pc(req); | 496 | blk_rq_set_block_pc(req); |
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 943b1dbe859a..70d9f6dabba0 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c | |||
@@ -1050,7 +1050,7 @@ pscsi_execute_cmd(struct se_cmd *cmd) | |||
1050 | req = blk_get_request(pdv->pdv_sd->request_queue, | 1050 | req = blk_get_request(pdv->pdv_sd->request_queue, |
1051 | (data_direction == DMA_TO_DEVICE), | 1051 | (data_direction == DMA_TO_DEVICE), |
1052 | GFP_KERNEL); | 1052 | GFP_KERNEL); |
1053 | if (!req) { | 1053 | if (IS_ERR(req)) { |
1054 | pr_err("PSCSI: blk_get_request() failed\n"); | 1054 | pr_err("PSCSI: blk_get_request() failed\n"); |
1055 | ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | 1055 | ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
1056 | goto fail; | 1056 | goto fail; |