From addfc2e6d4e3c30f7e51a2a5ba00643e5fc8015a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 5 Jan 2019 02:04:20 +0000 Subject: [PATCH] scst_vdisk: Avoid that saving and restoring scst.conf reduces vdisk_blockio size (merge r7841 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.3.x@7859 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index b9ca431df..f1696e833 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -8771,11 +8771,13 @@ static ssize_t vdev_size_show(struct kobject *kobj, struct kobj_attribute *attr, dev = container_of(kobj, struct scst_device, dev_kobj); virt_dev = dev->dh_priv; size = READ_ONCE(virt_dev->file_size); - - if (virt_dev->nullio && size == VDISK_NULLIO_SIZE) - key = false; - else - key = virt_dev->size_key; + /* + * Make sure that scstadmin only stores the 'size' attribute and that + * the 'size_mb' attribute is not stored. Otherwise when restoring + * scst.conf if 'size' is not a multiple of 1 MB it will be rounded + * down. + */ + key = !(virt_dev->nullio && size == VDISK_NULLIO_SIZE) && !size_shift; return sprintf(buf, "%llu\n%s", size >> size_shift, key ? SCST_SYSFS_KEY_MARK "\n" : "");