mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-09 12:58:41 +03:00
Rename segment and lv status flag from SNAPSHOT_MERGE to MERGING.
Eliminate 'merging_snapshot' from 'struct logical_volume' and just use 'snapshot' for origin lv's reference to the merging snapshot; also set MERGING in the origin lv's status.
This commit is contained in:
parent
cad03afc54
commit
fa684a97da
@ -61,7 +61,7 @@ static const struct flag _lv_flags[] = {
|
||||
{MIRRORED, NULL, 0},
|
||||
{VIRTUAL, NULL, 0},
|
||||
{SNAPSHOT, NULL, 0},
|
||||
{SNAPSHOT_MERGE, NULL, 0},
|
||||
{MERGING, NULL, 0},
|
||||
{ACTIVATE_EXCL, NULL, 0},
|
||||
{CONVERTING, NULL, 0},
|
||||
{PARTIAL_LV, NULL, 0},
|
||||
|
@ -1877,7 +1877,6 @@ struct logical_volume *alloc_lv(struct dm_pool *mem)
|
||||
}
|
||||
|
||||
lv->snapshot = NULL;
|
||||
lv->merging_snapshot = NULL;
|
||||
dm_list_init(&lv->snapshot_segs);
|
||||
dm_list_init(&lv->segments);
|
||||
dm_list_init(&lv->tags);
|
||||
|
@ -69,7 +69,7 @@
|
||||
//#define POSTORDER_OPEN_FLAG 0x04000000U temporary use inside vg_read_internal. */
|
||||
//#define VIRTUAL_ORIGIN 0x08000000U /* LV - internal use only */
|
||||
|
||||
#define SNAPSHOT_MERGE 0x10000000U /* SEG */
|
||||
#define MERGING 0x10000000U /* LV SEG */
|
||||
|
||||
#define LVM_READ 0x00000100U /* LV VG */
|
||||
#define LVM_WRITE 0x00000200U /* LV VG */
|
||||
@ -330,9 +330,6 @@ struct logical_volume {
|
||||
struct dm_list snapshot_segs;
|
||||
struct lv_segment *snapshot;
|
||||
|
||||
/* A snapshot that is merging into this origin */
|
||||
struct lv_segment *merging_snapshot;
|
||||
|
||||
struct dm_list segments;
|
||||
struct dm_list tags;
|
||||
struct dm_list segs_using_this_lv;
|
||||
|
@ -25,7 +25,7 @@ int lv_is_origin(const struct logical_volume *lv)
|
||||
|
||||
int lv_is_cow(const struct logical_volume *lv)
|
||||
{
|
||||
return lv->snapshot ? 1 : 0;
|
||||
return (!lv_is_origin(lv) && lv->snapshot) ? 1 : 0;
|
||||
}
|
||||
|
||||
int lv_is_visible(const struct logical_volume *lv)
|
||||
@ -53,18 +53,21 @@ int lv_is_virtual_origin(const struct logical_volume *lv)
|
||||
|
||||
int lv_is_merging_origin(const struct logical_volume *origin)
|
||||
{
|
||||
return origin->merging_snapshot ? 1 : 0;
|
||||
return (origin->status & MERGING) ? 1 : 0;
|
||||
}
|
||||
|
||||
struct lv_segment *find_merging_cow(const struct logical_volume *origin)
|
||||
{
|
||||
return origin->merging_snapshot;
|
||||
/* FIXME: eliminate this wrapper and just use find_cow()?
|
||||
* - find_merging_cow() adds to code clarity in caller
|
||||
*/
|
||||
return find_cow(origin);
|
||||
}
|
||||
|
||||
int lv_is_merging_cow(const struct logical_volume *snapshot)
|
||||
{
|
||||
/* NOTE: use of find_cow() rather than find_merging_cow() */
|
||||
return (find_cow(snapshot)->status & SNAPSHOT_MERGE) ? 1 : 0;
|
||||
/* checks lv_segment's status to see if cow is merging */
|
||||
return (find_cow(snapshot)->status & MERGING) ? 1 : 0;
|
||||
}
|
||||
|
||||
/* Given a cow LV, return the snapshot lv_segment that uses it */
|
||||
@ -117,15 +120,17 @@ void init_snapshot_merge(struct lv_segment *cow_seg,
|
||||
* merge metadata (cow_seg->lv is now "internal")
|
||||
*/
|
||||
cow_seg->lv->status &= ~VISIBLE_LV;
|
||||
cow_seg->status |= SNAPSHOT_MERGE;
|
||||
origin->merging_snapshot = cow_seg;
|
||||
cow_seg->status |= MERGING;
|
||||
origin->snapshot = cow_seg;
|
||||
origin->status |= MERGING;
|
||||
}
|
||||
|
||||
void clear_snapshot_merge(struct logical_volume *origin)
|
||||
{
|
||||
/* clear merge attributes */
|
||||
origin->merging_snapshot->status &= ~SNAPSHOT_MERGE;
|
||||
origin->merging_snapshot = NULL;
|
||||
origin->snapshot->status &= ~MERGING;
|
||||
origin->snapshot = NULL;
|
||||
origin->status &= ~MERGING;
|
||||
}
|
||||
|
||||
int vg_add_snapshot(struct logical_volume *origin,
|
||||
|
@ -84,7 +84,7 @@ static int _snap_text_export(const struct lv_segment *seg, struct formatter *f)
|
||||
{
|
||||
outf(f, "chunk_size = %u", seg->chunk_size);
|
||||
outf(f, "origin = \"%s\"", seg->origin->name);
|
||||
if (!(seg->status & SNAPSHOT_MERGE))
|
||||
if (!(seg->status & MERGING))
|
||||
outf(f, "cow_store = \"%s\"", seg->cow->name);
|
||||
else
|
||||
outf(f, "merging_store = \"%s\"", seg->cow->name);
|
||||
@ -144,7 +144,7 @@ static int _snap_target_present(struct cmd_context *cmd,
|
||||
_snap_checked = 1;
|
||||
}
|
||||
|
||||
if (!_snap_merge_checked && seg && (seg->status & SNAPSHOT_MERGE)) {
|
||||
if (!_snap_merge_checked && seg && (seg->status & MERGING)) {
|
||||
_snap_merge_present = target_present(cmd, "snapshot-merge", 0);
|
||||
_snap_merge_checked = 1;
|
||||
return _snap_present && _snap_merge_present;
|
||||
|
@ -1307,7 +1307,7 @@ void lv_spawn_background_polling(struct cmd_context *cmd,
|
||||
pvmove_poll(cmd, pvname, 1);
|
||||
}
|
||||
|
||||
if (lv->status & CONVERTING || lv_is_merging_origin(lv)) {
|
||||
if (lv->status & (CONVERTING|MERGING)) {
|
||||
log_verbose("Spawning background lvconvert process for %s",
|
||||
lv->name);
|
||||
lvconvert_poll(cmd, lv, 1);
|
||||
|
@ -69,8 +69,7 @@ static int _poll_lvs_in_vg(struct cmd_context *cmd,
|
||||
lv_active = info.exists;
|
||||
|
||||
if (lv_active &&
|
||||
(lv->status & (PVMOVE|CONVERTING) ||
|
||||
lv_is_merging_origin(lv))) {
|
||||
(lv->status & (PVMOVE|CONVERTING|MERGING))) {
|
||||
lv_spawn_background_polling(cmd, lv);
|
||||
count++;
|
||||
}
|
||||
@ -140,8 +139,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
|
||||
|
||||
if (background_polling() &&
|
||||
activate != CHANGE_AN && activate != CHANGE_ALN &&
|
||||
(lv->status & (PVMOVE|CONVERTING) ||
|
||||
lv_is_merging_origin(lv)))
|
||||
(lv->status & (PVMOVE|CONVERTING|MERGING)))
|
||||
lv_spawn_background_polling(cmd, lv);
|
||||
|
||||
count++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user