public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW doc/example.conf lib/config/d ...
@ 2009-08-01 17:08 snitzer
  0 siblings, 0 replies; 8+ messages in thread
From: snitzer @ 2009-08-01 17:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 9740 bytes --]

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2009-08-01 17:08:44

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/config     : defaults.h 
	lib/device     : device.c device.h 
	lib/metadata   : metadata.c 
	man            : lvm.conf.5.in 

Log message:
	Add devices/data_alignment_detection to lvm.conf.
	
	Adds 'data_alignment_detection' config option to the devices section of
	lvm.conf.  If your kernel provides topology information in sysfs (linux
	>= 2.6.31) for the Physical Volume, the start of data area will be
	aligned on a multiple of the ’minimum_io_size’ or ’optimal_io_size’
	exposed in sysfs.
	
	minimum_io_size is used if optimal_io_size is undefined (0).  If both
	md_chunk_alignment and data_alignment_detection are enabled the result
	of data_alignment_detection is used.
	
	Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1224&r2=1.1225
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.h.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.276&r2=1.277
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.conf.5.in.diff?cvsroot=lvm2&r1=1.5&r2=1.6

--- LVM2/WHATS_NEW	2009/08/01 17:07:36	1.1224
+++ LVM2/WHATS_NEW	2009/08/01 17:08:43	1.1225
@@ -4,6 +4,7 @@
   Added configure --enable-udev_rules --enable-udev_sync.
   Added configure --with-udev-prefix --with-udevdir.
   Added udev dir to hold udev rules.
+  Add devices/data_alignment_detection to lvm.conf.
   Add devices/data_alignment_offset_detection to lvm.conf.
   Add --dataalignmentoffset to pvcreate to shift start of aligned data area.
   Fix _mda_setup() to not check first mda's size before pe_align rounding.
--- LVM2/doc/example.conf	2009/08/01 17:07:36	1.43
+++ LVM2/doc/example.conf	2009/08/01 17:08:44	1.44
@@ -98,9 +98,21 @@
     # 1 enables; 0 disables.
     md_chunk_alignment = 1
 
+    # By default, the start of a PV's data area will be a multiple of
+    # the 'minimum_io_size' or 'optimal_io_size' exposed in sysfs.
+    # - minimum_io_size - the smallest request the device can perform
+    #   w/o incurring a read-modify-write penalty (e.g. MD's chunk size)
+    # - optimal_io_size - the device's preferred unit of receiving I/O
+    #   (e.g. MD's stripe width)
+    # minimum_io_size is used if optimal_io_size is undefined (0).
+    # If md_chunk_alignment is enabled, that detects the optimal_io_size.
+    # This setting takes precedence over md_chunk_alignment.
+    # 1 enables; 0 disables.
+    data_alignment_detection = 1
+
     # Alignment (in KB) of start of data area when creating a new PV.
-    # If a PV is placed directly upon an md device and md_chunk_alignment is
-    # enabled this parameter is ignored.
+    # If a PV is placed directly upon an md device and md_chunk_alignment or
+    # data_alignment_detection is enabled this parameter is ignored.
     # Set to 0 for the default alignment of 64KB or page size, if larger.
     data_alignment = 0
 
--- LVM2/lib/config/defaults.h	2009/08/01 17:07:37	1.48
+++ LVM2/lib/config/defaults.h	2009/08/01 17:08:44	1.49
@@ -35,6 +35,7 @@
 #define DEFAULT_MD_CHUNK_ALIGNMENT 1
 #define DEFAULT_IGNORE_SUSPENDED_DEVICES 1
 #define DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION 1
+#define DEFAULT_DATA_ALIGNMENT_DETECTION 1
 
 #define DEFAULT_LOCK_DIR "/var/lock/lvm"
 #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
--- LVM2/lib/device/device.c	2009/08/01 17:07:37	1.28
+++ LVM2/lib/device/device.c	2009/08/01 17:08:44	1.29
@@ -285,13 +285,36 @@
 
 #ifdef linux
 
+static int _primary_dev(const char *sysfs_dir,
+			struct device *dev, dev_t *result)
+{
+	char path[PATH_MAX+1];
+	struct stat info;
+
+	/* check if dev is a partition */
+	if (dm_snprintf(path, PATH_MAX, "%s/dev/block/%d:%d/partition",
+			sysfs_dir, (int)MAJOR(dev->dev), (int)MINOR(dev->dev)) < 0) {
+		log_error("dm_snprintf partition failed");
+		return 0;
+	}
+
+	if (stat(path, &info) < 0)
+		return 0;
+
+	*result = dev->dev -
+		(MINOR(dev->dev) % max_partitions(MAJOR(dev->dev)));
+	return 1;
+}
+
 static unsigned long _dev_topology_attribute(const char *attribute,
 					     const char *sysfs_dir,
 					     struct device *dev)
 {
+	const char *sysfs_fmt_str = "%s/dev/block/%d:%d/%s";
 	char path[PATH_MAX+1], buffer[64];
 	FILE *fp;
 	struct stat info;
+	dev_t uninitialized_var(primary);
 	unsigned long result = 0UL;
 
 	if (!attribute || !*attribute)
@@ -300,16 +323,32 @@
 	if (!sysfs_dir || !*sysfs_dir)
 		return_0;
 
-	if (dm_snprintf(path, PATH_MAX, "%s/dev/block/%d:%d/%s",
-			sysfs_dir, (int)MAJOR(dev->dev), (int)MINOR(dev->dev),
+	if (dm_snprintf(path, PATH_MAX, sysfs_fmt_str, sysfs_dir,
+			(int)MAJOR(dev->dev), (int)MINOR(dev->dev),
 			attribute) < 0) {
 		log_error("dm_snprintf %s failed", attribute);
 		return 0;
 	}
 
-	/* check if the desired sysfs attribute exists */
-	if (stat(path, &info) < 0)
-		return 0;
+	/*
+	 * check if the desired sysfs attribute exists
+	 * - if not: either the kernel doesn't have topology support
+	 *   or the device could be a partition
+	 */
+	if (stat(path, &info) < 0) {
+		if (!_primary_dev(sysfs_dir, dev, &primary))
+			return 0;
+
+		/* get attribute from partition's primary device */
+		if (dm_snprintf(path, PATH_MAX, sysfs_fmt_str, sysfs_dir,
+				(int)MAJOR(primary), (int)MINOR(primary),
+				attribute) < 0) {
+			log_error("primary dm_snprintf %s failed", attribute);
+			return 0;
+		}
+		if (stat(path, &info) < 0)
+			return 0;
+	}
 
 	if (!(fp = fopen(path, "r"))) {
 		log_sys_error("fopen", path);
@@ -344,6 +383,20 @@
 				       sysfs_dir, dev);
 }
 
+unsigned long dev_minimum_io_size(const char *sysfs_dir,
+				  struct device *dev)
+{
+	return _dev_topology_attribute("queue/minimum_io_size",
+				       sysfs_dir, dev);
+}
+
+unsigned long dev_optimal_io_size(const char *sysfs_dir,
+				  struct device *dev)
+{
+	return _dev_topology_attribute("queue/optimal_io_size",
+				       sysfs_dir, dev);
+}
+
 #else
 
 unsigned long dev_alignment_offset(const char *sysfs_dir,
@@ -352,4 +405,16 @@
 	return 0UL;
 }
 
+unsigned long dev_minimum_io_size(const char *sysfs_dir,
+				  struct device *dev)
+{
+	return 0UL;
+}
+
+unsigned long dev_optimal_io_size(const char *sysfs_dir,
+				  struct device *dev)
+{
+	return 0UL;
+}
+
 #endif
--- LVM2/lib/device/device.h	2009/08/01 17:07:37	1.41
+++ LVM2/lib/device/device.h	2009/08/01 17:08:44	1.42
@@ -103,4 +103,10 @@
 unsigned long dev_alignment_offset(const char *sysfs_dir,
 				   struct device *dev);
 
+unsigned long dev_minimum_io_size(const char *sysfs_dir,
+				  struct device *dev);
+
+unsigned long dev_optimal_io_size(const char *sysfs_dir,
+				  struct device *dev);
+
 #endif
--- LVM2/lib/metadata/metadata.c	2009/08/01 17:07:37	1.276
+++ LVM2/lib/metadata/metadata.c	2009/08/01 17:08:44	1.277
@@ -86,6 +86,25 @@
 				   dev_md_stripe_width(pv->fmt->cmd->sysfs_dir,
 						       pv->dev));
 
+	/*
+	 * Align to topology's minimum_io_size or optimal_io_size if present
+	 * - minimum_io_size - the smallest request the device can perform
+	 *   w/o incurring a read-modify-write penalty (e.g. MD's chunk size)
+	 * - optimal_io_size - the device's preferred unit of receiving I/O
+	 *   (e.g. MD's stripe width)
+	 */
+	if (find_config_tree_bool(pv->fmt->cmd,
+				  "devices/data_alignment_detection",
+				  DEFAULT_DATA_ALIGNMENT_DETECTION)) {
+		pv->pe_align = MAX(pv->pe_align,
+				   dev_minimum_io_size(pv->fmt->cmd->sysfs_dir,
+						       pv->dev));
+
+		pv->pe_align = MAX(pv->pe_align,
+				   dev_optimal_io_size(pv->fmt->cmd->sysfs_dir,
+						       pv->dev));
+	}
+
 	log_very_verbose("%s: Setting PE alignment to %lu sectors.",
 			 dev_name(pv->dev), pv->pe_align);
 
--- LVM2/man/lvm.conf.5.in	2009/08/01 17:07:37	1.5
+++ LVM2/man/lvm.conf.5.in	2009/08/01 17:08:44	1.6
@@ -137,11 +137,23 @@
 directly upon an md device, LVM2 will align its data blocks with the
 md device's stripe-width.
 .IP
+\fBdata_alignment_detection\fP \(em If set to 1, and your kernel provides
+topology information in sysfs for the Physical Volume, the start of data
+area will be aligned on a multiple of the ’minimum_io_size’ or
+’optimal_io_size’ exposed in sysfs.  minimum_io_size is the smallest
+request the device can perform without incurring a read-modify-write
+penalty (e.g. MD's chunk size).  optimal_io_size is the device's
+preferred unit of receiving I/O (e.g. MD's stripe width).  minimum_io_size
+is used if optimal_io_size is undefined (0).  If both \fBmd_chunk_alignment\fP
+and \fBdata_alignment_detection\fP are enabled the result of
+\fBdata_alignment_detection\fP is used.
+.IP
 \fBdata_alignment\fP \(em Default alignment (in KB) of start of data area
 when creating a new Physical Volume using the \fBlvm2\fP format.
 If a Physical Volume is placed directly upon an md device and
-\fBmd_chunk_alignment\fP is enabled this parameter is ignored.
-Set to 0 to use the default alignment of 64KB or the page size, if larger.
+\fBmd_chunk_alignment\fP or \fBdata_alignment_detection\fP is enabled
+this parameter is ignored.  Set to 0 to use the default alignment of
+64KB or the page size, if larger.
 .IP
 \fBdata_alignment_offset_detection\fP \(em If set to 1, and your kernel
 provides topology information in sysfs for the Physical Volume, the


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

* LVM2 ./WHATS_NEW doc/example.conf lib/config/d ...
@ 2010-01-06 13:27 mbroz
  0 siblings, 0 replies; 8+ messages in thread
From: mbroz @ 2010-01-06 13:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-01-06 13:27:07

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/config     : defaults.h 
	lib/metadata   : mirror.c 
	tools          : lvconvert.c 

Log message:
	Rename mirror_device_fault_policy to mirror_image_fault policy

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1366&r2=1.1367
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101

--- LVM2/WHATS_NEW	2010/01/06 13:26:21	1.1366
+++ LVM2/WHATS_NEW	2010/01/06 13:27:06	1.1367
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Rename mirror_device_fault_policy to mirror_image_fault policy.
   Remove empty PV devices if lvconvert --repair is using defined policies.
   Use fixed buffer to prevent stack overflow in persistent filter dump.
   Use snapshot metadata usage to determine if a snapshot is empty.
--- LVM2/doc/example.conf	2009/11/30 17:17:11	1.52
+++ LVM2/doc/example.conf	2010/01/06 13:27:07	1.53
@@ -405,7 +405,7 @@
     #            be allocated for the replacement.
 
     mirror_log_fault_policy = "allocate"
-    mirror_device_fault_policy = "remove"
+    mirror_image_fault_policy = "remove"
 }
 
 
--- LVM2/lib/config/defaults.h	2010/01/05 20:56:51	1.56
+++ LVM2/lib/config/defaults.h	2010/01/06 13:27:07	1.57
@@ -46,7 +46,7 @@
 
 #define DEFAULT_MIRRORLOG "disk"
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
-#define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
+#define DEFAULT_MIRROR_IMAGE_FAULT_POLICY "remove"
 #define DEFAULT_MIRROR_MAX_IMAGES 8 /* limited by kernel DM_KCOPYD_MAX_REGIONS */
 #define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
 #define DEFAULT_DMEVENTD_MONITOR 1
--- LVM2/lib/metadata/mirror.c	2010/01/05 21:07:31	1.102
+++ LVM2/lib/metadata/mirror.c	2010/01/06 13:27:07	1.103
@@ -783,9 +783,13 @@
 	if (log_policy)
 		policy = find_config_str(NULL, "activation/mirror_log_fault_policy",
 					 DEFAULT_MIRROR_LOG_FAULT_POLICY);
-	else
-		policy = find_config_str(NULL, "activation/mirror_device_fault_policy",
-					 DEFAULT_MIRROR_DEV_FAULT_POLICY);
+	else {
+		policy = find_config_str(NULL, "activation/mirror_image_fault_policy",
+					 NULL);
+		if (!policy)
+			policy = find_config_str(NULL, "activation/mirror_device_fault_policy",
+						 DEFAULT_MIRROR_IMAGE_FAULT_POLICY);
+	}
 
 	if (!strcmp(policy, "remove"))
 		return MIRROR_REMOVE;
--- LVM2/tools/lvconvert.c	2010/01/06 13:26:21	1.100
+++ LVM2/tools/lvconvert.c	2010/01/06 13:27:07	1.101
@@ -475,6 +475,9 @@
 
 	if (arg_count(cmd, use_policies_ARG)) {
 		leg_policy = find_config_tree_str(cmd,
+					"activation/mirror_image_fault_policy", NULL);
+		if (!leg_policy)
+			leg_policy = find_config_tree_str(cmd,
 					"activation/mirror_device_fault_policy",
 					DEFAULT_MIRROR_DEVICE_FAULT_POLICY);
 		log_policy = find_config_tree_str(cmd,


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

* LVM2 ./WHATS_NEW doc/example.conf lib/config/d ...
@ 2009-10-05 12:44 agk
  0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2009-10-05 12:44 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-10-05 12:44:21

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/config     : defaults.h 

Log message:
	Correct example.conf to indicate that lvm2 not lvm1 is the default format.
	Remove an unused stray LVM1_SUPPORT ifdef.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1289&r2=1.1290
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.52&r2=1.53

--- LVM2/WHATS_NEW	2009/10/05 12:11:30	1.1289
+++ LVM2/WHATS_NEW	2009/10/05 12:44:20	1.1290
@@ -1,5 +1,7 @@
 Version 2.02.54 -
 =====================================
+  Correct example.conf to indicate that lvm2 not lvm1 is the default format.
+  Remove an unused stray LVM1_SUPPORT ifdef.
   Only include selinux libs in libdevmapper.pc when selinux build enabled.
   Allow for a build directory separate from the source.
   Update distclean target for rename clogd to cmirrord. (2.02.52)
--- LVM2/doc/example.conf	2009/09/28 16:23:45	1.50
+++ LVM2/doc/example.conf	2009/10/05 12:44:21	1.51
@@ -262,8 +262,8 @@
 
     # The default metadata format that commands should use - "lvm1" or "lvm2".
     # The command line override is -M1 or -M2.
-    # Defaults to "lvm1" if compiled in, else "lvm2".
-    # format = "lvm1"
+    # Defaults to "lvm2".
+    # format = "lvm2"
 
     # Location of proc filesystem
     proc = "/proc"
--- LVM2/lib/config/defaults.h	2009/09/28 16:23:46	1.52
+++ LVM2/lib/config/defaults.h	2009/10/05 12:44:21	1.53
@@ -58,11 +58,7 @@
 #  define DEFAULT_FALLBACK_TO_LVM1 0
 #endif
 
-#ifdef LVM1_SUPPORT
-#  define DEFAULT_FORMAT "lvm1"
-#else
-#  define DEFAULT_FORMAT "lvm2"
-#endif
+#define DEFAULT_FORMAT "lvm2"
 
 #define DEFAULT_STRIPESIZE 64	/* KB */
 #define DEFAULT_PVMETADATASIZE 255


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

* LVM2 ./WHATS_NEW doc/example.conf lib/config/d ...
@ 2009-09-02 14:47 mornfall
  0 siblings, 0 replies; 8+ messages in thread
From: mornfall @ 2009-09-02 14:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2009-09-02 14:47:40

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/config     : defaults.h 
	lib/locking    : file_locking.c 

Log message:
	Implement write lock prioritisation for file locking and make it default.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1251&r2=1.1252
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43

--- LVM2/WHATS_NEW	2009/09/02 11:49:03	1.1251
+++ LVM2/WHATS_NEW	2009/09/02 14:47:39	1.1252
@@ -1,5 +1,6 @@
 Version 2.02.52 -
 =================================
+  Implement write lock prioritisation for file locking and make it default.
   Fix clogd build direcory.
   Drop unrequired clogd Makefile.
   Fix clvmd autodetection check and cleanup related configure messages.
--- LVM2/doc/example.conf	2009/08/04 15:36:14	1.45
+++ LVM2/doc/example.conf	2009/09/02 14:47:40	1.46
@@ -288,6 +288,13 @@
     # in progress.  A directory like /tmp that may get wiped on reboot is OK.
     locking_dir = "/var/lock/lvm"
 
+    # Whenever a read-only and read-write access compete on a single volume
+    # group, ensure that the write lock gets priority over the read lock.
+    # Without this setting, write access may be stalled by high volume of
+    # read-only traffic on LVM metadata. NB. This option only affects
+    # locking_type = 1, i.e. local file-based locking.
+    prioritise_write_locks = 1
+
     # Other entries can go here to allow you to load shared libraries
     # e.g. if support for LVM1 metadata was compiled as a shared library use
     #   format_libraries = "liblvm2format1.so" 
--- LVM2/lib/config/defaults.h	2009/08/04 15:36:14	1.50
+++ LVM2/lib/config/defaults.h	2009/09/02 14:47:40	1.51
@@ -42,6 +42,7 @@
 #define DEFAULT_FALLBACK_TO_LOCAL_LOCKING 1
 #define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1
 #define DEFAULT_WAIT_FOR_LOCKS 1
+#define DEFAULT_PRIORITISE_WRITE_LOCKS 1
 
 #define DEFAULT_MIRRORLOG "disk"
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
--- LVM2/lib/locking/file_locking.c	2009/08/13 13:23:52	1.42
+++ LVM2/lib/locking/file_locking.c	2009/09/02 14:47:40	1.43
@@ -38,6 +38,7 @@
 
 static struct dm_list _lock_list;
 static char _lock_dir[NAME_LEN];
+static int _prioritise_write_locks;
 
 static sig_t _oldhandler;
 static sigset_t _fullsigset, _intsigset;
@@ -47,6 +48,7 @@
 {
 	struct stat buf1, buf2;
 
+	log_debug("_undo_flock %s", file);
 	if (!flock(fd, LOCK_NB | LOCK_EX) &&
 	    !stat(file, &buf1) &&
 	    !fstat(fd, &buf2) &&
@@ -135,6 +137,8 @@
 	int old_errno;
 	struct stat buf1, buf2;
 
+	log_debug("_do_flock %s %c%c",
+		  file, operation == LOCK_EX ? 'W' : 'R', nonblock ? ' ' : 'B');
 	do {
 		if ((*fd > -1) && close(*fd))
 			log_sys_error("close", file);
@@ -169,6 +173,29 @@
 	return_0;
 }
 
+#define AUX_LOCK_SUFFIX ":aux"
+
+static int _do_write_priority_flock(const char *file, int *fd, int operation, uint32_t nonblock)
+{
+	int r, fd_aux = -1;
+	char *file_aux = alloca(strlen(file) + sizeof(AUX_LOCK_SUFFIX));
+
+	strcpy(file_aux, file);
+	strcat(file_aux, AUX_LOCK_SUFFIX);
+
+	if ((r = _do_flock(file_aux, &fd_aux, LOCK_EX, 0))) {
+		if (operation == LOCK_EX) {
+			r = _do_flock(file, fd, operation, nonblock);
+			_undo_flock(file_aux, fd_aux);
+		} else {
+			_undo_flock(file_aux, fd_aux);
+			r = _do_flock(file, fd, operation, nonblock);
+		}
+	}
+
+	return r;
+}
+
 static int _lock_file(const char *file, uint32_t flags)
 {
 	int operation;
@@ -207,7 +234,11 @@
 	log_very_verbose("Locking %s %c%c", ll->res, state,
 			 nonblock ? ' ' : 'B');
 
-	r = _do_flock(file, &ll->lf, operation, nonblock);
+	if (_prioritise_write_locks)
+		r = _do_write_priority_flock(file, &ll->lf, operation, nonblock);
+	else 
+		r = _do_flock(file, &ll->lf, operation, nonblock);
+
 	if (r)
 		dm_list_add(&_lock_list, &ll->list);
 	else {
@@ -299,6 +330,10 @@
 						DEFAULT_LOCK_DIR),
 		sizeof(_lock_dir));
 
+	_prioritise_write_locks =
+	    find_config_tree_bool(cmd, "global/prioritise_write_locks",
+				  DEFAULT_PRIORITISE_WRITE_LOCKS);
+
 	if (!dm_create_dir(_lock_dir))
 		return 0;
 


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

* LVM2 ./WHATS_NEW doc/example.conf lib/config/d ...
@ 2009-08-01 17:07 snitzer
  0 siblings, 0 replies; 8+ messages in thread
From: snitzer @ 2009-08-01 17:07 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2009-08-01 17:07:37

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/config     : defaults.h 
	lib/device     : device.c device.h 
	lib/format_text: format-text.c 
	lib/metadata   : metadata.c 
	man            : lvm.conf.5.in 

Log message:
	Add devices/data_alignment_offset_detection to lvm.conf.
	
	If the pvcreate --dataalignmentoffset option is not specified the start
	of a PV's aligned data area will be shifted by the associated
	'alignment_offset' exposed in sysfs (unless
	devices/data_alignment_offset_detection is disabled in lvm.conf).
	
	Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1223&r2=1.1224
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.h.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.275&r2=1.276
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.conf.5.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5

--- LVM2/WHATS_NEW	2009/07/31 18:30:31	1.1223
+++ LVM2/WHATS_NEW	2009/08/01 17:07:36	1.1224
@@ -4,6 +4,7 @@
   Added configure --enable-udev_rules --enable-udev_sync.
   Added configure --with-udev-prefix --with-udevdir.
   Added udev dir to hold udev rules.
+  Add devices/data_alignment_offset_detection to lvm.conf.
   Add --dataalignmentoffset to pvcreate to shift start of aligned data area.
   Fix _mda_setup() to not check first mda's size before pe_align rounding.
   Document -I option of clvmd in the man page.
--- LVM2/doc/example.conf	2009/07/24 23:29:03	1.42
+++ LVM2/doc/example.conf	2009/08/01 17:07:36	1.43
@@ -104,6 +104,15 @@
     # Set to 0 for the default alignment of 64KB or page size, if larger.
     data_alignment = 0
 
+    # By default, the start of the PV's aligned data area will be shifted by
+    # the 'alignment_offset' exposed in sysfs.  This offset is often 0 but
+    # may be non-zero; e.g.: certain 4KB sector drives that compensate for
+    # windows partitioning will have an alignment_offset of 3584 bytes
+    # (sector 7 is the lowest aligned logical block, the 4KB sectors start
+    # at LBA -1, and consequently sector 63 is aligned on a 4KB boundary).
+    # 1 enables; 0 disables.
+    data_alignment_offset_detection = 1
+
     # If, while scanning the system for PVs, LVM2 encounters a device-mapper
     # device that has its I/O suspended, it waits for it to become accessible.
     # Set this to 1 to skip such devices.  This should only be needed
--- LVM2/lib/config/defaults.h	2009/07/24 23:29:03	1.47
+++ LVM2/lib/config/defaults.h	2009/08/01 17:07:37	1.48
@@ -34,6 +34,7 @@
 #define DEFAULT_MD_COMPONENT_DETECTION 1
 #define DEFAULT_MD_CHUNK_ALIGNMENT 1
 #define DEFAULT_IGNORE_SUSPENDED_DEVICES 1
+#define DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION 1
 
 #define DEFAULT_LOCK_DIR "/var/lock/lvm"
 #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
--- LVM2/lib/device/device.c	2009/07/09 22:50:45	1.27
+++ LVM2/lib/device/device.c	2009/08/01 17:07:37	1.28
@@ -282,3 +282,74 @@
 	return 0;
 }
 #endif
+
+#ifdef linux
+
+static unsigned long _dev_topology_attribute(const char *attribute,
+					     const char *sysfs_dir,
+					     struct device *dev)
+{
+	char path[PATH_MAX+1], buffer[64];
+	FILE *fp;
+	struct stat info;
+	unsigned long result = 0UL;
+
+	if (!attribute || !*attribute)
+		return_0;
+
+	if (!sysfs_dir || !*sysfs_dir)
+		return_0;
+
+	if (dm_snprintf(path, PATH_MAX, "%s/dev/block/%d:%d/%s",
+			sysfs_dir, (int)MAJOR(dev->dev), (int)MINOR(dev->dev),
+			attribute) < 0) {
+		log_error("dm_snprintf %s failed", attribute);
+		return 0;
+	}
+
+	/* check if the desired sysfs attribute exists */
+	if (stat(path, &info) < 0)
+		return 0;
+
+	if (!(fp = fopen(path, "r"))) {
+		log_sys_error("fopen", path);
+		return 0;
+	}
+
+	if (!fgets(buffer, sizeof(buffer), fp)) {
+		log_sys_error("fgets", path);
+		goto out;
+	}
+
+	if (sscanf(buffer, "%lu", &result) != 1) {
+		log_error("sysfs file %s not in expected format: %s", path,
+			  buffer);
+		goto out;
+	}
+
+	log_very_verbose("Device %s %s is %lu bytes.",
+			 dev_name(dev), attribute, result);
+
+out:
+	if (fclose(fp))
+		log_sys_error("fclose", path);
+
+	return result >> SECTOR_SHIFT;
+}
+
+unsigned long dev_alignment_offset(const char *sysfs_dir,
+				   struct device *dev)
+{
+	return _dev_topology_attribute("alignment_offset",
+				       sysfs_dir, dev);
+}
+
+#else
+
+unsigned long dev_alignment_offset(const char *sysfs_dir,
+				   struct device *dev)
+{
+	return 0UL;
+}
+
+#endif
--- LVM2/lib/device/device.h	2009/07/06 19:04:25	1.40
+++ LVM2/lib/device/device.h	2009/08/01 17:07:37	1.41
@@ -100,4 +100,7 @@
 
 int is_partitioned_dev(struct device *dev);
 
+unsigned long dev_alignment_offset(const char *sysfs_dir,
+				   struct device *dev);
+
 #endif
--- LVM2/lib/format_text/format-text.c	2009/07/31 14:23:06	1.114
+++ LVM2/lib/format_text/format-text.c	2009/08/01 17:07:37	1.115
@@ -1772,7 +1772,11 @@
 				 "%lu sectors (requested %lu sectors)",
 				 pv_dev_name(pv), pv->pe_align, data_alignment);
 
-		set_pe_align_offset(pv, data_alignment_offset);
+		if (set_pe_align_offset(pv, data_alignment_offset) != data_alignment_offset &&
+		    data_alignment_offset)
+			log_warn("WARNING: %s: Overriding data alignment offset to "
+				 "%lu sectors (requested %lu sectors)",
+				 pv_dev_name(pv), pv->pe_align_offset, data_alignment_offset);
 
 		if (pv->pe_align < pv->pe_align_offset) {
 			log_error("%s: pe_align (%lu sectors) must not be less "
--- LVM2/lib/metadata/metadata.c	2009/07/30 17:45:29	1.275
+++ LVM2/lib/metadata/metadata.c	2009/08/01 17:07:37	1.276
@@ -105,6 +105,14 @@
 	if (!pv->dev)
 		goto out;
 
+	if (find_config_tree_bool(pv->fmt->cmd,
+				  "devices/data_alignment_offset_detection",
+				  DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION))
+		pv->pe_align_offset =
+			MAX(pv->pe_align_offset,
+			    dev_alignment_offset(pv->fmt->cmd->sysfs_dir,
+						 pv->dev));
+
 	log_very_verbose("%s: Setting PE alignment offset to %lu sectors.",
 			 dev_name(pv->dev), pv->pe_align_offset);
 
--- LVM2/man/lvm.conf.5.in	2009/07/24 23:29:03	1.4
+++ LVM2/man/lvm.conf.5.in	2009/08/01 17:07:37	1.5
@@ -142,10 +142,17 @@
 If a Physical Volume is placed directly upon an md device and
 \fBmd_chunk_alignment\fP is enabled this parameter is ignored.
 Set to 0 to use the default alignment of 64KB or the page size, if larger.
+.IP
+\fBdata_alignment_offset_detection\fP \(em If set to 1, and your kernel
+provides topology information in sysfs for the Physical Volume, the
+start of the aligned data area of the Physical Volume will be shifted
+by the alignment_offset exposed in sysfs.
 .sp
 To see the location of the first Physical Extent of an existing Physical Volume
 use \fBpvs -o +pe_start\fP .  It will be a multiple of the requested
-\fBdata_alignment\fP.
+\fBdata_alignment\fP plus the alignment_offset from
+\fBdata_alignment_offset_detection\fP (if enabled) or the pvcreate
+commandline.
 .TP
 \fBlog\fP \(em Default log settings
 .IP


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

* LVM2 ./WHATS_NEW doc/example.conf lib/config/d ...
@ 2009-07-24 23:29 agk
  0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2009-07-24 23:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-07-24 23:29:04

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/config     : defaults.h 
	lib/locking    : locking.c 
	man            : lvm.conf.5.in 

Log message:
	Add global/wait_for_locks to lvm.conf so blocking on locks can be disabled.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1201&r2=1.1202
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.conf.5.in.diff?cvsroot=lvm2&r1=1.3&r2=1.4

--- LVM2/WHATS_NEW	2009/07/24 18:15:06	1.1201
+++ LVM2/WHATS_NEW	2009/07/24 23:28:55	1.1202
@@ -1,5 +1,6 @@
 Version 2.02.50 - 
 ================================
+  Add global/wait_for_locks to lvm.conf so blocking for locks can be disabled.
   All LV locks are non-blocking so remove LCK_NONBLOCK from separate macros.
   Fix race condition with vgcreate and vgextend on same device (2.02.49).
   Remove redundant validate_name call from vgreduce.
--- LVM2/doc/example.conf	2009/07/06 19:04:25	1.41
+++ LVM2/doc/example.conf	2009/07/24 23:29:03	1.42
@@ -247,6 +247,9 @@
     # Type 3 uses built-in clustered locking.
     locking_type = 1
 
+    # Set to 0 to fail when a lock request cannot be satisfied immediately.
+    wait_for_locks = 1
+
     # If using external locking (type 2) and initialisation fails,
     # with this set to 1 an attempt will be made to use the built-in
     # clustered locking.
--- LVM2/lib/config/defaults.h	2009/07/09 10:00:36	1.46
+++ LVM2/lib/config/defaults.h	2009/07/24 23:29:03	1.47
@@ -39,6 +39,7 @@
 #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
 #define DEFAULT_FALLBACK_TO_LOCAL_LOCKING 1
 #define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1
+#define DEFAULT_WAIT_FOR_LOCKS 1
 
 #define DEFAULT_MIRRORLOG "disk"
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
--- LVM2/lib/locking/locking.c	2009/07/24 18:15:07	1.63
+++ LVM2/lib/locking/locking.c	2009/07/24 23:29:03	1.64
@@ -35,6 +35,7 @@
 static int _vg_lock_count = 0;		/* Number of locks held */
 static int _vg_write_lock_held = 0;	/* VG write lock held? */
 static int _signals_blocked = 0;
+static int _blocking_supported = 0;
 
 static volatile sig_atomic_t _sigint_caught = 0;
 static volatile sig_atomic_t _handler_installed;
@@ -217,7 +218,9 @@
 {
 	if (type < 0)
 		type = find_config_tree_int(cmd, "global/locking_type", 1);
-		
+
+	_blocking_supported = find_config_tree_int(cmd,
+	    "global/wait_for_locks", DEFAULT_WAIT_FOR_LOCKS);
 	
 	switch (type) {
 	case 0:
@@ -227,7 +230,9 @@
 		return 1;
 
 	case 1:
-		log_very_verbose("File-based locking selected.");
+		log_very_verbose("%sFile-based locking selected.",
+				 _blocking_supported ? "" : "Non-blocking ");
+
 		if (!init_file_locking(&_locking, cmd))
 			break;
 		return 1;
@@ -379,7 +384,7 @@
 		 * This will enforce correctness and prevent deadlocks rather
 		 * than relying on the caller to set the flag properly.
 		 */
-		if (vgs_locked())
+		if (!_blocking_supported || vgs_locked())
 			flags |= LCK_NONBLOCK;
 
 		/* Lock VG to change on-disk metadata. */
--- LVM2/man/lvm.conf.5.in	2009/07/06 19:04:25	1.3
+++ LVM2/man/lvm.conf.5.in	2009/07/24 23:29:03	1.4
@@ -270,6 +270,10 @@
 All changes to logical volumes and their states are communicated
 using locks.
 .IP
+\fBwait_for_locks\fP \(em When set to 1, the default, the tools
+wait if a lock request cannot be satisfied immediately.
+When set to 0, the operation is aborted instead.
+.IP
 \fBlocking_dir\fP \(em The directory LVM2 places its file locks
 if \fBlocking_type\fP is set to 1.  The default is \fB/var/lock/lvm\fP.
 .IP


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

* LVM2 ./WHATS_NEW doc/example.conf lib/config/d ...
@ 2006-09-02  1:18 agk
  0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2006-09-02  1:18 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-09-02 01:18:17

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/config     : defaults.h 
	lib/locking    : locking.c 
	tools          : lvconvert.c lvcreate.c lvrename.c lvresize.c 
	                 pvchange.c pvmove.c pvresize.c reporter.c 
	                 toollib.c vgextend.c vgmerge.c vgreduce.c 
	                 vgrename.c vgsplit.c 

Log message:
	When using local file locking, skip clustered VGs.
	Add fallback_to_clustered_locking and fallback_to_local_locking parameters.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.434&r2=1.435
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.123&r2=1.124
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvrename.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19

--- LVM2/WHATS_NEW	2006/08/31 22:21:00	1.434
+++ LVM2/WHATS_NEW	2006/09/02 01:18:16	1.435
@@ -1,5 +1,7 @@
 Version 2.02.10 - 
 ==================================
+  When using local file locking, skip clustered VGs.
+  Add fallback_to_clustered_locking and fallback_to_local_locking parameters.
   lvm.static uses built-in cluster locking instead of external locking.
   Don't attempt to load shared libraries if built statically.
   Change default locking_lib to liblvm2clusterlock.so.
--- LVM2/doc/example.conf	2006/08/31 20:56:33	1.26
+++ LVM2/doc/example.conf	2006/09/02 01:18:17	1.27
@@ -207,11 +207,26 @@
     # Location of proc filesystem
     proc = "/proc"
 
-    # Type of locking to use. Defaults to file-based locking (1).
+    # Type of locking to use. Defaults to local file-based locking (1).
     # Turn locking off by setting to 0 (dangerous: risks metadata corruption
     # if LVM2 commands get run concurrently).
+    # Type 2 uses the external shared library locking_library.
+    # Type 3 uses built-in clustered locking.
     locking_type = 1
 
+    # If using external locking (type 2) and initialisation fails,
+    # with this set to 1 an attempt will be made to use the built-in
+    # clustered locking.
+    # If you are using a customised locking_library you should set this to 0.
+    fallback_to_clustered_locking = 1
+
+    # If an attempt to initialise type 2 or type 3 locking failed, perhaps
+    # because cluster components such as clvmd are not running, with this set
+    # to 1 an attempt will be made to use local file-based locking (type 1).
+    # If this succeeds, only commands against local volume groups will proceed.
+    # Volume Groups marked as clustered will be ignored.
+    fallback_to_local_locking = 1
+
     # Local non-LV directory that holds file-based locks while commands are
     # in progress.  A directory like /tmp that may get wiped on reboot is OK.
     locking_dir = "/var/lock/lvm"
--- LVM2/lib/config/defaults.h	2006/08/31 20:56:33	1.28
+++ LVM2/lib/config/defaults.h	2006/09/02 01:18:17	1.29
@@ -33,6 +33,8 @@
 
 #define DEFAULT_LOCK_DIR "/var/lock/lvm"
 #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
+#define DEFAULT_FALLBACK_TO_LOCAL_LOCKING 1
+#define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1
 
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
 #define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
--- LVM2/lib/locking/locking.c	2006/08/31 22:21:00	1.32
+++ LVM2/lib/locking/locking.c	2006/09/02 01:18:17	1.33
@@ -20,6 +20,7 @@
 #include "activate.h"
 #include "toolcontext.h"
 #include "memlock.h"
+#include "defaults.h"
 
 #include <signal.h>
 #include <sys/stat.h>
@@ -147,6 +148,10 @@
 				break;
 			return 1;
 		}
+		if (!find_config_tree_int(cmd, "locking/fallback_to_clustered_locking",
+					  DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING))
+			break;
+		log_very_verbose("Falling back to clustered locking.");
 		/* Fall through */
 #endif
 
@@ -163,6 +168,16 @@
 		return 0;
 	}
 
+	if ((type == 2 || type == 3) &&
+            find_config_tree_int(cmd, "locking/fallback_to_local_locking",
+				 DEFAULT_FALLBACK_TO_LOCAL_LOCKING)) {
+		log_print("WARNING: Falling back to local file-based locking.");
+		log_print("Volume Groups with the clustered attribute will "
+			  "be inaccessible.");
+		if (init_file_locking(&_locking, cmd))
+			return 1;
+	}
+
 	if (!ignorelockingfailure())
 		return 0;
 
--- LVM2/tools/lvconvert.c	2006/08/17 18:23:44	1.19
+++ LVM2/tools/lvconvert.c	2006/09/02 01:18:17	1.20
@@ -565,6 +565,12 @@
 		goto error;
 	}
 
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", lp.vg_name);
+		goto error;
+	}
+
 	if (vg->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", lp.vg_name);
 		goto error;
--- LVM2/tools/lvcreate.c	2006/08/25 23:02:33	1.123
+++ LVM2/tools/lvcreate.c	2006/09/02 01:18:17	1.124
@@ -486,6 +486,12 @@
 		return 0;
 	}
 
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", lp->vg_name);
+		return 0;
+	}
+
 	if (vg->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", lp->vg_name);
 		return 0;
--- LVM2/tools/lvrename.c	2006/08/25 23:02:33	1.39
+++ LVM2/tools/lvrename.c	2006/09/02 01:18:17	1.40
@@ -109,6 +109,12 @@
 		goto error;
 	}
 
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg->name);
+		goto error;
+	}
+
 	if (vg->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", vg->name);
 		goto error;
--- LVM2/tools/lvresize.c	2006/08/21 12:54:53	1.74
+++ LVM2/tools/lvresize.c	2006/09/02 01:18:17	1.75
@@ -138,6 +138,12 @@
 		return ECMD_FAILED;
 	}
 
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg->name);
+		return ECMD_FAILED;
+	}
+
 	if (vg->status & EXPORTED_VG) {
 		log_error("Volume group %s is exported", vg->name);
 		return ECMD_FAILED;
--- LVM2/tools/pvchange.c	2006/05/09 21:23:51	1.42
+++ LVM2/tools/pvchange.c	2006/09/02 01:18:17	1.43
@@ -67,6 +67,12 @@
 			return 0;
 		}
 
+		if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+		    !lockingfailed()) {
+			log_error("Skipping clustered volume group %s", vg->name);
+			return 0;
+		}
+
 		if (vg->status & EXPORTED_VG) {
 			unlock_vg(cmd, pv->vg_name);
 			log_error("Volume group \"%s\" is exported", vg->name);
--- LVM2/tools/pvmove.c	2006/08/25 23:02:33	1.31
+++ LVM2/tools/pvmove.c	2006/09/02 01:18:17	1.32
@@ -66,6 +66,12 @@
 		return NULL;
 	}
 
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vgname);
+		return NULL;
+	}
+
 	if (vg->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", vgname);
 		unlock_vg(cmd, vgname);
--- LVM2/tools/pvresize.c	2006/04/12 21:23:04	1.2
+++ LVM2/tools/pvresize.c	2006/09/02 01:18:17	1.3
@@ -77,6 +77,13 @@
 			return ECMD_FAILED;
 		}
 
+		if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+		    !lockingfailed()) {
+			unlock_vg(cmd, vg_name);
+			log_error("Skipping clustered volume group %s", vg->name);
+			return ECMD_FAILED;
+		}
+
 		if (vg->status & EXPORTED_VG) {
 			unlock_vg(cmd, vg_name);
 			log_error("Volume group \"%s\" is exported", vg->name);
--- LVM2/tools/reporter.c	2006/05/16 16:48:31	1.15
+++ LVM2/tools/reporter.c	2006/09/02 01:18:17	1.16
@@ -68,13 +68,20 @@
 
 	if (!(vg = vg_read(cmd, pv->vg_name, NULL, &consistent))) {
 		log_error("Can't read %s: skipping", pv->vg_name);
-		unlock_vg(cmd, pv->vg_name);
-		return ECMD_FAILED;
+		goto out;
+	}
+
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg->name);
+		ret = ECMD_FAILED;
+		goto out;
 	}
 
 	if (!report_object(handle, vg, NULL, pv, NULL, pvseg))
 		ret = ECMD_FAILED;
 
+out:
 	unlock_vg(cmd, pv->vg_name);
 	return ret;
 }
@@ -109,14 +116,22 @@
 
 		if (!(vg = vg_read(cmd, pv->vg_name, (char *)&pv->vgid, &consistent))) {
 			log_error("Can't read %s: skipping", pv->vg_name);
-			unlock_vg(cmd, pv->vg_name);
-			return ECMD_FAILED;
+			goto out;
+		}
+
+		if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+		    !lockingfailed()) {
+			log_error("Skipping clustered volume group %s",
+				  vg->name);
+			ret = ECMD_FAILED;
+			goto out;
 		}
 	}
 
 	if (!report_object(handle, vg, NULL, pv, NULL, NULL))
 		ret = ECMD_FAILED;
 
+out:
 	if (pv->vg_name)
 		unlock_vg(cmd, pv->vg_name);
 
--- LVM2/tools/toollib.c	2006/08/25 23:02:33	1.86
+++ LVM2/tools/toollib.c	2006/09/02 01:18:17	1.87
@@ -329,9 +329,20 @@
 			if (!vg)
 				log_error("Volume group \"%s\" "
 					  "not found", vgname);
-			else
+			else {
+				if ((vg->status & CLUSTERED) &&
+			    	    !locking_is_clustered() &&
+				    !lockingfailed()) {
+					log_error("Skipping clustered volume "
+						  "group %s", vgname);
+					if (ret_max < ECMD_FAILED)
+						ret_max = ECMD_FAILED;
+					continue;
+				}
 				log_error("Volume group \"%s\" "
 					  "inconsistent", vgname);
+			}
+
 			if (!vg || !(vg = recover_vg(cmd, vgname, lock_type))) {
 				if (ret_max < ECMD_FAILED)
 					ret_max = ECMD_FAILED;
@@ -339,6 +350,15 @@
 			}
 		}
 
+		if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+		    !lockingfailed()) {
+			unlock_vg(cmd, vgname);
+			log_error("Skipping clustered volume group %s", vgname);
+			if (ret_max < ECMD_FAILED)
+				ret_max = ECMD_FAILED;
+			continue;
+		}
+
 		tags_arg = &tags;
 		list_init(&lvnames);	/* LVs to be processed in this VG */
 		list_iterate_items(sll, &arg_lvnames) {
@@ -438,6 +458,13 @@
 		return ECMD_FAILED;
 	}
 
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg_name);
+		unlock_vg(cmd, vg_name);
+		return ECMD_FAILED;
+	}
+
 	if (!list_empty(tags)) {
 		/* Only process if a tag matches or it's on arg_vgnames */
 		if (!str_list_match_item(arg_vgnames, vg_name) &&
@@ -680,6 +707,15 @@
 				}
 				if (!consistent)
 					continue;
+
+				if ((vg->status & CLUSTERED) &&
+				    !locking_is_clustered() &&
+				    !lockingfailed()) {
+					log_error("Skipping clustered volume "
+						  "group %s", sll->str);
+					continue;
+				}
+
 				ret = process_each_pv_in_vg(cmd, vg, &tags,
 							    handle,
 							    process_single);
@@ -1045,6 +1081,10 @@
 {
 	int consistent = 1;
 
+	/* Don't attempt automatic recovery without proper locking */
+	if (lockingfailed())
+		return NULL;
+
 	lock_type &= ~LCK_TYPE_MASK;
 	lock_type |= LCK_WRITE;
 
--- LVM2/tools/vgextend.c	2006/08/25 23:02:33	1.26
+++ LVM2/tools/vgextend.c	2006/09/02 01:18:17	1.27
@@ -53,6 +53,12 @@
 		goto error;
 	}
 
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg->name);
+		goto error;
+	}
+
 	if (vg->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", vg->name);
 		goto error;
--- LVM2/tools/vgmerge.c	2006/08/25 23:02:33	1.33
+++ LVM2/tools/vgmerge.c	2006/09/02 01:18:17	1.34
@@ -41,6 +41,13 @@
 		return ECMD_FAILED;
 	}
 
+	if ((vg_to->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg_name_to);
+		unlock_vg(cmd, vg_name_to);
+		return ECMD_FAILED;
+	}
+
 	if (vg_to->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", vg_to->name);
 		unlock_vg(cmd, vg_name_to);
@@ -66,6 +73,12 @@
 		goto error;
 	}
 
+        if ((vg_from->status & CLUSTERED) && !locking_is_clustered() &&
+            !lockingfailed()) {
+                log_error("Skipping clustered volume group %s", vg_name_from);
+                goto error;
+        }
+
 	if (vg_from->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", vg_from->name);
 		goto error;
--- LVM2/tools/vgreduce.c	2006/08/25 23:02:33	1.51
+++ LVM2/tools/vgreduce.c	2006/09/02 01:18:17	1.52
@@ -476,6 +476,13 @@
 		return ECMD_FAILED;
 	}
 
+	if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg->name);
+		unlock_vg(cmd, vg_name);
+		return ECMD_FAILED;
+	}
+
 	if (arg_count(cmd, removemissing_ARG)) {
 		if (vg && consistent) {
 			log_error("Volume group \"%s\" is already consistent",
@@ -491,6 +498,13 @@
 			unlock_vg(cmd, vg_name);
 			return ECMD_FAILED;
 		}
+		if ((vg->status & CLUSTERED) && !locking_is_clustered() &&
+		    !lockingfailed()) {
+			log_error("Skipping clustered volume group %s",
+				  vg->name);
+			unlock_vg(cmd, vg_name);
+			return ECMD_FAILED;
+		}
 		if (!archive(vg)) {
 			init_partial(0);
 			unlock_vg(cmd, vg_name);
--- LVM2/tools/vgrename.c	2006/08/25 23:02:33	1.40
+++ LVM2/tools/vgrename.c	2006/09/02 01:18:17	1.41
@@ -102,6 +102,13 @@
 		return ECMD_FAILED;
 	}
 
+	if ((vg_old->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg_old->name);
+		unlock_vg(cmd, vg_name_old);
+		return ECMD_FAILED;
+	}
+
 	if (vg_old->status & EXPORTED_VG)
 		log_info("Volume group \"%s\" is exported", vg_old->name);
 
--- LVM2/tools/vgsplit.c	2006/05/09 21:23:51	1.18
+++ LVM2/tools/vgsplit.c	2006/09/02 01:18:17	1.19
@@ -196,6 +196,13 @@
 		return ECMD_FAILED;
 	}
 
+	if ((vg_from->status & CLUSTERED) && !locking_is_clustered() &&
+	    !lockingfailed()) {
+		log_error("Skipping clustered volume group %s", vg_from->name);
+		unlock_vg(cmd, vg_name_from);
+		return ECMD_FAILED;
+	}
+
 	if (vg_from->status & EXPORTED_VG) {
 		log_error("Volume group \"%s\" is exported", vg_from->name);
 		unlock_vg(cmd, vg_name_from);


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

* LVM2 ./WHATS_NEW doc/example.conf lib/config/d ...
@ 2006-08-31 20:56 agk
  0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2006-08-31 20:56 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-08-31 20:56:33

Modified files:
	.              : WHATS_NEW 
	doc            : example.conf 
	lib/config     : defaults.h 
	man            : lvm.conf.5 

Log message:
	Change default locking_lib to liblvm2clusterlock.so.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.432&r2=1.433
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.conf.5.diff?cvsroot=lvm2&r1=1.16&r2=1.17

--- LVM2/WHATS_NEW	2006/08/25 23:02:33	1.432
+++ LVM2/WHATS_NEW	2006/08/31 20:56:33	1.433
@@ -1,5 +1,6 @@
 Version 2.02.10 - 
 ==================================
+  Change default locking_lib to liblvm2clusterlock.so.
   Add skip_dev_dir() to process command line VGs.
   Stop clvmd complaining about nodes that have left the cluster.
   Move lvm_snprintf(), split_words() and split_dm_name() into libdevmapper.
--- LVM2/doc/example.conf	2006/05/12 19:47:40	1.25
+++ LVM2/doc/example.conf	2006/08/31 20:56:33	1.26
@@ -223,6 +223,9 @@
 
     # Search this directory first for shared libraries.
     #   library_dir = "/lib"
+
+    # The external locking library to load if locking_type is set to 2.
+    #   locking_library = "liblvm2clusterlock.so"
 }
 
 activation {
--- LVM2/lib/config/defaults.h	2006/05/12 19:16:48	1.27
+++ LVM2/lib/config/defaults.h	2006/08/31 20:56:33	1.28
@@ -32,7 +32,7 @@
 #define DEFAULT_MD_COMPONENT_DETECTION 1
 
 #define DEFAULT_LOCK_DIR "/var/lock/lvm"
-#define DEFAULT_LOCKING_LIB "lvm2_locking.so"
+#define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
 
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
 #define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
--- LVM2/man/lvm.conf.5	2004/11/17 17:49:32	1.16
+++ LVM2/man/lvm.conf.5	2006/08/31 20:56:33	1.17
@@ -252,7 +252,7 @@
 .IP
 \fBlocking_library\fP \(em The name of the external locking
 library to load if \fBlocking_type\fP is set to 2.
-The default is \fBlvm2_locking.so\fP.  If you need to write
+The default is \fBliblvm2clusterlock.so\fP.  If you need to write
 such a library, look at the lib/locking source code directory.
 .TP
 \fBtags\fP \(em Host tag settings


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

end of thread, other threads:[~2010-01-06 13:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-01 17:08 LVM2 ./WHATS_NEW doc/example.conf lib/config/d snitzer
  -- strict thread matches above, loose matches on Subject: below --
2010-01-06 13:27 mbroz
2009-10-05 12:44 agk
2009-09-02 14:47 mornfall
2009-08-01 17:07 snitzer
2009-07-24 23:29 agk
2006-09-02  1:18 agk
2006-08-31 20:56 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).