nbd: Use invalidate_disk() helper on disconnect
authorXie Yongji <xieyongji@bytedance.com>
Wed, 22 Sep 2021 12:37:11 +0000 (20:37 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 21 Oct 2021 16:12:41 +0000 (10:12 -0600)
commit435c2acb307f19acc791b4295e29cc53a82bd24d
tree941a3a4dbb7bd27ce5fa1d71c30cacd72814a465
parent19f553db2ac03cb8407ec8efb8e140951afdfb87
nbd: Use invalidate_disk() helper on disconnect

When a nbd device encounters a writeback error, that error will
get propagated to the bd_inode's wb_err field. Then if this nbd
device's backend is disconnected and another is attached, we will
get back the previous writeback error on fsync, which is unexpected.

To fix it, let's use invalidate_disk() helper to invalidate the
disk on disconnect instead of just setting disk's capacity to zero.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210922123711.187-5-xieyongji@bytedance.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/nbd.c