Skip to contentSkip to conversation

LVM2 Release 2.00.09 / device-mapper Release 1.00.09

linux-lvm Alasdair G Kergon 2 participants 2 messages Mar 31, 2004 Library code

lore
Share & tools
lore
#0 lore raw

I have generated new tarballs from today's CVS.

Main LVM2 changes since the last release:

Use sysfs to speed up device filtering with 2.6 kernels.
Add basic infrastructure for internationalisation.
Various build process tidy-ups and fixes.
Option to compile tools into library form.
Add LVM1-style colon output to vgdisplay.
Fix vgmknodes to remove dud /dev/mapper entries. [needs libdevmapper 1.00.09] Add lvchange --refresh to reload active LVs.
Fix LVM1-format lvreduce PV extent calculation.
Add support for tagging PV/VG/LVs and hosts.
Update docs to reflect move to sources.redhat.com.

ftp://sources.redhat.com/pub/lvm2/LVM2.2.00.09.tgz
http://sources.redhat.com/lvm2/

Main device-mapper changes:

Support for DM_LIST_VERSIONS ('dmsetup targets') with 2.4 kernels. Move mknodes support from dmsetup to libdevmapper so LVM2 can use it. Generated patches against 2.4.26-rc1.

ftp://sources.redhat.com/pub/dm/device-mapper.1.00.09.tgz
http://sources.redhat.com/dm/

Alasdair

Signature · 1 line
[email protected]
#1 lore raw
Quoted 1 line · Alasdair G Kergon

I have generated new tarballs from today's CVS.

I have created a new patch to ignore md component devices, The previous one was dubbed as 'hardcoded crap', this one implements a filter and is controlled by an lvm.conf option, so i hope it can get a warmer welcome.

Reading this list it seems that some people is confused by the current behaviour, and it is not safe to touch an md component device, which could happen if we do 'vgscan;vgchange -a y' before the md is activated. I really think something has to be done to fix it.

3 patches follows,
- first one changes dev-io.c to use lseek64 instead of lseek, so it can read large (>2GB) devices. It is required by the next one.
- second one implements the ignore md component devices
- third adds a check for zero sized devices in filter.c, i find it useful since all /dev/md devices can be open()-ed, even if they are not started, and it is better to ignore them rather than have label.c complain later. It could be changed to ignore devices smaller than LABEL_SIZE, but maybe this could be confusing.

Oh, it is based on a checkout of a couple of days ago, so i believe it will apply to 2.00.09.

Regards,
L.

Signature · 6 lines
Luca Berra -- [email protected]
       Communication Media & Services S.r.l.
/"\
\ /     ASCII RIBBON CAMPAIGN
 X        AGAINST HTML MAIL
/ \
lib/device/dev-io.c +3 -7
diff -urN LVM2/lib/device/dev-io.c LVM2.work/lib/device/dev-io.c
@@ -42,11 +42,7 @@
 #  endif
 #endif
 
-
-/* FIXME Use _llseek for 64-bit
-_syscall5(int,  _llseek,  uint,  fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh);
- if (_llseek((unsigned) fd, (ulong) (offset >> 32), (ulong) (offset & 0xFFFFFFFF), &pos, SEEK_SET) < 0) { 
-*/
+extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 
 static LIST_INIT(_open_devices);
 
@@ -77,7 +73,7 @@
 		return 0;
 	}
 
-	if (lseek(fd, (off_t) where->start, SEEK_SET) < 0) {
+	if (lseek64(fd, where->start, SEEK_SET) < 0LL) {
 		log_sys_error("lseek", dev_name(where->dev));
 		return 0;
 	}
@@ -319,7 +315,7 @@
 #endif
 
 	if ((flags & O_CREAT) && !(flags & O_TRUNC)) {
-		dev->end = lseek(dev->fd, (off_t) 0, SEEK_END);
+		dev->end = lseek64(dev->fd, 0, SEEK_END);
 	}
 
 	list_add(&_open_devices, &dev->open_list);
doc/example.conf +6 -3
diff -urN LVM2/doc/example.conf LVM2.work/doc/example.conf
@@ -27,9 +27,6 @@
     # the device will be accepted or rejected (ignored).  Devices that
     # don't match any patterns are accepted.
 
-    # If using RAID md devices as physical volumes, you should
-    # set up a filter here to reject the constituent devices.
-
     # Remember to run vgscan after you change this parameter to ensure 
     # that the cache file gets regenerated (see below).
 
@@ -48,6 +45,12 @@
     # Use anchors if you want to be really specific
     # filter = [ "a|^/dev/hda8$|", "r/.*/" ]
 
+    # This option tells LVM2 to search for a RAID md superblock inside
+    # every device and to ignore those that contain one.
+    # If using RAID md devices as physical volumes, you should leave
+    # it at 1 or set up a filter to reject the constituent devices.
+    ignore_md_component = 1
+
     # The results of the filtering are cached on disk to avoid
     # rescanning dud devices (which can take a very long time).  By
     # default this cache file is hidden in the /etc/lvm directory.
include/.symlinks +1 -0
diff -urN LVM2/include/.symlinks LVM2.work/include/.symlinks
@@ -17,6 +17,7 @@
 ../lib/filters/filter-persistent.h
 ../lib/filters/filter-regex.h
 ../lib/filters/filter-sysfs.h
+../lib/filters/filter-md.h
 ../lib/filters/filter.h
 ../lib/format1/format1.h
 ../lib/format_text/format-text.h
lib/commands/toolcontext.c +9 -1
diff -urN LVM2/lib/commands/toolcontext.c LVM2.work/lib/commands/toolcontext.c
@@ -17,6 +17,7 @@
 #include "filter-persistent.h"
 #include "filter-regex.h"
 #include "filter-sysfs.h"
+#include "filter-md.h"
 #include "label.h"
 #include "lvm-file.h"
 #include "format-text.h"
@@ -266,7 +267,7 @@
 	return 1;
 }
 
-#define MAX_FILTERS 3
+#define MAX_FILTERS 4
 
 static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
 {
@@ -300,6 +301,13 @@
 		return NULL;
 	}
 
+	/* filter to skip md components */
+	if (find_config_bool(cmd->cft->root, "devices/ignore_md_component",
+			     DEFAULT_IGNORE_MD)) {
+		if ((filters[nr_filt] = md_filter_create()))
+			nr_filt++;
+	}
+
 	/* only build a composite filter if we really need it */
 	return (nr_filt == 1) ?
 	    filters[0] : composite_filter_create(nr_filt, filters);
lib/config/defaults.h +1 -0
diff -urN LVM2/lib/config/defaults.h LVM2.work/lib/config/defaults.h
@@ -20,6 +20,7 @@
 #define DEFAULT_DEV_DIR "/dev"
 #define DEFAULT_PROC_DIR "/proc"
 #define DEFAULT_SYSFS_SCAN 1
+#define DEFAULT_IGNORE_MD 1
 
 #define DEFAULT_LOCK_DIR "/var/lock/lvm"
 #define DEFAULT_LOCKING_LIB "lvm2_locking.so"
lib/filters/filter-md.c +71 -0

71 lines not on this page · raw message

lib/filters/filter-md.h +15 -0
diff -urN LVM2/lib/filters/filter-md.h LVM2.work/lib/filters/filter-md.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2004 Luca Berra
+ *
+ * This file is released under the GPL.
+ */
+
+#ifndef _LVM_FILTER_MD_H
+#define _LVM_FILTER_MD_H
+
+#include "config.h"
+#include "dev-cache.h"
+
+struct dev_filter *md_filter_create(void);
+
+#endif
lib/Makefile.in +1 -0
diff -urN LVM2/lib/Makefile.in LVM2.work/lib/Makefile.in
@@ -29,6 +29,7 @@
 	filters/filter-persistent.c \
 	filters/filter-regex.c \
 	filters/filter-sysfs.c \
+	filters/filter-md.c \
 	filters/filter.c \
 	format_text/archive.c \
 	format_text/export.c \
lib/filters/filter.c +5 -7
diff -urN LVM2/lib/filters/filter.c LVM2.work/lib/filters/filter.c
@@ -64,7 +65,7 @@
 static int _passes_lvm_type_device_filter(struct dev_filter *f,
 					  struct device *dev)
 {
-	int fd;
+	uint64_t size = 0;
 	const char *name = dev_name(dev);
 
 	/* Is this a recognised device type? */
@@ -74,15 +75,13 @@
 		return 0;
 	}
 
-	/* Check it's accessible */
-	if ((fd = open(name, O_RDONLY)) < 0) {
-		log_debug("%s: Skipping: open failed: %s", name,
-			  strerror(errno));
+	/* Check it's accessible and not empty */
+	dev_get_size(dev, &size);
+	if (size == 0) {
+		log_debug("%s: Skipping: Cannot open or empty", name);
 		return 0;
 	}
 
-	close(fd);
-
 	return 1;
 }