r187 - in devmapper/upstream/current: . dmsetup include kernel/ioctl lib lib/ioctl

Bastian Blank waldi at costa.debian.org
Thu Sep 29 16:50:44 UTC 2005


Author: waldi
Date: Thu Sep 29 16:50:43 2005
New Revision: 187

Modified:
   devmapper/upstream/current/VERSION
   devmapper/upstream/current/WHATS_NEW
   devmapper/upstream/current/dmsetup/dmsetup.c
   devmapper/upstream/current/include/list.h
   devmapper/upstream/current/kernel/ioctl/dm-ioctl.h
   devmapper/upstream/current/lib/ioctl/libdm-iface.c
   devmapper/upstream/current/lib/libdm-common.c
Log:
Load device-mapper.1.01.04 into /devmapper/upstream/current.


Modified: devmapper/upstream/current/VERSION
==============================================================================
--- devmapper/upstream/current/VERSION	(original)
+++ devmapper/upstream/current/VERSION	Thu Sep 29 16:50:43 2005
@@ -1 +1 @@
-1.01.04 (2005-08-02)
+1.01.05 (2005-09-26)

Modified: devmapper/upstream/current/WHATS_NEW
==============================================================================
--- devmapper/upstream/current/WHATS_NEW	(original)
+++ devmapper/upstream/current/WHATS_NEW	Thu Sep 29 16:50:43 2005
@@ -1,5 +1,13 @@
-Version 1.01.04 - 2 Aug 2005
+Version 1.01.05 - 26 Sep 2005
 =============================
+  Resync list.h with LVM2.
+  Remember increased buffer size and use for subsequent calls.
+  On 'buffer full' condition, double buffer size and repeat ioctl.
+  Fix termination of getopt_long() option array.
+  Report 'buffer full' condition with v4 ioctl as well as with v1.
+
+Version 1.01.04 - 2 Aug 2005
+============================
   Fix dmsetup ls -j and status --target with empty table.
 
 Version 1.01.03 - 13 Jun 2005

Modified: devmapper/upstream/current/dmsetup/dmsetup.c
==============================================================================
--- devmapper/upstream/current/dmsetup/dmsetup.c	(original)
+++ devmapper/upstream/current/dmsetup/dmsetup.c	Thu Sep 29 16:50:43 2005
@@ -1041,7 +1041,7 @@
 		{"uuid", 1, &ind, UUID_ARG},
 		{"verbose", 1, &ind, VERBOSE_ARG},
 		{"version", 0, &ind, VERSION_ARG},
-		{"", 0, NULL, 0}
+		{0, 0, 0, 0}
 	};
 #else
 	struct option long_options;

Modified: devmapper/upstream/current/include/list.h
==============================================================================
--- devmapper/upstream/current/include/list.h	(original)
+++ devmapper/upstream/current/include/list.h	Thu Sep 29 16:50:43 2005
@@ -105,6 +105,22 @@
 }
 
 /*
+ * Return first element of the list or NULL if empty
+ */
+static inline struct list *list_first(struct list *head)
+{
+	return (list_empty(head) ? NULL : head->n);
+}
+
+/*
+ * Return last element of the list or NULL if empty
+ */
+static inline struct list *list_last(struct list *head)
+{
+	return (list_empty(head) ? NULL : head->p);
+}
+
+/*
  * Return the previous element of the list, or NULL if we've reached the start.
  */
 static inline struct list *list_prev(struct list *head, struct list *elem)
@@ -188,6 +204,25 @@
 #define list_iterate_items(v, head) list_iterate_items_gen(v, (head), list)
 
 /*
+ * Walk a list backwards, setting 'v' in turn to the containing structure 
+ * of each item.
+ * The containing structure should be the same type as 'v'.
+ * The 'struct list' variable within the containing structure is 'field'.
+ */
+#define list_iterate_back_items_gen(v, head, field) \
+	for (v = list_struct_base((head)->p, typeof(*v), field); \
+	     &v->field != (head); \
+	     v = list_struct_base(v->field.p, typeof(*v), field))
+
+/*
+ * Walk a list backwards, setting 'v' in turn to the containing structure 
+ * of each item.
+ * The containing structure should be the same type as 'v'.
+ * The list should be 'struct list list' within the containing structure.
+ */
+#define list_iterate_back_items(v, head) list_iterate_back_items_gen(v, (head), list)
+
+/*
  * Return the number of elements in a list by walking it.
  */
 static inline unsigned int list_size(const struct list *head)

Modified: devmapper/upstream/current/kernel/ioctl/dm-ioctl.h
==============================================================================
--- devmapper/upstream/current/kernel/ioctl/dm-ioctl.h	(original)
+++ devmapper/upstream/current/kernel/ioctl/dm-ioctl.h	Thu Sep 29 16:50:43 2005
@@ -267,14 +267,16 @@
 #define DM_TABLE_CLEAR   _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
 #define DM_TABLE_DEPS    _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
 #define DM_TABLE_STATUS  _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
+
 #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
+
 #define DM_TARGET_MSG	 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
- 
+
 #define DM_VERSION_MAJOR	4
 #define DM_VERSION_MINOR	2
 #define DM_VERSION_PATCHLEVEL	0
 #define DM_VERSION_EXTRA	"-ioctl (2004-06-08)"
-  
+
 /* Status bits */
 #define DM_READONLY_FLAG	(1 << 0) /* In/Out */
 #define DM_SUSPEND_FLAG		(1 << 1) /* In/Out */

Modified: devmapper/upstream/current/lib/ioctl/libdm-iface.c
==============================================================================
--- devmapper/upstream/current/lib/ioctl/libdm-iface.c	(original)
+++ devmapper/upstream/current/lib/ioctl/libdm-iface.c	Thu Sep 29 16:50:43 2005
@@ -63,6 +63,7 @@
 static int _control_fd = -1;
 static int _version_checked = 0;
 static int _version_ok = 1;
+static unsigned _ioctl_buffer_double_factor = 0;
 
 /*
  * Support both old and new major numbers to ease the transition.
@@ -610,8 +611,10 @@
 	if (dmt->type == DM_DEVICE_TABLE)
 		dmi->flags |= DM_STATUS_TABLE_FLAG;
 
-	log_debug("dm %s %s %s %s", _cmd_data_v1[dmt->type].name, dmi->name,
-		  dmi->uuid, dmt->newname ? dmt->newname : "");
+	log_debug("dm %s %s %s%s%s [%u]", _cmd_data_v1[dmt->type].name,
+		  dmi->name, dmi->uuid, dmt->newname ? " " : "",
+		  dmt->newname ? dmt->newname : "",
+		  dmi->data_size);
 	if (dmt->type == DM_DEVICE_LIST) {
 		if (!_dm_names_v1(dmi))
 			goto bad;
@@ -1026,7 +1029,7 @@
 	return out;
 }
 
-static struct dm_ioctl *_flatten(struct dm_task *dmt)
+static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
 {
 	const size_t min_size = 16 * 1024;
 	const int (*version)[3];
@@ -1077,6 +1080,10 @@
 	if (len < min_size)
 		len = min_size;
 
+	/* Increase buffer size if repeating because buffer was too small */
+	while (repeat_count--)
+		len *= 2;
+
 	if (!(dmi = malloc(len)))
 		return NULL;
 
@@ -1276,40 +1283,15 @@
 	return r;
 }
 
-int dm_task_run(struct dm_task *dmt)
+static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
+				     unsigned repeat_count)
 {
-	struct dm_ioctl *dmi = NULL;
-	unsigned int command;
-
-#ifdef DM_COMPAT
-	if (_dm_version == 1)
-		return _dm_task_run_v1(dmt);
-#endif
-
-	if ((unsigned) dmt->type >=
-	    (sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) {
-		log_error("Internal error: unknown device-mapper task %d",
-			  dmt->type);
-		goto bad;
-	}
-
-	command = _cmd_data_v4[dmt->type].cmd;
-
-	/* Old-style creation had a table supplied */
-	if (dmt->type == DM_DEVICE_CREATE && dmt->head)
-		return _create_and_load_v4(dmt);
-
-	if (dmt->type == DM_DEVICE_MKNODES && !dmt->dev_name &&
-	    !dmt->uuid && dmt->major <= 0)
-		return _mknodes_v4(dmt);
-
-	if (!_open_control())
-		return 0;
+	struct dm_ioctl *dmi;
 
-	dmi = _flatten(dmt);
+	dmi = _flatten(dmt, repeat_count);
 	if (!dmi) {
 		log_error("Couldn't create ioctl argument");
-		return 0;
+		return NULL;
 	}
 
 	if (dmt->type == DM_DEVICE_TABLE)
@@ -1320,10 +1302,13 @@
 	if (dmt->no_open_count)
 		dmi->flags |= DM_SKIP_BDGET_FLAG;
 
-	log_debug("dm %s %s %s %s%c %.0llu %s", _cmd_data_v4[dmt->type].name,
-		  dmi->name, dmi->uuid, dmt->newname ? dmt->newname : "",
+	log_debug("dm %s %s %s%s%s %c %.0llu %s [%u]",
+		  _cmd_data_v4[dmt->type].name,
+		  dmi->name, dmi->uuid, dmt->newname ? " " : "",
+		  dmt->newname ? dmt->newname : "",
 		  dmt->no_open_count ? 'N' : 'O',
-		  dmt->sector, dmt->message ? dmt->message : "");
+		  dmt->sector, dmt->message ? dmt->message : "",
+		  dmi->data_size);
 #ifdef DM_IOCTLS
 	if (ioctl(_control_fd, command, dmi) < 0) {
 		if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) ||
@@ -1338,11 +1323,64 @@
 				log_error("device-mapper ioctl "
 					  "cmd %d failed: %s",
 					  _IOC_NR(command), strerror(errno));
-			goto bad;
+			free(dmi);
+			return NULL;
 		}
 	}
 #else /* Userspace alternative for testing */
 #endif
+	return dmi;
+}
+
+int dm_task_run(struct dm_task *dmt)
+{
+	struct dm_ioctl *dmi;
+	unsigned command;
+
+#ifdef DM_COMPAT
+	if (_dm_version == 1)
+		return _dm_task_run_v1(dmt);
+#endif
+
+	if ((unsigned) dmt->type >=
+	    (sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) {
+		log_error("Internal error: unknown device-mapper task %d",
+			  dmt->type);
+		return 0;
+	}
+
+	command = _cmd_data_v4[dmt->type].cmd;
+
+	/* Old-style creation had a table supplied */
+	if (dmt->type == DM_DEVICE_CREATE && dmt->head)
+		return _create_and_load_v4(dmt);
+
+	if (dmt->type == DM_DEVICE_MKNODES && !dmt->dev_name &&
+	    !dmt->uuid && dmt->major <= 0)
+		return _mknodes_v4(dmt);
+
+	if (!_open_control())
+		return 0;
+
+repeat_ioctl:
+	if (!(dmi = _do_dm_ioctl(dmt, command, _ioctl_buffer_double_factor)))
+		return 0;
+
+	if (dmi->flags & DM_BUFFER_FULL_FLAG) {
+		switch (dmt->type) {
+		case DM_DEVICE_LIST_VERSIONS:
+		case DM_DEVICE_LIST:
+		case DM_DEVICE_DEPS:
+		case DM_DEVICE_STATUS:
+		case DM_DEVICE_TABLE:
+		case DM_DEVICE_WAITEVENT:
+			_ioctl_buffer_double_factor++;
+			free(dmi);
+			goto repeat_ioctl;
+		default:
+			log_error("Warning: libdevmapper buffer too small for data");
+		}
+	}
 
 	switch (dmt->type) {
 	case DM_DEVICE_CREATE:

Modified: devmapper/upstream/current/lib/libdm-common.c
==============================================================================
--- devmapper/upstream/current/lib/libdm-common.c	(original)
+++ devmapper/upstream/current/lib/libdm-common.c	Thu Sep 29 16:50:43 2005
@@ -111,6 +111,7 @@
 	dmt->uid = DEVICE_UID;
 	dmt->gid = DEVICE_GID;
 	dmt->mode = DEVICE_MODE;
+	dmt->no_open_count = 0;
 
 	return dmt;
 }



More information about the pkg-lvm-commits mailing list