Commit 06d9c2905f745c8b1920a335cbb366ba6b0fc754
Committed by
Artem Bityutskiy
1 parent
978d649675
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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+
Showing 1 changed file with 14 additions and 2 deletions Side-by-side Diff
drivers/mtd/ubi/block.c
... | ... | @@ -524,8 +524,12 @@ |
524 | 524 | } |
525 | 525 | |
526 | 526 | 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 | + } | |
529 | 533 | mutex_unlock(&dev->dev_mutex); |
530 | 534 | mutex_unlock(&devices_mutex); |
531 | 535 | return 0; |
... | ... | @@ -548,6 +552,14 @@ |
548 | 552 | break; |
549 | 553 | case UBI_VOLUME_RESIZED: |
550 | 554 | ubiblock_resize(&nt->vi); |
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); | |
551 | 563 | break; |
552 | 564 | default: |
553 | 565 | break; |