Bug 2064810

Summary: RFE: complete libblkid FSSIZE implementation
Product: Red Hat Enterprise Linux 9 Reporter: David Teigland <teigland>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED ERRATA QA Contact: Radka Brychtova <rskvaril>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: aalbersh, dwysocha, esandeen, kzak
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: util-linux-2.37.4-8.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 11:23:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Teigland 2022-03-16 15:41:21 UTC
Description of problem:

FSSIZE has not bee fully implemented for specific file systems (by reading on-disk structures.)  I'd like to use it in lvreduce (bug 1878893).

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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Eric Sandeen 2022-03-16 16:34:43 UTC
Sure, I'll see if someone on our team can work on this, should not be a major effort.

Comment 3 David Teigland 2022-03-17 15:53:31 UTC
After talking with Eric, it sounds like FSSIZE is already closely associated with statfs values (e.g. in lsblk), so FSSIZE should probably be emulating the statfs values.  However, for our purposes in bug 1878893, we actually need to know the last block on the device used by the fs.  That seems like a new property with a name like FSLASTBLOCK or FSBLOCKCOUNT.

Comment 4 Eric Sandeen 2022-03-17 16:16:28 UTC
Yup - FSSIZE in lsblk is reporting dev->fsstat.f_frsize * dev->fsstat.f_blocks, and filesystems tend to exclude internal metadata blocks for that; it's more like "total data blocks" and often excludes i.e. the log, etc. And surely blkid FSSIZE should match lsblk's FSSIZE.

So while FSSIZE is still interesting and useful for blkid, I think we might want to add something like FSLASTBLOCK as well, depending on what kzak thinks about it.

Thanks,
-Eric

Comment 5 Karel Zak 2022-03-18 09:39:21 UTC
libblkid is completely open for arbitrary variables, we can introduce whatever you need :-)

I like both, FSSIZE (in statfs meaning) as well as FSLASTBLOCK (for the size of the area occupated by FS).

Comment 6 Andrey Albershteyn (aalbersh) 2022-05-05 09:48:53 UTC
The FSLASTBLOCK and FSSIZE tags were merged into util-linux. Both tags are implemented for XFS. FSLASTBLOCK is implemented for ext2/3/4/jbd and btrfs. I'll implement FSSIZE for ext and btrfs, later.

FSSIZE - mimics statfs + lsblk's FSSIZE (total_blocks*block_size - fs_overhead). However, in case of ext and btrfs it would be just total_blocks*block_size.
FSLASTBLOCK - area occupied by FS, number of the last block of FS.

Both these tags could be enabled by BLKID_SUBLKS_FSINFO flag.

Comment 8 David Teigland 2022-05-23 22:14:57 UTC
Hi, I've begun adding some lvm code to use this, and the units of FSLASTBLOCK are not immediately clear to me.  From what I'm seeing, it seems likely they are units of the fs block size, but the fs block size doesn't seem to be exposed in blkid.  The BLOCK_SIZE (512 or 4096) is available, but this doesn't quite look like it's what I need here.  Perhaps the units of FSLASTBLOCK could be changed to BLOCK_SIZE (or bytes), or the FSBLOCKSIZE could be added?

Comment 9 Karel Zak 2022-05-25 07:39:47 UTC
Andrey, I guess FSLASTBLOCK is counted in BLOCK_SIZE, right?

Comment 10 Andrey Albershteyn (aalbersh) 2022-05-26 09:28:43 UTC
Hey, the FSLASTBLOCK is in fs block size units. The XFS implementation sets BLOCK_SIZE to the sector size (which is intended). I will work on adding FSBLOCKSIZE tag which would expose fs block size.

Comment 11 Andrey Albershteyn (aalbersh) 2022-05-31 09:22:42 UTC
Hey David, the FSBLOCKSIZE was merged into util-linux. Now you should be able to do FSLASTBLOCK*FSBLOCKSIZE to get a fs size.

Relevant upstream patches:
895f0b609 libblkid: update documentation of BLOCK_SIZE tag
0f447d490 libblkid: add FSBLOCKSIZE tag

Comment 17 errata-xmlrpc 2022-11-15 11:23: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 (util-linux bug fix and enhancement update), 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/RHBA-2022:8404