diff options
author | Ezequiel Garcia <ezequiel.garcia@free-electrons.com> | 2014-08-29 17:42:29 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2014-09-16 12:02:04 -0400 |
commit | 06d9c2905f745c8b1920a335cbb366ba6b0fc754 (patch) | |
tree | e5a777c9e2bf459f5ae1b5258218d05fdce3e6d2 | |
parent | 978d6496758d19de2431ebf163337fc7b92f8c45 (diff) |
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+
-rw-r--r-- | drivers/mtd/ubi/block.c | 16 |
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) | |||
524 | } | 524 | } |
525 | 525 | ||
526 | mutex_lock(&dev->dev_mutex); | 526 | mutex_lock(&dev->dev_mutex); |
527 | set_capacity(dev->gd, disk_capacity); | 527 | |
528 | ubi_msg("%s resized to %lld bytes", dev->gd->disk_name, vi->used_bytes); | 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 | } | ||
529 | mutex_unlock(&dev->dev_mutex); | 533 | mutex_unlock(&dev->dev_mutex); |
530 | mutex_unlock(&devices_mutex); | 534 | mutex_unlock(&devices_mutex); |
531 | return 0; | 535 | return 0; |
@@ -549,6 +553,14 @@ static int ubiblock_notify(struct notifier_block *nb, | |||
549 | case UBI_VOLUME_RESIZED: | 553 | case UBI_VOLUME_RESIZED: |
550 | ubiblock_resize(&nt->vi); | 554 | ubiblock_resize(&nt->vi); |
551 | break; | 555 | 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; | ||
552 | default: | 564 | default: |
553 | break; | 565 | break; |
554 | } | 566 | } |