Re: [PATCH 4/4] block: don't hold part0's refcount in IO path

Christoph Hellwig
2020-05-07T14:20:52Z

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.