mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Validate orphan and VG_GLOBAL lock order too.
This commit is contained in:
parent
8c965cafb7
commit
34220fe292
@ -1,5 +1,6 @@
|
||||
Version 2.02.66 -
|
||||
===============================
|
||||
Validate orphan and VG_GLOBAL lock order too.
|
||||
Accept orphan VG names as parameters to lock_vol() and related functions.
|
||||
Use is_orphan_vg in place of hard-coded prefix tests.
|
||||
|
||||
|
14
lib/cache/lvmcache.c
vendored
14
lib/cache/lvmcache.c
vendored
@ -224,11 +224,21 @@ void lvmcache_drop_metadata(const char *vgname, int drop_precommitted)
|
||||
|
||||
/*
|
||||
* Ensure vgname2 comes after vgname1 alphabetically.
|
||||
* Orphans don't count.
|
||||
* Orphan locks come last.
|
||||
* VG_GLOBAL comes first.
|
||||
*/
|
||||
static int _vgname_order_correct(const char *vgname1, const char *vgname2)
|
||||
{
|
||||
if (is_orphan_vg(vgname1) || is_orphan_vg(vgname2))
|
||||
if (is_global_vg(vgname1))
|
||||
return 1;
|
||||
|
||||
if (is_global_vg(vgname2))
|
||||
return 0;
|
||||
|
||||
if (is_orphan_vg(vgname1))
|
||||
return 0;
|
||||
|
||||
if (is_orphan_vg(vgname2))
|
||||
return 1;
|
||||
|
||||
if (strcmp(vgname1, vgname2) < 0)
|
||||
|
@ -424,7 +424,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
|
||||
if (is_orphan_vg(vol))
|
||||
vol = VG_ORPHANS;
|
||||
/* VG locks alphabetical, ORPHAN lock last */
|
||||
else if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
|
||||
if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
|
||||
!(flags & LCK_CACHE) &&
|
||||
!lvmcache_verify_lock_order(vol))
|
||||
return 0;
|
||||
|
@ -423,6 +423,7 @@ int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
|
||||
int move_pvs_used_by_lv(struct volume_group *vg_from,
|
||||
struct volume_group *vg_to,
|
||||
const char *lv_name);
|
||||
int is_global_vg(const char *vg_name);
|
||||
int is_orphan_vg(const char *vg_name);
|
||||
int is_orphan(const struct physical_volume *pv);
|
||||
int is_missing_pv(const struct physical_volume *pv);
|
||||
|
@ -3326,6 +3326,11 @@ int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int is_global_vg(const char *vg_name)
|
||||
{
|
||||
return (vg_name && !strcmp(vg_name, VG_GLOBAL)) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* is_orphan_vg - Determine whether a vg_name is an orphan
|
||||
* @vg_name: pointer to the vg_name
|
||||
|
Loading…
Reference in New Issue
Block a user