]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: track delayed allocation reservations across the filesystem
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)
committerEric Sandeen <sandeen@redhat.com>
Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)
Source kernel commit: 9fe82b8c422b5d9e9011bc08e27b9044936d945f

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>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_priv.h
libxfs/xfs_bmap.c

index 3fe313197469a2e99e4310b7867fb287a007394d..c014b28f41cb731d57ee574bc9f30d324918c7d9 100644 (file)
@@ -120,6 +120,7 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
 
 
 #define xfs_force_shutdown(d,n)                ((void) 0)
+#define xfs_mod_delalloc(a,b)          ((void) 0)
 
 /* stop unused var warnings by assigning mp to itself */
 
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;
 }