Bug 190730

Summary: lvdisplay -c uses incorrect size units
Product: [Fedora] Fedora Reporter: Frank Sweetser <fs>
Component: lvm2Assignee: Dave Wysochanski <dwysocha>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5CC: agk, dwysocha, mbroz
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-07-24 11:00:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Frank Sweetser 2006-05-04 18:52:58 UTC
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 12:42:06 UTC
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 14:46:15 UTC
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 15:09:43 UTC
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 11:00:08 UTC
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 12:46:52 UTC
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