]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: teach buftargs to maintain their own buffer hashtable
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:01:10 +0000 (10:01 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:40 +0000 (11:37 -0700)
Source kernel commit: e7b58f7c1be20550d4f51cec6307b811e7555f52

Currently, cached buffers are indexed by per-AG hashtables.  This works
great for the data device, but won't work for in-memory btrees.  To
handle that use case, buftargs will need to be able to index buffers
independently of other data structures.

We accomplish this by hoisting the rhashtable and its lock into a
separate xfs_buf_cache structure, make the buftarg point to the
_buf_cache structure, and rework various functions to use it.  This
will enable the in-memory buftarg to come up with its own _buf_cache.

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

index 0a4f686d94551d3c51c47d6b04ffb0aff0cdc11d..aee85c155abf656a2ea2f5b1d7149cee632b0ddc 100644 (file)
@@ -550,8 +550,8 @@ unsigned int hweight8(unsigned int w);
 unsigned int hweight32(unsigned int w);
 unsigned int hweight64(__u64 w);
 
-static inline int xfs_buf_hash_init(struct xfs_perag *pag) { return 0; }
-static inline void xfs_buf_hash_destroy(struct xfs_perag *pag) { }
+#define xfs_buf_cache_init(bch)                (0)
+#define xfs_buf_cache_destroy(bch)     ((void)0)
 
 static inline int xfs_iunlink_init(struct xfs_perag *pag) { return 0; }
 static inline void xfs_iunlink_destroy(struct xfs_perag *pag) { }
index 389a8288e989ff5c9edc48c46f84df6ca7914e0f..06a88128568218f7bd940ef905638ee6f0c2e445 100644 (file)
@@ -262,7 +262,7 @@ xfs_free_perag(
                xfs_defer_drain_free(&pag->pag_intents_drain);
 
                cancel_delayed_work_sync(&pag->pag_blockgc_work);
-               xfs_buf_hash_destroy(pag);
+               xfs_buf_cache_destroy(&pag->pag_bcache);
 
                /* drop the mount's active reference */
                xfs_perag_rele(pag);
@@ -350,7 +350,7 @@ xfs_free_unused_perag_range(
                spin_unlock(&mp->m_perag_lock);
                if (!pag)
                        break;
-               xfs_buf_hash_destroy(pag);
+               xfs_buf_cache_destroy(&pag->pag_bcache);
                xfs_defer_drain_free(&pag->pag_intents_drain);
                kfree(pag);
        }
@@ -417,7 +417,7 @@ xfs_initialize_perag(
                pag->pagb_tree = RB_ROOT;
 #endif /* __KERNEL__ */
 
-               error = xfs_buf_hash_init(pag);
+               error = xfs_buf_cache_init(&pag->pag_bcache);
                if (error)
                        goto out_remove_pag;
 
index 19eddba098941d4a4cbc9a047052bd0c881c3c80..29bfa6273decb05b1fa335774d3e6093f9b19195 100644 (file)
@@ -106,9 +106,7 @@ struct xfs_perag {
        int             pag_ici_reclaimable;    /* reclaimable inodes */
        unsigned long   pag_ici_reclaim_cursor; /* reclaim restart point */
 
-       /* buffer cache index */
-       spinlock_t      pag_buf_lock;   /* lock for pag_buf_hash */
-       struct rhashtable pag_buf_hash;
+       struct xfs_buf_cache    pag_bcache;
 
        /* background prealloc block trimming */
        struct delayed_work     pag_blockgc_work;