From: Ming Lei <ming.lei@redhat.com>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, ming.lei@redhat.com
Subject: Re: Potential hang on ublk_ctrl_del_dev()
Date: Wed, 4 Jan 2023 13:42:10 +0800 [thread overview]
Message-ID: <Y7URsuwxaAHFmn8S@T590> (raw)
In-Reply-To: <862272BC-C6A3-4A60-A620-4C5596972D01@gmail.com>
On Tue, Jan 03, 2023 at 01:47:37PM -0800, Nadav Amit wrote:
> Hello Ming,
>
> I am trying the ublk and it seems very exciting.
>
> However, I encounter an issue when I remove a ublk device that is mounted or
> in use.
>
> In ublk_ctrl_del_dev(), shouldn’t we *not* wait if ublk_idr_freed() is false?
> It seems to me that it is saner to return -EBUSY in such a case and let
> userspace deal with the results.
>
> For instance, if I run the following (using ubdsrv):
>
> $ mkfs.ext4 /dev/ram0
> $ ./ublk add -t loop -f /dev/ram0
> $ sudo mount /dev/ublkb0 tmp
> $ sudo ./ublk del -a
>
> ublk_ctrl_del_dev() would not be done until the partition is unmounted, and you
> can get a splat that is similar to the one below.
The splat itself can be avoided easily by replace wait_event with
wait_event_timeout() plus loop, but I guess you think the sync delete
isn't good too?
>
> What do you say? Would you agree to change the behavior to return -EBUSY?
It is designed in this way from beginning, and I believe it is just for
the sake of simplicity, and one point is that the device number needs
to be freed after 'ublk del' returns.
But if it isn't friendly from user's viewpoint, we can change to return
-EBUSY. One simple solution is to check if the ublk block device
is opened before running any deletion action, if yes, stop to delete it
and return -EBUSY; otherwise go ahead and stop & delete the pair of devices.
And the userspace part(ublk utility) needs update too.
However, -EBUSY isn't perfect too, cause user has to retry the delete
command manually.
thanks,
Ming
next prev parent reply other threads:[~2023-01-04 5:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 21:47 Potential hang on ublk_ctrl_del_dev() Nadav Amit
2023-01-03 21:51 ` Jens Axboe
2023-01-04 7:50 ` Ming Lei
2023-01-04 5:42 ` Ming Lei [this message]
2023-01-04 18:13 ` Nadav Amit
2023-01-05 3:16 ` Ming Lei
2023-01-05 17:52 ` Nadav Amit
2023-01-06 1:40 ` 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=Y7URsuwxaAHFmn8S@T590 \
--to=ming.lei@redhat.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