public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/metadata/metadata.c lib/d ...
@ 2008-10-03 14:22 agk
  0 siblings, 0 replies; 2+ messages in thread
From: agk @ 2008-10-03 14:22 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-10-03 14:22:18

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

Log message:
	Fix conversion of md chunk size into sectors.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.970&r2=1.971
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.193&r2=1.194
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13

--- LVM2/WHATS_NEW	2008/10/01 22:48:26	1.970
+++ LVM2/WHATS_NEW	2008/10/03 14:22:17	1.971
@@ -1,7 +1,8 @@
 Version 2.02.41 -
 =====================================
+  Fix conversion of md chunk size into sectors.
   Free text metadata buffer after a failure writing it.
-  Fix misleading error message when there is no allocatable extents in VG.
+  Fix misleading error message when there are no allocatable extents in VG.
   Fix handling of PVs which reappeared with old metadata version.
   Fix mirror DSO to call vgreduce with proper parameters.
   Fix validation of --minor and --major in lvcreate to require -My always.
--- LVM2/lib/metadata/metadata.c	2008/09/25 15:59:10	1.193
+++ LVM2/lib/metadata/metadata.c	2008/10/03 14:22:18	1.194
@@ -75,13 +75,18 @@
 	/*
 	 * Align to chunk size of underlying md device if present
 	 */
-	if (pv->dev &&
-	    find_config_tree_bool(pv->fmt->cmd, "devices/md_chunk_alignment",
+	if (!pv->dev)
+		goto out;
+
+	if (find_config_tree_bool(pv->fmt->cmd, "devices/md_chunk_alignment",
 				  DEFAULT_MD_CHUNK_ALIGNMENT))
 		pv->pe_align = MAX(pv->pe_align,
 				   dev_md_chunk_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);
+
 out:
 	return pv->pe_align;
 }
--- LVM2/lib/device/dev-md.c	2008/09/19 07:18:03	1.12
+++ LVM2/lib/device/dev-md.c	2008/10/03 14:22:18	1.13
@@ -133,7 +133,7 @@
 	char path[PATH_MAX+1], buffer[64];
 	FILE *fp;
 	struct stat info;
-	unsigned long chunk_size = 0UL;
+	unsigned long chunk_size_bytes = 0UL;
 
 	if (MAJOR(dev->dev) != md_major())
 		return 0;
@@ -165,20 +165,20 @@
 		goto out;
 	}
 
-	if (sscanf(buffer, "%lu", &chunk_size) != 1) {
+	if (sscanf(buffer, "%lu", &chunk_size_bytes) != 1) {
 		log_error("sysfs file %s not in expected format: %s", path,
 			  buffer);
 		goto out;
 	}
 
-	log_very_verbose("Found chunksize %lu for md device %s.", chunk_size,
-			 dev_name(dev));
+	log_very_verbose("Device %s md chunk size is %lu bytes.",
+			 dev_name(dev), chunk_size_bytes);
 
 out:
 	if (fclose(fp))
 		log_sys_error("fclose", path);
 
-	return chunk_size;
+	return chunk_size_bytes >> SECTOR_SHIFT;
 }
 
 #else


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

* LVM2 ./WHATS_NEW lib/metadata/metadata.c lib/d ...
@ 2008-09-19  5:19 agk
  0 siblings, 0 replies; 2+ messages in thread
From: agk @ 2008-09-19  5:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-09-19 05:19:09

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

Log message:
	adjust pe_align for md chunk size

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.957&r2=1.958
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.188&r2=1.189
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.h.diff?cvsroot=lvm2&r1=1.35&r2=1.36

--- LVM2/WHATS_NEW	2008/09/19 04:27:27	1.957
+++ LVM2/WHATS_NEW	2008/09/19 05:19:08	1.958
@@ -1,6 +1,6 @@
 Version 2.02.40 - 
 ================================
-  Pass struct physical_volume to pe_align.
+  Pass struct physical_volume to pe_align and adjust for md chunk size.
   Store sysfs location in struct cmd_context.
   Avoid shuffling remaining mirror images when removing one, retaining primary.
   Add missing LV error target activation in _remove_mirror_images.
--- LVM2/lib/metadata/metadata.c	2008/09/19 04:27:27	1.188
+++ LVM2/lib/metadata/metadata.c	2008/09/19 05:19:09	1.189
@@ -66,9 +66,20 @@
 
 unsigned long pe_align(struct physical_volume *pv)
 {
-	if (!pv->pe_align)
-		pv->pe_align = MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
+	if (pv->pe_align)
+		goto out;
 
+	pv->pe_align = MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;
+
+	/*
+	 * Align to chunk size of underlying md device if present
+	 */
+	if (pv->dev)
+		pv->pe_align = MAX(pv->pe_align,
+				   dev_md_chunk_size(pv->fmt->cmd->sysfs_dir,
+						     pv->dev));
+
+out:
 	return pv->pe_align;
 }
 
--- LVM2/lib/device/dev-md.c	2008/06/23 19:26:21	1.10
+++ LVM2/lib/device/dev-md.c	2008/09/19 05:19:09	1.11
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004 Luca Berra
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -16,6 +16,7 @@
 #include "lib.h"
 #include "metadata.h"
 #include "xlate.h"
+#include "filter.h"
 
 #ifdef linux
 
@@ -124,6 +125,62 @@
 	return ret;
 }
 
+/*
+ * Retrieve chunk size from md device using sysfs.
+ */
+unsigned long dev_md_chunk_size(const char *sysfs_dir, struct device *dev)
+{
+	char path[PATH_MAX+1], buffer[64];
+	FILE *fp;
+	struct stat info;
+	unsigned long chunk_size = 0UL;
+
+	if (MAJOR(dev->dev) != md_major())
+		return 0;
+
+	if (!sysfs_dir || !*sysfs_dir)
+		return_0;
+
+	if (dm_snprintf(path, PATH_MAX, "%s/dev/block/%d:%d/md/chunk_size",
+	    sysfs_dir, MAJOR(dev->dev), MINOR(dev->dev)) < 0) {
+		log_error("dm_snprintf md chunk_size failed");
+		return 0;
+	}
+
+	/* old sysfs structure */
+	if (stat(path, &info) &&
+	    dm_snprintf(path, PATH_MAX, "%s/block/md%d/md/chunk_size",
+			sysfs_dir, MINOR(dev->dev)) < 0) {
+		log_error("dm_snprintf old md chunk size failed");
+		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", &chunk_size) != 1) {
+		log_error("sysfs file %s not in expected format: %s", path,
+			  buffer);
+		goto out;
+	}
+
+	log_very_verbose("Found chunksize %u for md device %s.", chunk_size,
+			 dev_name(dev));
+
+out:
+	if (fclose(fp))
+		log_sys_error("fclose", path);
+
+	return chunk_size;
+}
+
 #else
 
 int dev_is_md(struct device *dev __attribute((unused)),
@@ -132,4 +189,10 @@
 	return 0;
 }
 
+unsigned long dev_md_chunk_size(const char *sysfs_dir __attribute((unused)),
+				struct device *dev  __attribute((unused)))
+{
+	return 0UL;
+}
+
 #endif
--- LVM2/lib/device/device.h	2008/07/23 19:46:33	1.35
+++ LVM2/lib/device/device.h	2008/09/19 05:19:09	1.36
@@ -93,6 +93,7 @@
 
 /* Does device contain md superblock?  If so, where? */
 int dev_is_md(struct device *dev, uint64_t *sb);
+unsigned long dev_md_chunk_size(const char *sysfs_dir, struct device *dev);
 
 int is_partitioned_dev(struct device *dev);
 


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

end of thread, other threads:[~2008-10-03 14:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-03 14:22 LVM2 ./WHATS_NEW lib/metadata/metadata.c lib/d agk
  -- strict thread matches above, loose matches on Subject: below --
2008-09-19  5:19 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).