From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: hch@infradead.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/7] xfs: treat CoW fork operations as delalloc for quota accounting
Date: Mon, 29 Jan 2018 07:26:38 -0500 [thread overview]
Message-ID: <20180129122637.GA38852@bfoster.bfoster> (raw)
In-Reply-To: <151701543454.3070.15432025661660161748.stgit@magnolia>
On Fri, Jan 26, 2018 at 05:10:34PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Since the CoW fork only exists in memory, it is incorrect to update the
> on-disk quota block counts when we modify the CoW fork. Unlike the data
> fork, even real extents in the CoW fork are only delalloc-style
> reservations (on-disk they're owned by the refcountbt) so they must not
> be tracked in the on disk quota info. Ensure the i_delayed_blks
> accounting reflects this too.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
Patch doesn't apply.. I'm guessing because xfs_bmap_btalloc_accounting()
doesn't exist. Is this series incomplete, or perhaps not consistent with
for-next..?
Brian
> fs/xfs/libxfs/xfs_bmap.c | 32 ++++++++++++++++++++++++++++++--
> fs/xfs/xfs_reflink.c | 15 +++++++++++----
> 2 files changed, 41 insertions(+), 6 deletions(-)
>
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 4582f55..cad21fd 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -3343,8 +3343,35 @@ xfs_bmap_btalloc_accounting(
> struct xfs_bmalloca *ap,
> struct xfs_alloc_arg *args)
> {
> - if (!(ap->flags & XFS_BMAPI_COWFORK))
> - ap->ip->i_d.di_nblocks += args->len;
> + if (ap->flags & XFS_BMAPI_COWFORK) {
> + /*
> + * COW fork blocks are in-core only and thus are treated as
> + * in-core quota reservation (like delalloc blocks) even when
> + * converted to real blocks. The quota reservation is not
> + * accounted to disk until blocks are remapped to the data
> + * fork. So if these blocks were previously delalloc, we
> + * already have quota reservation and there's nothing to do
> + * yet.
> + */
> + if (ap->wasdel)
> + return;
> +
> + /*
> + * Otherwise, we've allocated blocks in a hole. The transaction
> + * has acquired in-core quota reservation for this extent.
> + * Rather than account these as real blocks, however, we reduce
> + * the transaction quota reservation based on the allocation.
> + * This essentially transfers the transaction quota reservation
> + * to that of a delalloc extent.
> + */
> + ap->ip->i_delayed_blks += args->len;
> + xfs_trans_mod_dquot_byino(ap->tp, ap->ip, XFS_TRANS_DQ_RES_BLKS,
> + -(long)args->len);
> + return;
> + }
> +
> + /* data/attr fork only */
> + ap->ip->i_d.di_nblocks += args->len;
> xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
> if (ap->wasdel)
> ap->ip->i_delayed_blks -= args->len;
> @@ -4820,6 +4847,7 @@ xfs_bmap_del_extent_cow(
> xfs_iext_insert(ip, icur, &new, state);
> break;
> }
> + ip->i_delayed_blks -= del->br_blockcount;
> }
>
> /*
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 85a119e..c4f0aff 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -599,10 +599,6 @@ xfs_reflink_cancel_cow_blocks(
> del.br_startblock, del.br_blockcount,
> NULL);
>
> - /* Update quota accounting */
> - xfs_trans_mod_dquot_byino(*tpp, ip, XFS_TRANS_DQ_BCOUNT,
> - -(long)del.br_blockcount);
> -
> /* Roll the transaction */
> xfs_defer_ijoin(&dfops, ip);
> error = xfs_defer_finish(tpp, &dfops);
> @@ -613,6 +609,13 @@ xfs_reflink_cancel_cow_blocks(
>
> /* Remove the mapping from the CoW fork. */
> xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
> +
> + /* Remove the quota reservation */
> + error = xfs_trans_reserve_quota_nblks(NULL, ip,
> + -(long)del.br_blockcount, 0,
> + XFS_QMOPT_RES_REGBLKS);
> + if (error)
> + break;
> } else {
> /* Didn't do anything, push cursor back. */
> xfs_iext_prev(ifp, &icur);
> @@ -795,6 +798,10 @@ xfs_reflink_end_cow(
> if (error)
> goto out_defer;
>
> + /* Charge this new data fork mapping to the on-disk quota. */
> + xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_DELBCOUNT,
> + (long)del.br_blockcount);
> +
> /* Remove the mapping from the CoW fork. */
> xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-01-29 12:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-27 1:10 [PATCH v3 0/7] xfs: reflink/scrub/quota fixes Darrick J. Wong
2018-01-27 1:10 ` [PATCH 1/7] xfs: reflink should break pnfs leases before sharing blocks Darrick J. Wong
2018-01-27 7:31 ` Christoph Hellwig
2018-01-27 1:10 ` [PATCH 2/7] xfs: allow xfs_lock_two_inodes to take different EXCL/SHARED modes Darrick J. Wong
2018-01-27 7:32 ` Christoph Hellwig
2018-01-27 1:10 ` [PATCH 3/7] xfs: only grab shared inode locks for source file during reflink Darrick J. Wong
2018-01-27 7:33 ` Christoph Hellwig
2018-01-27 1:10 ` [PATCH 4/7] xfs: treat CoW fork operations as delalloc for quota accounting Darrick J. Wong
2018-01-27 7:33 ` Christoph Hellwig
2018-01-29 12:26 ` Brian Foster [this message]
2018-01-29 23:00 ` Darrick J. Wong
2018-01-30 11:48 ` Brian Foster
2018-01-27 1:10 ` [PATCH 5/7] iomap: warn on zero-length mappings Darrick J. Wong
2018-01-27 7:34 ` Christoph Hellwig
2018-01-27 18:04 ` Darrick J. Wong
2018-01-27 18:08 ` [PATCH v2 " Darrick J. Wong
2018-01-27 1:10 ` [PATCH 6/7] xfs: check reflink allocation mappings Darrick J. Wong
2018-01-27 7:35 ` Christoph Hellwig
2018-01-27 1:10 ` [PATCH 7/7] xfs: don't screw up direct writes when freesp is fragmented Darrick J. Wong
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=20180129122637.GA38852@bfoster.bfoster \
--to=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
/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 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.