Bug 190730 - lvdisplay -c uses incorrect size units
lvdisplay -c uses incorrect size units
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: lvm2 (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: Dave Wysochanski
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-05-04 14:52 EDT by Frank Sweetser
Modified: 2007-11-30 17:11 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-07-24 07:00:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Frank Sweetser 2006-05-04 14:52:58 EDT
lvm2-2.02.01-1.2.1

From the man page of lvdisplay

---8<---
       -c, --colon
              Generate colon separated output for easier parsing in scripts or
              programs.  N.B. lvs (8) provides considerably more control  over
              the output.

              The values are:

              * logical volume name
              * volume group name
              * logical volume access
              * logical volume status
              * internal logical volume number
              * open count of logical volume
              * logical volume size in kilobytes
              * current logical extents associated to logical volume
              * allocated logical extents of logical volume
              * allocation policy of logical volume
              * read ahead sectors of logical volume
              * major device number of logical volume
              * minor device number of logical volume
---8<---

So the 7th field should print out the size of the LV in kb.  However, on
checking up on it, it appears to be printing the size in 512byte sectors.  Note
how in this example, the count in lvdisplay differs from the count in lvdisplay
-c by exactly a factor of 2.

[root@erwin info]# lvdisplay /dev/vg00/root --units k
  --- Logical volume ---
  LV Name                /dev/vg00/root
  VG Name                vg00
  LV UUID                Ifyj3F-nV6n-XQxa-xfn1-IupD-T62P-iXvBYB
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                41943040.00 KB
  Current LE             10240
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0
   
[root@erwin info]# lvdisplay /dev/vg00/root -c       
  /dev/vg00/root:vg00:3:1:-1:1:83886080:10240:-1:0:0:253:0
Comment 1 Milan Broz 2006-05-09 08:42:06 EDT
Volume size is in 512byte sectors. There is bug in man page. 
Better use lvs in lvm2 environment.
Comment 2 Alasdair Kergon 2006-05-09 10:46:15 EDT
The -c output is provided only for compatibility with LVM1, and is supposed to
produce output close to that produced by LVM1.

New scripts should be using 'lvs' instead.

Unsure which would be the least disruptive way to fix this discrepancy.
Comment 3 Frank Sweetser 2006-05-09 11:09:43 EDT
So should lvdisplay -c be considered depracated in favor of lvs?  And if so, is
this formally mentioned in thedocs anywhere beyond man page just mentioning lvs
as an alternative?
Comment 4 Dave Wysochanski 2007-07-24 07:00:08 EDT
Fix to man page checked in.  Closing as NEXTRELEASE.

If this is inadequate and/or anyone cares to comment, feel free.
Comment 5 Dave Wysochanski 2007-07-24 08:46:52 EDT
I did a quick run with a 64MB LV on upstream lvm2 and a lvm1 on a rhel3.9
machine.  Both lvm1 and lvm2 display the LV size in sectors so the man page
change seems warranted.

The summary of differences in output for "lvdisplay -c" is as follows:
* logical volume name - SAME
* volume group name - SAME
* logical volume access - SAME
* logical volume status - SAME
* internal logical volume number - '0' (lvm1), '-1' (lvm2)
* open count of logical volume - SAME
* logical volume size in kilobytes - SAME (but this is really sectors)
* current logical extents associated to logical volume - '2' (lvm1) '16' (lvm2)
* allocated logical extents of logical volume - '2' (lvm1) '-1' (lvm2)
* allocation policy of logical volume - SAME
* read ahead sectors of logical volume - 1024 (lvm1) '0' (lvm2)
* major device number of logical volume - 58 (lvm1) 253 (lvm2)
* minor device number of logical volume - OK
~
diff --ignore-all-space lvdisplay_c-lvm1.txt lvdisplay_c-lvm2.txt 
1,2c1
< /dev/vg0/lv0:vg0:3:1:0:0:131072:2:2:0:1024:58:0
< 
---
>   /dev/vg0/lv0:vg0:3:1:-1:0:131072:16:-1:0:0:253:0



The significant differences between lvdisplay (without the -c) on lvm1 vs lvm2
seem to be:
1) lvm2 has a couple extra fields - UUID and "Allocated LE"
2) lvm2 does not have "LV #"

diff --ignore-all-space lvdisplay-lvm1.txt lvdisplay-lvm2.txt 
3a4
>   LV UUID                ZurW9y-XMS7-E1Vh-Y5gA-bg2j-pn61-agD06N
6d6
< LV #                   1
8,14c8,13
< LV Size                64 MB
< Current LE             2
< Allocated LE           2
< Allocation             next free
< Read ahead sectors     1024
< Block device           58:0
< 
---
>   LV Size                64.00 MB
>   Current LE             16
>   Segments               1
>   Allocation             inherit
>   Read ahead sectors     0
>   Block device           253:0



Note You need to log in before you can comment on or make changes to this bug.