Commit 58643460 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Chandan Babu R

xfs: also use xfs_bmap_btalloc_accounting for RT allocations

Make xfs_bmap_btalloc_accounting more generic by handling the RT quota
reservations and then also use it from xfs_bmap_rtalloc instead of
open coding the accounting logic there.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
parent eef519d7
...@@ -3263,10 +3263,14 @@ xfs_bmap_btalloc_select_lengths( ...@@ -3263,10 +3263,14 @@ xfs_bmap_btalloc_select_lengths(
} }
/* Update all inode and quota accounting for the allocation we just did. */ /* Update all inode and quota accounting for the allocation we just did. */
static void void
xfs_bmap_btalloc_accounting( xfs_bmap_alloc_account(
struct xfs_bmalloca *ap) struct xfs_bmalloca *ap)
{ {
bool isrt = XFS_IS_REALTIME_INODE(ap->ip) &&
(ap->flags & XFS_BMAPI_ATTRFORK);
uint fld;
if (ap->flags & XFS_BMAPI_COWFORK) { if (ap->flags & XFS_BMAPI_COWFORK) {
/* /*
* COW fork blocks are in-core only and thus are treated as * COW fork blocks are in-core only and thus are treated as
...@@ -3291,7 +3295,8 @@ xfs_bmap_btalloc_accounting( ...@@ -3291,7 +3295,8 @@ xfs_bmap_btalloc_accounting(
* to that of a delalloc extent. * to that of a delalloc extent.
*/ */
ap->ip->i_delayed_blks += ap->length; ap->ip->i_delayed_blks += ap->length;
xfs_trans_mod_dquot_byino(ap->tp, ap->ip, XFS_TRANS_DQ_RES_BLKS, xfs_trans_mod_dquot_byino(ap->tp, ap->ip, isrt ?
XFS_TRANS_DQ_RES_RTBLKS : XFS_TRANS_DQ_RES_BLKS,
-(long)ap->length); -(long)ap->length);
return; return;
} }
...@@ -3302,10 +3307,12 @@ xfs_bmap_btalloc_accounting( ...@@ -3302,10 +3307,12 @@ xfs_bmap_btalloc_accounting(
if (ap->wasdel) { if (ap->wasdel) {
ap->ip->i_delayed_blks -= ap->length; ap->ip->i_delayed_blks -= ap->length;
xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)ap->length); xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)ap->length);
fld = isrt ? XFS_TRANS_DQ_DELRTBCOUNT : XFS_TRANS_DQ_DELBCOUNT;
} else {
fld = isrt ? XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT;
} }
xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT, xfs_trans_mod_dquot_byino(ap->tp, ap->ip, fld, ap->length);
ap->length);
} }
static int static int
...@@ -3379,7 +3386,7 @@ xfs_bmap_process_allocated_extent( ...@@ -3379,7 +3386,7 @@ xfs_bmap_process_allocated_extent(
ap->offset = orig_offset; ap->offset = orig_offset;
else if (ap->offset + ap->length < orig_offset + orig_length) else if (ap->offset + ap->length < orig_offset + orig_length)
ap->offset = orig_offset + orig_length - ap->length; ap->offset = orig_offset + orig_length - ap->length;
xfs_bmap_btalloc_accounting(ap); xfs_bmap_alloc_account(ap);
} }
#ifdef DEBUG #ifdef DEBUG
......
...@@ -116,6 +116,8 @@ static inline int xfs_bmapi_whichfork(uint32_t bmapi_flags) ...@@ -116,6 +116,8 @@ static inline int xfs_bmapi_whichfork(uint32_t bmapi_flags)
return XFS_DATA_FORK; return XFS_DATA_FORK;
} }
void xfs_bmap_alloc_account(struct xfs_bmalloca *ap);
/* /*
* Special values for xfs_bmbt_irec_t br_startblock field. * Special values for xfs_bmbt_irec_t br_startblock field.
*/ */
......
...@@ -168,17 +168,7 @@ xfs_bmap_rtalloc( ...@@ -168,17 +168,7 @@ xfs_bmap_rtalloc(
if (rtx != NULLRTEXTNO) { if (rtx != NULLRTEXTNO) {
ap->blkno = xfs_rtx_to_rtb(mp, rtx); ap->blkno = xfs_rtx_to_rtb(mp, rtx);
ap->length = xfs_rtxlen_to_extlen(mp, ralen); ap->length = xfs_rtxlen_to_extlen(mp, ralen);
ap->ip->i_nblocks += ap->length; xfs_bmap_alloc_account(ap);
xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
if (ap->wasdel)
ap->ip->i_delayed_blks -= ap->length;
/*
* Adjust the disk quota also. This was reserved
* earlier.
*/
xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT :
XFS_TRANS_DQ_RTBCOUNT, ap->length);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment