On Thu, May 07, 2020 at 07:20:50AM -0700, Christoph Hellwig wrote: > 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@xxxxxxxxxx> > > Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx> > > Cc: Hou Tao <houtao1@xxxxxxxxxx> > > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> > > --- > > 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? You are right, blk_account_io_merge needs it too. > > Maybe it should go into hd_struct_put and the other helpers to be > centralized? I think that is doable. Thanks, Ming