nbd: fix I/O hang on dead socket and rate-limit console error - #37
Open
blktests-ci-block-trial[bot] wants to merge 1 commit into
Open
nbd: fix I/O hang on dead socket and rate-limit console error#37blktests-ci-block-trial[bot] wants to merge 1 commit into
blktests-ci-block-trial[bot] wants to merge 1 commit into
Conversation
When an NBD device is configured with a timeout of 0, a closed socket can lead to a permanent I/O hang. The sequence is as follows: a request is sent and marked in-flight, but then the socket becomes dead (e.g., due to a connection failure). Since the socket is dead, no reply will ever arrive. In nbd_xmit_timeout(), if the configured timeout is 0, the code currently only checks if the socket has been replaced by comparing cookies. If the cookie still matches, the request timer is unconditionally reset and the request stays in-flight forever. This causes tasks to hang indefinitely in TASK_UNINTERRUPTIBLE, triggering the hung task detector: INFO: task udevd:5915 blocked in I/O wait for more than 143 seconds. Call Trace: <TASK> schedule+0x164/0x2b0 io_schedule+0x7f/0xd0 folio_wait_bit_common+0x836/0xbc0 do_read_cache_folio+0x1ac/0x590 read_part_sector+0xb6/0x2b0 adfspart_check_POWERTEC+0x9a/0x7a0 bdev_disk_changed+0x851/0x17a0 blkdev_get_whole+0x372/0x510 bdev_open+0x324/0xd70 ... </TASK> Fix this by checking nsock->dead in addition to the cookie check in nbd_xmit_timeout(). If the socket is dead, the command is requeued. Requeuing returns the request to the existing fallback, reconnect, or failure policy. For the reported configuration where no reconnect is possible, this results in the request being properly failed, which terminates the hung operation. A secondary issue was observed where repeated attempts to connect to an already-in-use NBD device cause console spam because the "nbd%d already in use" error message in nbd_genl_connect() is not rate-limited. This can delay console_unlock() and trigger NMI backtraces. This is fixed by changing the pr_err() to pr_err_ratelimited(). Fixes: 2c27254 ("nbd: requeue command if the soecket is changed") Assisted-by: Gemini:gemini-3.1-pro-preview Gemini:gemini-3-flash-preview syzbot Reported-by: syzbot+82de77d3f217960f087d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=82de77d3f217960f087d Link: https://syzkaller.appspot.com/ai_job?id=40e56b38-627e-4b49-b7ac-d3a21e77dba2 Signed-off-by: Kusaram Devineni <kusaram@devineni.in>
Author
|
Upstream branch: 248951d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: nbd: fix I/O hang on dead socket and rate-limit console error
version: 1
url: http://redsun45:8000/project/linux-block/list/?series=364