All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Manzanares <Adam.Manzanares@wdc.com>
To: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>
Cc: "viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 7/7] block: Initialize BIO I/O priority early
Date: Mon, 19 Nov 2018 19:11:53 +0000	[thread overview]
Message-ID: <d0ea8395e43bd634a9001d9cf96bc807cdb688d7.camel@wdc.com> (raw)
In-Reply-To: <20181119035131.11255-8-damien.lemoal@wdc.com>

On Mon, 2018-11-19 at 12:51 +0900, Damien Le Moal wrote:
> For the synchronous I/O path case (read(), write() etc system calls),
> a
> BIO I/O priority is not initialized until the execution of
> blk_init_request_from_bio() when the BIO is submitted and a request
> initialized for the BIO execution. This is due to the ki_ioprio field
> of
> the struct kiocb defined on stack being always initialized to
> IOPRIO_CLASS_NONE, regardless of the calling process I/O context
> ioprio
> value set with ioprio_set(). This late initialization can result in
> the
> BIO being merged to pending requests even when the I/O priorities
> differ.
> 
> Fix this by initializing the ki_iopriority field of on stack struct
> kiocb using the get_current_ioprio() helper, ensuring that all BIOs
> allocated and submitted for the system call execution see the correct
> intended I/O priority early. With this, since a BIO I/O priority is
> always set to the intended effective value for both the sync and
> async
> path, blk_init_request_from_bio() can be simplified.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>

Nice cleanup, looks good. Thanks Damien.

Reviewed-by: Adam Manzanares <adam.manzanares@wdc.com>


> ---
>  block/blk-core.c   | 5 +----
>  include/linux/fs.h | 2 +-
>  2 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index dde30b08aa14..04f5be473638 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -814,10 +814,7 @@ void blk_init_request_from_bio(struct request
> *req, struct bio *bio)
>  		req->cmd_flags |= REQ_FAILFAST_MASK;
>  
>  	req->__sector = bio->bi_iter.bi_sector;
> -	if (ioprio_valid(bio_prio(bio)))
> -		req->ioprio = bio_prio(bio);
> -	else
> -		req->ioprio = get_current_ioprio();
> +	req->ioprio = bio_prio(bio);
>  	req->write_hint = bio->bi_write_hint;
>  	blk_rq_bio_prep(req->q, req, bio);
>  }
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index c95c0807471f..a1ab233e6469 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2021,7 +2021,7 @@ static inline void init_sync_kiocb(struct kiocb
> *kiocb, struct file *filp)
>  		.ki_filp = filp,
>  		.ki_flags = iocb_flags(filp),
>  		.ki_hint = ki_hint_validate(file_write_hint(filp)),
> -		.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0),
> +		.ki_ioprio = get_current_ioprio(),
>  	};
>  }
>  

      parent reply	other threads:[~2018-11-19 19:11 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19  3:51 [PATCH 0/7] Improve I/O priority handling Damien Le Moal
2018-11-19  3:51 ` [PATCH 1/7] aio: Comment use of IOCB_FLAG_IOPRIO aio flag Damien Le Moal
2018-11-19  8:12   ` Christoph Hellwig
2018-11-19  8:15   ` Johannes Thumshirn
2018-11-19  3:51 ` [PATCH 2/7] block: Remove bio->bi_ioc Damien Le Moal
2018-11-19  8:13   ` Christoph Hellwig
2018-11-19  8:16   ` Johannes Thumshirn
2018-11-19 19:07   ` Adam Manzanares
2018-11-20 17:21   ` Ming Lei
2018-11-20 17:31     ` Jens Axboe
2018-11-20 23:58       ` Damien Le Moal
2018-11-21  1:24         ` Ming Lei
2018-11-21  1:31           ` Damien Le Moal
2018-11-21  2:10         ` Jens Axboe
2018-11-21  2:14           ` Damien Le Moal
2018-11-21  2:45           ` Damien Le Moal
2018-11-21  2:48             ` Jens Axboe
2018-11-21  2:50               ` Damien Le Moal
2018-11-21  1:21       ` Ming Lei
2018-11-19  3:51 ` [PATCH 3/7] block: Fix get_task_ioprio() default return value Damien Le Moal
2018-11-19  8:16   ` Christoph Hellwig
2018-11-20  1:47     ` Damien Le Moal
2018-11-19  3:51 ` [PATCH 4/7] block: Introduce get_current_ioprio() Damien Le Moal
2018-11-19  8:17   ` Christoph Hellwig
2018-11-19  8:26   ` Johannes Thumshirn
2018-11-19 18:17   ` Adam Manzanares
2018-11-19 23:46     ` Damien Le Moal
2018-11-19  3:51 ` [PATCH 5/7] aio: Fix fallback I/O priority value Damien Le Moal
2018-11-19  8:18   ` Christoph Hellwig
2018-11-19  8:27   ` Johannes Thumshirn
2018-11-19 19:08   ` Adam Manzanares
2018-11-19  3:51 ` [PATCH 6/7] block: prevent merging of requests with different priorities Damien Le Moal
2018-11-19  8:19   ` Christoph Hellwig
2018-11-19  8:31   ` Johannes Thumshirn
2018-11-19  3:51 ` [PATCH 7/7] block: Initialize BIO I/O priority early Damien Le Moal
2018-11-19  8:19   ` Christoph Hellwig
2018-11-19 19:11   ` Adam Manzanares [this message]

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=d0ea8395e43bd634a9001d9cf96bc807cdb688d7.camel@wdc.com \
    --to=adam.manzanares@wdc.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.