linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Yufen Yu <yuyufen@huawei.com>,
	Christoph Hellwig <hch@infradead.org>,
	Hou Tao <houtao1@huawei.com>
Subject: Re: [PATCH 4/4] block: don't hold part0's refcount in IO path
Date: Thu, 7 May 2020 07:20:50 -0700	[thread overview]
Message-ID: <20200507142050.GD11551@infradead.org> (raw)
In-Reply-To: <20200507085239.1354854-5-ming.lei@redhat.com>

On Thu, May 07, 2020 at 04:52:39PM +0800, Ming Lei wrote:
> gendisk can't be gone when there is IO activity, so not hold
> part0's refcount in IO path.
> 
> Cc: Yufen Yu <yuyufen@huawei.com>
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: Hou Tao <houtao1@huawei.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>  block/blk-core.c | 3 ++-
>  block/genhd.c    | 1 -
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 826a8980997d..56cc61354671 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -1343,7 +1343,8 @@ void blk_account_io_done(struct request *req, u64 now)
>  		part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
>  		part_dec_in_flight(req->q, part, rq_data_dir(req));
>  
> -		hd_struct_put(part);
> +		if (part->partno)
> +			hd_struct_put(part);
>  		part_stat_unlock();

Doesn't blk_account_io_merge needs the check as well?

Maybe it should go into hd_struct_put and the other helpers to be
centralized?

Otherwise this looks fine to me.

  reply	other threads:[~2020-05-07 14:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07  8:52 [PATCH 0/4] block: fix partition use-after-free and optimization Ming Lei
2020-05-07  8:52 ` [PATCH 1/4] block: fix use-after-free on cached last_lookup partition Ming Lei
2020-05-07 14:16   ` Christoph Hellwig
2020-05-08  1:54     ` Ming Lei
2020-05-07  8:52 ` [PATCH 2/4] block: only define 'nr_sects_seq' in hd_part for 32bit SMP Ming Lei
2020-05-07 14:16   ` Christoph Hellwig
2020-05-07  8:52 ` [PATCH 3/4] block: re-organize fields of 'struct hd_part' Ming Lei
2020-05-07 14:16   ` Christoph Hellwig
2020-05-07  8:52 ` [PATCH 4/4] block: don't hold part0's refcount in IO path Ming Lei
2020-05-07 14:20   ` Christoph Hellwig [this message]
2020-05-08  1:59     ` Ming Lei
  -- strict thread matches above, loose matches on Subject: below --
2020-01-09  6:21 [PATCH 0/4] block: fix partition use-after-free and optimization Ming Lei
2020-01-09  6:21 ` [PATCH 4/4] block: don't hold part0's refcount in IO path Ming Lei

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=20200507142050.GD11551@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=houtao1@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=yuyufen@huawei.com \
    /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).