From a083187168bfcf59aa3fec264d5800a3713ebd36 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 8 Sep 2011 20:55:39 +0000 Subject: [PATCH] Add 7th lv_attr char to show the related kernel target. Add thin volume types to lv_attr. --- WHATS_NEW | 1 + lib/metadata/lv.c | 39 +++++++++++++++++++++++++------- lib/metadata/metadata-exported.h | 6 +++++ man/lvs.8.in | 12 +++++++++- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 573c98a88..77b93a9da 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add 7th lv_attr char to show the related kernel target. Terminate pv_attr field correctly. (2.02.86) Fix 'not not' typo in pvcreate man page. Improve man page style for fsadm, lvreduce, lvremove, lvrename, lvresize. diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c index c6643eebf..cfcae48d3 100644 --- a/lib/metadata/lv.c +++ b/lib/metadata/lv.c @@ -298,7 +298,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv) struct lvinfo info; char *repstr; - if (!(repstr = dm_pool_zalloc(mem, 7))) { + if (!(repstr = dm_pool_zalloc(mem, 8))) { log_error("dm_pool_alloc failed"); return 0; } @@ -311,15 +311,22 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv) repstr[0] = 'p'; else if (lv->status & CONVERTING) repstr[0] = 'c'; - else if (lv->status & VIRTUAL) - repstr[0] = 'v'; - /* Origin takes precedence over Mirror */ - else if (lv_is_origin(lv)) { + /* Origin takes precedence over mirror and thin volume */ + else if (lv_is_origin(lv)) repstr[0] = (lv_is_merging_origin(lv)) ? 'O' : 'o'; - } - else if (lv->status & MIRRORED) { + else if (lv->status & MIRRORED) repstr[0] = (lv->status & LV_NOTSYNCED) ? 'M' : 'm'; - }else if (lv->status & MIRROR_IMAGE) + else if (lv_is_thin_volume(lv)) + repstr[0] = 'V'; + else if (lv->status & VIRTUAL) + repstr[0] = 'v'; + else if (lv_is_thin_pool(lv)) + repstr[0] = 't'; + else if (lv_is_thin_pool_data(lv)) + repstr[0] = 'T'; + else if (lv_is_thin_pool_metadata(lv) || (lv->status & RAID_META)) + repstr[0] = 'e'; + else if (lv->status & MIRROR_IMAGE) repstr[0] = (_lv_mimage_in_sync(lv)) ? 'i' : 'I'; else if (lv->status & MIRROR_LOG) repstr[0] = 'l'; @@ -370,6 +377,22 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv) repstr[4] = '-'; repstr[5] = '-'; } + + if (lv_is_thin_type(lv)) + repstr[6] = 't'; + else if (lv_is_mirror_type(lv)) + repstr[6] = 'm'; + else if (lv_is_raid_type(lv)) + repstr[6] = 'r'; + else if (lv_is_cow(lv) || lv_is_origin(lv)) + repstr[6] = 's'; + else if (lv_has_unknown_segments(lv)) + repstr[6] = 'u'; + else if (lv_is_virtual(lv)) + repstr[6] = 'v'; + else + repstr[6] = '-'; + out: return repstr; } diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 9765637aa..45e515766 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -141,6 +141,12 @@ #define lv_is_mirrored(lv) ((lv)->status & MIRRORED ? 1 : 0) #define lv_is_rlog(lv) ((lv)->status & REPLICATOR_LOG ? 1 : 0) +#define lv_is_thin_type(lv) ((lv)->status & (THIN_POOL | THIN_VOLUME | THIN_POOL_DATA | THIN_POOL_METADATA) ? 1 : 0) +#define lv_is_mirror_type(lv) ((lv)->status & (MIRROR_LOG | MIRROR_IMAGE | MIRRORED | PVMOVE) ? 1 : 0) +#define lv_is_raid_type(lv) ((lv)->status & (RAID | RAID_IMAGE | RAID_META)) + +#define lv_is_virtual(lv) ((lv)->status & VIRTUAL) + /* Ordered list - see lv_manip.c */ typedef enum { AREA_UNASSIGNED, diff --git a/man/lvs.8.in b/man/lvs.8.in index baa14ab49..70a874620 100644 --- a/man/lvs.8.in +++ b/man/lvs.8.in @@ -70,7 +70,9 @@ The lv_attr bits are: .IP 1 3 Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (O)rigin with merging snapshot, (s)napshot, merging (S)napshot, (p)vmove, -(v)irtual, mirror (i)mage, mirror (I)mage out-of-sync, under (c)onversion +(v)irtual, mirror (i)mage, mirror (I)mage out-of-sync, mirror (l)og device, +under (c)onversion, thin (V)olume, (t)hin pool, (T)hin pool data, thin pool +m(e)tadata .IP 2 3 Permissions: (w)riteable, (r)ead-only .IP 3 3 @@ -84,6 +86,14 @@ State: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, mapped (d)evice present without tables, mapped device present with (i)nactive table .IP 6 3 device (o)pen +.IP 7 3 +Target type: (m)irror, (r)aid, (s)napshot, (t)hin, (u)nknown, (v)irtual. +This groups logical volumes related to the same kernel target together. So, +for example, mirror images, mirror logs as well as mirrors themselves appear as +(m) if they use the original device-mapper mirror kernel driver; whereas the raid +equivalents using the md raid kernel driver all appear as (r). +Snapshots using the original device-mapper driver appear as (s); whereas +snapshots of thin volumes using the new thin provisioning driver appear as (t). .RE .TP .I \-\-segments -- 2.43.5