Re: [PATCH] block: ublk: improve handling device deletion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> > Suggested-by: Nadav Amit <nadav.amit@xxxxxxxxx>
> > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
> 
> 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@xxxxxx/T/#u

Thanks,
Ming




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux