mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmcache: remove lvmcache_update_vg_from_write
After a vg_write, this function was used to attempt to make lvmcache data match the new state written to disk. It was not updated correctly in a many or most cases, and the resulting lvmcache is not actually used after vg_write, making the update unnecessary.
This commit is contained in:
parent
5e428d22d9
commit
cb798ee1c1
44
lib/cache/lvmcache.c
vendored
44
lib/cache/lvmcache.c
vendored
@ -2239,50 +2239,6 @@ int lvmcache_update_vgname_and_id(struct cmd_context *cmd, struct lvmcache_info
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: quit trying to mirror changes that a command is making into lvmcache.
|
||||
*
|
||||
* First, it's complicated and hard to ensure it's done correctly in every case
|
||||
* (it would be much easier and safer to just toss out what's in lvmcache and
|
||||
* reread the info to recreate it from scratch instead of trying to make sure
|
||||
* every possible discrete state change is correct.)
|
||||
*
|
||||
* Second, it's unnecessary if commands just use the vg they are modifying
|
||||
* rather than also trying to get info from lvmcache. The lvmcache state
|
||||
* should be populated by label_scan, used to perform vg_read's, and then
|
||||
* ignored (or dropped so it can't be used).
|
||||
*
|
||||
* lvmcache info is already used very little after a command begins its
|
||||
* operation. The code that's supposed to keep the lvmcache in sync with
|
||||
* changes being made to disk could be half wrong and we wouldn't know it.
|
||||
* That creates a landmine for someone who might try to use a bit of it that
|
||||
* isn't being updated correctly.
|
||||
*/
|
||||
|
||||
int lvmcache_update_vg_from_write(struct volume_group *vg)
|
||||
{
|
||||
char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
|
||||
struct pv_list *pvl;
|
||||
struct lvmcache_info *info;
|
||||
struct lvmcache_vgsummary vgsummary = {
|
||||
.vgname = vg->name,
|
||||
.vgstatus = vg->status,
|
||||
.system_id = vg->system_id,
|
||||
.lock_type = vg->lock_type
|
||||
};
|
||||
|
||||
memcpy(vgid, &vg->id, ID_LEN);
|
||||
memcpy(vgsummary.vgid, vgid, ID_LEN);
|
||||
|
||||
dm_list_iterate_items(pvl, &vg->pvs) {
|
||||
if ((info = lvmcache_info_from_pv_id(&pvl->pv->id, pvl->pv->dev, 0)) &&
|
||||
!lvmcache_update_vgname_and_id(vg->cmd, info, &vgsummary))
|
||||
return_0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The lvmcache representation of a VG after label_scan can be incorrect
|
||||
* because the label_scan does not use the full VG metadata to construct
|
||||
|
1
lib/cache/lvmcache.h
vendored
1
lib/cache/lvmcache.h
vendored
@ -84,7 +84,6 @@ void lvmcache_del_dev(struct device *dev);
|
||||
int lvmcache_update_vgname_and_id(struct cmd_context *cmd, struct lvmcache_info *info,
|
||||
struct lvmcache_vgsummary *vgsummary);
|
||||
int lvmcache_update_vg_from_read(struct volume_group *vg, unsigned precommitted);
|
||||
int lvmcache_update_vg_from_write(struct volume_group *vg);
|
||||
|
||||
void lvmcache_lock_vgname(const char *vgname, int read_only);
|
||||
void lvmcache_unlock_vgname(const char *vgname);
|
||||
|
@ -3102,7 +3102,6 @@ static int _vg_commit_mdas(struct volume_group *vg)
|
||||
DM_LIST_INIT(ignored);
|
||||
int failed = 0;
|
||||
int good = 0;
|
||||
int cache_updated = 0;
|
||||
|
||||
/* Rearrange the metadata_areas_in_use so ignored mdas come first. */
|
||||
dm_list_iterate_items_safe(mda, tmda, &vg->fid->metadata_areas_in_use)
|
||||
@ -3123,12 +3122,6 @@ static int _vg_commit_mdas(struct volume_group *vg)
|
||||
failed = 1;
|
||||
} else
|
||||
good++;
|
||||
|
||||
/* Update cache first time we succeed */
|
||||
if (!failed && !cache_updated) {
|
||||
lvmcache_update_vg_from_write(vg);
|
||||
cache_updated = 1;
|
||||
}
|
||||
}
|
||||
if (good)
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user