Skip to contentSkip to conversation

RFC: Command line support to create sparse devices

PATCH Alasdair G Kergon 1 participant 2 messages Apr 23, 2009

lore
Share & tools
lore
#0 lore raw

Here's a quick patch I've thrown together to make it easier to create sparse devices.

Usage is exactly like creating a snapshot except instead of providing an origin LV you give the size of the virtual origin you want to use with --virtualoriginsize. The name of the VG must still be provided of course.

E.g.
lvcreate -s vg1 -L 400M --virtualoriginsize 1T

Comments?

Alasdair

args.h +1 -0
@@ -58,6 +58,7 @@
 arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
 arg(rows_ARG, '\0', "rows", NULL, 0)
 arg(dataalignment_ARG, '\0', "dataalignment", size_kb_arg, 0)
+arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
 
 /* Allow some variations */
 arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
commands.h +2 -1
@@ -162,6 +162,7 @@
    "\t[-r|--readahead ReadAheadSectors|auto|none]\n"
    "\t[-t|--test]\n"
    "\t[-v|--verbose]\n"
+   "\t[--virtualoriginsize VirtualOriginSize]\n"
    "\t[--version]\n"
    "\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
 
@@ -169,7 +170,7 @@
    corelog_ARG, extents_ARG, major_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG,
    name_ARG, nosync_ARG, permission_ARG, persistent_ARG, readahead_ARG,
    regionsize_ARG, size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG,
-   test_ARG, type_ARG, zero_ARG)
+   test_ARG, type_ARG, virtualoriginsize_ARG, zero_ARG)
 
 xx(lvdisplay,
    "Display information about a logical volume",
lvcreate.c +132 -50

240 lines not on this page · raw message

toollib.c +6 -0
@@ -1229,6 +1229,12 @@
 		return 0;
 	}
 
+	if (strstr(name, "_vorigin")) {
+		log_error("Names including \"_vorigin\" are reserved. "
+			  "Please choose a different LV name.");
+		return 0;
+	}
+
 	return 1;
 }
 
#1 lore raw
Quoted 2 lines · Alasdair G Kergon

Here's a quick patch I've thrown together to make it easier to create sparse devices.

Unfinished bits I can think of:
- disallow multiple snapshots of the same origin if origin is invisible
- if origin is invisible, remove it when its snapshot is removed
- deal with activation/deactivation by translating the command from the snapshot to the origin iff the origin is hidden

And it needs testing.

Alasdair

Signature · 1 line
agk at redhat.com