Re: Potential hang on ublk_ctrl_del_dev()

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

 



On 1/3/23 2:47?PM, 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.
> 
> What do you say? Would you agree to change the behavior to return -EBUSY?
> 
> Thanks,
> Nadav
> 
> 
> [  974.149938] INFO: task ublk:2250 blocked for more than 120 seconds.
> [  974.157786]       Not tainted 6.1.0 #30
> [  974.162369] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> [  974.171417] task:ublk            state:D stack:0     pid:2250  ppid:2249   flags:0x00004004
> [  974.181054] Call Trace:
> [  974.184097]  <TASK>
> [  974.186726]  __schedule+0x37e/0xe10
> [  974.190915]  ? __this_cpu_preempt_check+0x13/0x20
> [  974.196463]  ? lock_release+0x133/0x2a0
> [  974.201043]  schedule+0x67/0xe0
> [  974.204846]  ublk_ctrl_uring_cmd+0xf45/0x1110
> [  974.210016]  ? lock_is_held_type+0xdd/0x130
> [  974.214990]  ? var_wake_function+0x60/0x60
> [  974.219872]  ? rcu_read_lock_sched_held+0x4f/0x80
> [  974.225443]  io_uring_cmd+0x9a/0x130
> [  974.229743]  ? io_uring_cmd_prep+0xf0/0xf0
> [  974.234638]  io_issue_sqe+0xfe/0x340
> [  974.238946]  io_submit_sqes+0x231/0x750
> [  974.243553]  __x64_sys_io_uring_enter+0x22b/0x640
> [  974.249134]  ? trace_hardirqs_on+0x3c/0xe0
> [  974.254042]  do_syscall_64+0x35/0x80
> [  974.258361]  entry_SYSCALL_64_after_hwframe+0x46/0xb0

Ming, this also looks like ublk doesn't always honor
IO_URING_F_NONBLOCK, we can't be sleeping like that under issue. Then it
should be bounced with -EAGAIN and retried from an io-wq worker.

-- 
Jens Axboe




[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