Skip to contentSkip to conversation

nfs-utils: blkmapd

PATCH In review Jim Rees 2 participants 5 messages Jan 21, 2011 – Jan 24, 2011

Subsystems (2)
lore
Share & tools
lore

Jim Rees

author
#0 lore raw

cover nfs-utils: blkmapd

This set of patches fixes various bugs in stripe size calculation turned up in testing. I believe blkmapd will now handle any layout that is allowed by the spec and can be constructed by device-mapper.

If a striped device is not a multiple of both the number of constituent devices and the stripe width, blkmapd will truncate the device so that device-mapper can handle it.

Jim Rees (3):
change device offset to signed to match the spec Fix calculation of stripe device and unit sizes Various improvements to comments and syslog messages

 utils/blkmapd/device-discovery.c |    2 -
 utils/blkmapd/device-discovery.h |    4 +-
 utils/blkmapd/device-process.c   |   50 +++++++++++++++++++------------------
 utils/blkmapd/dm-device.c        |   28 ++++++++++++++++-----
 4 files changed, 49 insertions(+), 35 deletions(-)
author
#1 lore raw

PATCH 1/3 change device offset to signed to match the spec

---
 utils/blkmapd/device-discovery.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
utils/blkmapd/device-discovery.h +1 -1
index 8fe3b29..a55ccfe 100644
@@ -51,7 +51,7 @@ struct bl_volume {
 };
 
 struct bl_sig_comp {
-	uint64_t bs_offset;		/* In bytes */
+	int64_t bs_offset;		/* In bytes */
 	uint32_t bs_length;		/* In bytes */
 	char *bs_string;
 };
Signature · 1 line
1.7.1
author
#2 lore raw

PATCH 2/3 Fix calculation of stripe device and unit sizes

In reply to Jim Rees

- Total size is size of each individual device times number of devices
- Stripe unit is in bytes, not sectors
- Round total device size down to a muliple of the stripe size

---
 utils/blkmapd/dm-device.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)
utils/blkmapd/dm-device.c +19 -5
index d720086..ee7d787 100644
@@ -371,7 +371,7 @@ static int dm_device_exists(char *dev_name)
 /* TODO: check the value for DM_DEV_NAME_LEN, DM_TYPE_LEN, DM_PARAMS_LEN */
 uint64_t dm_device_create(struct bl_volume *vols, int num_vols)
 {
-	uint64_t size, dev = 0;
+	uint64_t size, stripe_unit, stripe_size, nstripes, dev = 0;
 	unsigned int count = dev_count;
 	int volnum, i, pos;
 	struct bl_volume *node;
@@ -416,11 +416,25 @@ uint64_t dm_device_create(struct bl_volume *vols, int num_vols)
 			if (!table)
 				goto out;
 			table->offset = 0;
-			table->size = node->bv_size;
+			stripe_unit = node->param.bv_stripe_unit << 9;
+			stripe_size = stripe_unit * node->bv_vol_n;
+			nstripes = node->bv_size * node->bv_vol_n / stripe_size;
+			/* Make sure total size is a multiple of stripe size */
+			size = node->bv_size * node->bv_vol_n;
+			if (size % stripe_size != 0) {
+				/* XXX Should this be an error? */
+				BL_LOG_WARNING(
+					"%s: %d units of %llu bytes is not a multiple of %lld stripe size\n",
+					__func__, node->bv_vol_n,
+					(long long unsigned) node->bv_size,
+					(long long unsigned) stripe_size);
+				size = nstripes * stripe_size;
+			}
+			table->size = size;
 			strcpy(table->target_type, "striped");
-			sprintf(table->params, "%d %lu %n", node->bv_vol_n,
-				node->param.bv_stripe_unit, &pos);
-			/* Repeatedly copy subdev to params */
+			sprintf(table->params, "%d %llu %n", node->bv_vol_n,
+				(long long unsigned) stripe_unit, &pos);
+			/* Copy subdev major:minor to params */
 			tmp = table->params + pos;
 			len = DM_PARAMS_LEN - pos;
 			for (i = 0; i < node->bv_vol_n; i++) {
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH 3/3 Various improvements to comments and syslog messages

In reply to Jim Rees

Minor reformat and eliminate unneeded code, no functional changes

---
 utils/blkmapd/device-discovery.c |    2 -
 utils/blkmapd/device-discovery.h |    2 +-
 utils/blkmapd/device-process.c   |   50 +++++++++++++++++++------------------
 utils/blkmapd/dm-device.c        |    4 +-
 4 files changed, 29 insertions(+), 29 deletions(-)
utils/blkmapd/device-discovery.c +0 -2
index 5656be3..b4cb8a4 100644
@@ -178,8 +178,6 @@ void bl_add_disk(char *filepath)
 	if (disk && diskpath)
 		return;
 
-	BL_LOG_INFO("%s: %s\n", __func__, filepath);
-
 	/* add path */
 	path = malloc(sizeof(struct bl_disk_path));
 	if (!path) {
utils/blkmapd/device-discovery.h +1 -1
index a55ccfe..e25dd44 100644
@@ -89,7 +89,7 @@ struct bl_disk {
 	struct bl_disk *next;
 	struct bl_serial *serial;
 	dev_t dev;
-	off_t size;
+	off_t size;			/* in 512-byte sectors */
 	struct bl_disk_path *valid_path;
 	struct bl_disk_path *paths;
 };
utils/blkmapd/device-process.c +26 -24

142 lines not on this page · raw message

utils/blkmapd/dm-device.c +2 -2
index ee7d787..2e87db8 100644
@@ -180,8 +180,6 @@ dm_device_create_mapped(const char *dev_name, struct bl_dm_table *p)
 		goto err_out;
 
 	dm_task_update_nodes();
-	BL_LOG_ERR("%s: %s %d/%d\n", __func__, dev_name,
-		   (int)dminfo.major, (int)dminfo.minor);
 
  err_out:
 	dm_task_destroy(dmt);
@@ -502,6 +500,8 @@ uint64_t dm_device_create(struct bl_volume *vols, int num_vols)
 		} while (dm_device_exists(dev_name));
 
 		dev = dm_device_create_mapped(dev_name, bl_table_head);
+		BL_LOG_INFO("%s: %d %s %d:%d\n", __func__, volnum, dev_name,
+			    (int) MAJOR(dev), (int) MINOR(dev));
 		if (!dev) {
 			/* Delete previous temporary devices */
 			dm_devicelist_remove(count, dev_count);
Signature · 1 line
1.7.1
#4 lore raw
In reply to Jim Rees

Thanks. Merged at pnfs-nfs-utils-1-2-4-rc5

Benny

Quoted 19 lines · Jim Rees

This set of patches fixes various bugs in stripe size calculation turned up in testing. I believe blkmapd will now handle any layout that is allowed by the spec and can be constructed by device-mapper.

If a striped device is not a multiple of both the number of constituent devices and the stripe width, blkmapd will truncate the device so that device-mapper can handle it.

Jim Rees (3):
change device offset to signed to match the spec Fix calculation of stripe device and unit sizes Various improvements to comments and syslog messages

 utils/blkmapd/device-discovery.c |    2 -
 utils/blkmapd/device-discovery.h |    4 +-
 utils/blkmapd/device-process.c   |   50 +++++++++++++++++++------------------
 utils/blkmapd/dm-device.c        |   28 ++++++++++++++++-----
 4 files changed, 49 insertions(+), 35 deletions(-)