diff mbox

UBI: weaken the 'exclusive' constraint when opening volumes to rename

Message ID 1397681253-5203-1-git-send-email-ezequiel.garcia@free-electrons.com
State Accepted
Headers show

Commit Message

Ezequiel Garcia April 16, 2014, 8:47 p.m. UTC
The UBI volume rename ioctl (UBI_IOCRNVOL) open the volumes in exclusive
mode. The volumes are opened for two reasons: to build a volume rename list,
and a volume remove list.

However, the first open constraint is excessive and can be replaced by
a 'read-write' open mode. The second open constraint is properly set as
'exclusive' given the volume is opened for removal and we don't want any
users around.

By weakening the former 'exclusive' mode, we allow 'read-only' users to keep
the volume open, while a rename is taking place. This is useful to perform
an atomic rename, in a firmware upgrade scenario, while keeping the volume
in read-only use (for instance, if a ubiblock is mounted as rootfs).

It's worth mention this is not the case of UBIFS, which keeps the volume
opened as 'read-write' despite mounted as read-write or read-only mode.

This change was suggested at least twice by Artem:
http://lists.infradead.org/pipermail/linux-mtd/2012-September/044175.html
http://permalink.gmane.org/gmane.linux.drivers.mtd/39866

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/mtd/ubi/cdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Artem Bityutskiy May 5, 2014, 6:39 a.m. UTC | #1
On Wed, 2014-04-16 at 17:47 -0300, Ezequiel Garcia wrote:
> The UBI volume rename ioctl (UBI_IOCRNVOL) open the volumes in exclusive
> mode. The volumes are opened for two reasons: to build a volume rename list,
> and a volume remove list.
> 
> However, the first open constraint is excessive and can be replaced by
> a 'read-write' open mode. The second open constraint is properly set as
> 'exclusive' given the volume is opened for removal and we don't want any
> users around.

Pushed to l2-mtd.git, thanks!
diff mbox

Patch

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index f54562a..7646220 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -731,7 +731,7 @@  static int rename_volumes(struct ubi_device *ubi,
 			goto out_free;
 		}
 
-		re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_EXCLUSIVE);
+		re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_READWRITE);
 		if (IS_ERR(re->desc)) {
 			err = PTR_ERR(re->desc);
 			ubi_err("cannot open volume %d, error %d", vol_id, err);