Skip to contentSkip to conversation

scsi: ->queue_rq can't sleep

PATCH In review Christoph Hellwig 4 participants 4 messages Jan 7, 2015 – Jan 9, 2015 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ->queue_rq can't sleep

The blk-mq ->queue_rq method is always called from process context, but might have preemption disabled. This means we still always have to use GFP_ATOMIC for memory allocations, and thus need to revert part of commit 3c356bde1 ("scsi: stop passing a gfp_mask argument down the command setup path").

---
 drivers/scsi/scsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +1 -2
index 9ea95dd..6d5c0b8 100644
@@ -591,7 +591,6 @@ static void scsi_free_sgtable(struct scsi_data_buffer *sdb, bool mq)
 static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq)
 {
 	struct scatterlist *first_chunk = NULL;
-	gfp_t gfp_mask = mq ? GFP_NOIO : GFP_ATOMIC;
 	int ret;
 
 	BUG_ON(!nents);
@@ -606,7 +605,7 @@ static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq)
 	}
 
 	ret = __sg_alloc_table(&sdb->table, nents, SCSI_MAX_SG_SEGMENTS,
-			       first_chunk, gfp_mask, scsi_sg_alloc);
+			       first_chunk, GFP_ATOMIC, scsi_sg_alloc);
 	if (unlikely(ret))
 		scsi_free_sgtable(sdb, mq);
 	return ret;
Signature · 1 line
1.9.1
#1 lore raw

Any chance to get a review / ack for this one?

Quoted 40 lines · Christoph Hellwig

The blk-mq ->queue_rq method is always called from process context, but might have preemption disabled. This means we still always have to use GFP_ATOMIC for memory allocations, and thus need to revert part of commit 3c356bde1 ("scsi: stop passing a gfp_mask argument down the command setup path").

---
 drivers/scsi/scsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +1 -2
index 9ea95dd..6d5c0b8 100644
@@ -591,7 +591,6 @@ static void scsi_free_sgtable(struct scsi_data_buffer *sdb, bool mq)
 static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq)
 {
 	struct scatterlist *first_chunk = NULL;
-	gfp_t gfp_mask = mq ? GFP_NOIO : GFP_ATOMIC;
 	int ret;
 
 	BUG_ON(!nents);
@@ -606,7 +605,7 @@ static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq)
 	}
 
 	ret = __sg_alloc_table(&sdb->table, nents, SCSI_MAX_SG_SEGMENTS,
-			       first_chunk, gfp_mask, scsi_sg_alloc);
+			       first_chunk, GFP_ATOMIC, scsi_sg_alloc);
 	if (unlikely(ret))
 		scsi_free_sgtable(sdb, mq);
 	return ret;
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

---end quoted text---

#2 lore raw
Quoted 1 line · Christoph Hellwig

Any chance to get a review / ack for this one?

You can my reviewed-by, looks fine to me.

Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#3 lore raw
In reply to Christoph Hellwig
Quoted 26 lines · Christoph Hellwig

The blk-mq ->queue_rq method is always called from process context, but might have preemption disabled. This means we still always have to use GFP_ATOMIC for memory allocations, and thus need to revert part of commit 3c356bde1 ("scsi: stop passing a gfp_mask argument down the command setup path").

---
  drivers/scsi/scsi_lib.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +0 -1
index 9ea95dd..6d5c0b8 100644
@@ -591,7 +591,6 @@ static void scsi_free_sgtable(struct scsi_data_buffer *sdb, bool mq)
  static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq)
  {
      struct scatterlist *first_chunk = NULL;
-     gfp_t gfp_mask = mq ? GFP_NOIO : GFP_ATOMIC;
      int ret;
 
      BUG_ON(!nents);

drivers/scsi/scsi_lib.c static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq) · line 611

Quoted 8 lines
drivers/scsi/scsi_lib.c +1 -1
@@ -606,7 +605,7 @@ static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq)
      }
 
      ret = __sg_alloc_table(&sdb->table, nents, SCSI_MAX_SG_SEGMENTS,
-                            first_chunk, gfp_mask, scsi_sg_alloc);
+                            first_chunk, GFP_ATOMIC, scsi_sg_alloc);
      if (unlikely(ret))
              scsi_free_sgtable(sdb, mq);
      return ret;

(note: I have been asked to use my company e-mail address for kernel related work)

________________________________

PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies).