Skip to content

Commit 06d9c29

Browse files
ezequielgarciadedekind
authored andcommitted
UBI: block: Add support for the UBI_VOLUME_UPDATED notification
Static volumes can change its 'used_bytes' when they get updated, and so the block interface must listen to the UBI_VOLUME_UPDATED notification to resize the block device accordingly. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: stable@vger.kernel.org # v3.15+
1 parent 978d649 commit 06d9c29

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎drivers/mtd/ubi/block.c‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,12 @@ static int ubiblock_resize(struct ubi_volume_info *vi)
524524
}
525525

526526
mutex_lock(&dev->dev_mutex);
527-
set_capacity(dev->gd, disk_capacity);
528-
ubi_msg("%s resized to %lld bytes", dev->gd->disk_name, vi->used_bytes);
527+
528+
if (get_capacity(dev->gd) != disk_capacity) {
529+
set_capacity(dev->gd, disk_capacity);
530+
ubi_msg("%s resized to %lld bytes", dev->gd->disk_name,
531+
vi->used_bytes);
532+
}
529533
mutex_unlock(&dev->dev_mutex);
530534
mutex_unlock(&devices_mutex);
531535
return 0;
@@ -549,6 +553,14 @@ static int ubiblock_notify(struct notifier_block *nb,
549553
case UBI_VOLUME_RESIZED:
550554
ubiblock_resize(&nt->vi);
551555
break;
556+
case UBI_VOLUME_UPDATED:
557+
/*
558+
* If the volume is static, a content update might mean the
559+
* size (i.e. used_bytes) was also changed.
560+
*/
561+
if (nt->vi.vol_type == UBI_STATIC_VOLUME)
562+
ubiblock_resize(&nt->vi);
563+
break;
552564
default:
553565
break;
554566
}

0 commit comments

Comments
 (0)