block: Fix dio->ref leak on integrity error in __blkdev_direct_IO()#1005
Open
blktests-ci[bot] wants to merge 1 commit into
Open
block: Fix dio->ref leak on integrity error in __blkdev_direct_IO()#1005blktests-ci[bot] wants to merge 1 commit into
blktests-ci[bot] wants to merge 1 commit into
Conversation
Author
|
Upstream branch: bade58e |
7d8604f to
4cc45a3
Compare
Author
|
Upstream branch: 4edcdef |
dcd0613 to
0c9a008
Compare
Author
|
Upstream branch: 4edcdef |
0c9a008 to
787106d
Compare
4cc45a3 to
90ffd56
Compare
When __blkdev_direct_IO() splits an I/O across multiple bios and bio_integrity_map_iter() fails on a non-first bio, the function jumps to the 'fail' label which frees the current bio without accounting for the dio->ref increments from previously submitted bios. The in-flight bios complete normally but their atomic_dec_and_test() in blkdev_bio_end_io() can never bring dio->ref to zero, leaving the dio structure (and the first bio it is embedded in) permanently leaked. For synchronous I/O, the waiter is never woken, causing a hang. Fix by matching the existing error handling pattern used for blkdev_iov_iter_get_pages() failure: end the current bio with an error status and break out of the submission loop. This ensures the normal completion path properly accounts for all dio->ref references, both from the current errored bio and from any in-flight bios. The NOWAIT error path is unaffected as its goto fail only triggers on the first iteration where no bios have been submitted yet. Cc: stable@vger.kernel.org Fixes: 3d8b5a2 ("block: add support to pass user meta buffer") Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Reviewed-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
Author
|
Upstream branch: dc59e4f |
787106d to
a5bfdbb
Compare
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: block: Fix dio->ref leak on integrity error in __blkdev_direct_IO()
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1116406