From: Greg Kroah-Hartman Date: Mon, 21 Jan 2019 14:23:35 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v4.20.4~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=218bf6e77c819a26cb227d8eac14743d9d91a297;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: nbd-set-the-logical-and-physical-blocksize-properly.patch nbd-use-set_blocksize-to-set-device-blocksize.patch --- diff --git a/queue-4.9/nbd-set-the-logical-and-physical-blocksize-properly.patch b/queue-4.9/nbd-set-the-logical-and-physical-blocksize-properly.patch new file mode 100644 index 00000000000..3d6fb05aed1 --- /dev/null +++ b/queue-4.9/nbd-set-the-logical-and-physical-blocksize-properly.patch @@ -0,0 +1,94 @@ +From e544541b0765c341174613b416d4b074fa7571c2 Mon Sep 17 00:00:00 2001 +From: Josef Bacik +Date: Mon, 13 Feb 2017 10:39:47 -0500 +Subject: nbd: set the logical and physical blocksize properly + +From: Josef Bacik + +commit e544541b0765c341174613b416d4b074fa7571c2 upstream. + +We noticed when trying to do O_DIRECT to an export on the server side +that we were getting requests smaller than the 4k sectorsize of the +device. This is because the client isn't setting the logical and +physical blocksizes properly for the underlying device. Fix this up by +setting the queue blocksizes and then calling bd_set_size. + +Signed-off-by: Josef Bacik +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/block/nbd.c | 36 ++++++++++++++---------------------- + 1 file changed, 14 insertions(+), 22 deletions(-) + +--- a/drivers/block/nbd.c ++++ b/drivers/block/nbd.c +@@ -108,7 +108,7 @@ static const char *nbdcmd_to_ascii(int c + + static int nbd_size_clear(struct nbd_device *nbd, struct block_device *bdev) + { +- bdev->bd_inode->i_size = 0; ++ bd_set_size(bdev, 0); + set_capacity(nbd->disk, 0); + kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); + +@@ -117,29 +117,20 @@ static int nbd_size_clear(struct nbd_dev + + static void nbd_size_update(struct nbd_device *nbd, struct block_device *bdev) + { +- if (!nbd_is_connected(nbd)) +- return; +- +- bdev->bd_inode->i_size = nbd->bytesize; ++ blk_queue_logical_block_size(nbd->disk->queue, nbd->blksize); ++ blk_queue_physical_block_size(nbd->disk->queue, nbd->blksize); ++ bd_set_size(bdev, nbd->bytesize); + set_capacity(nbd->disk, nbd->bytesize >> 9); + kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); + } + +-static int nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, ++static void nbd_size_set(struct nbd_device *nbd, struct block_device *bdev, + loff_t blocksize, loff_t nr_blocks) + { +- int ret; +- +- ret = set_blocksize(bdev, blocksize); +- if (ret) +- return ret; +- + nbd->blksize = blocksize; + nbd->bytesize = blocksize * nr_blocks; +- +- nbd_size_update(nbd, bdev); +- +- return 0; ++ if (nbd_is_connected(nbd)) ++ nbd_size_update(nbd, bdev); + } + + static void nbd_end_request(struct nbd_cmd *cmd) +@@ -655,16 +646,17 @@ static int __nbd_ioctl(struct block_devi + case NBD_SET_BLKSIZE: { + loff_t bsize = div_s64(nbd->bytesize, arg); + +- return nbd_size_set(nbd, bdev, arg, bsize); ++ nbd_size_set(nbd, bdev, arg, bsize); ++ return 0; + } + + case NBD_SET_SIZE: +- return nbd_size_set(nbd, bdev, nbd->blksize, +- div_s64(arg, nbd->blksize)); +- ++ nbd_size_set(nbd, bdev, nbd->blksize, ++ div_s64(arg, nbd->blksize)); ++ return 0; + case NBD_SET_SIZE_BLOCKS: +- return nbd_size_set(nbd, bdev, nbd->blksize, arg); +- ++ nbd_size_set(nbd, bdev, nbd->blksize, arg); ++ return 0; + case NBD_SET_TIMEOUT: + if (arg) { + nbd->tag_set.timeout = arg * HZ; diff --git a/queue-4.9/nbd-use-set_blocksize-to-set-device-blocksize.patch b/queue-4.9/nbd-use-set_blocksize-to-set-device-blocksize.patch new file mode 100644 index 00000000000..5a42e2e0188 --- /dev/null +++ b/queue-4.9/nbd-use-set_blocksize-to-set-device-blocksize.patch @@ -0,0 +1,32 @@ +From c8a83a6b54d0ca078de036aafb3f6af58c1dc5eb Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 14 Jan 2019 09:48:09 +0100 +Subject: nbd: Use set_blocksize() to set device blocksize + +From: Jan Kara + +commit c8a83a6b54d0ca078de036aafb3f6af58c1dc5eb upstream. + +NBD can update block device block size implicitely through +bd_set_size(). Make it explicitely set blocksize with set_blocksize() as +this behavior of bd_set_size() is going away. + +CC: Josef Bacik +Signed-off-by: Jan Kara +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/block/nbd.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/block/nbd.c ++++ b/drivers/block/nbd.c +@@ -120,6 +120,7 @@ static void nbd_size_update(struct nbd_d + blk_queue_logical_block_size(nbd->disk->queue, nbd->blksize); + blk_queue_physical_block_size(nbd->disk->queue, nbd->blksize); + bd_set_size(bdev, nbd->bytesize); ++ set_blocksize(bdev, nbd->blksize); + set_capacity(nbd->disk, nbd->bytesize >> 9); + kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); + } diff --git a/queue-4.9/series b/queue-4.9/series index 9000b3a534d..3e544399602 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -50,3 +50,5 @@ loop-fix-double-mutex_unlock-loop_ctl_mutex-in-loop_control_ioctl.patch drm-fb-helper-ignore-the-value-of-fb_var_screeninfo.pixclock.patch mm-memcg-fix-reclaim-deadlock-with-writeback.patch media-vb2-be-sure-to-unlock-mutex-on-errors.patch +nbd-set-the-logical-and-physical-blocksize-properly.patch +nbd-use-set_blocksize-to-set-device-blocksize.patch