Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rnbd-clt: check capacity inside rnbd_clt_change_capacity

Currently, process_msg_open_rsp checks if capacity changed or not before
call rnbd_clt_change_capacity while the checking also make sense for
rnbd_clt_resize_dev_store, let's move the checking into the function.

Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Link: https://lore.kernel.org/r/20220706133152.12058-7-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Guoqing Jiang and committed by
Jens Axboe
fb516fa3 59f070de

+7 -6
+7 -6
drivers/block/rnbd/rnbd-clt.c
··· 71 71 static int rnbd_clt_change_capacity(struct rnbd_clt_dev *dev, 72 72 size_t new_nsectors) 73 73 { 74 + if (get_capacity(dev->gd) == new_nsectors) 75 + return 0; 76 + 77 + /* 78 + * If the size changed, we need to revalidate it 79 + */ 74 80 rnbd_clt_info(dev, "Device size changed from %llu to %zu sectors\n", 75 81 get_capacity(dev->gd), new_nsectors); 76 82 set_capacity_and_notify(dev->gd, new_nsectors); ··· 99 93 if (dev->dev_state == DEV_STATE_MAPPED_DISCONNECTED) { 100 94 u64 nsectors = le64_to_cpu(rsp->nsectors); 101 95 102 - /* 103 - * If the device was remapped and the size changed in the 104 - * meantime we need to revalidate it 105 - */ 106 - if (get_capacity(dev->gd) != nsectors) 107 - rnbd_clt_change_capacity(dev, nsectors); 96 + rnbd_clt_change_capacity(dev, nsectors); 108 97 gd_kobj = &disk_to_dev(dev->gd)->kobj; 109 98 kobject_uevent(gd_kobj, KOBJ_ONLINE); 110 99 rnbd_clt_info(dev, "Device online, device remapped successfully\n");