find for shared extents

"Philip Rowlands" <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
If files share data by hard link, there's no good API for converting inode number to path, but we can use 
$ find -inum 12345

to identify all hard links to a particular inode.

When file data blocks are shared with FICLONE, it's harder to track down who's using what. Specifically, if it's desirable to free up space by deleting files, shared extents can make this task more challenging. With coreutils 9.1 defaulting to --reflink=auto, these are now more common.

Although utilities like filefrag / xfs_bmap can display the fe_physical and fe_flags values, this is presented inconsistently and isn't amenable to scripting.

Would there be any interest for a new test for find? By providing a physical byte offset in the filesystem, all extents using that offset would match.

find -xdev -physicaloffsetnum 3079180288 -ls
# I deliberately chose a bad test name to provoke folks to improve it

To look for shared extents, perhaps "-physicaloffsetnum 3079180288S" could signify matching on the FIEMAP_EXTENT_SHARED flag.

If this isn't a good idea, suggestions on a postcard please of how to find all files sharing a given physical_offset, sprinkled around the filesystem.


Cheers,
Phil
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.