diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2018-02-26 22:43:19 -0600 |
---|---|---|
committer | Eric Sandeen <sandeen@redhat.com> | 2018-02-26 22:43:19 -0600 |
commit | d07cc7245eaaebd6a9073936965a4d9737773ccb (patch) | |
tree | 8ad3237f3dfb0d3fb9d7a3ddea920081e0a68607 | |
parent | 3cb68815a885ca9c39e7d288ed6f4bd026b22b9c (diff) | |
download | xfsprogs-dev-d07cc7245eaaebd6a9073936965a4d9737773ccb.tar.gz |
xfs: treat CoW fork operations as delalloc for quota accounting
Source kernel commit: 4b4c1326fd7c7210d23d9dd3bfc51f2b6477bb9e
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | libxfs/xfs_bmap.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 87b9b12a6c..15a0f8f0c4 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -3334,8 +3334,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; @@ -4811,6 +4838,7 @@ xfs_bmap_del_extent_cow( xfs_iext_insert(ip, icur, &new, state); break; } + ip->i_delayed_blks -= del->br_blockcount; } /* |