public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Question about xfs/440
       [not found] <OS3PR01MB9499A747D11EFFD2654354D483E69@OS3PR01MB9499.jpnprd01.prod.outlook.com>
@ 2022-12-20 22:55 ` Darrick J. Wong
  0 siblings, 0 replies; only message in thread
From: Darrick J. Wong @ 2022-12-20 22:55 UTC (permalink / raw)
  To: yangx.jy@fujitsu.com; +Cc: xfs

On Fri, Dec 16, 2022 at 01:02:18PM +0000, yangx.jy@fujitsu.com wrote:
> Hi Darrick,
> 
> As you know, the following steps comes from xfs/440. I have two
> questions about these steps.
> The first one:
> Why repquota -u command shows "128" rather than "64" for fsgqa user
> after cp --reflink command is completed?

Quota resource usage are charged for each file, even for shared blocks.
There's no easy way to amortize the cost of a shared block among its
owners unless you can walk backwards from a piece of storage back to its
owners, which is too much work to make it worth the effort.

Hence reflinking a 64k file to another file creates 128k worth of usage.

> The second one:
> Why repquota -u command shows "1152" for fsgqa user after CoW(Copy on
> Write) is completed?

The space extents used to stage COW operations are separate space
allocations, which means they're charged to the quota and hang around
until writeback happens.  In xfs/440, we set a cow extent size hint of
1mb, so we've actually staged 1mb of cow so that appending writes to /b
will end up in contiguous space.  That's why usage goes from 128 to
1152.

--D

> 
> How does the kernel process reflink and CoW?
> How does the kernel calculate the number(e.g. 128,1152)?
> 
> # mount -o usrquota,grpquota /dev/pmem1 /mnt/scratch/
> # touch /mnt/scratch/a /mnt/scratch/force_fsgqa
> # chown fsgqa /mnt/scratch/a /mnt/scratch/force_fsgqa
> # xfs_io -c "pwrite -S 0x58 0 64k" /mnt/scratch/a
> # repquota -u /mnt/scratch/
> ...
>                         Block limits                File limits
> User            used    soft    hard  grace    used  soft  hard  grace
> ----------------------------------------------------------------------
> root      --       0       0       0              3     0     0
> fsgqa     --      64       0       0              2     0     0
> 
> # cp --reflink=always -p /mnt/scratch/a /mnt/scratch/b
> # repquota -u /mnt/scratch/
> ...
>                         Block limits                File limits
> User            used    soft    hard  grace    used  soft  hard  grace
> ----------------------------------------------------------------------
> root      --       0       0       0              3     0     0
> fsgqa     --     128       0       0              3     0     0
> 
> # xfs_io -c "pwrite -S 0x59 0 64k" /mnt/scratch/a
> # repquota -u /mnt/scratch/
> ...
>                         Block limits                File limits
> User            used    soft    hard  grace    used  soft  hard  grace
> ----------------------------------------------------------------------
> root      --       0       0       0              3     0     0
> fsgqa     --    1152       0       0              3     0     0
> 
> Best Regards,
> Xiao Yang

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-20 22:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <OS3PR01MB9499A747D11EFFD2654354D483E69@OS3PR01MB9499.jpnprd01.prod.outlook.com>
2022-12-20 22:55 ` Question about xfs/440 Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox