diff mbox

Allow switch device-mapper tables to READ-WRITE

Message ID 200907081419.20857.knikanth@suse.de (mailing list archive)
State Rejected, archived
Delegated to: Alasdair Kergon
Headers show

Commit Message

Nikanth Karthikesan July 8, 2009, 8:49 a.m. UTC
From: Hannes Reinecke <hare@suse.de>
Subject: Allow switch device-mapper tables to READ-WRITE

Switching a device-mapper table to READ-ONLY works quite well, but
we can't switch back to READ-WRITE as this change will be masked out.
So get rid of this masking and use the flags directly.
And implement a fallback to automatically switch to read-only.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

Index: linux-2.6-dm/drivers/md/dm-table.c
===================================================================
--- linux-2.6-dm.orig/drivers/md/dm-table.c
+++ linux-2.6-dm/drivers/md/dm-table.c
@@ -403,10 +403,15 @@  static int upgrade_mode(struct dm_dev_in
 
 	dd_new = dd_old = *dd;
 
-	dd_new.dm_dev.mode |= new_mode;
+	dd_new.dm_dev.mode = new_mode;
 	dd_new.dm_dev.bdev = NULL;
 
 	r = open_dev(&dd_new, dd->dm_dev.bdev->bd_dev, md);
+	if (r == -EROFS) {
+		dd_new.dm_dev.mode &= ~FMODE_WRITE;
+		r = open_dev(&dd_new, dd->dm_dev.bdev->bd_dev, md);
+	}
+
 	if (r)
 		return r;
 
@@ -473,7 +478,7 @@  static int __table_get_device(struct dm_
 		atomic_set(&dd->count, 0);
 		list_add(&dd->list, &t->devices);
 
-	} else if (dd->dm_dev.mode != (mode | dd->dm_dev.mode)) {
+	} else if (dd->dm_dev.mode != mode) {
 		r = upgrade_mode(dd, mode, t->md);
 		if (r)
 			return r;