aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>2014-08-29 18:42:29 -0300
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-09-16 19:02:04 +0300
commit06d9c2905f745c8b1920a335cbb366ba6b0fc754 (patch)
treee5a777c9e2bf459f5ae1b5258218d05fdce3e6d2 /drivers/mtd
parentUBI: block: Fix block device size setting (diff)
downloadlinux-dev-06d9c2905f745c8b1920a335cbb366ba6b0fc754.tar.xz
linux-dev-06d9c2905f745c8b1920a335cbb366ba6b0fc754.zip
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+
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/block.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index 581784485376..8876c7d3d712 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -524,8 +524,12 @@ static int ubiblock_resize(struct ubi_volume_info *vi)
}
mutex_lock(&dev->dev_mutex);
- set_capacity(dev->gd, disk_capacity);
- ubi_msg("%s resized to %lld bytes", dev->gd->disk_name, vi->used_bytes);
+
+ if (get_capacity(dev->gd) != disk_capacity) {
+ set_capacity(dev->gd, disk_capacity);
+ ubi_msg("%s resized to %lld bytes", dev->gd->disk_name,
+ vi->used_bytes);
+ }
mutex_unlock(&dev->dev_mutex);
mutex_unlock(&devices_mutex);
return 0;
@@ -549,6 +553,14 @@ static int ubiblock_notify(struct notifier_block *nb,
case UBI_VOLUME_RESIZED:
ubiblock_resize(&nt->vi);
break;
+ case UBI_VOLUME_UPDATED:
+ /*
+ * If the volume is static, a content update might mean the
+ * size (i.e. used_bytes) was also changed.
+ */
+ if (nt->vi.vol_type == UBI_STATIC_VOLUME)
+ ubiblock_resize(&nt->vi);
+ break;
default:
break;
}