Skip to contentSkip to conversation

nfs-utils: blkmapd fixex

PATCH In review Christoph Hellwig 2 participants 5 messages Aug 7, 2014 – Aug 13, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This series fixed the broken ѕupport for dm-multipath devices in blkmapd, and adds some useful logging to syslog that allows triaging pnfs block layout setup issues.

This work was sponsored by NetApp, Inc.

#1 lore raw

PATCH 1/2 blkmapd: fix broken multipath handling

We do want to use the dm-multipath device if it exists, which the code is generally prepared for, except that this check excludes them early. In addition this will also add the passive path to the device list, which is harmless if an active one exists as that or the multipath device will be preferred, and at least allows us to work if it doesn't.

Also fix up the check if an path needs to be updated to remove the silly partition check - pNFS block offset are relative to the device so partion should never match it instead of the full device. On the other hand the simplistic check easily creates false positives, e.g. dm-10 is considered a partition of dm-1.

---
 utils/blkmapd/device-discovery.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)
utils/blkmapd/device-discovery.c +4 -23
index df4627e..bcfb060 100644
@@ -77,16 +77,6 @@ struct bl_disk_path *bl_get_path(const char *filepath,
 	return tmp;
 }
 
-/* Check whether valid_path is a substring(partition) of path */
-int bl_is_partition(struct bl_disk_path *valid_path, struct bl_disk_path *path)
-{
-	if (!strncmp(valid_path->full_path, path->full_path,
-		     strlen(valid_path->full_path)))
-		return 1;
-
-	return 0;
-}
-
 /*
  * For multipath devices, devices state could be PASSIVE/ACTIVE/PSEUDO,
  * where PSEUDO > ACTIVE > PASSIVE. Device with highest state is used to
@@ -95,19 +85,13 @@ int bl_is_partition(struct bl_disk_path *valid_path, struct bl_disk_path *path)
  * If device-mapper multipath support is a must, pseudo devices should
  * exist for each multipath device. If not, active device path will be
  * chosen for device creation.
- * Treat partition as invalid path.
  */
-int bl_update_path(struct bl_disk_path *path, enum bl_path_state_e state,
-		   struct bl_disk *disk)
+int bl_update_path(enum bl_path_state_e state, struct bl_disk *disk)
 {
 	struct bl_disk_path *valid_path = disk->valid_path;
 
-	if (valid_path) {
-		if (valid_path->state >= state) {
-			if (bl_is_partition(valid_path, path))
-				return 0;
-		}
-	}
+	if (valid_path && valid_path->state >= state)
+		return 0;
 	return 1;
 }
 
@@ -170,9 +154,6 @@ void bl_add_disk(char *filepath)
 		ap_state = bldev_read_ap_state(fd);
 	close(fd);
 
-	if (ap_state != BL_PATH_STATE_ACTIVE)
-		return;
-
 	for (disk = visible_disk_list; disk != NULL; disk = disk->next) {
 		/* Already scanned or a partition?
 		 * XXX: if released each time, maybe not need to compare
@@ -216,7 +197,7 @@ void bl_add_disk(char *filepath)
 		path->next = disk->paths;
 		disk->paths = path;
 		/* check whether we need to update disk info */
-		if (bl_update_path(path, path->state, disk)) {
+		if (bl_update_path(path->state, disk)) {
 			disk->dev = dev;
 			disk->size = size;
 			disk->valid_path = path;
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 1/2] blkmapd: fix broken multipath handling

Quoted 6 lines · Christoph Hellwig

We do want to use the dm-multipath device if it exists, which the code is generally prepared for, except that this check excludes them early. In addition this will also add the passive path to the device list, which is harmless if an active one exists as that or the multipath device will be preferred, and at least allows us to work if it doesn't.

Quoted 7 lines

Also fix up the check if an path needs to be updated to remove the silly partition check - pNFS block offset are relative to the device so partion should never match it instead of the full device. On the other hand the simplistic check easily creates false positives, e.g. dm-10 is considered a partition of dm-1.

Committed...

steved.

Quoted 68 lines
---
 utils/blkmapd/device-discovery.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)
utils/blkmapd/device-discovery.c +4 -23
index df4627e..bcfb060 100644
@@ -77,16 +77,6 @@ struct bl_disk_path *bl_get_path(const char *filepath,
 	return tmp;
 }
 
-/* Check whether valid_path is a substring(partition) of path */
-int bl_is_partition(struct bl_disk_path *valid_path, struct bl_disk_path *path)
-{
-	if (!strncmp(valid_path->full_path, path->full_path,
-		     strlen(valid_path->full_path)))
-		return 1;
-
-	return 0;
-}
-
 /*
  * For multipath devices, devices state could be PASSIVE/ACTIVE/PSEUDO,
  * where PSEUDO > ACTIVE > PASSIVE. Device with highest state is used to
@@ -95,19 +85,13 @@ int bl_is_partition(struct bl_disk_path *valid_path, struct bl_disk_path *path)
  * If device-mapper multipath support is a must, pseudo devices should
  * exist for each multipath device. If not, active device path will be
  * chosen for device creation.
- * Treat partition as invalid path.
  */
-int bl_update_path(struct bl_disk_path *path, enum bl_path_state_e state,
-		   struct bl_disk *disk)
+int bl_update_path(enum bl_path_state_e state, struct bl_disk *disk)
 {
 	struct bl_disk_path *valid_path = disk->valid_path;
 
-	if (valid_path) {
-		if (valid_path->state >= state) {
-			if (bl_is_partition(valid_path, path))
-				return 0;
-		}
-	}
+	if (valid_path && valid_path->state >= state)
+		return 0;
 	return 1;
 }
 
@@ -170,9 +154,6 @@ void bl_add_disk(char *filepath)
 		ap_state = bldev_read_ap_state(fd);
 	close(fd);
 
-	if (ap_state != BL_PATH_STATE_ACTIVE)
-		return;
-
 	for (disk = visible_disk_list; disk != NULL; disk = disk->next) {
 		/* Already scanned or a partition?
 		 * XXX: if released each time, maybe not need to compare
@@ -216,7 +197,7 @@ void bl_add_disk(char *filepath)
 		path->next = disk->paths;
 		disk->paths = path;
 		/* check whether we need to update disk info */
-		if (bl_update_path(path, path->state, disk)) {
+		if (bl_update_path(path->state, disk)) {
 			disk->dev = dev;
 			disk->size = size;
 			disk->valid_path = path;
#3 lore raw

PATCH 2/2 blkmapd: dump useful device information to syslog

In reply to Christoph Hellwig

Dump some information about used devices to syslog so that an admin can troubleshoot failing blocklayout mounts.

---
 utils/blkmapd/device-discovery.c | 6 +++++-
 utils/blkmapd/device-process.c   | 2 ++
 utils/blkmapd/dm-device.c        | 4 ++++
 3 files changed, 11 insertions(+), 1 deletion(-)
utils/blkmapd/device-discovery.c +5 -1
index bcfb060..b52afe2 100644
@@ -148,7 +148,11 @@ void bl_add_disk(char *filepath)
 
 	dev = sb.st_rdev;
 	serial = bldev_read_serial(fd, filepath);
-	if (dm_is_dm_major(major(dev)))
+	if (!serial) {
+		BL_LOG_ERR("%s: no serial found for %s\n",
+				 __func__, filepath);
+		ap_state = BL_PATH_STATE_PASSIVE;
+	} else if (dm_is_dm_major(major(dev)))
 		ap_state = BL_PATH_STATE_PSEUDO;
 	else
 		ap_state = bldev_read_ap_state(fd);
utils/blkmapd/device-process.c +2 -0
index 5fe3dff..f53a616 100644
@@ -181,6 +181,8 @@ static int map_sig_to_device(struct bl_sig *sig, struct bl_volume *vol)
 		/* FIXME: should we use better algorithm for disk scan? */
 		mapped = verify_sig(disk, sig);
 		if (mapped) {
+			BL_LOG_INFO("%s: using device %s\n",
+					__func__, disk->valid_path->full_path);
 			vol->param.bv_dev = disk->dev;
 			vol->bv_size = disk->size;
 			break;
utils/blkmapd/dm-device.c +4 -0
index 0f4f148..8ffb19e 100644
@@ -400,6 +400,8 @@ uint64_t dm_device_create(struct bl_volume *vols, int num_vols)
 			}
 			dev = node->bv_vols[0]->param.bv_dev;
 			tmp = table->params;
+			BL_LOG_INFO("%s: major %u minor %u", __func__,
+					MAJOR(dev), MINOR(dev));
 			if (!dm_format_dev(tmp, DM_PARAMS_LEN,
 					   MAJOR(dev), MINOR(dev))) {
 				free(table);
@@ -459,6 +461,8 @@ uint64_t dm_device_create(struct bl_volume *vols, int num_vols)
 				strcpy(table->target_type, "linear");
 				tmp = table->params;
 				dev = node->bv_vols[i]->param.bv_dev;
+				BL_LOG_INFO("%s: major %u minor %u", __func__,
+					MAJOR(dev), MINOR(dev));
 				if (!dm_format_dev(tmp, DM_PARAMS_LEN,
 						   MAJOR(dev), MINOR(dev))) {
 					free(table);
Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH 2/2] blkmapd: dump useful device information to syslog

Quoted 4 lines · Christoph Hellwig

Dump some information about used devices to syslog so that an admin can troubleshoot failing blocklayout mounts.

Committed... after fixing a couple format warnings...

steved.

Quoted 59 lines
---
 utils/blkmapd/device-discovery.c | 6 +++++-
 utils/blkmapd/device-process.c   | 2 ++
 utils/blkmapd/dm-device.c        | 4 ++++
 3 files changed, 11 insertions(+), 1 deletion(-)
utils/blkmapd/device-discovery.c +5 -1
index bcfb060..b52afe2 100644
@@ -148,7 +148,11 @@ void bl_add_disk(char *filepath)
 
 	dev = sb.st_rdev;
 	serial = bldev_read_serial(fd, filepath);
-	if (dm_is_dm_major(major(dev)))
+	if (!serial) {
+		BL_LOG_ERR("%s: no serial found for %s\n",
+				 __func__, filepath);
+		ap_state = BL_PATH_STATE_PASSIVE;
+	} else if (dm_is_dm_major(major(dev)))
 		ap_state = BL_PATH_STATE_PSEUDO;
 	else
 		ap_state = bldev_read_ap_state(fd);
utils/blkmapd/device-process.c +2 -0
index 5fe3dff..f53a616 100644
@@ -181,6 +181,8 @@ static int map_sig_to_device(struct bl_sig *sig, struct bl_volume *vol)
 		/* FIXME: should we use better algorithm for disk scan? */
 		mapped = verify_sig(disk, sig);
 		if (mapped) {
+			BL_LOG_INFO("%s: using device %s\n",
+					__func__, disk->valid_path->full_path);
 			vol->param.bv_dev = disk->dev;
 			vol->bv_size = disk->size;
 			break;
utils/blkmapd/dm-device.c +4 -0
index 0f4f148..8ffb19e 100644
@@ -400,6 +400,8 @@ uint64_t dm_device_create(struct bl_volume *vols, int num_vols)
 			}
 			dev = node->bv_vols[0]->param.bv_dev;
 			tmp = table->params;
+			BL_LOG_INFO("%s: major %u minor %u", __func__,
+					MAJOR(dev), MINOR(dev));
 			if (!dm_format_dev(tmp, DM_PARAMS_LEN,
 					   MAJOR(dev), MINOR(dev))) {
 				free(table);
@@ -459,6 +461,8 @@ uint64_t dm_device_create(struct bl_volume *vols, int num_vols)
 				strcpy(table->target_type, "linear");
 				tmp = table->params;
 				dev = node->bv_vols[i]->param.bv_dev;
+				BL_LOG_INFO("%s: major %u minor %u", __func__,
+					MAJOR(dev), MINOR(dev));
 				if (!dm_format_dev(tmp, DM_PARAMS_LEN,
 						   MAJOR(dev), MINOR(dev))) {
 					free(table);