public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW doc/example.conf.in lib/comma ...
@ 2011-02-18 14:11 zkabelac
  0 siblings, 0 replies; 4+ messages in thread
From: zkabelac @ 2011-02-18 14:11 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-02-18 14:11:24

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf.in 
	lib/commands   : toolcontext.c 
	lib/filters    : filter.c 
	lib/metadata   : metadata-exported.h metadata.c metadata.h 
	lib/misc       : lvm-globals.c lvm-globals.h 
	tools          : pvresize.c 
Added files:
	test           : t-pv-min-size.sh 

Log message:
	Replace PV_MIN_SIZE with function pv_min_size()
	
	Add configurable option to define minimal size of
	of block device usable as a PV.
	
	pv_min_size() is added to lvm-globals and it's being
	initialized through _process_config.
	
	Macro PV_MIN_SIZE is unused and removed.
	
	New define DEFAULT_PV_MIN_SIZE_KB is added to lvm-global
	and unlike PV_MIN_SIZE it uses KB units.
	
	Should help users with various slow devices attached to the system,
	which cannot be easily filtered out (like FDD on /dev/sdX):
	https://bugzilla.redhat.com/show_bug.cgi?id=644578

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1914&r2=1.1915
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.174&r2=1.175
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.421&r2=1.422
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.228&r2=1.229
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.h.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pv-min-size.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38

--- LVM2/WHATS_NEW	2011/02/18 14:08:22	1.1914
+++ LVM2/WHATS_NEW	2011/02/18 14:11:22	1.1915
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Add configurable pv_min_size to select block devices by its size.
   Add function to read 64bit ints from config find_config_tree_int64.
   Fix to make resuming exclusive cluster mirror use local target type.
 
--- LVM2/doc/example.conf.in	2010/11/09 12:34:41	1.17
+++ LVM2/doc/example.conf.in	2011/02/18 14:11:22	1.18
@@ -144,6 +144,14 @@
 
     # Allow use of pvcreate --uuid without requiring --restorefile.
     require_restorefile_with_uuid = 1
+
+    # Minimal size (in KB) of the block device which can be used as a PV.
+    # In clustered environment all nodes have to use the same value.
+    # Any value smaller then 512KB is ignored.
+    pv_min_size = 512
+
+    # Example: Ignore devices smaller then 2MB (i.e. floppy drives).
+    # pv_min_size = 2048
 }
 
 # This section allows you to configure the way in which LVM selects
--- LVM2/lib/commands/toolcontext.c	2011/01/06 15:29:24	1.114
+++ LVM2/lib/commands/toolcontext.c	2011/02/18 14:11:22	1.115
@@ -205,6 +205,7 @@
 	struct stat st;
 	const struct config_node *cn;
 	const struct config_value *cv;
+	int64_t pv_min_kb;
 
 	/* umask */
 	cmd->default_settings.umask = find_config_tree_int(cmd,
@@ -318,6 +319,15 @@
 	cmd->metadata_read_only = find_config_tree_int(cmd, "global/metadata_read_only",
 						       DEFAULT_METADATA_READ_ONLY);
 
+	pv_min_kb = find_config_tree_int64(cmd, "devices/pv_min_size", DEFAULT_PV_MIN_SIZE_KB);
+	if (pv_min_kb < DEFAULT_PV_MIN_SIZE_KB) {
+		log_warn("Ignoring too small pv_min_size %" PRId64 "KB, using default %dKB.",
+			 pv_min_kb, DEFAULT_PV_MIN_SIZE_KB);
+		pv_min_kb = DEFAULT_PV_MIN_SIZE_KB;
+	}
+	/* lvm internally works with device size in 512b sectors */
+	init_pv_min_size((uint64_t)pv_min_kb * (1024 >> SECTOR_SHIFT));
+
 	return 1;
 }
 
@@ -1113,7 +1123,6 @@
 {
 	init_full_scan_done(0);
 	init_mirror_in_sync(0);
-
 }
 
 /* Entry point */
--- LVM2/lib/filters/filter.c	2011/01/27 00:21:37	1.60
+++ LVM2/lib/filters/filter.c	2011/02/18 14:11:23	1.61
@@ -158,7 +158,7 @@
 		goto out;
 	}
 
-	if (size < PV_MIN_SIZE) {
+	if (size < pv_min_size()) {
 		log_debug("%s: Skipping: Too small to hold a PV", name);
 		goto out;
 	}
--- LVM2/lib/metadata/metadata-exported.h	2011/01/12 20:42:51	1.174
+++ LVM2/lib/metadata/metadata-exported.h	2011/02/18 14:11:23	1.175
@@ -33,7 +33,6 @@
 #define STRIPE_SIZE_MIN ( (unsigned) lvm_getpagesize() >> SECTOR_SHIFT)	/* PAGESIZE in sectors */
 #define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 #define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
-#define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 #define MAX_RESTRICTED_LVS 255	/* Used by FMT_RESTRICTED_LVIDS */
 
 /* Layer suffix */
--- LVM2/lib/metadata/metadata.c	2011/02/14 19:27:05	1.421
+++ LVM2/lib/metadata/metadata.c	2011/02/18 14:11:23	1.422
@@ -1626,9 +1626,9 @@
 		pv->size = size;
 	}
 
-	if (pv->size < PV_MIN_SIZE) {
-		log_error("%s: Size must exceed minimum of %ld sectors.",
-			  pv_dev_name(pv), PV_MIN_SIZE);
+	if (pv->size < pv_min_size()) {
+		log_error("%s: Size must exceed minimum of %" PRIu64 " sectors.",
+			  pv_dev_name(pv), pv_min_size());
 		goto bad;
 	}
 
--- LVM2/lib/metadata/metadata.h	2011/01/10 13:13:43	1.228
+++ LVM2/lib/metadata/metadata.h	2011/02/18 14:11:23	1.229
@@ -32,7 +32,6 @@
 //#define STRIPE_SIZE_MIN ( (unsigned) lvm_getpagesize() >> SECTOR_SHIFT)	/* PAGESIZE in sectors */
 //#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 //#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
-//#define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT)	/* 512 KB in sectors */
 //#define MAX_RESTRICTED_LVS 255	/* Used by FMT_RESTRICTED_LVIDS */
 #define MIRROR_LOG_OFFSET	2	/* sectors */
 #define VG_MEMPOOL_CHUNK	10240	/* in bytes, hint only */
--- LVM2/lib/misc/lvm-globals.c	2011/01/24 14:19:05	1.8
+++ LVM2/lib/misc/lvm-globals.c	2011/02/18 14:11:23	1.9
@@ -19,6 +19,7 @@
 #include "lvm-string.h"
 #include "lvm-file.h"
 #include "defaults.h"
+#include "metadata-exported.h"
 
 #include <stdarg.h>
 
@@ -42,6 +43,7 @@
 static int _udev_checking = 1;
 static char _sysfs_dir_path[PATH_MAX] = "";
 static int _dev_disable_after_error_count = DEFAULT_DISABLE_AFTER_ERROR_COUNT;
+static uint64_t _pv_min_size = (DEFAULT_PV_MIN_SIZE_KB * 1024L >> SECTOR_SHIFT);
 
 void init_verbose(int level)
 {
@@ -128,6 +130,11 @@
 	_dev_disable_after_error_count = value;
 }
 
+void init_pv_min_size(uint64_t sectors)
+{
+	_pv_min_size = sectors;
+}
+
 void set_cmd_name(const char *cmd)
 {
 	strncpy(_cmd_name, cmd, sizeof(_cmd_name));
@@ -247,3 +254,8 @@
 {
 	return _dev_disable_after_error_count;
 }
+
+uint64_t pv_min_size(void)
+{
+	return _pv_min_size;
+}
--- LVM2/lib/misc/lvm-globals.h	2010/10/13 15:40:39	1.8
+++ LVM2/lib/misc/lvm-globals.h	2011/02/18 14:11:23	1.9
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -18,6 +18,7 @@
 
 #define VERBOSE_BASE_LEVEL _LOG_WARN
 #define SECURITY_LEVEL 0
+#define DEFAULT_PV_MIN_SIZE_KB		512		/* 512 KB */
 
 void init_verbose(int level);
 void init_test(int level);
@@ -38,6 +39,7 @@
 void init_is_static(unsigned value);
 void init_udev_checking(int checking);
 void init_dev_disable_after_error_count(int value);
+void init_pv_min_size(uint64_t sectors);
 
 void set_cmd_name(const char *cmd_name);
 void set_sysfs_dir_path(const char *path);
@@ -59,6 +61,7 @@
 unsigned is_static(void);
 int udev_checking(void);
 const char *sysfs_dir_path(void);
+uint64_t pv_min_size(void);
 
 #define DMEVENTD_MONITOR_IGNORE -1
 int dmeventd_monitor_mode(void);
/cvs/lvm2/LVM2/test/t-pv-min-size.sh,v  -->  standard output
revision 1.1
--- LVM2/test/t-pv-min-size.sh
+++ -	2011-02-18 14:11:25.704477000 +0000
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+. lib/test
+
+# use small default size  - 512KB
+aux lvmconf 'devices/pv_min_size = 512'
+
+aux prepare_pvs 1 8
+
+check pv_field $dev1 pv_name $dev1
+
+# increase min size beyond created PV size 10MB
+aux lvmconf 'devices/pv_min_size = 10240'
+
+# and test device is not visible
+not check pv_field $dev1 pv_name $dev1
+
+# set too low value errornous value
+aux lvmconf 'devices/pv_min_size = -100'
+
+# check the incorrect value is printed
+pvs $dev1 2>&1 | grep -- -100
--- LVM2/tools/pvresize.c	2010/12/08 20:50:51	1.37
+++ LVM2/tools/pvresize.c	2011/02/18 14:11:23	1.38
@@ -111,9 +111,9 @@
 		size = new_size;
 	}
 
-	if (size < PV_MIN_SIZE) {
-		log_error("%s: Size must exceed minimum of %ld sectors.",
-			  pv_name, PV_MIN_SIZE);
+	if (size < pv_min_size()) {
+		log_error("%s: Size must exceed minimum of %" PRIu64 " sectors.",
+			  pv_name, pv_min_size());
 		goto out;
 	}
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2 ./WHATS_NEW doc/example.conf.in lib/comma ...
@ 2011-04-22 12:05 prajnoha
  0 siblings, 0 replies; 4+ messages in thread
From: prajnoha @ 2011-04-22 12:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-04-22 12:05:33

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf.in 
	lib/commands   : toolcontext.c 
	lib/config     : defaults.h 
	lib/device     : dev-cache.c dev-cache.h 
	lib/filters    : filter-persistent.c 
	lib/misc       : lvm-globals.c lvm-globals.h 
	tools          : lvmcmdline.c 

Log message:
	Obtain device list from udev by default if LVM2 is compiled with udev support.
	
	Also, add a new 'obtain_device_list_from_udev' setting to lvm.conf with which
	we can turn this feature on or off if needed.
	
	If set, the cache of block device nodes with all associated symlinks
	will be constructed out of the existing udev database content.
	This avoids using and opening any inapplicable non-block devices or
	subdirectories found in the device directory. This setting is applied
	to udev-managed device directory only, other directories will be scanned
	fully. LVM2 needs to be compiled with udev support for this setting to
	take effect. N.B. Any device node or symlink not managed by udev in
	udev directory will be ignored with this setting on.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1974&r2=1.1975
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.73&r2=1.74
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.h.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.h.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.139&r2=1.140

--- LVM2/WHATS_NEW	2011/04/21 17:03:38	1.1974
+++ LVM2/WHATS_NEW	2011/04/22 12:05:32	1.1975
@@ -1,5 +1,7 @@
 Version 2.02.85 - 
 ===================================
+  Add new obtain_device_list_from_udev setting to lvm.conf.
+  Obtain device list from udev by default if LVM2 is compiled with udev support.
   Add nightly test for vgimportclone and querying of vgnames with duplicate pvs.
   Fix use of released memory when duplicate PV is found.
   Add "devices/issue_discards" to lvm.conf.
--- LVM2/doc/example.conf.in	2011/04/13 18:26:39	1.22
+++ LVM2/doc/example.conf.in	2011/04/22 12:05:32	1.23
@@ -19,6 +19,16 @@
     # to use with LVM2.
     scan = [ "/dev" ]
 
+    # If set, the cache of block device nodes with all associated symlinks
+    # will be constructed out of the existing udev database content.
+    # This avoids using and opening any inapplicable non-block devices or
+    # subdirectories found in the device directory. This setting is applied
+    # to udev-managed device directory only, other directories will be scanned
+    # fully. LVM2 needs to be compiled with udev support for this setting to
+    # take effect. N.B. Any device node or symlink not managed by udev in
+    # udev directory will be ignored with this setting on.
+    # obtain_device_list_from_udev = 1
+
     # If several entries in the scanned directories correspond to the
     # same block device and the tools need to display a name for device,
     # all the pathnames are matched against each item in the following
--- LVM2/lib/commands/toolcontext.c	2011/02/18 14:11:22	1.115
+++ LVM2/lib/commands/toolcontext.c	2011/04/22 12:05:32	1.116
@@ -573,6 +573,9 @@
 {
 	const struct config_node *cn;
 	const struct config_value *cv;
+	size_t udev_dir_len, len;
+	int device_list_from_udev;
+	const char *udev_dir;
 
 	init_dev_disable_after_error_count(
 		find_config_tree_int(cmd, "devices/disable_after_error_count",
@@ -581,6 +584,14 @@
 	if (!dev_cache_init(cmd))
 		return_0;
 
+	if ((device_list_from_udev = udev_is_running() ?
+		find_config_tree_bool(cmd, "devices/obtain_device_list_from_udev",
+				      DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV) : 0)) {
+		udev_dir = udev_get_dev_dir();
+		udev_dir_len = strlen(udev_dir);
+	}
+	init_obtain_device_list_from_udev(device_list_from_udev);
+
 	if (!(cn = find_config_tree_node(cmd, "devices/scan"))) {
 		if (!dev_cache_add_dir("/dev")) {
 			log_error("Failed to add /dev to internal "
@@ -599,6 +610,16 @@
 			return 0;
 		}
 
+		if (device_list_from_udev) {
+			len = strlen(cv->v.str);
+			len = udev_dir_len > len ? len : udev_dir_len;
+			if (strncmp(udev_dir, cv->v.str, len) ||
+			    udev_dir[len] != cv->v.str[len]) {
+				device_list_from_udev = 0;
+				init_obtain_device_list_from_udev(0);
+			}
+		}
+
 		if (!dev_cache_add_dir(cv->v.str)) {
 			log_error("Failed to add %s to internal device cache",
 				  cv->v.str);
--- LVM2/lib/config/defaults.h	2011/04/12 21:59:01	1.73
+++ LVM2/lib/config/defaults.h	2011/04/22 12:05:32	1.74
@@ -29,6 +29,7 @@
 
 #define DEFAULT_DEV_DIR "/dev"
 #define DEFAULT_PROC_DIR "/proc"
+#define DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV 1
 #define DEFAULT_SYSFS_SCAN 1
 #define DEFAULT_MD_COMPONENT_DETECTION 1
 #define DEFAULT_MD_CHUNK_ALIGNMENT 1
--- LVM2/lib/device/dev-cache.c	2011/01/17 15:16:55	1.63
+++ LVM2/lib/device/dev-cache.c	2011/04/22 12:05:33	1.64
@@ -52,7 +52,7 @@
 #define _free(x) dm_pool_free(_cache.mem, (x))
 #define _strdup(x) dm_pool_strdup(_cache.mem, (x))
 
-static int _insert(const char *path, int rec);
+static int _insert(const char *path, int rec, int check_with_udev_db);
 
 struct device *dev_create_file(const char *filename, struct device *dev,
 			       struct str_list *alias, int use_malloc)
@@ -319,8 +319,7 @@
 		}
 	}
 
-	if (!(sl->str = dm_pool_strdup(_cache.mem, path)))
-		return_0;
+	sl->str = path;
 
 	if (!dm_list_empty(&dev->aliases)) {
 		oldpath = dm_list_item(dev->aliases.n, struct str_list)->str;
@@ -348,6 +347,7 @@
 	struct device *dev;
 	static dev_t loopfile_count = 0;
 	int loopfile = 0;
+	char *path_copy;
 
 	/* Generate pretend device numbers for loopfiles */
 	if (!d) {
@@ -374,12 +374,17 @@
 		}
 	}
 
-	if (!loopfile && !_add_alias(dev, path)) {
+	if (!(path_copy = dm_pool_strdup(_cache.mem, path))) {
+		log_error("Failed to duplicate path string.");
+		return 0;
+	}
+
+	if (!loopfile && !_add_alias(dev, path_copy)) {
 		log_error("Couldn't add alias to dev cache.");
 		return 0;
 	}
 
-	if (!dm_hash_insert(_cache.names, path, dev)) {
+	if (!dm_hash_insert(_cache.names, path_copy, dev)) {
 		log_error("Couldn't add name to hash in dev cache.");
 		return 0;
 	}
@@ -437,7 +442,7 @@
 				return_0;
 
 			_collapse_slashes(path);
-			r &= _insert(path, 1);
+			r &= _insert(path, 1, 0);
 			dm_free(path);
 
 			free(dirent[n]);
@@ -468,7 +473,102 @@
 	return 1;
 }
 
-static int _insert(const char *path, int rec)
+#ifdef UDEV_SYNC_SUPPORT
+
+static int _device_in_udev_db(const dev_t d)
+{
+	struct udev *udev;
+	struct udev_device *udev_device;
+
+	if (!(udev = udev_get_library_context()))
+		return_0;
+
+	if ((udev_device = udev_device_new_from_devnum(udev, 'b', d))) {
+		udev_device_unref(udev_device);
+		return 1;
+	}
+
+	return 0;
+}
+
+static int _insert_udev_dir(struct udev *udev, const char *dir)
+{
+	struct udev_enumerate *udev_enum = NULL;
+	struct udev_list_entry *device_entry, *symlink_entry;
+	const char *node_name, *symlink_name;
+	struct udev_device *device;
+	int r = 1;
+
+	if (!(udev_enum = udev_enumerate_new(udev)))
+		goto bad;
+
+	if (udev_enumerate_add_match_subsystem(udev_enum, "block") ||
+	    udev_enumerate_scan_devices(udev_enum))
+		goto bad;
+
+	udev_list_entry_foreach(device_entry, udev_enumerate_get_list_entry(udev_enum)) {
+		device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(device_entry));
+
+		node_name = udev_device_get_devnode(device);
+		r &= _insert(node_name, 0, 0);
+
+		udev_list_entry_foreach(symlink_entry, udev_device_get_devlinks_list_entry(device)) {
+			symlink_name = udev_list_entry_get_name(symlink_entry);
+			r &= _insert(symlink_name, 0, 0);
+		}
+
+		udev_device_unref(device);
+	}
+
+	udev_enumerate_unref(udev_enum);
+	return r;
+
+bad:
+	log_error("Failed to enumerate udev device list.");
+	udev_enumerate_unref(udev_enum);
+	return 0;
+}
+
+static void _insert_dirs(struct dm_list *dirs)
+{
+	struct dir_list *dl;
+	struct udev *udev;
+	int with_udev;
+
+	with_udev = obtain_device_list_from_udev() &&
+		    (udev = udev_get_library_context());
+
+	dm_list_iterate_items(dl, &_cache.dirs) {
+		if (with_udev) {
+			if (!_insert_udev_dir(udev, dl->dir))
+				log_debug("%s: Failed to insert devices from "
+					  "udev-managed directory to device "
+					  "cache fully", dl->dir);
+		}
+		else if (!_insert_dir(dl->dir))
+			log_debug("%s: Failed to insert devices to"
+				  "device cache fully", dl->dir);
+	}
+}
+
+#else	/* UDEV_SYNC_SUPPORT */
+
+static int _device_in_udev_db(const dev_t d)
+{
+	return 0;
+}
+
+static void _insert_dirs(struct dm_list *dirs)
+{
+	struct dir_list *dl;
+
+	dm_list_iterate_items(dl, &_cache.dirs)
+		_insert_dir(dl->dir);
+}
+
+#endif	/* UDEV_SYNC_SUPPORT */
+
+static int _insert(const char *path, int rec, int check_with_udev_db)
 {
 	struct stat info;
 	int r = 0;
@@ -478,6 +578,11 @@
 		return 0;
 	}
 
+	if (check_with_udev_db && !_device_in_udev_db(info.st_rdev)) {
+		log_very_verbose("%s: Not in udev db", path);
+		return 0;
+	}
+
 	if (S_ISDIR(info.st_mode)) {	/* add a directory */
 		/* check it's not a symbolic link */
 		if (lstat(path, &info) < 0) {
@@ -515,8 +620,7 @@
 	if (_cache.has_scanned && !dev_scan)
 		return;
 
-	dm_list_iterate_items(dl, &_cache.dirs)
-		_insert_dir(dl->dir);
+	_insert_dirs(&_cache.dirs);
 
 	dm_list_iterate_items(dl, &_cache.files)
 		_insert_file(dl->dir);
@@ -760,7 +864,7 @@
 		if (dm_list_size(&dev->aliases) > 1) {
 			dm_list_del(dev->aliases.n);
 			if (!r)
-				_insert(name, 0);
+				_insert(name, 0, obtain_device_list_from_udev());
 			continue;
 		}
 
@@ -788,7 +892,7 @@
 	}
 
 	if (!d) {
-		_insert(name, 0);
+		_insert(name, 0, obtain_device_list_from_udev());
 		d = (struct device *) dm_hash_lookup(_cache.names, name);
 		if (!d) {
 			_full_scan(0);
--- LVM2/lib/device/dev-cache.h	2010/10/13 15:40:39	1.13
+++ LVM2/lib/device/dev-cache.h	2011/04/22 12:05:33	1.14
@@ -17,6 +17,7 @@
 #define _LVM_DEV_CACHE_H
 
 #include "device.h"
+#include "lvm-wrappers.h"
 
 /*
  * predicate for devices.
--- LVM2/lib/filters/filter-persistent.c	2011/01/06 15:29:24	1.48
+++ LVM2/lib/filters/filter-persistent.c	2011/04/22 12:05:33	1.49
@@ -103,6 +103,17 @@
 	struct stat info;
 	int r = 0;
 
+	if (obtain_device_list_from_udev()) {
+		if (!stat(pf->file, &info)) {
+			log_very_verbose("Obtaining device list from "
+					 "udev. Removing obolete %s.",
+					 pf->file);
+			if (unlink(pf->file) < 0)
+				log_sys_error("unlink", pf->file);
+		}
+		return 1;
+	}
+
 	if (!stat(pf->file, &info))
 		pf->ctime = info.st_ctime;
 	else {
@@ -180,6 +191,9 @@
 	int lockfd;
 	int r = 0;
 
+	if (obtain_device_list_from_udev())
+		return 1;
+
 	if (!f)
 		return_0;
 	pf = (struct pfilter *) f->private;
--- LVM2/lib/misc/lvm-globals.c	2011/03/29 20:30:08	1.10
+++ LVM2/lib/misc/lvm-globals.c	2011/04/22 12:05:33	1.11
@@ -28,6 +28,7 @@
 static int _md_filtering = 0;
 static int _pvmove = 0;
 static int _full_scan_done = 0;	/* Restrict to one full scan during each cmd */
+static int _obtain_device_list_from_udev = DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV;
 static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
 static int _debug_level = 0;
 static int _log_cmd_name = 0;
@@ -72,6 +73,11 @@
 	_full_scan_done = level;
 }
 
+void init_obtain_device_list_from_udev(int device_list_from_udev)
+{
+	_obtain_device_list_from_udev = device_list_from_udev;
+}
+
 void init_trust_cache(int trustcache)
 {
 	_trust_cache = trustcache;
@@ -185,6 +191,11 @@
 	return _full_scan_done;
 }
 
+int obtain_device_list_from_udev()
+{
+	return _obtain_device_list_from_udev;
+}
+
 int trust_cache(void)
 {
 	return _trust_cache;
--- LVM2/lib/misc/lvm-globals.h	2011/02/18 14:11:23	1.9
+++ LVM2/lib/misc/lvm-globals.h	2011/04/22 12:05:33	1.10
@@ -25,6 +25,7 @@
 void init_md_filtering(int level);
 void init_pvmove(int level);
 void init_full_scan_done(int level);
+void init_obtain_device_list_from_udev(int device_list_from_udev);
 void init_trust_cache(int trustcache);
 void init_debug(int level);
 void init_cmd_name(int status);
@@ -48,6 +49,7 @@
 int md_filtering(void);
 int pvmove_mode(void);
 int full_scan_done(void);
+int obtain_device_list_from_udev(void);
 int trust_cache(void);
 int verbose_level(void);
 int debug_level(void);
--- LVM2/tools/lvmcmdline.c	2011/04/22 11:56:41	1.139
+++ LVM2/tools/lvmcmdline.c	2011/04/22 12:05:33	1.140
@@ -1282,6 +1282,9 @@
 {
 	struct cmd_context *cmd;
 
+	if (!udev_init_library_context())
+		stack;
+
 	if (!(cmd = create_toolcontext(0, NULL)))
 		return_NULL;
 
@@ -1313,6 +1316,7 @@
 {
 	_fin_commands();
 	destroy_toolcontext(cmd);
+	udev_fin_library_context();
 }
 
 static int _run_script(struct cmd_context *cmd, int argc, char **argv)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2 ./WHATS_NEW doc/example.conf.in lib/comma ...
@ 2010-10-25 11:20 agk
  0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2010-10-25 11:20 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-10-25 11:20:56

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf.in 
	lib/commands   : toolcontext.c toolcontext.h 
	lib/config     : defaults.h 
	lib/locking    : locking.c 
	lib/metadata   : metadata.c 
	tools          : commands.h lvmcmdline.c tools.h 

Log message:
	Add global/metadata_read_only to use unrepaired metadata in read-only cmds.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1768&r2=1.1769
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.70&r2=1.71
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.405&r2=1.406
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.156&r2=1.157
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.71&r2=1.72

--- LVM2/WHATS_NEW	2010/10/25 10:40:13	1.1768
+++ LVM2/WHATS_NEW	2010/10/25 11:20:54	1.1769
@@ -1,5 +1,6 @@
 Version 2.02.75 - 
 =====================================
+  Add global/metadata_read_only to use unrepaired metadata in read-only cmds.
   Don't take write lock in vgchange --refresh, --poll or --monitor.
   Skip dm devices in scan if they contain only error targets or are empty.
   Fix strict-aliasing compile warning in partition table scanning.
--- LVM2/doc/example.conf.in	2010/10/15 16:28:15	1.15
+++ LVM2/doc/example.conf.in	2010/10/25 11:20:55	1.16
@@ -334,6 +334,13 @@
     # Treat any internal errors as fatal errors, aborting the process that
     # encountered the internal error. Please only enable for debugging.
     abort_on_internal_errors = 0
+
+    # If set to 1, no operations that change on-disk metadata will be permitted.
+    # Additionally, read-only commands that encounter metadata in need of repair
+    # will still be allowed to proceed exactly as if the repair had been 
+    # performed (except for the unchanged vg_seqno).
+    # Inappropriate use could mess up your system, so seek advice first!
+    metadata_read_only = 0
 }
 
 activation {
--- LVM2/lib/commands/toolcontext.c	2010/10/13 15:40:38	1.106
+++ LVM2/lib/commands/toolcontext.c	2010/10/25 11:20:55	1.107
@@ -314,6 +314,9 @@
 			if ((cv->type != CFG_STRING) || !cv->v.str[0]) 
 				log_error("Ignoring invalid activation/mlock_filter entry in config file");
 
+	cmd->metadata_read_only = find_config_tree_int(cmd, "global/metadata_read_only",
+						       DEFAULT_METADATA_READ_ONLY);
+
 	return 1;
 }
 
--- LVM2/lib/commands/toolcontext.h	2010/08/11 12:14:23	1.39
+++ LVM2/lib/commands/toolcontext.h	2010/10/25 11:20:55	1.40
@@ -73,6 +73,7 @@
 	unsigned handles_unknown_segments:1;
 	unsigned partial_activation:1;
 	unsigned si_unit_consistency:1;
+	unsigned metadata_read_only:1;
 
 	struct dev_filter *filter;
 	int dump_filter;	/* Dump filter when exiting? */
--- LVM2/lib/config/defaults.h	2010/10/15 16:28:15	1.70
+++ LVM2/lib/config/defaults.h	2010/10/25 11:20:55	1.71
@@ -44,6 +44,7 @@
 #define DEFAULT_WAIT_FOR_LOCKS 1
 #define DEFAULT_PRIORITISE_WRITE_LOCKS 1
 #define DEFAULT_USE_MLOCKALL 0
+#define DEFAULT_METADATA_READ_ONLY 0
 
 #define DEFAULT_MIRRORLOG "disk"
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
--- LVM2/lib/locking/locking.c	2010/10/13 15:40:39	1.86
+++ LVM2/lib/locking/locking.c	2010/10/25 11:20:55	1.87
@@ -374,6 +374,13 @@
 		return 0;
 	}
 
+	if (cmd->metadata_read_only &&
+	    ((flags & LCK_TYPE_MASK) == LCK_WRITE) &&
+	    strcmp(resource, VG_GLOBAL)) {
+		log_error("Operation prohibited while global/metadata_read_only is set.");
+		return 0;
+	}
+
 	if ((ret = _locking.lock_resource(cmd, resource, flags))) {
 		if ((flags & LCK_SCOPE_MASK) == LCK_VG &&
 		    !(flags & LCK_CACHE)) {
--- LVM2/lib/metadata/metadata.c	2010/10/13 12:18:53	1.405
+++ LVM2/lib/metadata/metadata.c	2010/10/25 11:20:56	1.406
@@ -2729,8 +2729,14 @@
 
 		/* FIXME Also ensure contents same - checksum compare? */
 		if (correct_vg->seqno != vg->seqno) {
-			inconsistent = 1;
-			inconsistent_seqno = 1;
+			if (cmd->metadata_read_only)
+				log_very_verbose("Not repairing VG %s metadata seqno (%d != %d) "
+						  "as global/metadata_read_only is set.",
+						  vgname, vg->seqno, correct_vg->seqno);
+			else {
+				inconsistent = 1;
+				inconsistent_seqno = 1;
+			}
 			if (vg->seqno > correct_vg->seqno) {
 				vg_release(correct_vg);
 				correct_vg = vg;
@@ -2805,8 +2811,8 @@
 			}
 		}
 
-		if (dm_list_size(&correct_vg->pvs) != dm_list_size(pvids)
-		    + vg_missing_pv_count(correct_vg)) {
+		if (dm_list_size(&correct_vg->pvs) !=
+		    dm_list_size(pvids) + vg_missing_pv_count(correct_vg)) {
 			log_debug("Cached VG %s had incorrect PV list",
 				  vgname);
 
@@ -2882,8 +2888,15 @@
 
 			/* FIXME Also ensure contents same - checksums same? */
 			if (correct_vg->seqno != vg->seqno) {
-				inconsistent = 1;
-				inconsistent_seqno = 1;
+				/* Ignore inconsistent seqno if told to skip repair logic */
+				if (cmd->metadata_read_only)
+					log_very_verbose("Not repairing VG %s metadata seqno (%d != %d) "
+							  "as global/metadata_read_only is set.",
+							  vgname, vg->seqno, correct_vg->seqno);
+				else {
+					inconsistent = 1;
+					inconsistent_seqno = 1;
+				}
 				if (!_update_pv_list(cmd->mem, &all_pvs, vg)) {
 					vg_release(vg);
 					vg_release(correct_vg);
--- LVM2/tools/commands.h	2010/10/15 16:28:16	1.156
+++ LVM2/tools/commands.h	2010/10/25 11:20:56	1.157
@@ -30,7 +30,7 @@
 
 xx(dumpconfig,
    "Dump active configuration",
-   0,
+   PERMITTED_READ_ONLY,
    "dumpconfig "
    "\t[-f|--file filename] " "\n"
    "[ConfigurationVariable...]\n",
@@ -38,12 +38,12 @@
 
 xx(formats,
    "List available metadata formats",
-   0,
+   PERMITTED_READ_ONLY,
    "formats\n")
 
 xx(help,
    "Display help for commands",
-   0,
+   PERMITTED_READ_ONLY,
    "help <command>" "\n")
 
 /*********
@@ -58,7 +58,7 @@
 
 xx(lvchange,
    "Change the attributes of logical volume(s)",
-   CACHE_VGMETADATA,
+   CACHE_VGMETADATA | PERMITTED_READ_ONLY,
    "lvchange\n"
    "\t[-A|--autobackup y|n]\n"
    "\t[-a|--available [e|l]y|n]\n"
@@ -207,7 +207,7 @@
 
 xx(lvdisplay,
    "Display information about a logical volume",
-   0,
+   PERMITTED_READ_ONLY,
    "lvdisplay\n"
    "\t[-a|--all]\n"
    "\t[-c|--colon]\n"
@@ -287,7 +287,7 @@
 
 xx(lvmdiskscan,
    "List devices that may be used as physical volumes",
-   0,
+   PERMITTED_READ_ONLY,
    "lvmdiskscan\n"
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
@@ -401,7 +401,7 @@
 
 xx(lvs,
    "Display information about logical volumes",
-   0,
+   PERMITTED_READ_ONLY,
    "lvs" "\n"
    "\t[-a|--all]\n"
    "\t[--aligned]\n"
@@ -432,7 +432,7 @@
 
 xx(lvscan,
    "List all logical volumes in all volume groups",
-   0,
+   PERMITTED_READ_ONLY,
    "lvscan " "\n"
    "\t[-a|--all]\n"
    "\t[-b|--blockdevice] " "\n"
@@ -545,7 +545,7 @@
 
 xx(pvdisplay,
    "Display various attributes of physical volume(s)",
-   CACHE_VGMETADATA,
+   CACHE_VGMETADATA | PERMITTED_READ_ONLY,
    "pvdisplay\n"
    "\t[-c|--colon]\n"
    "\t[-d|--debug]\n"
@@ -620,7 +620,7 @@
 
 xx(pvs,
    "Display information about physical volumes",
-   CACHE_VGMETADATA,
+   CACHE_VGMETADATA | PERMITTED_READ_ONLY,
    "pvs" "\n"
    "\t[-a|--all]\n"
    "\t[--aligned]\n"
@@ -651,7 +651,7 @@
 
 xx(pvscan,
    "List all physical volumes",
-   0,
+   PERMITTED_READ_ONLY,
    "pvscan " "\n"
    "\t[-d|--debug] " "\n"
    "\t{-e|--exported | -n|--novolumegroup} " "\n"
@@ -668,12 +668,12 @@
 
 xx(segtypes,
    "List available segment types",
-   0,
+   PERMITTED_READ_ONLY,
    "segtypes\n")
 
 xx(vgcfgbackup,
    "Backup volume group configuration(s)",
-   0,
+   PERMITTED_READ_ONLY,
    "vgcfgbackup " "\n"
    "\t[-d|--debug] " "\n"
    "\t[-f|--file filename] " "\n"
@@ -704,7 +704,7 @@
 
 xx(vgchange,
    "Change volume group attributes",
-   CACHE_VGMETADATA,
+   CACHE_VGMETADATA | PERMITTED_READ_ONLY,
    "vgchange" "\n"
    "\t[-A|--autobackup {y|n}] " "\n"
    "\t[--alloc AllocationPolicy] " "\n"
@@ -797,7 +797,7 @@
 
 xx(vgdisplay,
    "Display volume group information",
-   0,
+   PERMITTED_READ_ONLY,
    "vgdisplay " "\n"
    "\t[-A|--activevolumegroups]" "\n"
    "\t[-c|--colon | -s|--short | -v|--verbose]" "\n"
@@ -961,7 +961,7 @@
 
 xx(vgs,
    "Display information about volume groups",
-   0,
+   PERMITTED_READ_ONLY,
    "vgs" "\n"
    "\t[--aligned]\n"
    "\t[-a|--all]\n"
@@ -991,7 +991,7 @@
 
 xx(vgscan,
    "Search for all volume groups",
-   0,
+   PERMITTED_READ_ONLY,
    "vgscan "
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
@@ -1029,6 +1029,6 @@
 
 xx(version,
    "Display software and driver version information",
-   0,
+   PERMITTED_READ_ONLY,
    "version\n" )
 
--- LVM2/tools/lvmcmdline.c	2010/09/30 11:44:54	1.128
+++ LVM2/tools/lvmcmdline.c	2010/10/25 11:20:56	1.129
@@ -1073,6 +1073,13 @@
 	if ((ret = _process_common_commands(cmd)))
 		goto_out;
 
+	if (cmd->metadata_read_only &&
+	    !(cmd->command->flags & PERMITTED_READ_ONLY)) {
+		log_error("%s: Command not permitted while global/metadata_read_only "
+			  "is set.", cmd->cmd_line);
+		goto out;
+	}
+
 	if (arg_count(cmd, nolocking_ARG))
 		locking_type = 0;
 	else
--- LVM2/tools/tools.h	2010/07/09 15:34:48	1.71
+++ LVM2/tools/tools.h	2010/10/25 11:20:56	1.72
@@ -117,7 +117,8 @@
 /*	void *ptr; // Currently not used. */
 };
 
-#define CACHE_VGMETADATA 0x00000001
+#define CACHE_VGMETADATA	0x00000001
+#define PERMITTED_READ_ONLY 	0x00000002
 
 /* a register of the lvm commands */
 struct command {


^ permalink raw reply	[flat|nested] 4+ messages in thread

* LVM2 ./WHATS_NEW doc/example.conf.in lib/comma ...
@ 2010-07-02  2:09 agk
  0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2010-07-02  2:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-07-02 02:09:57

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf.in 
	lib/commands   : toolcontext.c 
	lib/filters    : filter-persistent.c filter.c filter.h 

Log message:
	Always pass unsuspended dm devices through persistent filter to other filters.
	Move test for suspended dm devices ahead of other filters.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1648&r2=1.1649
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.h.diff?cvsroot=lvm2&r1=1.17&r2=1.18

--- LVM2/WHATS_NEW	2010/07/01 21:46:09	1.1648
+++ LVM2/WHATS_NEW	2010/07/02 02:09:57	1.1649
@@ -1,5 +1,7 @@
 Version 2.02.70 - 
 ================================
+  Always pass unsuspended dm devices through persistent filter to other filters.
+  Move test for suspended dm devices ahead of other filters.
   Fix another segfault in clvmd -R if no response from daemon received. (2.02.68)
   Remove superfluous suspended device counter from clvmd.
   Fix lvm shell crash when input is entirely whitespace.
--- LVM2/doc/example.conf.in	2010/06/30 14:04:15	1.4
+++ LVM2/doc/example.conf.in	2010/07/02 02:09:57	1.5
@@ -457,13 +457,15 @@
     # pvmetadatacopies = 1
 
     # Default number of copies of metadata to maintain for each VG.
-    # If set to a non-zero value, LVM automatically manages the PV
-    # 'metadataignore' flags (see pvchange) to achieve the requested
-    # copies of metadata.  You may set a value larger than the
-    # the sum of all metadata areas on all physical volumes.  This value
-    # can be overridden on the command line of various commands. The
-    # default value of 0 indicates that LVM should not automatically
-    # manage the 'metadataignore' flags.
+    # If set to a non-zero value, LVM automatically chooses which of
+    # the available metadata areas to use to achieve the requested
+    # number of copies of the VG metadata.  If you set a value larger
+    # than the the total number of metadata areas available then
+    # metadata is stored in them all.
+    # The default value of 0 ("unmanaged") disables this automatic
+    # management and allows you to control which metadata areas
+    # are used at the individual PV level using 'pvchange
+    # --metadataignore y/n'.
 
     # vgmetadatacopies = 0
 
--- LVM2/lib/commands/toolcontext.c	2010/06/01 21:47:57	1.100
+++ LVM2/lib/commands/toolcontext.c	2010/07/02 02:09:57	1.101
@@ -24,6 +24,7 @@
 #include "filter-md.h"
 #include "filter-persistent.h"
 #include "filter-regex.h"
+#include "filter-suspended.h"
 #include "filter-sysfs.h"
 #include "label.h"
 #include "lvm-file.h"
--- LVM2/lib/filters/filter-persistent.c	2010/06/01 19:02:12	1.42
+++ LVM2/lib/filters/filter-persistent.c	2010/07/02 02:09:57	1.43
@@ -16,9 +16,11 @@
 #include "lib.h"
 #include "config.h"
 #include "dev-cache.h"
+#include "filter.h"
 #include "filter-persistent.h"
 #include "lvm-file.h"
 #include "lvm-string.h"
+#include "activate.h"
 
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -266,15 +268,31 @@
 	void *l = dm_hash_lookup(pf->devices, dev_name(dev));
 	struct str_list *sl;
 
+	/* Cached BAD? */
+	if (l == PF_BAD_DEVICE) {
+		log_debug("%s: Skipping (cached)", dev_name(dev));
+		return 0;
+	}
+
+        /* Test dm devices every time, so cache them as GOOD. */
+	if (MAJOR(dev->dev) == dm_major()) {
+		if (!l)
+			dm_list_iterate_items(sl, &dev->aliases)
+				dm_hash_insert(pf->devices, sl->str, PF_GOOD_DEVICE);
+		if (ignore_suspended_devices() && !device_is_usable(dev)) {
+                	log_debug("%s: Skipping (suspended/internal)", dev_name(dev));
+			return 0;
+		}
+		return pf->real->passes_filter(pf->real, dev);
+	}
+
+	/* Uncached */
 	if (!l) {
-		l = pf->real->passes_filter(pf->real, dev) ?
-		    PF_GOOD_DEVICE : PF_BAD_DEVICE;
+		l = pf->real->passes_filter(pf->real, dev) ?  PF_GOOD_DEVICE : PF_BAD_DEVICE;
 
 		dm_list_iterate_items(sl, &dev->aliases)
 			dm_hash_insert(pf->devices, sl->str, l);
-
-	} else if (l == PF_BAD_DEVICE)
-			log_debug("%s: Skipping (cached)", dev_name(dev));
+	}
 
 	return (l == PF_BAD_DEVICE) ? 0 : 1;
 }
--- LVM2/lib/filters/filter.c	2010/05/17 18:39:03	1.53
+++ LVM2/lib/filters/filter.c	2010/07/02 02:09:57	1.54
@@ -42,6 +42,11 @@
 static int _drbd_major = -1;
 static int _device_mapper_major = -1;
 
+int dm_major(void)
+{
+	return _device_mapper_major;
+}
+
 int md_major(void)
 {
 	return _md_major;
@@ -130,14 +135,6 @@
 		return 0;
 	}
 
-	/* FIXME Always check 'layer' regardless of ignore_suspended_devices */
-	/* Skip suspended devices */
-	if (MAJOR(dev->dev) == _device_mapper_major &&
-	    ignore_suspended_devices() && !device_is_usable(dev)) {
-		log_debug("%s: Skipping: Suspended or internal dm device", name);
-		return 0;
-	}
-
 	/* Check it's accessible */
 	if (!dev_open_flags(dev, O_RDONLY, 0, 1)) {
 		log_debug("%s: Skipping: open failed", name);
--- LVM2/lib/filters/filter.h	2009/10/27 17:00:46	1.17
+++ LVM2/lib/filters/filter.h	2010/07/02 02:09:57	1.18
@@ -35,6 +35,7 @@
 
 void lvm_type_filter_destroy(struct dev_filter *f);
 
+int dm_major(void);
 int md_major(void);
 int blkext_major(void);
 int max_partitions(int major);


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-22 12:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-18 14:11 LVM2 ./WHATS_NEW doc/example.conf.in lib/comma zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2011-04-22 12:05 prajnoha
2010-10-25 11:20 agk
2010-07-02  2:09 agk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).