IOCTL-XFS-FSCOUNTS(2)

✨ ioctl_xfs_fscounts β€” query XFS summary counter information ✨

okay bestie, so this is a page from the XFS corner of the System Calls Manual (section 2, iykyk) πŸ’… and it's genuinely so useful, no cap.


🌸 NAME 🌸

ioctl_xfs_fscounts β€” the way to go ask your XFS filesystem for its summary counter tea β˜•πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <xfs/xfs_fs.h>

int ioctl(int fd, XFS_IOC_FSCOUNTS, struct xfs_fsop_counts *arg);

literally that's the whole vibe. one ioctl call, one struct pointer, and the filesystem spills its counters to you 🫢


πŸ’– DESCRIPTION πŸ’–

So. You want the raw filesystem summary counters? This is that. πŸŽ€

And here's the part that matters, bestie: unlike statvfs(3), the values you get back here are the raw values. They do not reflect any alterations or limits set by project quotas. so if you're comparing the two, don't be shocked when the numbers don't match β€” one of them is wearing a quota filter and this one absolutely is not πŸ™ˆβœ¨

The counter info comes back in a structure shaped like this:

struct xfs_fsop_counts {
     __u64   freedata;
     __u64   freertx;
     __u64   freeino;
     __u64   allocino;
};

and the fields are, one by one, iconic in their own right πŸ‘‘:

  • freedata β€” the number of free filesystem blocks on the data device. πŸ“
  • freertx β€” the number of free extents on the realtime device. ⭐
  • freeino β€” the number of inode records that are not in use within the space that has been allocated for them. πŸ’œ
  • allocino β€” the number of inode records for which space has been allocated. 🌈

like, that's the whole struct. four __u64s. zero drama. main character energy fr fr.


😭 RETURN VALUE 😭

On error, -1 is returned, and errno is set to indicate the error. that's it, that's the rule. πŸ’€


πŸ”₯ ERRORS πŸ”₯

Error codes can be one of, but are not limited to, the following β€” so don't come for me if your errno isn't on this list, bestie, the list is honest about being partial:

  • EFSBADCRC β€” metadata checksum validation failed while performing the query. πŸ’€ checksum said no.
  • EFSCORRUPTED β€” metadata corruption was encountered while performing the query. 🚨 like, actually corrupted. not great.
  • EINVAL β€” the specified allocation group number is not valid for this filesystem.
  • EIO β€” an I/O error was encountered while performing the query.
ngl if you're seeing EFSBADCRC or EFSCORRUPTED your filesystem is having a moment and you should probably pay attention to that. this is not a vibe check you want to fail. 🫠

🧚 CONFORMING TO 🧚

This API is specific to XFS filesystem on the Linux kernel. no POSIX, no portability, no pretending. it's an XFS thing, for XFS, on Linux, periodt. πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page!! go forth and query your counters, you gorgeous nerd πŸ¦‹πŸ’–

β€” with love, from the XFS manual, dated 2019-06-17 🌸✨

πŸ“¦ where this page comes from