Skip to contentSkip to conversation

External origin support for thin provisioning

PATCH New Joe Thornber 1 participant 3 messages Jan 22, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover External origin support for thin provisioning

This patchset adds support for external origins to thin provisioning.

It's had some testing on a single machine; more needed on different architectures before pushing upstream.

Joe Thornber (2):
Unlock the superblock on an error path for new metadata dev creation. Add support for external origins.

#1 lore raw

PATCH 1/2 Unlock the superblock on an error path for new metadata dev creation.

---
 drivers/md/dm-thin-metadata.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/md/dm-thin-metadata.c +1 -0
index 28f98cb..b23d27d 100644
@@ -385,6 +385,7 @@ static int init_pmd(struct dm_pool_metadata *pmd,
 		data_sm = dm_sm_disk_create(tm, nr_blocks);
 		if (IS_ERR(data_sm)) {
 			DMERR("sm_disk_create failed");
+			dm_tm_unlock(tm, sblock);
 			r = PTR_ERR(data_sm);
 			goto bad;
 		}
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/2 Add support for external origins.

In reply to Joe Thornber
---
 Documentation/device-mapper/thin-provisioning.txt |   38 ++++++++++-
 drivers/md/dm-thin.c                              |   81 +++++++++++++++++----
 2 files changed, 105 insertions(+), 14 deletions(-)
Documentation/device-mapper/thin-provisioning.txt +37 -1
index 801d9d1..60fc5cf 100644
@@ -167,6 +167,38 @@ ii) Using an internal snapshot.
 
     dmsetup create snap --table "0 2097152 thin /dev/mapper/pool 1"
 
+External snapshots
+------------------
+
+You can use an external, _read only_, device as an origin for a thin
+device.  Any read to an unprovisioned area of the thin device will be
+passed through to the origin.  Writes trigger allocation of new blocks
+as usual.
+
+One possible use case for this would be VM hosts who want to run
+guests on thinp volumes, but have the base image on another device
+(possibly shared between many VMs).
+
+You must not write to the origin device if you use this technique!  Of
+course you can write to the thin device, and take internal snapshots
+of the thin.
+
+i) Creating an external snapshot
+
+  Same as creating a thin device.  You don't need to mention the
+  origin at this stage.
+
+    dmsetup message /dev/mapper/pool 0 "create_thin 0"
+
+ii) Using an external snapshot.
+
+  Add an extra parameter to the thin target specifying the origin:
+
+    dmsetup create snap --table "0 2097152 thin /dev/mapper/pool 0 /dev/image"
+
+  All descendants (internal snapshots) of an external snapshot will
+  need the extra origin argument.
+
 Deactivation
 ------------
 
@@ -262,7 +294,7 @@ iii) Messages
 
 i) Constructor
 
-    thin <pool dev> <dev id>
+    thin <pool dev> <dev id> [external origin id]
 
     pool dev:
 	the thin-pool device, e.g. /dev/mapper/my_pool or 253:0
@@ -271,6 +303,10 @@ i) Constructor
 	the internal device identifier of the device to be
 	activated.
 
+    external origin dev:
+        a block device; reads to unprovisioned areas of the thin target
+        will be mapped to here.
+
 The pool doesn't store any size against the thin devices.  If you
 load a thin target that is smaller than you've been using previously,
 then you'll have no access to blocks mapped beyond the end.  If you
drivers/md/dm-thin.c +68 -13

175 lines not on this page · raw message

Signature · 1 line
1.7.5.4