Skip to contentSkip to conversation

master - vgimportclone: add native command

PATCH David Teigland 1 participant 1 message Jun 22, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ebd2758dab39bb70fd63d0d77314971f8bc9cbfd
Commit:        ebd2758dab39bb70fd63d0d77314971f8bc9cbfd
Parent:        dfc516f9bfd35ec36c60165bd319a9b0008764a3
Author:        David Teigland <[email protected]>
AuthorDate:    Wed May 25 13:57:33 2016 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Wed Jun 22 13:13:10 2016 -0500

vgimportclone: add native command

This is cleaner and more efficient than the script. The args and usage are unchanged.

---
 lib/Makefile.in               |    1 +
 lib/commands/toolcontext.c    |    9 +-
 lib/filters/filter-internal.c |   81 +++++++++
 lib/filters/filter.h          |    4 +
 lib/metadata/metadata.c       |    3 +
 lib/misc/lvm-globals.c        |   11 ++
 lib/misc/lvm-globals.h        |    2 +
 scripts/Makefile.in           |    2 +-
 test/Makefile.in              |    3 +-
 tools/Makefile.in             |    1 +
 tools/args.h                  |    2 +
 tools/commands.h              |   15 ++
 tools/vgimportclone.c         |  363 +++++++++++++++++++++++++++++++++++++++++
 13 files changed, 493 insertions(+), 4 deletions(-)
lib/Makefile.in +1 -0
index 467ef90..451d96d 100644
@@ -76,6 +76,7 @@ SOURCES =\
 	filters/filter-partitioned.c \
 	filters/filter-type.c \
 	filters/filter-usable.c \
+	filters/filter-internal.c \
 	format_text/archive.c \
 	format_text/archiver.c \
 	format_text/export.c \
lib/commands/toolcontext.c +8 -1
index 75f19c9..3ee9410 100644
@@ -1053,7 +1053,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
 	return 1;
 }
 
-#define MAX_FILTERS 8
+#define MAX_FILTERS 9
 
 static struct dev_filter *_init_lvmetad_filter_chain(struct cmd_context *cmd)
 {
@@ -1078,6 +1078,13 @@ static struct dev_filter *_init_lvmetad_filter_chain(struct cmd_context *cmd)
 			nr_filt++;
 	}
 
+	/* internal filter used by command processing. */
+	if (!(filters[nr_filt] = internal_filter_create())) {
+		log_error("Failed to create internal device filter");
+		goto bad;
+	}
+	nr_filt++;
+
 	/* global regex filter. Optional. */
 	if ((cn = find_config_tree_node(cmd, devices_global_filter_CFG, NULL))) {
 		if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
lib/filters/filter-internal.c new file +81 -0

81 lines not on this page · raw message

lib/filters/filter.h +4 -0
index ebd25e2..d75f6e1 100644
@@ -32,6 +32,10 @@ struct dev_filter *persistent_filter_create(struct dev_types *dt,
 					    const char *file);
 struct dev_filter *sysfs_filter_create(void);
 
+struct dev_filter *internal_filter_create(void);
+int internal_filter_allow(struct dm_pool *mem, struct device *dev);
+void internal_filter_clear(void);
+
 /*
  * patterns must be an array of strings of the form:
  * [ra]<sep><regex><sep>, eg,
lib/metadata/metadata.c +3 -0
index ea42fb7..9b1fd31 100644
@@ -3306,6 +3306,9 @@ static int _check_old_pv_ext_for_vg(struct volume_group *vg)
 		    !pvl->pv->fmt->ops->pv_needs_rewrite)
 			continue;
 
+		if (_pv_in_pv_list(pvl->pv, &vg->pv_write_list))
+			continue;
+
 		if (!pvl->pv->fmt->ops->pv_needs_rewrite(pvl->pv->fmt, pvl->pv,
 							 &pv_needs_rewrite))
 			return_0;
lib/misc/lvm-globals.c +11 -0
index b7af353..9c78f3e 100644
@@ -26,6 +26,7 @@ static int _verbose_level = VERBOSE_BASE_LEVEL;
 static int _silent = 0;
 static int _test = 0;
 static int _md_filtering = 0;
+static int _internal_filtering = 0;
 static int _fwraid_filtering = 0;
 static int _pvmove = 0;
 static int _full_scan_done = 0;	/* Restrict to one full scan during each cmd */
@@ -79,6 +80,11 @@ void init_md_filtering(int level)
 	_md_filtering = level;
 }
 
+void init_internal_filtering(int level)
+{
+	_internal_filtering = level;
+}
+
 void init_fwraid_filtering(int level)
 {
 	_fwraid_filtering = level;
@@ -242,6 +248,11 @@ int md_filtering(void)
 	return _md_filtering;
 }
 
+int internal_filtering(void)
+{
+	return _internal_filtering;
+}
+
 int fwraid_filtering(void)
 {
 	return _fwraid_filtering;
lib/misc/lvm-globals.h +2 -0
index 77c01b4..14a7d43 100644
@@ -26,6 +26,7 @@ void init_verbose(int level);
 void init_silent(int silent);
 void init_test(int level);
 void init_md_filtering(int level);
+void init_internal_filtering(int level);
 void init_fwraid_filtering(int level);
 void init_pvmove(int level);
 void init_full_scan_done(int level);
@@ -60,6 +61,7 @@ void set_sysfs_dir_path(const char *path);
 
 int test_mode(void);
 int md_filtering(void);
+int internal_filtering(void);
 int fwraid_filtering(void);
 int pvmove_mode(void);
 int full_scan_done(void);
scripts/Makefile.in +1 -1
index 9c3d72d..e674239 100644
@@ -31,7 +31,7 @@ endif
 	LVMLIBS = @LVM2APP_LIB@ -ldevmapper
 endif
 
-LVM_SCRIPTS = lvmdump.sh lvmconf.sh vgimportclone.sh
+LVM_SCRIPTS = lvmdump.sh lvmconf.sh
 DM_SCRIPTS =
 
 ifeq ("@FSADM@", "yes")
test/Makefile.in +1 -2
index 59fcc96..f48d6ea 100644
@@ -321,7 +321,6 @@ LIB = $(addprefix lib/, $(LIB_SHARED) $(LIB_LOCAL) $(LIB_NOT) $(LIB_LINK_NOT) $(
 	$(LN_S) -f $(abs_top_builddir)/tools/dmsetup lib/dmstats
 	$(LN_S) -f $(abs_top_srcdir)/conf/thin-performance.profile lib/
 	$(LN_S) -f $(abs_top_srcdir)/scripts/fsadm.sh lib/fsadm
-	$(LN_S) -f $(abs_top_srcdir)/scripts/vgimportclone.sh lib/vgimportclone
 	test "$(srcdir)" = . || for i in $(LIB_LVMLOCKD_CONF); do \
 		$(LN_S) -f $(abs_top_srcdir)/test/lib/$$i lib/; done
 	touch $@
@@ -333,7 +332,7 @@ endif
 
 CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $(LIB) $(addprefix lib/,\
 	$(CMDS) clvmd dmeventd dmsetup dmstats lvmetad lvmpolld \
-	harness thin-performance.profile fsadm vgimportclone \
+	harness thin-performance.profile fsadm \
 	dm-version-expected version-expected \
 	paths-installed paths-installed-t paths-common paths-common-t)
 
tools/Makefile.in +1 -0
index 8dfac7f..d93c31b 100644
@@ -60,6 +60,7 @@ SOURCES =\
 	vgmerge.c \
 	vgmknodes.c \
 	lvpoll.c \
+	vgimportclone.c \
 	vgreduce.c \
 	vgremove.c \
 	vgrename.c \
tools/args.h +2 -0
index 670d6a0..5902513 100644
@@ -154,6 +154,7 @@ arg(autobackup_ARG, 'A', "autobackup", yes_no_arg, 0, 0)
 arg(activevolumegroups_ARG, 'A', "activevolumegroups", NULL, 0, 0)
 arg(background_ARG, 'b', "background", NULL, 0, 0)
 arg(backgroundfork_ARG, 'b', "background", NULL, 0, 0)
+arg(basevgname_ARG, 'n', "basevgname", string_arg, 0, 0)
 arg(blockdevice_ARG, 'b', "blockdevice", NULL, 0, 0)
 arg(chunksize_ARG, 'c', "chunksize", size_kb_arg, 0, 0)
 arg(clustered_ARG, 'c', "clustered", yes_no_arg, 0, 0)
@@ -170,6 +171,7 @@ arg(help_ARG, 'h', "help", NULL, 0, 0)
 arg(cache_ARG, 'H', "cache", NULL, 0, 0)
 arg(history_ARG, 'H', "history", NULL, 0, 0)
 arg(help2_ARG, '?', "", NULL, 0, 0)
+arg(import_ARG, 'i', "import", NULL, 0, 0)
 arg(interval_ARG, 'i', "interval", int_arg, 0, 0)
 arg(iop_version_ARG, 'i', "iop_version", NULL, 0, 0)
 arg(stripes_ARG, 'i', "stripes", int_arg, 0, 0)
tools/commands.h +15 -0
index c0b3f3b..ed86b7f 100644
@@ -1358,6 +1358,21 @@ xx(vgimport,
 
    all_ARG, force_ARG, reportformat_ARG, select_ARG, test_ARG)
 
+xx(vgimportclone,
+   "Import a VG from cloned PVs",
+   NO_LVMETAD_AUTOSCAN,
+   "vgimportclone\n"
+   "\t[-d|--debug]\n"
+   "\t[-h|--help]\n"
+   "\t[-i|--import]\n"
+   "\t[-n|--basevgname]\n"
+   "\t[-t|--test]\n"
+   "\t[-v|--verbose]\n"
+   "\t[--version]\n"
+   "\t[PhysicalVolumePath...]\n",
+
+   basevgname_ARG, test_ARG, import_ARG)
+
 xx(vgmerge,
    "Merge volume groups",
    0,
tools/vgimportclone.c new file +363 -0

363 lines not on this page · raw message