mirror of
				git://sourceware.org/git/lvm2.git
				synced 2025-10-30 20:23:49 +03:00 
			
		
		
		
	Add mda location specific mda_copy constructor.
Because of the way mdas are handled internally, where a PV in a VG has mdas on both info->mdas and vg->fid->metadata_areas list, we need a location independent copy constructor for struct metadata_area. Break up the existing format-text specific copy constructor into a format independent piece and a format dependent piece. This function is necessary to properly implement pv_set_mda_ignored(). Signed-off-by: Dave Wysochanski <dwysocha@redhat.com> Reviewed-by: Alasdair G Kergon <agk@redhat.com>
This commit is contained in:
		| @@ -1622,32 +1622,20 @@ static int _populate_pv_fields(struct lvmcache_info *info, | ||||
| } | ||||
|  | ||||
| /* | ||||
|  * Copy constructor for a metadata_area. | ||||
|  * Copy constructor for a metadata_locn. | ||||
|  */ | ||||
| static struct metadata_area *_mda_copy(struct dm_pool *mem, | ||||
| 				       struct metadata_area *mda) | ||||
| static void *_metadata_locn_copy_raw(struct dm_pool *mem, void *metadata_locn) | ||||
| { | ||||
| 	struct metadata_area *mda_new; | ||||
| 	struct mda_context *mdac, *mdac_new; | ||||
|  | ||||
| 	if (!(mda_new = dm_pool_alloc(mem, sizeof(*mda_new)))) { | ||||
| 		log_error("metadata_area allocation failed"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	/* FIXME: Should have a per-format constructor here */ | ||||
| 	mdac = (struct mda_context *) mda->metadata_locn; | ||||
| 	mdac = (struct mda_context *) metadata_locn; | ||||
| 	if (!(mdac_new = dm_pool_alloc(mem, sizeof(*mdac_new)))) { | ||||
| 		log_error("mda_context allocation failed"); | ||||
| 		dm_pool_free(mem, mda_new); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	memcpy(mda_new, mda, sizeof(*mda)); | ||||
| 	memcpy(mdac_new, mdac, sizeof(*mdac)); | ||||
| 	mda_new->metadata_locn = mdac_new; | ||||
|  | ||||
| 	/* FIXME mda 'list' left invalid here */ | ||||
|  | ||||
| 	return mda_new; | ||||
| 	return mdac_new; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -1675,7 +1663,7 @@ static int _text_pv_read(const struct format_type *fmt, const char *pv_name, | ||||
|  | ||||
| 	/* Add copy of mdas to supplied list */ | ||||
| 	dm_list_iterate_items(mda, &info->mdas) { | ||||
| 		mda_new = _mda_copy(fmt->cmd->mem, mda); | ||||
| 		mda_new = mda_copy(fmt->cmd->mem, mda); | ||||
| 		if (!mda_new) | ||||
| 			return 0; | ||||
| 		dm_list_add(mdas, &mda_new->list); | ||||
| @@ -1742,6 +1730,7 @@ static struct metadata_area_ops _metadata_text_raw_ops = { | ||||
| 	.vg_precommit = _vg_precommit_raw, | ||||
| 	.vg_commit = _vg_commit_raw, | ||||
| 	.vg_revert = _vg_revert_raw, | ||||
| 	.mda_metadata_locn_copy = _metadata_locn_copy_raw, | ||||
| 	.mda_free_sectors = _mda_free_sectors_raw, | ||||
| 	.mda_total_sectors = _mda_total_sectors_raw, | ||||
| 	.mda_in_vg = _mda_in_vg_raw, | ||||
| @@ -1812,7 +1801,7 @@ static int _text_pv_setup(const struct format_type *fmt, | ||||
| 				if (found) | ||||
| 					continue; | ||||
|  | ||||
| 				mda_new = _mda_copy(fmt->cmd->mem, mda); | ||||
| 				mda_new = mda_copy(fmt->cmd->mem, mda); | ||||
| 				if (!mda_new) | ||||
| 					return_0; | ||||
| 				dm_list_add(mdas, &mda_new->list); | ||||
| @@ -1980,7 +1969,7 @@ static struct format_instance *_text_create_text_instance(const struct format_ty | ||||
| 			mdas = &info->mdas; | ||||
| 			dm_list_iterate_items(mda, mdas) { | ||||
| 				/* FIXME Check it holds this VG */ | ||||
| 				mda_new = _mda_copy(fmt->cmd->mem, mda); | ||||
| 				mda_new = mda_copy(fmt->cmd->mem, mda); | ||||
| 				if (!mda_new) | ||||
| 					return_NULL; | ||||
| 				dm_list_add(&fid->metadata_areas, &mda_new->list); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user