From: Ming Lei <ming.lei@redhat.com>
To: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
Cc: linux-block@vger.kernel.org, Nadav Amit <nadav.amit@gmail.com>,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH] block: ublk: improve handling device deletion
Date: Wed, 8 Feb 2023 15:31:29 +0800 [thread overview]
Message-ID: <Y+NP0ZGsSnGDeGT1@T590> (raw)
In-Reply-To: <fcd7fec3-d8f0-f04b-f7eb-10e2d583bfe6@linux.alibaba.com>
On Wed, Feb 08, 2023 at 01:57:42PM +0800, Ziyang Zhang wrote:
> On 2023/2/7 23:07, Ming Lei wrote:
> > Inside ublk_ctrl_del_dev(), when the device is removed, we wait
> > until the device number is freed with holding global lock of
> > ublk_ctl_mutex, this way isn't friendly from user viewpoint:
> >
> > 1) if device is in-use, the current delete command hangs in
> > ublk_ctrl_del_dev(), and user can't break from the handling
> > because wait_event() is used
> >
> > 2) global lock is held, so any new device can't be added and
> > other old devices can't be removed.
> >
> > Improve the deleting handling by the following way, suggested by
> > Nadav:
> >
> > 1) wait without holding the global lock
> >
> > 2) replace wait_event() with wait_event_interruptible()
> >
> > Reported-by: Nadav Amit <nadav.amit@gmail.com>
> > Suggested-by: Nadav Amit <nadav.amit@gmail.com>
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
>
> Hi Ming,
>
> I tried this patch. And the folloing NPE bug was trigged by:
>
> (0) dd if=/dev/zero of=/root/img bs=4096 count=1024768
> (1) ublk add -t loop -f /root/img
> (2) mkdir -p /root/ublk
> (3) mount /dev/ublkb0 /root/ublk
> (4) echo "hello" > /root/ublk
> (5) ./ublk del -n 0
>
> So I delete the ublk device while it is mounting as
> an ext4 filesystem. I think ublk should handle this
> by (1) returning -EBUSY or (2) blocking incoming IO.
That isn't ublk unique, and is one recent block layer regression,
see the following report:
https://lore.kernel.org/linux-block/20230208063552.GA15030@lst.de/T/#u
Thanks,
Ming
next prev parent reply other threads:[~2023-02-08 7:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 15:07 [PATCH] block: ublk: improve handling device deletion Ming Lei
2023-02-08 5:57 ` Ziyang Zhang
2023-02-08 7:31 ` Ming Lei [this message]
2023-02-09 15:12 ` 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=Y+NP0ZGsSnGDeGT1@T590 \
--to=ming.lei@redhat.com \
--cc=ZiyangZhang@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=nadav.amit@gmail.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).