[PATCH OLK-6.6] nbd: skip the capacity-change printk on device bringup and release
hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9724 ---------------------------------------- Before commit 2ebcabf3dba5 ("nbd: use set_capacity_and_notify"), nbd setup called nbd_set_size() to update the size and did not print "detected capacity change". On the release path nbd_config_put() calls invalidate_disk(), which calls set_capacity(), and that path did not print either. For a genuine size change like size1 -> size2 this printk should remain, but for nbd setup or release it should not be printed, especially since it adds latency to the setup path. Skip set_capacity_and_notify() and use the silent set_capacity() when either side of the change is 0, i.e. on bringup (0 -> size) . Runtime resizes keep set_capacity_and_notify() for the message and uevent, and the explicit kobject_uevent() preserves a uevent on every call as blktests expects. Fixes: 2ebcabf3dba5 ("nbd: use set_capacity_and_notify") Signed-off-by: Yang Erkun <yangerkun@huawei.com> --- drivers/block/nbd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index f9b51b09730a..be2191f7c4c1 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -355,7 +355,11 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, if (max_part) set_bit(GD_NEED_PART_SCAN, &nbd->disk->state); - if (!set_capacity_and_notify(nbd->disk, bytesize >> 9)) + /* Avoid the capacity-change printk on probe (0 -> size) */ + if (!get_capacity(nbd->disk)) { + set_capacity(nbd->disk, bytesize >> 9); + kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); + } else if (!set_capacity_and_notify(nbd->disk, bytesize >> 9)) kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); return 0; } -- 2.52.0
hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9724 ---------------------------------------- Before commit 2ebcabf3dba5 ("nbd: use set_capacity_and_notify"), nbd setup called nbd_set_size() to update the size and did not print "detected capacity change". On the release path nbd_config_put() calls invalidate_disk(), which calls set_capacity(), and that path did not print either. For a genuine size change like size1 -> size2 this printk should remain, but for nbd setup or release it should not be printed, especially since it adds latency to the setup path. Skip set_capacity_and_notify() and use the silent set_capacity() when either side of the change is 0, i.e. on bringup (0 -> size) . Runtime resizes keep set_capacity_and_notify() for the message and uevent, and the explicit kobject_uevent() preserves a uevent on every call as blktests expects. Fixes: 2ebcabf3dba5 ("nbd: use set_capacity_and_notify") Signed-off-by: Yang Erkun <yangerkun@huawei.com> --- drivers/block/nbd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index f9b51b09730a..be2191f7c4c1 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -355,7 +355,11 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, if (max_part) set_bit(GD_NEED_PART_SCAN, &nbd->disk->state); - if (!set_capacity_and_notify(nbd->disk, bytesize >> 9)) + /* Avoid the capacity-change printk on probe (0 -> size) */ + if (!get_capacity(nbd->disk)) { + set_capacity(nbd->disk, bytesize >> 9); + kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); + } else if (!set_capacity_and_notify(nbd->disk, bytesize >> 9)) kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); return 0; } -- 2.52.0
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/25737 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/UHF... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/25737 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/UHF...
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/25735 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/P6A... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/25735 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/P6A...
participants (2)
-
patchwork bot -
Yang Erkun