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. pvs -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/reporter.c | 3 ++- 5 files changed, 20 insertions(+), 2 deletions(-) Index: lvm2/lib/format_text/flags.c =================================================================== --- lvm2.orig/lib/format_text/flags.c +++ lvm2/lib/format_text/flags.c @@ -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/lib/metadata/metadata-exported.h =================================================================== --- lvm2.orig/lib/metadata/metadata-exported.h +++ lvm2/lib/metadata/metadata-exported.h @@ -72,6 +72,7 @@ #define MERGING 0x10000000U /* LV SEG */ #define SNAPSHOT_SHARED 0x20000000U /* LV SEG */ +#define ACCESS_HIDDEN_LV 0x40000000U /* LV */ #define LVM_READ 0x00000100U /* LV VG */ #define LVM_WRITE 0x00000200U /* LV VG */ @@ -631,6 +632,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/lib/metadata/snapshot_manip.c =================================================================== --- lvm2.orig/lib/metadata/snapshot_manip.c +++ lvm2/lib/metadata/snapshot_manip.c @@ -30,6 +30,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) @@ -143,6 +154,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/tools/reporter.c =================================================================== --- lvm2.orig/tools/reporter.c +++ lvm2/tools/reporter.c @@ -33,7 +33,8 @@ static int _vgs_single(struct cmd_contex static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv, void *handle) { - if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv)) + if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv) && + !lv_is_accessible_hidden(lv)) return ECMD_PROCESSED; if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL)) { Index: lvm2/tools/lvresize.c =================================================================== --- lvm2.orig/tools/lvresize.c +++ lvm2/tools/lvresize.c @@ -323,7 +323,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; }