Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06d9c290 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Artem Bityutskiy
Browse files

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: default avatarEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: stable@vger.kernel.org # v3.15+
parent 978d6496
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -524,8 +524,12 @@ static int ubiblock_resize(struct ubi_volume_info *vi)
	}

	mutex_lock(&dev->dev_mutex);

	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);
		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;
	}