public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: "yangx.jy@fujitsu.com" <yangx.jy@fujitsu.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: Re: Question about xfs/440
Date: Tue, 20 Dec 2022 14:55:41 -0800	[thread overview]
Message-ID: <Y6I9bdpTFhsa+eLW@magnolia> (raw)
In-Reply-To: <OS3PR01MB9499A747D11EFFD2654354D483E69@OS3PR01MB9499.jpnprd01.prod.outlook.com>

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

           reply	other threads:[~2022-12-20 22:55 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <OS3PR01MB9499A747D11EFFD2654354D483E69@OS3PR01MB9499.jpnprd01.prod.outlook.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y6I9bdpTFhsa+eLW@magnolia \
    --to=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=yangx.jy@fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox