]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: double link the unlinked inode list
authorDave Chinner <dchinner@redhat.com>
Wed, 24 Aug 2022 14:22:35 +0000 (16:22 +0200)
committerCarlos Maiolino <cem@kernel.org>
Tue, 30 Aug 2022 08:30:30 +0000 (10:30 +0200)
Source kernel commit: 2fd26cc07e9f8050e29bf314cbf1bcb64dbe088c

Now we have forwards traversal via the incore inode in place, we now
need to add back pointers to the incore inode to entirely replace
the back reference cache. We use the same lookup semantics and
constraints as for the forwards pointer lookups during unlinks, and
so we can look up any inode in the unlinked list directly and update
the list pointers, forwards or backwards, at any time.

The only wrinkle in converting the unlinked list manipulations to
use in-core previous pointers is that log recovery doesn't have the
incore inode state built up so it can't just read in an inode and
release it to finish off the unlink. Hence we need to modify the
traversal in recovery to read one inode ahead before we
release the inode at the head of the list. This populates the
next->prev relationship sufficient to be able to replay the unlinked
list and hence greatly simplify the runtime code.

This recovery algorithm also requires that we actually remove inodes
from the unlinked list one at a time as background inode
inactivation will result in unlinked list removal racing with the
building of the in-memory unlinked list state. We could serialise
this by holding the AGI buffer lock when constructing the in memory
state, but all that does is lockstep background processing with list
building. It is much simpler to flush the inodegc immediately after
releasing the inode so that it is unlinked immediately and there is
no races present at all.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_ag.c
libxfs/xfs_ag.h

index 7515dd12783fd3694bf83268c4e46288b644a0be..70ae1da7649d2bf2ce45ce9d3adafdd6a87aea77 100644 (file)
@@ -192,7 +192,6 @@ xfs_free_perag(
                XFS_IS_CORRUPT(pag->pag_mount, atomic_read(&pag->pag_ref) != 0);
 
                cancel_delayed_work_sync(&pag->pag_blockgc_work);
-               xfs_iunlink_destroy(pag);
                xfs_buf_hash_destroy(pag);
 
                call_rcu(&pag->rcu_head, __xfs_free_perag);
@@ -321,10 +320,6 @@ xfs_initialize_perag(
                if (error)
                        goto out_remove_pag;
 
-               error = xfs_iunlink_init(pag);
-               if (error)
-                       goto out_hash_destroy;
-
                /* first new pag is fully initialized */
                if (first_initialised == NULLAGNUMBER)
                        first_initialised = index;
@@ -347,8 +342,6 @@ xfs_initialize_perag(
        mp->m_ag_prealloc_blocks = xfs_prealloc_blocks(mp);
        return 0;
 
-out_hash_destroy:
-       xfs_buf_hash_destroy(pag);
 out_remove_pag:
        radix_tree_delete(&mp->m_perag_tree, index);
 out_free_pag:
@@ -360,7 +353,6 @@ out_unwind_new_pags:
                if (!pag)
                        break;
                xfs_buf_hash_destroy(pag);
-               xfs_iunlink_destroy(pag);
                kmem_free(pag);
        }
        return error;
index 75f7c10c110a5e789525fb39ab6d7fa70de51a36..517a138faa669b8494dda3810edbab78dc1930ac 100644 (file)
@@ -103,12 +103,6 @@ struct xfs_perag {
        /* background prealloc block trimming */
        struct delayed_work     pag_blockgc_work;
 
-       /*
-        * Unlinked inode information.  This incore information reflects
-        * data stored in the AGI, so callers must hold the AGI buffer lock
-        * or have some other means to control concurrency.
-        */
-       struct rhashtable       pagi_unlinked_hash;
 #endif /* __KERNEL__ */
 };