How to tell how fragmented the free space is on an XFS filesystem?

This document (7014320) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 10
 

Situation

On an XFS filesystem, containing a large number of small files (i.e. <= 4KiB in size), the adding and deleting of files can cause the free space to get fragmented.  This fragmentation can cause a false "out of space" message despite there being a significant amount of free space available.

Further, a severely fragmented filesystem can cause the inability to create new files as outlined in 7014318 - Error: "no space available" on XFS filesystem

Resolution

Monitor your Allocation Groups (AGs) periodically -- starting with a baseline measurement and comparing periodically.

Additional Information

If you're not already familiar with xfs_info, you will want to run this first against a mounted XFS filesystem.  It will return data as follows:

meta-data=/dev/evms/csm/fence4   isize=256    agcount=288, agsize=8388607 blks
         =                       sectsz=512   attr=0
data     =                       bsize=4096   blocks=2409365488, imaxpct=25
         =                       sunit=0      swidth=0 blks, unwritten=1
naming   =version 2              bsize=4096
log      =internal               bsize=4096   blocks=32512, version=1
         =                       sectsz=512   sunit=0 blks, lazy-count=0
realtime =none                   extsz=4096   blocks=0, rtextents=0


Of interest for our purposes is:
  •  the "agcount" which is 288 AGs -- numbered 0 - 287
  • the volume in question is right after "metadata=", or /dev/evms/csm/fence4

Knowing how many AGs we have, one can manually run a simple command line to generate a report on each AG and list it out to a file.  The following is such a command line that will report on each AG to a separate file:

for AGNO in `seq 0 287`;do /usr/sbin/xfs_db -r -c "freesp -s -a $AGNO" /dev/evms/csm/fence4 1>ag${AGNO}.txt

where:
  • the "287" is the agcount value
  • the "/dev/evms/csm/fence4" is the XFS filesystem
  • ag${AGNO}.txt is the file capturing the output.
After running the above, you will get a number of ag*.txt files.  Looking into each of them you will see a histogram of contiguous free blocks.  Here is an example of an AG in fairly good shape:

   from      to extents  blocks    pct
      1       1       6       6   0.00
      8      15   31220  467872  26.33
1048576 2097151       1 1308895  73.67
total free extents 31227
total free blocks 1776773
average free extent size 56.8986


It shows there are:
   - only 6, 1 block "orphans" -- meaning there are no other free blocks around each block.
   - there are 31220 clusters of 8-15 contiguous blocks
   - there is 1 cluster of 1048576-2097151 contiguous blocks

Conversely, here is an AG that is greatly fragmented:

   from      to extents  blocks    pct
      1       1  979870  979870  68.79
      2       3  205140  444668  31.21
total free extents 1185010
total free blocks 1424538
average free extent size 1.20213


This shows that 68.79% of the free space on the filesystem is made up of only single blocks; and 31.21% is made up of 2-3 block clusters.

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7014320
  • Creation Date: 18-Dec-2013
  • Modified Date:04-Mar-2021
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center