]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: track active state of allocation btree cursors
authorBrian Foster <bfoster@redhat.com>
Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)
Source kernel commit: f6b428a46d60186a38105c71fa435f31240721f9

The upcoming allocation algorithm update searches multiple
allocation btree cursors concurrently. As such, it requires an
active state to track when a particular cursor should continue
searching. While active state will be modified based on higher level
logic, we can define base functionality based on the result of
allocation btree lookups.

Define an active flag in the private area of the btree cursor.
Update it based on the result of lookups in the existing allocation
btree helpers. Finally, provide a new helper to query the current
state.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_alloc.c
libxfs/xfs_alloc_btree.c
libxfs/xfs_btree.h

index 76af2f2fb332c9875f5f40310237129e53076da2..23a902818b839086e382df3aa15f132cc7e21f64 100644 (file)
@@ -141,9 +141,13 @@ xfs_alloc_lookup_eq(
        xfs_extlen_t            len,    /* length of extent */
        int                     *stat)  /* success/failure */
 {
+       int                     error;
+
        cur->bc_rec.a.ar_startblock = bno;
        cur->bc_rec.a.ar_blockcount = len;
-       return xfs_btree_lookup(cur, XFS_LOOKUP_EQ, stat);
+       error = xfs_btree_lookup(cur, XFS_LOOKUP_EQ, stat);
+       cur->bc_private.a.priv.abt.active = (*stat == 1);
+       return error;
 }
 
 /*
@@ -157,9 +161,13 @@ xfs_alloc_lookup_ge(
        xfs_extlen_t            len,    /* length of extent */
        int                     *stat)  /* success/failure */
 {
+       int                     error;
+
        cur->bc_rec.a.ar_startblock = bno;
        cur->bc_rec.a.ar_blockcount = len;
-       return xfs_btree_lookup(cur, XFS_LOOKUP_GE, stat);
+       error = xfs_btree_lookup(cur, XFS_LOOKUP_GE, stat);
+       cur->bc_private.a.priv.abt.active = (*stat == 1);
+       return error;
 }
 
 /*
@@ -173,9 +181,19 @@ xfs_alloc_lookup_le(
        xfs_extlen_t            len,    /* length of extent */
        int                     *stat)  /* success/failure */
 {
+       int                     error;
        cur->bc_rec.a.ar_startblock = bno;
        cur->bc_rec.a.ar_blockcount = len;
-       return xfs_btree_lookup(cur, XFS_LOOKUP_LE, stat);
+       error = xfs_btree_lookup(cur, XFS_LOOKUP_LE, stat);
+       cur->bc_private.a.priv.abt.active = (*stat == 1);
+       return error;
+}
+
+static inline bool
+xfs_alloc_cur_active(
+       struct xfs_btree_cur    *cur)
+{
+       return cur && cur->bc_private.a.priv.abt.active;
 }
 
 /*
index 361b642476a04b5797b651975274439c6819bfe5..d39c973ab52a3632d1792528d04ec97027335e30 100644 (file)
@@ -503,6 +503,7 @@ xfs_allocbt_init_cursor(
 
        cur->bc_private.a.agbp = agbp;
        cur->bc_private.a.agno = agno;
+       cur->bc_private.a.priv.abt.active = false;
 
        if (xfs_sb_version_hascrc(&mp->m_sb))
                cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
index ff8343b0af1602273fe9ed189e0c910491007113..cfd8450a9c122b25515fe13ab5b16b3c809a387d 100644 (file)
@@ -183,6 +183,9 @@ union xfs_btree_cur_private {
                unsigned long   nr_ops;         /* # record updates */
                int             shape_changes;  /* # of extent splits */
        } refc;
+       struct {
+               bool            active;         /* allocation cursor state */
+       } abt;
 };
 
 /*