Skip to content

Commit 5864346

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
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: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent eef519d commit 5864346

3 files changed

Lines changed: 17 additions & 18 deletions

File tree

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,10 +3263,14 @@ xfs_bmap_btalloc_select_lengths(
32633263
}
32643264

32653265
/* Update all inode and quota accounting for the allocation we just did. */
3266-
static void
3267-
xfs_bmap_btalloc_accounting(
3266+
void
3267+
xfs_bmap_alloc_account(
32683268
struct xfs_bmalloca *ap)
32693269
{
3270+
bool isrt = XFS_IS_REALTIME_INODE(ap->ip) &&
3271+
(ap->flags & XFS_BMAPI_ATTRFORK);
3272+
uint fld;
3273+
32703274
if (ap->flags & XFS_BMAPI_COWFORK) {
32713275
/*
32723276
* COW fork blocks are in-core only and thus are treated as
@@ -3291,7 +3295,8 @@ xfs_bmap_btalloc_accounting(
32913295
* to that of a delalloc extent.
32923296
*/
32933297
ap->ip->i_delayed_blks += ap->length;
3294-
xfs_trans_mod_dquot_byino(ap->tp, ap->ip, XFS_TRANS_DQ_RES_BLKS,
3298+
xfs_trans_mod_dquot_byino(ap->tp, ap->ip, isrt ?
3299+
XFS_TRANS_DQ_RES_RTBLKS : XFS_TRANS_DQ_RES_BLKS,
32953300
-(long)ap->length);
32963301
return;
32973302
}
@@ -3302,10 +3307,12 @@ xfs_bmap_btalloc_accounting(
33023307
if (ap->wasdel) {
33033308
ap->ip->i_delayed_blks -= ap->length;
33043309
xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)ap->length);
3310+
fld = isrt ? XFS_TRANS_DQ_DELRTBCOUNT : XFS_TRANS_DQ_DELBCOUNT;
3311+
} else {
3312+
fld = isrt ? XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT;
33053313
}
3306-
xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
3307-
ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT,
3308-
ap->length);
3314+
3315+
xfs_trans_mod_dquot_byino(ap->tp, ap->ip, fld, ap->length);
33093316
}
33103317

33113318
static int
@@ -3379,7 +3386,7 @@ xfs_bmap_process_allocated_extent(
33793386
ap->offset = orig_offset;
33803387
else if (ap->offset + ap->length < orig_offset + orig_length)
33813388
ap->offset = orig_offset + orig_length - ap->length;
3382-
xfs_bmap_btalloc_accounting(ap);
3389+
xfs_bmap_alloc_account(ap);
33833390
}
33843391

33853392
#ifdef DEBUG

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ static inline int xfs_bmapi_whichfork(uint32_t bmapi_flags)
116116
return XFS_DATA_FORK;
117117
}
118118

119+
void xfs_bmap_alloc_account(struct xfs_bmalloca *ap);
120+
119121
/*
120122
* Special values for xfs_bmbt_irec_t br_startblock field.
121123
*/

fs/xfs/xfs_bmap_util.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,7 @@ xfs_bmap_rtalloc(
168168
if (rtx != NULLRTEXTNO) {
169169
ap->blkno = xfs_rtx_to_rtb(mp, rtx);
170170
ap->length = xfs_rtxlen_to_extlen(mp, ralen);
171-
ap->ip->i_nblocks += ap->length;
172-
xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
173-
if (ap->wasdel)
174-
ap->ip->i_delayed_blks -= ap->length;
175-
/*
176-
* Adjust the disk quota also. This was reserved
177-
* earlier.
178-
*/
179-
xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
180-
ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT :
181-
XFS_TRANS_DQ_RTBCOUNT, ap->length);
171+
xfs_bmap_alloc_account(ap);
182172
return 0;
183173
}
184174

0 commit comments

Comments
 (0)