]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: switch (back) to a per-buftarg buffer hash
authorChristoph Hellwig <hch@lst.de>
Thu, 2 Jul 2026 19:59:34 +0000 (12:59 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Wed, 8 Jul 2026 08:40:42 +0000 (10:40 +0200)
Source kernel commit: 497560b9ef42a4ab22ada7f1ea975a89cd3c5dfa

The per-AG buffer hashes were added when all buffer lookups took a
per-hash look.  Since then we've made lookups entirely lockless and
removed the need for a hash-wide lock for inserts and removals as
well.  With this there is no need to sharding the hash, so reduce the
used resources by using a per-buftarg hash for all buftargs.

Long after writing this initially, syzbot found a problem in the buffer
cache teardown order, which this happens to fix as well by doing the
entire buffer cache teardown in one places instead of splitting it
between destroying the buftarg and the perag structures.

Link: https://lore.kernel.org/linux-xfs/aLeUdemAZ5wmtZel@dread.disaster.area/
Reported-by: syzbot+0391d34e801643e2809b@syzkaller.appspotmail.com
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Tested-by: syzbot+0391d34e801643e2809b@syzkaller.appspotmail.com
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_ag.c
libxfs/xfs_ag.h

index fd5f902b052435c57f31c468fbee659e1224443f..1c75ef510567890f0a2afb67b583689b31e339e3 100644 (file)
@@ -108,10 +108,7 @@ xfs_perag_uninit(
        struct xfs_group        *xg)
 {
 #ifdef __KERNEL__
-       struct xfs_perag        *pag = to_perag(xg);
-
-       cancel_delayed_work_sync(&pag->pag_blockgc_work);
-       xfs_buf_cache_destroy(&pag->pag_bcache);
+       cancel_delayed_work_sync(&to_perag(xg)->pag_blockgc_work);
 #endif
 }
 
@@ -233,10 +230,6 @@ xfs_perag_alloc(
        INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC);
 #endif /* __KERNEL__ */
 
-       error = xfs_buf_cache_init(&pag->pag_bcache);
-       if (error)
-               goto out_free_perag;
-
        /*
         * Pre-calculated geometry
         */
@@ -248,12 +241,10 @@ xfs_perag_alloc(
 
        error = xfs_group_insert(mp, pag_group(pag), index, XG_TYPE_AG);
        if (error)
-               goto out_buf_cache_destroy;
+               goto out_free_perag;
 
        return 0;
 
-out_buf_cache_destroy:
-       xfs_buf_cache_destroy(&pag->pag_bcache);
 out_free_perag:
        kfree(pag);
        return error;
index 3cd4790768ff91ac8028693cd416bc27e54432e3..16a9b43a3c270c32cc5abecf3a43433cdb642f0c 100644 (file)
@@ -85,8 +85,6 @@ struct xfs_perag {
        int             pag_ici_reclaimable;    /* reclaimable inodes */
        unsigned long   pag_ici_reclaim_cursor; /* reclaim restart point */
 
-       struct xfs_buf_cache    pag_bcache;
-
        /* background prealloc block trimming */
        struct delayed_work     pag_blockgc_work;
 #endif /* __KERNEL__ */