From: Christoph Hellwig <hch@lst.de>
To: axboe@kernel.dk
Cc: Bart.VanAssche@wdc.com, willy@infradead.org,
linux-block@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 4/6] block: pass an explicit gfp_t to get_request
Date: Wed, 9 May 2018 09:54:06 +0200 [thread overview]
Message-ID: <20180509075408.16388-5-hch@lst.de> (raw)
In-Reply-To: <20180509075408.16388-1-hch@lst.de>
blk_old_get_request already has it at hand, and in blk_queue_bio, which
is the fast path, it is constant.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
---
block/blk-core.c | 14 +++++++-------
drivers/scsi/scsi_error.c | 4 ----
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 5013027eae70..cc56e56c2eff 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1333,6 +1333,7 @@ int blk_update_nr_requests(struct request_queue *q, unsigned int nr)
* @op: operation and flags
* @bio: bio to allocate request for (can be %NULL)
* @flags: BLQ_MQ_REQ_* flags
+ * @gfp_mask: allocator flags
*
* Get a free request from @q. This function may fail under memory
* pressure or if @q is dead.
@@ -1342,7 +1343,7 @@ int blk_update_nr_requests(struct request_queue *q, unsigned int nr)
* Returns request pointer on success, with @q->queue_lock *not held*.
*/
static struct request *__get_request(struct request_list *rl, unsigned int op,
- struct bio *bio, blk_mq_req_flags_t flags)
+ struct bio *bio, blk_mq_req_flags_t flags, gfp_t gfp_mask)
{
struct request_queue *q = rl->q;
struct request *rq;
@@ -1351,8 +1352,6 @@ static struct request *__get_request(struct request_list *rl, unsigned int op,
struct io_cq *icq = NULL;
const bool is_sync = op_is_sync(op);
int may_queue;
- gfp_t gfp_mask = flags & BLK_MQ_REQ_NOWAIT ? GFP_ATOMIC :
- __GFP_DIRECT_RECLAIM;
req_flags_t rq_flags = RQF_ALLOCED;
lockdep_assert_held(q->queue_lock);
@@ -1516,6 +1515,7 @@ static struct request *__get_request(struct request_list *rl, unsigned int op,
* @op: operation and flags
* @bio: bio to allocate request for (can be %NULL)
* @flags: BLK_MQ_REQ_* flags.
+ * @gfp: allocator flags
*
* Get a free request from @q. If %BLK_MQ_REQ_NOWAIT is set in @flags,
* this function keeps retrying under memory pressure and fails iff @q is dead.
@@ -1525,7 +1525,7 @@ static struct request *__get_request(struct request_list *rl, unsigned int op,
* Returns request pointer on success, with @q->queue_lock *not held*.
*/
static struct request *get_request(struct request_queue *q, unsigned int op,
- struct bio *bio, blk_mq_req_flags_t flags)
+ struct bio *bio, blk_mq_req_flags_t flags, gfp_t gfp)
{
const bool is_sync = op_is_sync(op);
DEFINE_WAIT(wait);
@@ -1537,7 +1537,7 @@ static struct request *get_request(struct request_queue *q, unsigned int op,
rl = blk_get_rl(q, bio); /* transferred to @rq on success */
retry:
- rq = __get_request(rl, op, bio, flags);
+ rq = __get_request(rl, op, bio, flags, gfp);
if (!IS_ERR(rq))
return rq;
@@ -1591,7 +1591,7 @@ static struct request *blk_old_get_request(struct request_queue *q,
if (ret)
return ERR_PTR(ret);
spin_lock_irq(q->queue_lock);
- rq = get_request(q, op, NULL, flags);
+ rq = get_request(q, op, NULL, flags, gfp_mask);
if (IS_ERR(rq)) {
spin_unlock_irq(q->queue_lock);
blk_queue_exit(q);
@@ -2057,7 +2057,7 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
* Returns with the queue unlocked.
*/
blk_queue_enter_live(q);
- req = get_request(q, bio->bi_opf, bio, 0);
+ req = get_request(q, bio->bi_opf, bio, 0, __GFP_DIRECT_RECLAIM);
if (IS_ERR(req)) {
blk_queue_exit(q);
__wbt_done(q->rq_wb, wb_acct);
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 61d280f560df..b36e73090018 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1933,10 +1933,6 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
struct request *req;
struct scsi_request *rq;
- /*
- * blk_get_request with GFP_KERNEL (__GFP_RECLAIM) sleeps until a
- * request becomes available
- */
req = blk_get_request(sdev->request_queue, REQ_OP_SCSI_IN, 0);
if (IS_ERR(req))
return;
--
2.17.0
next prev parent reply other threads:[~2018-05-09 7:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 7:54 fix confusion around GFP_* flags and blk_get_request Christoph Hellwig
2018-05-09 7:54 ` [PATCH 1/6] scsi/osd: remove the gfp argument to osd_start_request Christoph Hellwig
2018-05-14 15:14 ` Bart Van Assche
2018-05-09 7:54 ` [PATCH 2/6] block: fix __get_request documentation Christoph Hellwig
2018-05-14 15:22 ` Bart Van Assche
2018-05-09 7:54 ` [PATCH 3/6] block: sanitize blk_get_request calling conventions Christoph Hellwig
2018-05-14 15:26 ` Bart Van Assche
2018-05-09 7:54 ` Christoph Hellwig [this message]
2018-05-14 15:28 ` [PATCH 4/6] block: pass an explicit gfp_t to get_request Bart Van Assche
2018-05-09 7:54 ` [PATCH 5/6] block: use GFP_NOIO instead of __GFP_DIRECT_RECLAIM Christoph Hellwig
2018-05-14 15:30 ` Bart Van Assche
2018-05-09 7:54 ` [PATCH 6/6] block: consistently use GFP_NOIO instead of __GFP_NORECLAIM Christoph Hellwig
2018-05-14 15:35 ` Bart Van Assche
2018-05-14 14:38 ` fix confusion around GFP_* flags and blk_get_request Christoph Hellwig
2018-05-14 14:54 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180509075408.16388-5-hch@lst.de \
--to=hch@lst.de \
--cc=Bart.VanAssche@wdc.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).