RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1525262 - virt-df displays zeros for filesystems with block size =512
Summary: virt-df displays zeros for filesystems with block size =512
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1525241 1551055
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-12 22:25 UTC by Richard W.M. Jones
Modified: 2018-10-30 07:47 UTC (History)
4 users (show)

Fixed In Version: libguestfs-1.38.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1525241
Environment:
Last Closed: 2018-10-30 07:45:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:3021 0 None None None 2018-10-30 07:47:20 UTC

Description Richard W.M. Jones 2017-12-12 22:25:17 UTC
+++ This bug was initially created as a clone of Bug #1525241 +++

Description of problem:

Call virt-df for disk image which contains filesystem with block size = 512 bytes. virt-df shows zeroes for such filesystems in all numeric fields (except Use%). But everything is OK if you call it with --human-readable option.

Version-Release number of selected component (if applicable):

Any. Tested on 1.36.10 Fedora 25 and 1.36.11 CentOS 6.

How reproducible:

virt-df -a disk.qcow2

Actual results:

Filesystem                           1K-blocks       Used  Available  Use%
disk.qcow2:/dev/sda1                         0          0          0    1%

Expected results:

Filesystem                           1K-blocks       Used  Available  Use%
disk.qcow2:/dev/sda1                     99800          1      99800    1%

Additional info:

statvfs:

bsize: 512
blocks: 199600
bfree: 199599

Here is a root of the issue: https://github.com/libguestfs/libguestfs/blob/master/df/output.c#L112

--- Additional comment from Richard W.M. Jones on 2017-12-12 16:29:47 EST ---

Can reproduce the same with virt-df 1.37.34fedora=28,release=3.fc28,libvirt

--- Additional comment from Richard W.M. Jones on 2017-12-12 16:33:13 EST ---

Relevant part of the trace output is:

libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs = bsize: 512, frsize: 512, blocks: 199600, bfree: 199599, bavail: 199599, files: 0, ffree: 0, favail: 0, fsid: 2049, flag: 4097, namemax: 1530, >

Note that bsize = 512, therefore factor = bsize / 1024 = 0, so
everything is multiplied by zero resulting in:

image:/dev/sda1                              0          0          0    1%

--- Additional comment from Richard W.M. Jones on 2017-12-12 17:24:07 EST ---

Patch posted:

https://www.redhat.com/archives/libguestfs/2017-December/msg00051.html

Comment 2 Xianghua Chen 2017-12-14 08:04:36 UTC
I can't reproduce it with:
libguestfs-1.36.10-4.el7.x86_64

Could you help to check the steps:
#  qemu-img create -f qcow2 fstest.qcow2 100M
# guestfish -a fstest.qcow2 
><fs> run
><fs> part-disk /dev/sda mbr
><fs> mkfs fat /dev/sda1 blocksize:512
><fs> list-filesystems
/dev/sda1: vfat
><fs> blockdev-getbsz /dev/sda1
512
><fs>  quit

[root@dhcp-66-71-68 ~]# virt-df  -a fstest.qcow2 
Filesystem                           1K-blocks       Used  Available  Use%
fstest.qcow2:/dev/sda1                  102056          0     102056    0%

Anything that I misunderstand ? Thank you !

Comment 3 Richard W.M. Jones 2017-12-14 08:59:11 UTC
You need to have ’bsize’ < 1024 to see the bug.  In the case
above the blocksize is 2048:

><fs> part-disk /dev/sda mbr
><fs> mkfs fat /dev/sda1 blocksize:512
><fs> list-filesystems 
/dev/sda1: vfat
><fs> mount /dev/sda1 /
><fs> statvfs /
bsize: 2048            <-----
[...]

In the original bug there is an attached filesystem which demonstrates
the problem, and it's probably easiest just to use that:

https://bugzilla.redhat.com/show_bug.cgi?id=1525241#c0

Comment 4 Xianghua Chen 2017-12-15 02:49:31 UTC
(In reply to Richard W.M. Jones from comment #3)
> You need to have ’bsize’ < 1024 to see the bug.  In the case
> above the blocksize is 2048:
> 
> ><fs> part-disk /dev/sda mbr
> ><fs> mkfs fat /dev/sda1 blocksize:512
> ><fs> list-filesystems 
> /dev/sda1: vfat
> ><fs> mount /dev/sda1 /
> ><fs> statvfs /
> bsize: 2048            <-----
> [...]
> 
> In the original bug there is an attached filesystem which demonstrates
> the problem, and it's probably easiest just to use that:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1525241#c0

Thank you very much, I've reproduced it with the attached filesystem, but I still want to know how did you set bsize to 512?

I thought "mkfs fat /dev/sda1 blocksize:512" did this thing, but actually it didn't.

Comment 5 Xianghua Chen 2017-12-15 02:52:28 UTC
Reproduced with package:
libguestfs-1.36.10-4.el7.x86_64

1. Download the filesystem attached in: 
https://bugzilla.redhat.com/show_bug.cgi?id=1525241#c0
2. 
# guestfish -a disk.qcow2
><fs> run
><fs> mount /dev/sda1 /
><fs> statvfs /
bsize: 512
frsize: 512
blocks: 199600
bfree: 199599
bavail: 199599
files: 0
ffree: 0
favail: 0
fsid: 2049
flag: 4096
namemax: 1530
><fs> exit
3. 
# virt-df -a disk.qcow2 
Filesystem                           1K-blocks       Used  Available  Use%
disk.qcow2:/dev/sda1                         0          0          0    1%

The 1K-blocks is 0 , which is wrong.

Comment 6 Richard W.M. Jones 2017-12-18 10:22:32 UTC
(In reply to Xianghua Chen from comment #4)
> Thank you very much, I've reproduced it with the attached filesystem, but I
> still want to know how did you set bsize to 512?
> 
> I thought "mkfs fat /dev/sda1 blocksize:512" did this thing, but actually it
> didn't.

This is a bug: https://bugzilla.redhat.com/show_bug.cgi?id=1527003

Comment 7 Mykola Ivanets 2017-12-18 12:05:12 UTC
(In reply to Xianghua Chen from comment #4)
> ... but I still want to know how did you set bsize to 512?

For example:

1. qemu-img create -f raw fat.raw 100M
2. losetup /dev/loop0 fat.raw
3. fdisk /dev/loop0 <<EOF
o
n




w
EOF
4. mkfs.fat /dev/loop0p1 -s 1 -S 512 -F 32
5. guestfish --ro -a fat.raw <<EOF
run
mount /dev/sda1 /
statvfs /
EOF

Output:
bsize: 512
frsize: 512
...

Comment 8 Pino Toscano 2018-01-17 17:19:10 UTC
This was fixed upstream with commit
d3afdb6e3edbfe031aac86c14df60c530781ace5
which is in libguestfs >= 1.37.36.

Comment 10 Xianghua Chen 2018-04-25 02:39:20 UTC
Verified with package:
libguestfs-1.38.0-1.el7.x86_64

Steps:
1. Create a image with block size smaller than 1K
# qemu-img create -f raw fat.raw 100M
# losetup /dev/loop0 fat.raw
# fdisk /dev/loop0 <<EOF
o
n




w
EOF
# mkfs.fat /dev/loop0 -s 1 -S 512 -F 32
# guestfish --ro -a fat.raw <<EOF
run
mount /dev/sda /
statvfs /
EOF

Output:
bsize: 512
frsize: 512
blocks: 201616
bfree: 201615
bavail: 201615
files: 0
ffree: 0
favail: 0
fsid: 2048
flag: 4096
namemax: 1530

2. 
# virt-df -a disk.qcow2 
Filesystem                           1K-blocks       Used  Available  Use%
fat.raw:/dev/sda                        100808          0     100807    1%

So verified.

Comment 12 errata-xmlrpc 2018-10-30 07:45:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:3021


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