lkml.org 
[lkml]   [2019]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.2 023/144] bdev: Fixup error handling in blkdev_get()
    Date
    From: Jan Kara <jack@suse.cz>

    commit e91455bad5cff40a8c232f2204a5104127e3fec2 upstream.

    Commit 89e524c04fa9 ("loop: Fix mount(2) failure due to race with
    LOOP_SET_FD") converted blkdev_get() to use the new helpers for
    finishing claiming of a block device. However the conversion botched the
    error handling in blkdev_get() and thus the bdev has been marked as held
    even in case __blkdev_get() returned error. This led to occasional
    warnings with block/001 test from blktests like:

    kernel: WARNING: CPU: 5 PID: 907 at fs/block_dev.c:1899 __blkdev_put+0x396/0x3a0

    Correct the error handling.

    CC: stable@vger.kernel.org
    Fixes: 89e524c04fa9 ("loop: Fix mount(2) failure due to race with LOOP_SET_FD")
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    fs/block_dev.c | 5 ++++-
    1 file changed, 4 insertions(+), 1 deletion(-)

    --- a/fs/block_dev.c
    +++ b/fs/block_dev.c
    @@ -1723,7 +1723,10 @@ int blkdev_get(struct block_device *bdev

    /* finish claiming */
    mutex_lock(&bdev->bd_mutex);
    - bd_finish_claiming(bdev, whole, holder);
    + if (!res)
    + bd_finish_claiming(bdev, whole, holder);
    + else
    + bd_abort_claiming(bdev, whole, holder);
    /*
    * Block event polling for write claims if requested. Any
    * write holder makes the write_holder state stick until

    \
     
     \ /
      Last update: 2019-08-14 19:03    [W:4.025 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site