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
This commit is contained in:
Bart Van Assche
2019-01-05 02:04:20 +00:00
parent 3ee65c81cd
commit addfc2e6d4

View File

@@ -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" : "");