Add ACCESS_HIDDEN_LV state flag. An LV that has the ACCESS_HIDDEN_LV state flag set conveys to the user that it is an internal LV but that it may be managed directly. As such it should be displayed without requiring special flags (e.g. lvs -a). Otherwise this important LV's usage information will not be easily seen or managed by the end user. The -shared cow LV has the ACCESS_HIDDEN_LV state flag set. Signed-off-by: Mike Snitzer --- lib/format_text/flags.c | 1 + lib/metadata/metadata-exported.h | 4 ++++ lib/metadata/snapshot_manip.c | 12 ++++++++++++ tools/lvresize.c | 2 +- tools/toollib.c | 7 ++++--- 5 files changed, 22 insertions(+), 4 deletions(-) Index: LVM2.2.02.73/lib/format_text/flags.c =================================================================== --- LVM2.2.02.73.orig/lib/format_text/flags.c 2010-09-10 19:15:17.000000000 +0200 +++ LVM2.2.02.73/lib/format_text/flags.c 2010-09-10 19:15:22.000000000 +0200 @@ -53,6 +53,7 @@ static const struct flag _lv_flags[] = { {LVM_WRITE, "WRITE", STATUS_FLAG}, {FIXED_MINOR, "FIXED_MINOR", STATUS_FLAG}, {VISIBLE_LV, "VISIBLE", STATUS_FLAG}, + {ACCESS_HIDDEN_LV, "ACCESS_HIDDEN", STATUS_FLAG}, {PVMOVE, "PVMOVE", STATUS_FLAG}, {LOCKED, "LOCKED", STATUS_FLAG}, {MIRROR_NOTSYNCED, "NOTSYNCED", STATUS_FLAG}, Index: LVM2.2.02.73/lib/metadata/metadata-exported.h =================================================================== --- LVM2.2.02.73.orig/lib/metadata/metadata-exported.h 2010-09-10 19:15:17.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/metadata-exported.h 2010-09-10 19:15:22.000000000 +0200 @@ -72,6 +72,7 @@ #define MERGING 0x10000000U /* LV SEG */ #define SNAPSHOT_SHARED 0x20000000U /* LV SEG */ +#define ACCESS_HIDDEN_LV 0x40000000U /* LV */ #define REPLICATOR 0x20000000U /* LV -internal use only for replicator */ #define REPLICATOR_LOG 0x40000000U /* LV -internal use only for replicator-dev */ @@ -728,6 +729,9 @@ int lv_is_multisnap_origin(const struct int lv_is_multisnap_cow(const struct logical_volume *lv); int lv_is_shared_cow(const struct logical_volume *lv); +/* Test if given LV is accessible yet hidden */ +int lv_is_accessible_hidden(const struct logical_volume *lv); + /* Test if given LV is visible from user's perspective */ int lv_is_visible(const struct logical_volume *lv); Index: LVM2.2.02.73/lib/metadata/snapshot_manip.c =================================================================== --- LVM2.2.02.73.orig/lib/metadata/snapshot_manip.c 2010-09-10 19:15:17.000000000 +0200 +++ LVM2.2.02.73/lib/metadata/snapshot_manip.c 2010-09-10 19:15:22.000000000 +0200 @@ -31,6 +31,17 @@ int lv_is_cow(const struct logical_volum return (!lv_is_origin(lv) && lv->snapshot) ? 1 : 0; } +int lv_is_accessible_hidden(const struct logical_volume *lv) +{ + if (lv->status & SNAPSHOT) + return 0; + + if (lv_is_cow(lv)) + return (find_cow(lv)->lv->status & ACCESS_HIDDEN_LV) ? 1 : 0; + + return (lv->status & ACCESS_HIDDEN_LV) ? 1 : 0; +} + int lv_is_visible(const struct logical_volume *lv) { if (lv->status & SNAPSHOT) @@ -144,6 +155,7 @@ static void init_shared_snapshot(struct struct logical_volume *origin) { cow_seg->lv->status &= ~VISIBLE_LV; + cow_seg->lv->status |= ACCESS_HIDDEN_LV; origin->snapshot = cow_seg; origin->status |= SNAPSHOT_SHARED; } Index: LVM2.2.02.73/tools/lvresize.c =================================================================== --- LVM2.2.02.73.orig/tools/lvresize.c 2010-09-10 19:15:15.000000000 +0200 +++ LVM2.2.02.73/tools/lvresize.c 2010-09-10 19:15:22.000000000 +0200 @@ -319,7 +319,7 @@ static int _lvresize(struct cmd_context lv = lvl->lv; - if (!lv_is_visible(lv)) { + if (!lv_is_visible(lv) && !lv_is_accessible_hidden(lv)) { log_error("Can't resize internal logical volume %s", lv->name); return ECMD_FAILED; } Index: LVM2.2.02.73/tools/toollib.c =================================================================== --- LVM2.2.02.73.orig/tools/toollib.c 2010-06-30 22:03:53.000000000 +0200 +++ LVM2.2.02.73/tools/toollib.c 2010-09-10 19:15:22.000000000 +0200 @@ -127,10 +127,11 @@ int process_each_lv_in_vg(struct cmd_con continue; /* - * Only let hidden LVs through it --all was used or the LVs - * were specifically named on the command line. + * Only let inaccessible hidden LVs through if --all was used or + * the LVs were specifically named on the command line. */ - if (!lvargs_supplied && !lv_is_visible(lvl->lv) && !arg_count(cmd, all_ARG)) + if (!lvargs_supplied && !arg_count(cmd, all_ARG) && + !lv_is_visible(lvl->lv) && !lv_is_accessible_hidden(lvl->lv)) continue; /* Should we process this LV? */