diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 2ad342abe..fb2a25705 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -426,7 +426,7 @@ static struct file *vdisk_open(const struct scst_vdisk_dev *virt_dev) * * Description: *************************************************************/ -static int vdisk_get_check_file_size(const char *file_name, bool blockio, +static int vdisk_get_file_size(const char *file_name, bool blockio, loff_t *file_size) { struct inode *inode; @@ -543,7 +543,7 @@ static int vdisk_attach(struct scst_device *dev) if (virt_dev->nullio) err = VDISK_NULLIO_SIZE; else { - res = vdisk_get_check_file_size(virt_dev->file_name, + res = vdisk_get_file_size(virt_dev->file_name, virt_dev->blockio, &err); if (res != 0) goto out; @@ -2839,22 +2839,28 @@ static void vdisk_report_registering(const char *type, /* scst_vdisk_mutex supposed to be held */ static int vdisk_resync_size(struct scst_vdisk_dev *virt_dev) { - loff_t err; + loff_t file_size; int res = 0; if (!virt_dev->nullio) { - res = vdisk_get_check_file_size(virt_dev->file_name, - virt_dev->blockio, &err); + res = vdisk_get_file_size(virt_dev->file_name, + virt_dev->blockio, &file_size); if (res != 0) goto out; } else - err = VDISK_NULLIO_SIZE; + file_size = VDISK_NULLIO_SIZE; + + if (file_size == virt_dev->file_size) { + PRINT_INFO("Size of virtual disk %s remained the same", + virt_dev->name); + goto out; + } res = scst_suspend_activity(true); if (res != 0) goto out; - virt_dev->file_size = err; + virt_dev->file_size = file_size; virt_dev->nblocks = virt_dev->file_size >> virt_dev->block_shift; scst_dev_del_all_thr_data(virt_dev->dev); @@ -3340,7 +3346,7 @@ static int vcdrom_change(char *p, char *name) strncpy(fn, file_name, len); virt_dev->file_name = fn; - res = vdisk_get_check_file_size(virt_dev->file_name, + res = vdisk_get_file_size(virt_dev->file_name, virt_dev->blockio, &err); if (res != 0) goto out_free;