]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs: track delayed allocation reservations across
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 25 Jun 2019 21:57:55 +0000 (14:57 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 26 Jun 2019 01:46:26 +0000 (18:46 -0700)
Add a percpu counter to track the number of blocks directly reserved for
delayed allocations on the data device.  This counter (in contrast to
i_delayed_blks) does not track allocated CoW staging extents or anything
going on with the realtime device.  It will be used in the upcoming
summary counter scrub function to check the free block counts without
having to freeze the filesystem or walk all the inodes to find the
delayed allocations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
libxfs/libxfs_priv.h
libxfs/xfs_bmap.c

index 3fe313197469a2e99e4310b7867fb287a007394d..adcf93d4fbc39c49ccdb514139610a0fd819c604 100644 (file)
@@ -664,4 +664,6 @@ int xfs_bmap_last_extent(struct xfs_trans *tp, struct xfs_inode *ip,
                         int whichfork, struct xfs_bmbt_irec *rec,
                         int *is_empty);
 
+#define xfs_mod_delalloc(mp, delta)    do { } while (0)
+
 #endif /* __LIBXFS_INTERNAL_XFS_H__ */
index cd570fba897b95bc1fe45bb42a111a796adfed82..5f4879c091cefb4624716b746c0dc0b6325cdaa4 100644 (file)
@@ -2000,6 +2000,9 @@ xfs_bmap_add_extent_delay_real(
                        goto done;
        }
 
+       if (da_new != da_old)
+               xfs_mod_delalloc(mp, (int64_t)da_new - da_old);
+
        if (bma->cur) {
                da_new += bma->cur->bc_private.b.allocated;
                bma->cur->bc_private.b.allocated = 0;
@@ -2631,6 +2634,7 @@ xfs_bmap_add_extent_hole_delay(
                /*
                 * Nothing to do for disk quota accounting here.
                 */
+               xfs_mod_delalloc(ip->i_mount, (int64_t)newlen - oldlen);
        }
 }
 
@@ -3343,8 +3347,10 @@ xfs_bmap_btalloc_accounting(
                 * already have quota reservation and there's nothing to do
                 * yet.
                 */
-               if (ap->wasdel)
+               if (ap->wasdel) {
+                       xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)args->len);
                        return;
+               }
 
                /*
                 * Otherwise, we've allocated blocks in a hole. The transaction
@@ -3363,8 +3369,10 @@ xfs_bmap_btalloc_accounting(
        /* 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)
+       if (ap->wasdel) {
                ap->ip->i_delayed_blks -= args->len;
+               xfs_mod_delalloc(ap->ip->i_mount, -(int64_t)args->len);
+       }
        xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
                ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT,
                args->len);
@@ -3960,6 +3968,7 @@ xfs_bmapi_reserve_delalloc(
 
 
        ip->i_delayed_blks += alen;
+       xfs_mod_delalloc(ip->i_mount, alen + indlen);
 
        got->br_startoff = aoff;
        got->br_startblock = nullstartblock(indlen);
@@ -4831,8 +4840,10 @@ xfs_bmap_del_extent_delay(
        da_diff = da_old - da_new;
        if (!isrt)
                da_diff += del->br_blockcount;
-       if (da_diff)
+       if (da_diff) {
                xfs_mod_fdblocks(mp, da_diff, false);
+               xfs_mod_delalloc(mp, -da_diff);
+       }
        return error;
 }