public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/device/dev-md.c
@ 2011-07-08 15:54 mbroz
  0 siblings, 0 replies; 5+ messages in thread
From: mbroz @ 2011-07-08 15:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-07-08 15:53:59

Modified files:
	.              : WHATS_NEW 
	lib/device     : dev-md.c 

Log message:
	Fix warning for pvcreate over MD linear.
	
	If MD linear device has set rounding (overload chunk size attribute),
	the pvcreate command prints this warning:
	
	/dev/md0 sysfs attr level not in expected format: linear

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2038&r2=1.2039
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22

--- LVM2/WHATS_NEW	2011/07/08 12:49:50	1.2038
+++ LVM2/WHATS_NEW	2011/07/08 15:53:59	1.2039
@@ -1,5 +1,6 @@
 Version 2.02.86 -  
 =================================
+  Fix warning in pvcreate for MD linear devices.
   Move snapshot removal activation logic into lib/activate.
   Cope with a PV only discovered missing when creating deptree.
   Abort operation if dm_tree_node_add_target_area fails.
--- LVM2/lib/device/dev-md.c	2011/05/28 09:48:14	1.21
+++ LVM2/lib/device/dev-md.c	2011/07/08 15:53:59	1.22
@@ -27,6 +27,7 @@
 #define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
 #define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) \
 				- MD_RESERVED_SECTORS)
+#define MD_MAX_SYSFS_SIZE 64
 
 static int _dev_has_md_magic(struct device *dev, uint64_t sb_offset)
 {
@@ -176,7 +177,7 @@
 				     const char *attribute_fmt,
 				     void *attribute_value)
 {
-	char path[PATH_MAX+1], buffer[64];
+	char path[PATH_MAX+1], buffer[MD_MAX_SYSFS_SIZE];
 	FILE *fp;
 	int ret = 0;
 
@@ -231,15 +232,20 @@
  */
 static int dev_md_level(const char *sysfs_dir, struct device *dev)
 {
+	char level_string[MD_MAX_SYSFS_SIZE];
 	const char *attribute = "level";
 	int level = -1;
 
 	if (_md_sysfs_attribute_scanf(sysfs_dir, dev, attribute,
-				      "raid%d", &level) != 1)
+				      "%s", &level_string) != 1)
 		return -1;
 
-	log_very_verbose("Device %s %s is raid%d.",
-			 dev_name(dev), attribute, level);
+	log_very_verbose("Device %s %s is %s.",
+			 dev_name(dev), attribute, level_string);
+
+	/*  We only care about raid - ignore linear/faulty/multipath etc. */
+	if (sscanf(level_string, "raid%d", &level) != 1)
+		return -1;
 
 	return level;
 }


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

* LVM2 ./WHATS_NEW lib/device/dev-md.c
@ 2008-06-23 19:26 wysochanski
  0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2008-06-23 19:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-06-23 19:26:21

Modified files:
	.              : WHATS_NEW 
	lib/device     : dev-md.c 

Log message:
	Suppress invalid 'sb_offset' compiler warning (FC8) with uninitialized_var().
	
	device/dev-md.c:61: warning: ‘sb_offset’ may be used uninitialized in this function

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.913&r2=1.914
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10

--- LVM2/WHATS_NEW	2008/06/23 19:04:34	1.913
+++ LVM2/WHATS_NEW	2008/06/23 19:26:20	1.914
@@ -1,5 +1,6 @@
 Version 2.02.39 -
 ================================
+  Suppress invalid 'sb_offset' compiler warning with uninitialzed_var().
   Add uninitialzed_var() macro to suppress invalid compiler warnings.
   Suppress 'sb_offset' compiler warning by using enum for md minor sb version. 
   lvm2_run: Don't return uninitialized "ret" for _memlock_inc or _memlock_dec.
--- LVM2/lib/device/dev-md.c	2008/06/23 14:54:50	1.9
+++ LVM2/lib/device/dev-md.c	2008/06/23 19:26:21	1.10
@@ -58,7 +58,7 @@
 
 static uint64_t _v1_sb_offset(uint64_t size, md_minor_version_t minor_version)
 {
-	uint64_t sb_offset;
+	uint64_t uninitialized_var(sb_offset);
 
 	switch(minor_version) {
 	case MD_MINOR_V0:


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

* LVM2 ./WHATS_NEW lib/device/dev-md.c
@ 2008-06-23 14:54 wysochanski
  0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2008-06-23 14:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-06-23 14:54:50

Modified files:
	.              : WHATS_NEW 
	lib/device     : dev-md.c 

Log message:
	Suppress 'sb_offset' compiler warning by using enum for md superblock versions.
	
	The warning is bogus and is only seen on certain versions of gcc.
	However using the enum does seem to clarify the intent of the code - only
	3 possible md minor superblock versions.
	
	Related compiler warning:
	device/dev-md.c:53: warning: 'sb_offset' may be used uninitialized in this function

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.911&r2=1.912
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9

--- LVM2/WHATS_NEW	2008/06/23 09:27:45	1.911
+++ LVM2/WHATS_NEW	2008/06/23 14:54:49	1.912
@@ -1,5 +1,6 @@
 Version 2.02.39 -
 ================================
+  Suppress 'sb_offset' compiler warning by using enum for md minor sb version. 
   lvm2_run: Don't return uninitialized "ret" for _memlock_inc or _memlock_dec.
   Avoid link failure when configuring without --enable-cmdlib.
   Avoid link failure when configuring without --enable-readline.
--- LVM2/lib/device/dev-md.c	2007/10/24 11:24:24	1.8
+++ LVM2/lib/device/dev-md.c	2008/06/23 14:54:50	1.9
@@ -48,18 +48,26 @@
  * 1: At start of device
  * 2: 4K from start of device.
  */
-static uint64_t _v1_sb_offset(uint64_t size, unsigned minor_version)
+typedef enum {
+	MD_MINOR_VERSION_MIN,
+	MD_MINOR_V0 = MD_MINOR_VERSION_MIN,
+	MD_MINOR_V1,
+	MD_MINOR_V2,
+	MD_MINOR_VERSION_MAX = MD_MINOR_V2
+} md_minor_version_t;
+
+static uint64_t _v1_sb_offset(uint64_t size, md_minor_version_t minor_version)
 {
 	uint64_t sb_offset;
 
 	switch(minor_version) {
-	case 0:
+	case MD_MINOR_V0:
 		sb_offset = (size - 8 * 2) & ~(4 * 2 - 1ULL);
 		break;
-	case 1:
+	case MD_MINOR_V1:
 		sb_offset = 0;
 		break;
-	case 2:
+	case MD_MINOR_V2:
 		sb_offset = 4 * 2;
 		break;
 	}
@@ -74,7 +82,7 @@
 int dev_is_md(struct device *dev, uint64_t *sb)
 {
 	int ret = 1;
-	unsigned minor = 0;
+	md_minor_version_t minor;
 	uint64_t size, sb_offset;
 
 	if (!dev_get_size(dev, &size)) {
@@ -96,12 +104,13 @@
 	if (_dev_has_md_magic(dev, sb_offset))
 		goto out;
 
+	minor = MD_MINOR_VERSION_MIN;
 	/* Version 1, try v1.0 -> v1.2 */
 	do {
 		sb_offset = _v1_sb_offset(size, minor);
 		if (_dev_has_md_magic(dev, sb_offset))
 			goto out;
-	} while (++minor <= 2);
+	} while (++minor <= MD_MINOR_VERSION_MAX);
 
 	ret = 0;
 


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

* LVM2 ./WHATS_NEW lib/device/dev-md.c
@ 2007-10-24  0:51 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-10-24  0:51 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-10-24 00:51:05

Modified files:
	.              : WHATS_NEW 
	lib/device     : dev-md.c 

Log message:
	Detect md superblocks version 1.0, 1.1 and 1.2.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.721&r2=1.722
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7

--- LVM2/WHATS_NEW	2007/10/12 18:37:19	1.721
+++ LVM2/WHATS_NEW	2007/10/24 00:51:05	1.722
@@ -1,5 +1,6 @@
 Version 2.02.29 -
 ==================================
+  Detect md superblocks version 1.0, 1.1 and 1.2.
   Add _alloc_pv() and _free_pv() from _pv_create() code and fix error paths.
   Add pv_dev_name() to access PV device name.
   Add const attributes to pv accessor functions.
--- LVM2/lib/device/dev-md.c	2007/10/24 00:30:30	1.6
+++ LVM2/lib/device/dev-md.c	2007/10/24 00:51:05	1.7
@@ -40,15 +40,35 @@
 	return 0;
 }
 
+/* FIXME Explain this algorithm */
+static uint64_t _v1_sb_offset(uint64_t size, int minor_version)
+{
+	uint64_t sb_offset;
+
+	switch(minor_version) {
+	case 0:
+		sb_offset = (size - 8 * 2) & ~(4 * 2 - 1);
+		break;
+	case 1:
+		sb_offset = 0;
+		break;
+	case 2:
+		sb_offset = 4 * 2;
+		break;
+	}
+	sb_offset <<= SECTOR_SHIFT;
+
+	return sb_offset;
+}
+
 /*
  * Returns -1 on error
  */
 int dev_is_md(struct device *dev, uint64_t *sb)
 {
-	int ret = 0;
-
+	int ret = 1;
+	unsigned minor = 0;
 	uint64_t size, sb_offset;
-	uint32_t md_magic;
 
 	if (!dev_get_size(dev, &size)) {
 		stack;
@@ -63,24 +83,35 @@
 		return -1;
 	}
 
+	/* Check if it is an md component device. */
+	/* Version 0.90.0 */
 	sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
+	if (_dev_has_md_magic(dev, sb_offset))
+		goto out;
 
-	/* Check if it is an md component device. */
-	if (_dev_has_md_magic(dev, sb_offset)) {
-		if (sb)
-			*sb = sb_offset;
-		ret = 1;
-	}
+	/* Version 1, try v1.0 -> v1.2 */
+	do {
+		sb_offset = _v1_sb_offset(size, minor);
+		if (_dev_has_md_magic(dev, sb_offset))
+			goto out;
+	} while (++minor <= 2);
+
+	ret = 0;
 
+out:
 	if (!dev_close(dev))
 		stack;
 
+	if (ret && sb)
+		*sb = sb_offset;
+
 	return ret;
 }
 
 #else
 
-int dev_is_md(struct device *dev __attribute((unused)), uint64_t *sb __attribute((unused)))
+int dev_is_md(struct device *dev __attribute((unused)),
+	      uint64_t *sb __attribute((unused)))
 {
 	return 0;
 }


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

* LVM2 ./WHATS_NEW lib/device/dev-md.c
@ 2007-01-26 17:15 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-01-26 17:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-01-26 17:15:16

Modified files:
	.              : WHATS_NEW 
	lib/device     : dev-md.c 

Log message:
	Fix md signature check to handle both endiannesses.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.562&r2=1.563
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4

--- LVM2/WHATS_NEW	2007/01/25 23:40:33	1.562
+++ LVM2/WHATS_NEW	2007/01/26 17:15:16	1.563
@@ -1,5 +1,6 @@
 Version 2.02.21 -
 ===================================
+  Fix md signature check to handle both endiannesses.
 
 Version 2.02.20 - 25th January 2007
 ===================================
--- LVM2/lib/device/dev-md.c	2004/11/27 22:07:41	1.3
+++ LVM2/lib/device/dev-md.c	2007/01/26 17:15:16	1.4
@@ -53,8 +53,10 @@
 	sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
 
 	/* Check if it is an md component device. */
+	/* Version 1 is little endian; version 0.90.0 is machine endian */
 	if (dev_read(dev, sb_offset, sizeof(uint32_t), &md_magic) &&
-	    (md_magic == xlate32(MD_SB_MAGIC))) {
+	    ((md_magic == xlate32(MD_SB_MAGIC)) ||
+	     (md_magic == MD_SB_MAGIC))) {
 		if (sb)
 			*sb = sb_offset;
 		ret = 1;


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

end of thread, other threads:[~2011-07-08 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-08 15:54 LVM2 ./WHATS_NEW lib/device/dev-md.c mbroz
  -- strict thread matches above, loose matches on Subject: below --
2008-06-23 19:26 wysochanski
2008-06-23 14:54 wysochanski
2007-10-24  0:51 agk
2007-01-26 17:15 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).