* Query: XFS reflink unique block measurement / snapshot accounting
@ 2025-07-12 7:49 Priya PM
2025-07-14 5:58 ` Christoph Hellwig
2025-07-14 20:54 ` Dave Chinner
0 siblings, 2 replies; 5+ messages in thread
From: Priya PM @ 2025-07-12 7:49 UTC (permalink / raw)
To: linux-xfs
Hi,
I was using reflinks to create snapshots of an XFS filesystem;
however, I’m looking for ways to determine the unique snapshot usage
or perform snapshot accounting.
We tried using filefrag, but it doesn’t help when editing files with
vi, as vi changes the block numbers with every write operation. This
causes the snapshot accounting to show unique blocks even though there
are shared blocks with the original file.
Can anyone suggest a better method for snapshot accounting on XFS?
Thanks in advance for your help!
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Query: XFS reflink unique block measurement / snapshot accounting
2025-07-12 7:49 Query: XFS reflink unique block measurement / snapshot accounting Priya PM
@ 2025-07-14 5:58 ` Christoph Hellwig
2025-07-15 13:51 ` Priya PM
2025-07-14 20:54 ` Dave Chinner
1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2025-07-14 5:58 UTC (permalink / raw)
To: Priya PM; +Cc: linux-xfs
On Sat, Jul 12, 2025 at 01:19:19PM +0530, Priya PM wrote:
> Hi,
>
> I was using reflinks to create snapshots of an XFS filesystem;
> however, I’m looking for ways to determine the unique snapshot usage
> or perform snapshot accounting.
Can you explain what you are trying to measure? How many blocks in a
given file are refcounted blocks with other users? Or the difference
between i_blocks for all files combined vs actual space usage?
There isn't really such a thing as snapshot accouting in XFS.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Query: XFS reflink unique block measurement / snapshot accounting
2025-07-12 7:49 Query: XFS reflink unique block measurement / snapshot accounting Priya PM
2025-07-14 5:58 ` Christoph Hellwig
@ 2025-07-14 20:54 ` Dave Chinner
1 sibling, 0 replies; 5+ messages in thread
From: Dave Chinner @ 2025-07-14 20:54 UTC (permalink / raw)
To: Priya PM; +Cc: linux-xfs
On Sat, Jul 12, 2025 at 01:19:19PM +0530, Priya PM wrote:
> Hi,
>
> I was using reflinks to create snapshots of an XFS filesystem;
> however, I’m looking for ways to determine the unique snapshot usage
> or perform snapshot accounting.
XFS doesn't have any "snapshot" functionality in it. What are you
trying to measure, exactly?
-Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Query: XFS reflink unique block measurement / snapshot accounting
2025-07-14 5:58 ` Christoph Hellwig
@ 2025-07-15 13:51 ` Priya PM
2025-07-15 16:09 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Priya PM @ 2025-07-15 13:51 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-xfs
For example,
/mnt/fs1 has file1 of size 40KB
Do a reflink cp of /mnt/fs1 to /mnt/.snap/1
Now, when I check the size of /mnt/.snap/1/, it should show only snap
usage. In this case, it should be 0, as no blocks are unique to this
snap.
Modify file1 in /mnt/fs1, modify 2 blocks of block size 4 KB.
Take snapshot /mnt/snap/2 --.> This should show only the unique snap
usage as 8KB.
I understand there is no snap accounting in XFS. However, to achieve
the above things, is there any XFS command that can help?
Thanks in advance for your time.
On Mon, Jul 14, 2025 at 11:28 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Sat, Jul 12, 2025 at 01:19:19PM +0530, Priya PM wrote:
> > Hi,
> >
> > I was using reflinks to create snapshots of an XFS filesystem;
> > however, I’m looking for ways to determine the unique snapshot usage
> > or perform snapshot accounting.
>
> Can you explain what you are trying to measure? How many blocks in a
> given file are refcounted blocks with other users? Or the difference
> between i_blocks for all files combined vs actual space usage?
>
> There isn't really such a thing as snapshot accouting in XFS.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Query: XFS reflink unique block measurement / snapshot accounting
2025-07-15 13:51 ` Priya PM
@ 2025-07-15 16:09 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2025-07-15 16:09 UTC (permalink / raw)
To: Priya PM; +Cc: Christoph Hellwig, linux-xfs
On Tue, Jul 15, 2025 at 07:21:22PM +0530, Priya PM wrote:
> For example,
> /mnt/fs1 has file1 of size 40KB
> Do a reflink cp of /mnt/fs1 to /mnt/.snap/1
> Now, when I check the size of /mnt/.snap/1/, it should show only snap
> usage. In this case, it should be 0, as no blocks are unique to this
> snap.
> Modify file1 in /mnt/fs1, modify 2 blocks of block size 4 KB.
> Take snapshot /mnt/snap/2 --.> This should show only the unique snap
> usage as 8KB.
>
> I understand there is no snap accounting in XFS. However, to achieve
> the above things, is there any XFS command that can help?
reflinked blocks are not owned by either file, so the usage is shared
by them.
There's a few things you could theoretically do:
- check how many non-shared blocks a file has. The easiest way to
do that would be to call fiemap on the inode, and count the extents
that don't have the shared flag set on them. You'd probably need to
write that at the C level, as the filefrag and xfs_io fiemap commands
aren't all that great
- look how many shared vs unshared block a file system has in total.
For thay you'd want a rmap-enabled file system and look at the fsmap
output.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-15 16:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-12 7:49 Query: XFS reflink unique block measurement / snapshot accounting Priya PM
2025-07-14 5:58 ` Christoph Hellwig
2025-07-15 13:51 ` Priya PM
2025-07-15 16:09 ` Christoph Hellwig
2025-07-14 20:54 ` Dave Chinner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.