]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
UBI: block: Add support for the UBI_VOLUME_UPDATED notification
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Fri, 29 Aug 2014 21:42:29 +0000 (18:42 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Nov 2014 18:10:24 +0000 (10:10 -0800)
commit 06d9c2905f745c8b1920a335cbb366ba6b0fc754 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/ubi/block.c

index e64765944d15069ba9a3237c623d9a9d8313c969..5f9a1e2f3fd4626178aa800ff8def795f32486f8 100644 (file)
@@ -523,8 +523,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;
@@ -548,6 +552,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;
        }