All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix _copy_pv to allocate even new pv->vg_name
@ 2009-04-02 14:19 Milan Broz
  2009-04-02 14:42 ` Alasdair G Kergon
  0 siblings, 1 reply; 2+ messages in thread
From: Milan Broz @ 2009-04-02 14:19 UTC (permalink / raw)
  To: lvm-devel

Allocate new pv->vg_name from pool, it can be destroyed later.

(The mempool rename will be used later by vg private mempools)

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 lib/metadata/metadata.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 7848d82..c90de6f 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -201,15 +201,17 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
 static int _copy_pv(struct physical_volume *pv_to,
 		    struct physical_volume *pv_from)
 {
+	struct dm_pool *pvmem = pv_from->fmt->cmd->mem;
+
 	memcpy(pv_to, pv_from, sizeof(*pv_to));
 
-	if (!str_list_dup(pv_to->fmt->cmd->mem, &pv_to->tags, &pv_from->tags)) {
-		log_error("PV tags duplication failed");
-		return 0;
-	}
+	if (!(pv_to->vg_name = dm_pool_strdup(pvmem, pv_from->vg_name)))
+		return_0;
 
-	if (!peg_dup(pv_to->fmt->cmd->mem, &pv_to->segments,
-		     &pv_from->segments))
+	if (!str_list_dup(pvmem, &pv_to->tags, &pv_from->tags))
+		return_0;
+
+	if (!peg_dup(pvmem, &pv_to->segments, &pv_from->segments))
 		return_0;
 
 	return 1;
@@ -235,8 +237,10 @@ int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
 
 	dm_list_iterate_items(pvl, &vg->pvs) {
 		if (id_equal(&pvl->pv->id, (const struct id *) pvid)) {
-			if (!_copy_pv(pv, pvl->pv))
+			if (!_copy_pv(pv, pvl->pv)) {
+				log_error("internal PV duplication failed");
 				return_0;
+			}
 			return 1;
 		}
 	}




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] fix _copy_pv to allocate even new pv->vg_name
  2009-04-02 14:19 [PATCH] fix _copy_pv to allocate even new pv->vg_name Milan Broz
@ 2009-04-02 14:42 ` Alasdair G Kergon
  0 siblings, 0 replies; 2+ messages in thread
From: Alasdair G Kergon @ 2009-04-02 14:42 UTC (permalink / raw)
  To: lvm-devel

On Thu, Apr 02, 2009 at 04:19:54PM +0200, Milan Broz wrote:
> Allocate new pv->vg_name from pool, it can be destroyed later.
 
Ack.

Alasdair
-- 
agk at redhat.com



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-02 14:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-02 14:19 [PATCH] fix _copy_pv to allocate even new pv->vg_name Milan Broz
2009-04-02 14:42 ` Alasdair G Kergon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.