public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
	Caleb Sander Mateos <csander@purestorage.com>,
	Uday Shankar <ushankar@purestorage.com>
Subject: Re: [PATCH V2] ublk: fix deadlock when reading partition table
Date: Sat, 13 Dec 2025 10:28:35 +0800	[thread overview]
Message-ID: <aTzPUzyZ21lVOk1L@fedora> (raw)
In-Reply-To: <8dd3c141-3e92-44f3-91e2-2bf4827b36a4@kernel.dk>

On Fri, Dec 12, 2025 at 12:49:49PM -0700, Jens Axboe wrote:
> On 12/12/25 7:34 AM, Ming Lei wrote:
> > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> > index df9831783a13..38f138f248e6 100644
> > --- a/drivers/block/ublk_drv.c
> > +++ b/drivers/block/ublk_drv.c
> > @@ -1080,12 +1080,20 @@ static inline struct ublk_uring_cmd_pdu *ublk_get_uring_cmd_pdu(
> >  	return io_uring_cmd_to_pdu(ioucmd, struct ublk_uring_cmd_pdu);
> >  }
> >  
> > +static void ublk_end_request(struct request *req, blk_status_t error)
> > +{
> > +	local_bh_disable();
> > +	blk_mq_end_request(req, error);
> > +	local_bh_enable();
> > +}
> 
> This is really almost too ugly to live, as a work-around for what just
> happens to be in __fput_deferred()... Surely we can come up with
> something better here? Heck even a PF_ flag would be better than this,
> imho.

task flag will switch to release all files opened by current from wq context,
and there may be chance to cause regression, especially this fix needs to
backport to stable.

So I'd suggest to take it for safe stable purpose.


> 
> > @@ -1117,14 +1125,26 @@ static inline void __ublk_complete_rq(struct request *req, struct ublk_io *io,
> >  	if (unlikely(unmapped_bytes < io->res))
> >  		io->res = unmapped_bytes;
> >  
> > -	if (blk_update_request(req, BLK_STS_OK, io->res))
> > +	/*
> > +	 * Run bio->bi_end_io() from softirq context for preventing this
> > +	 * ublk's blkdev_release() from being called on current's task
> > +	 * work, see fput() implementation.
> 
> But that's not what it does, running it from softirq context. It simply
> disables local bottomhalf interrupts to trick __fput_deferred(), it's
> not scheduling ->bi_end_io() to run from softirq context itself.

Yes, I can twink the words if you don't object this approach, but it isn't
different from core code viewpoint, in_interrupt() returns true.

Thanks,
Ming


  reply	other threads:[~2025-12-13  2:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-12 14:34 [PATCH V2] ublk: fix deadlock when reading partition table Ming Lei
2025-12-12 16:57 ` Caleb Sander Mateos
2025-12-12 19:49 ` Jens Axboe
2025-12-13  2:28   ` Ming Lei [this message]
2025-12-14  6:41     ` Jens Axboe
2025-12-16  8:56       ` Ming Lei
2025-12-16 15:03         ` Jens Axboe
2025-12-16 17:57           ` Jens Axboe
2025-12-17  3:09             ` Ming Lei
2025-12-17  3:19               ` Jens Axboe
2025-12-17  3:33                 ` Ming Lei
2025-12-18  2:37                   ` Jens Axboe
2025-12-18  2:41 ` 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=aTzPUzyZ21lVOk1L@fedora \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ushankar@purestorage.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