mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_02_187-mirror-fix-leg-splitting.patch

b83e05
 lib/activate/activate.c    | 40 +++++++++++++++++++++++++---------------
b83e05
 lib/activate/activate.h    |  2 ++
b83e05
 lib/activate/dev_manager.c | 28 +++++++++++++++++++---------
b83e05
 lib/activate/dev_manager.h |  2 +-
b83e05
 4 files changed, 47 insertions(+), 25 deletions(-)
b83e05
b83e05
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
b83e05
index aba5d14..c395d58 100644
b83e05
--- a/lib/activate/activate.c
b83e05
+++ b/lib/activate/activate.c
b83e05
@@ -671,7 +671,7 @@ static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
b83e05
 		    int use_layer, struct lvinfo *info,
b83e05
 		    const struct lv_segment *seg,
b83e05
 		    struct lv_seg_status *seg_status,
b83e05
-		    int with_open_count, int with_read_ahead)
b83e05
+		    int with_open_count, int with_read_ahead, int with_name_check)
b83e05
 {
b83e05
 	struct dm_info dminfo;
b83e05
 
b83e05
@@ -691,7 +691,7 @@ static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
b83e05
 	/* New thin-pool has no layer, but -tpool suffix needs to be queried */
b83e05
 	if (!use_layer && lv_is_new_thin_pool(lv)) {
b83e05
 		/* Check if there isn't existing old thin pool mapping in the table */
b83e05
-		if (!dev_manager_info(cmd, lv, NULL, 0, 0, &dminfo, NULL, NULL))
b83e05
+		if (!dev_manager_info(cmd, lv, NULL, 0, 0, 0, &dminfo, NULL, NULL))
b83e05
 			return_0;
b83e05
 		if (!dminfo.exists)
b83e05
 			use_layer = 1;
b83e05
@@ -704,8 +704,9 @@ static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
b83e05
 
b83e05
 	if (!dev_manager_info(cmd, lv,
b83e05
 			      (use_layer) ? lv_layer(lv) : NULL,
b83e05
-			      with_open_count, with_read_ahead,
b83e05
-			      &dminfo, (info) ? &info->read_ahead : NULL,
b83e05
+			      with_open_count, with_read_ahead, with_name_check,
b83e05
+			      &dminfo,
b83e05
+			      (info) ? &info->read_ahead : NULL,
b83e05
 			      seg_status))
b83e05
 		return_0;
b83e05
 
b83e05
@@ -734,7 +735,7 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
b83e05
 	if (!activation())
b83e05
 		return 0;
b83e05
 
b83e05
-	return _lv_info(cmd, lv, use_layer, info, NULL, NULL, with_open_count, with_read_ahead);
b83e05
+	return _lv_info(cmd, lv, use_layer, info, NULL, NULL, with_open_count, with_read_ahead, 0);
b83e05
 }
b83e05
 
b83e05
 int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
b83e05
@@ -752,6 +753,15 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
b83e05
 	return r;
b83e05
 }
b83e05
 
b83e05
+int lv_info_with_name_check(struct cmd_context *cmd, const struct logical_volume *lv,
b83e05
+			    int use_layer, struct lvinfo *info)
b83e05
+{
b83e05
+	if (!activation())
b83e05
+		return 0;
b83e05
+
b83e05
+	return _lv_info(cmd, lv, use_layer, info, NULL, NULL, 0, 0, 1);
b83e05
+}
b83e05
+
b83e05
 /*
b83e05
  * Returns 1 if lv_with_info_and_seg_status info structure populated,
b83e05
  * else 0 on failure or if device not active locally.
b83e05
@@ -779,16 +789,16 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
b83e05
 		 * STATUS is collected from cache LV */
b83e05
 		if (!(lv_seg = get_only_segment_using_this_lv(lv)))
b83e05
 			return_0;
b83e05
-		(void) _lv_info(cmd, lv_seg->lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
b83e05
+		(void) _lv_info(cmd, lv_seg->lv, 1, NULL, lv_seg, &status->seg_status, 0, 0, 0);
b83e05
 		return 1;
b83e05
 	}
b83e05
 
b83e05
 	if (lv_is_thin_pool(lv)) {
b83e05
 		/* Always collect status for '-tpool' */
b83e05
-		if (_lv_info(cmd, lv, 1, &status->info, lv_seg, &status->seg_status, 0, 0) &&
b83e05
+		if (_lv_info(cmd, lv, 1, &status->info, lv_seg, &status->seg_status, 0, 0, 0) &&
b83e05
 		    (status->seg_status.type == SEG_STATUS_THIN_POOL)) {
b83e05
 			/* There is -tpool device, but query 'active' state of 'fake' thin-pool */
b83e05
-			if (!_lv_info(cmd, lv, 0, NULL, NULL, NULL, 0, 0) &&
b83e05
+			if (!_lv_info(cmd, lv, 0, NULL, NULL, NULL, 0, 0, 0) &&
b83e05
 			    !status->seg_status.thin_pool->needs_check)
b83e05
 				status->info.exists = 0; /* So pool LV is not active */
b83e05
 		}
b83e05
@@ -797,10 +807,10 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
b83e05
 
b83e05
 	if (lv_is_external_origin(lv)) {
b83e05
 		if (!_lv_info(cmd, lv, 0, &status->info, NULL, NULL,
b83e05
-			      with_open_count, with_read_ahead))
b83e05
+			      with_open_count, with_read_ahead, 0))
b83e05
 			return_0;
b83e05
 
b83e05
-		(void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
b83e05
+		(void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0, 0);
b83e05
 		return 1;
b83e05
 	}
b83e05
 
b83e05
@@ -813,13 +823,13 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
b83e05
 		/* Show INFO for actual origin and grab status for merging origin */
b83e05
 		if (!_lv_info(cmd, lv, 0, &status->info, lv_seg,
b83e05
 			      lv_is_merging_origin(lv) ? &status->seg_status : NULL,
b83e05
-			      with_open_count, with_read_ahead))
b83e05
+			      with_open_count, with_read_ahead, 0))
b83e05
 			return_0;
b83e05
 
b83e05
 		if (status->info.exists &&
b83e05
 		    (status->seg_status.type != SEG_STATUS_SNAPSHOT)) /* Not merging */
b83e05
 			/* Grab STATUS from layered -real */
b83e05
-			(void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0);
b83e05
+			(void) _lv_info(cmd, lv, 1, NULL, lv_seg, &status->seg_status, 0, 0, 0);
b83e05
 		return 1;
b83e05
 	}
b83e05
 
b83e05
@@ -828,7 +838,7 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
b83e05
 			olv = origin_from_cow(lv);
b83e05
 
b83e05
 			if (!_lv_info(cmd, olv, 0, &status->info, first_seg(olv), &status->seg_status,
b83e05
-				      with_open_count, with_read_ahead))
b83e05
+				      with_open_count, with_read_ahead, 0))
b83e05
 				return_0;
b83e05
 
b83e05
 			if (status->seg_status.type == SEG_STATUS_SNAPSHOT ||
b83e05
@@ -849,7 +859,7 @@ int lv_info_with_seg_status(struct cmd_context *cmd,
b83e05
 	}
b83e05
 
b83e05
 	return _lv_info(cmd, lv, 0, &status->info, lv_seg, &status->seg_status,
b83e05
-			with_open_count, with_read_ahead);
b83e05
+			with_open_count, with_read_ahead, 0);
b83e05
 }
b83e05
 
b83e05
 #define OPEN_COUNT_CHECK_RETRIES 25
b83e05
@@ -2834,7 +2844,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
b83e05
 			     laopts->noscan ? " noscan" : "",
b83e05
 			     laopts->temporary ? " temporary" : "");
b83e05
 
b83e05
-	if (!lv_info(cmd, lv, 0, &info, 0, 0))
b83e05
+	if (!lv_info_with_name_check(cmd, lv, 0, &info))
b83e05
 		goto_out;
b83e05
 
b83e05
 	/*
b83e05
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
b83e05
index 43d26d1..a938cb4 100644
b83e05
--- a/lib/activate/activate.h
b83e05
+++ b/lib/activate/activate.h
b83e05
@@ -135,6 +135,8 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
b83e05
 	    struct lvinfo *info, int with_open_count, int with_read_ahead);
b83e05
 int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
b83e05
 		    struct lvinfo *info, int with_open_count, int with_read_ahead);
b83e05
+int lv_info_with_name_check(struct cmd_context *cmd, const struct logical_volume *lv,
b83e05
+			    int use_layer, struct lvinfo *info);
b83e05
 
b83e05
 /*
b83e05
  * Returns 1 if lv_info_and_seg_status structure has been populated,
b83e05
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
b83e05
index a5e026c..1ca97c1 100644
b83e05
--- a/lib/activate/dev_manager.c
b83e05
+++ b/lib/activate/dev_manager.c
b83e05
@@ -239,6 +239,7 @@ static uint32_t _seg_len(const struct lv_segment *seg)
b83e05
 static int _info_run(const char *dlid, struct dm_info *dminfo,
b83e05
 		     uint32_t *read_ahead,
b83e05
 		     struct lv_seg_status *seg_status,
b83e05
+		     const char *name_check,
b83e05
 		     int with_open_count, int with_read_ahead,
b83e05
 		     uint32_t major, uint32_t minor)
b83e05
 {
b83e05
@@ -249,6 +250,7 @@ static int _info_run(const char *dlid, struct dm_info *dminfo,
b83e05
 	void *target = NULL;
b83e05
 	uint64_t target_start, target_length, start, length;
b83e05
 	char *target_name, *target_params;
b83e05
+	const char *dev_name;
b83e05
 
b83e05
 	if (seg_status) {
b83e05
 		dmtask = DM_DEVICE_STATUS;
b83e05
@@ -262,6 +264,11 @@ static int _info_run(const char *dlid, struct dm_info *dminfo,
b83e05
 				    with_open_count, with_flush, 0)))
b83e05
 		return_0;
b83e05
 
b83e05
+	if (name_check && dminfo->exists &&
b83e05
+	    (dev_name = dm_task_get_name(dmt)) &&
b83e05
+	    (strcmp(name_check, dev_name) != 0))
b83e05
+		dminfo->exists = 0;	/* mismatching name -> device does not exist */
b83e05
+
b83e05
 	if (with_read_ahead && dminfo->exists) {
b83e05
 		if (!dm_task_get_read_ahead(dmt, read_ahead))
b83e05
 			goto_out;
b83e05
@@ -777,18 +784,19 @@ static int _original_uuid_format_check_required(struct cmd_context *cmd)
b83e05
 
b83e05
 static int _info(struct cmd_context *cmd,
b83e05
 		 const char *name, const char *dlid,
b83e05
-		 int with_open_count, int with_read_ahead,
b83e05
+		 int with_open_count, int with_read_ahead, int with_name_check,
b83e05
 		 struct dm_info *dminfo, uint32_t *read_ahead,
b83e05
 		 struct lv_seg_status *seg_status)
b83e05
 {
b83e05
 	char old_style_dlid[sizeof(UUID_PREFIX) + 2 * ID_LEN];
b83e05
 	const char *suffix, *suffix_position;
b83e05
+	const char *name_check = (with_name_check) ? name : NULL;
b83e05
 	unsigned i = 0;
b83e05
 
b83e05
 	log_debug_activation("Getting device info for %s [%s].", name, dlid);
b83e05
 
b83e05
 	/* Check for dlid */
b83e05
-	if (!_info_run(dlid, dminfo, read_ahead, seg_status,
b83e05
+	if (!_info_run(dlid, dminfo, read_ahead, seg_status, name_check,
b83e05
 		       with_open_count, with_read_ahead, 0, 0))
b83e05
 		return_0;
b83e05
 
b83e05
@@ -804,7 +812,8 @@ static int _info(struct cmd_context *cmd,
b83e05
 			(void) strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
b83e05
 			old_style_dlid[sizeof(old_style_dlid) - 1] = '\0';
b83e05
 			if (!_info_run(old_style_dlid, dminfo, read_ahead, seg_status,
b83e05
-				       with_open_count, with_read_ahead, 0, 0))
b83e05
+				       name_check, with_open_count, with_read_ahead,
b83e05
+				       0, 0))
b83e05
 				return_0;
b83e05
 			if (dminfo->exists)
b83e05
 				return 1;
b83e05
@@ -817,7 +826,7 @@ static int _info(struct cmd_context *cmd,
b83e05
 
b83e05
 	/* Check for dlid before UUID_PREFIX was added */
b83e05
 	if (!_info_run(dlid + sizeof(UUID_PREFIX) - 1, dminfo, read_ahead, seg_status,
b83e05
-		       with_open_count, with_read_ahead, 0, 0))
b83e05
+		       name_check, with_open_count, with_read_ahead, 0, 0))
b83e05
 		return_0;
b83e05
 
b83e05
 	return 1;
b83e05
@@ -825,12 +834,12 @@ static int _info(struct cmd_context *cmd,
b83e05
 
b83e05
 static int _info_by_dev(uint32_t major, uint32_t minor, struct dm_info *info)
b83e05
 {
b83e05
-	return _info_run(NULL, info, NULL, 0, 0, 0, major, minor);
b83e05
+	return _info_run(NULL, info, NULL, NULL, NULL, 0, 0, major, minor);
b83e05
 }
b83e05
 
b83e05
 int dev_manager_info(struct cmd_context *cmd,
b83e05
 		     const struct logical_volume *lv, const char *layer,
b83e05
-		     int with_open_count, int with_read_ahead,
b83e05
+		     int with_open_count, int with_read_ahead, int with_name_check,
b83e05
 		     struct dm_info *dminfo, uint32_t *read_ahead,
b83e05
 		     struct lv_seg_status *seg_status)
b83e05
 {
b83e05
@@ -843,7 +852,8 @@ int dev_manager_info(struct cmd_context *cmd,
b83e05
 	if (!(dlid = build_dm_uuid(cmd->mem, lv, layer)))
b83e05
 		goto_out;
b83e05
 
b83e05
-	if (!(r = _info(cmd, name, dlid, with_open_count, with_read_ahead,
b83e05
+	if (!(r = _info(cmd, name, dlid,
b83e05
+			with_open_count, with_read_ahead, with_name_check,
b83e05
 			dminfo, read_ahead, seg_status)))
b83e05
 		stack;
b83e05
 out:
b83e05
@@ -1953,7 +1963,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
b83e05
 	if (!(dlid = build_dm_uuid(dm->track_pending_delete ? dm->cmd->pending_delete_mem : dm->mem, lv, layer)))
b83e05
 		return_0;
b83e05
 
b83e05
-	if (!_info(dm->cmd, name, dlid, 1, 0, &info, NULL, NULL))
b83e05
+	if (!_info(dm->cmd, name, dlid, 1, 0, 0, &info, NULL, NULL))
b83e05
 		return_0;
b83e05
 
b83e05
 	/*
b83e05
@@ -2479,7 +2489,7 @@ static char *_add_error_or_zero_device(struct dev_manager *dm, struct dm_tree *d
b83e05
 				      seg->lv->name, errid)))
b83e05
 		return_NULL;
b83e05
 
b83e05
-	if (!_info(dm->cmd, name, dlid, 1, 0, &info, NULL, NULL))
b83e05
+	if (!_info(dm->cmd, name, dlid, 1, 0, 0, &info, NULL, NULL))
b83e05
 		return_NULL;
b83e05
 
b83e05
 	if (!info.exists) {
b83e05
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
b83e05
index 5be417b..20b6a26 100644
b83e05
--- a/lib/activate/dev_manager.h
b83e05
+++ b/lib/activate/dev_manager.h
b83e05
@@ -47,7 +47,7 @@ void dev_manager_exit(void);
b83e05
  */
b83e05
 int dev_manager_info(struct cmd_context *cmd, const struct logical_volume *lv,
b83e05
 		     const char *layer,
b83e05
-		     int with_open_count, int with_read_ahead,
b83e05
+		     int with_open_count, int with_read_ahead, int with_name_check,
b83e05
 		     struct dm_info *dminfo, uint32_t *read_ahead,
b83e05
 		     struct lv_seg_status *seg_status);
b83e05