Skip to content

nbd: Defer request transmission to a workqueue

Bart Van Assche linux-block 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8nbd: Wake up config->conn_wait when setting NBD_RT_DISCONNECTEDdrivers/block/nbd.c+2 -10 replies
2/8nbd: Requeue requests directly in nbd_send_cmd()drivers/block/nbd.c+5 -50 replies
3/8nbd: Stop taking a config_refs reference per requestdrivers/block/nbd.c+48 -190 replies
4/8nbd: Defer request transmission to a workqueuedrivers/block/nbd.c+112 -460 replies
5/8nbd: Call sk_set_memalloc() outside nsock->tx_lockdrivers/block/nbd.c+13 -80 replies
6/8nbd: Remove socket lockdep reclassificationdrivers/block/nbd.c+0 -370 replies
7/8nbd: Remove the partial-send handlingdrivers/block/nbd.c+3 -1750 replies
8/8nbd: Remove the sent argument of sock_xmit()drivers/block/nbd.c+8 -100 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/8] nbd: Defer request transmission to a workqueue

Hi Jens,

The NBD driver transmits requests over sockets owned by user space directly from nbd_queue_rq(). Hence, sk_lock is acquired while blk-mq holds q->q_usage_counter and set->srcu. Since other kernel code acquires sk_lock before fs_reclaim, mm->mmap_lock and other subsystem locks, syzbot reports multiple circular locking dependencies. Socket lockdep reclassification, the existing workaround, introduces new races and module reference count leaks, and does not suppress all of these reports.

This patch series fixes these lockdep complaints by deferring request transmission to a workqueue, similar to the loop driver, and by removing the socket lockdep reclassification code. Since requests are no longer transmitted from a context in which signals can be pending, the partial-send handling code is removed.

This patch series is organized as follows:
- Patch 1 fixes a missing wakeup of wait_for_reconnect() callers when NBD_RT_DISCONNECTED is set.
- Patches 2 and 3 prepare for deferring request transmission by simplifying the nbd_send_cmd() return values and by no longer taking a config_refs reference for each request.
- Patch 4 defers request transmission to a workqueue.
- Patch 5 fixes a nsock->tx_lock -> cpu_hotplug_lock lockdep complaint.
- Patch 6 removes the socket lockdep reclassification code.
- Patches 7 and 8 remove the partial-send handling code that has become unreachable.

Please consider this patch series for the next merge window.

Thanks,

Bart.

Bart Van Assche (8):
nbd: Wake up config->conn_wait when setting NBD_RT_DISCONNECTED
nbd: Requeue requests directly in nbd_send_cmd()
nbd: Stop taking a config_refs reference per request
nbd: Defer request transmission to a workqueue
nbd: Call sk_set_memalloc() outside nsock->tx_lock
nbd: Remove socket lockdep reclassification
nbd: Remove the partial-send handling
nbd: Remove the sent argument of sock_xmit()

 drivers/block/nbd.c | 394 ++++++++++++++++----------------------------
 1 file changed, 142 insertions(+), 252 deletions(-)