]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs: also use xfs_bmap_btalloc_accounting for RT allocations
authorChristoph Hellwig <hch@lst.de>
Mon, 15 Apr 2024 23:07:40 +0000 (16:07 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 17 Apr 2024 21:06:26 +0000 (14:06 -0700)
Source kernel commit: 58643460546da1dc61593fc6fd78762798b4534f

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>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
libxfs/libxfs_priv.h
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h
libxfs/xfs_bmap_btree.c

index 30ff8dba9178c3c16f8777eaa2b4888647ca4ae5..28ee192509c75c92b4a6d0be597b57353b301a47 100644 (file)
@@ -434,7 +434,10 @@ void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa);
 #define xfs_filestream_select_ag(...)          (-ENOSYS)
 
 /* quota bits */
-#define xfs_trans_mod_dquot_byino(t,i,f,d)             ((void) 0)
+#define xfs_trans_mod_dquot_byino(t,i,f,d)             ({ \
+       uint _f = (f); \
+       _f = _f; /* shut up gcc */ \
+})
 #define xfs_trans_reserve_quota_nblks(t,i,b,n,f)       (0)
 
 /* hack too silence gcc */
index ad058bb126e25f9b1c15c2fa422359c90ef769fb..4f6bd8dff47e594f72f67ad230f05e8153354717 100644 (file)
@@ -3257,10 +3257,14 @@ xfs_bmap_btalloc_select_lengths(
 }
 
 /* Update all inode and quota accounting for the allocation we just did. */
-static void
-xfs_bmap_btalloc_accounting(
+void
+xfs_bmap_alloc_account(
        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) {
                /*
                 * COW fork blocks are in-core only and thus are treated as
@@ -3285,7 +3289,8 @@ xfs_bmap_btalloc_accounting(
                 * to that of a delalloc extent.
                 */
                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);
                return;
        }
@@ -3296,10 +3301,12 @@ xfs_bmap_btalloc_accounting(
        if (ap->wasdel) {
                ap->ip->i_delayed_blks -= 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,
-               ap->length);
+
+       xfs_trans_mod_dquot_byino(ap->tp, ap->ip, fld, ap->length);
 }
 
 static int
@@ -3373,7 +3380,7 @@ xfs_bmap_process_allocated_extent(
                ap->offset = orig_offset;
        else if (ap->offset + ap->length < orig_offset + orig_length)
                ap->offset = orig_offset + orig_length - ap->length;
-       xfs_bmap_btalloc_accounting(ap);
+       xfs_bmap_alloc_account(ap);
 }
 
 #ifdef DEBUG
index 4b83f6148e0071c00c9d88744c2d60261c991fd4..f6b73f1bad5f742f9aa2e832594122543c1376a6 100644 (file)
@@ -116,6 +116,8 @@ static inline int xfs_bmapi_whichfork(uint32_t bmapi_flags)
        return XFS_DATA_FORK;
 }
 
+void xfs_bmap_alloc_account(struct xfs_bmalloca *ap);
+
 /*
  * Special values for xfs_bmbt_irec_t br_startblock field.
  */
index 73ba067df06ef630ea090c939760fd77c0594b41..887ba56f3b7b4b6aac7a4c68ddab1f9819da4ccd 100644 (file)
@@ -21,6 +21,7 @@
 #include "xfs_trace.h"
 #include "xfs_rmap.h"
 #include "xfs_ag.h"
+#include "xfs_quota_defs.h"
 
 static struct kmem_cache       *xfs_bmbt_cur_cache;