From 75d74b5894c182393a225d2f10a3db7462ac324a Mon Sep 17 00:00:00 2001 From: Matthew DeVore Date: Tue, 3 Nov 2020 15:13:17 -0800 Subject: [PATCH] debug helps --- .../FSAL_MDCACHE/mdcache_lru.c | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/FSAL/Stackable_FSALs/FSAL_MDCACHE/mdcache_lru.c b/src/FSAL/Stackable_FSALs/FSAL_MDCACHE/mdcache_lru.c index f54a858f7..50be69156 100644 --- a/src/FSAL/Stackable_FSALs/FSAL_MDCACHE/mdcache_lru.c +++ b/src/FSAL/Stackable_FSALs/FSAL_MDCACHE/mdcache_lru.c @@ -25,20 +25,21 @@ * 02110-1301 USA * * ------------- */ /** * @addtogroup FSAL_MDCACHE * @{ */ +#include #include "config.h" #include "nfs_init.h" #include #include #include #include #include #include #include #include @@ -1957,20 +1958,35 @@ void mdcache_lru_insert(mdcache_entry_t *entry, mdc_reason_t reason) switch (reason) { case MDC_REASON_DEFAULT: lru_insert_entry(entry, &LRU[entry->lru.lane].L1, LRU_LRU); break; case MDC_REASON_SCAN: lru_insert_entry(entry, &LRU[entry->lru.lane].L2, LRU_MRU); break; } } +static void report_mdcache_refcount(int32_t refcnt, mdcache_entry_t *entry, int change) +{ + void *syms[256]; + int size = 256; + + size = backtrace(syms, size); + + backtrace_symbols_fd(syms, size, STDERR_FILENO); + + fprintf(stderr, "refcnt of %p->%p: %"PRIi32" (change of %d)\n", entry, entry->sub_handle, refcnt, change); + + if (refcnt < 0) + abort(); +} + /** * @brief Get a reference * * This function acquires a reference on the given cache entry. * * @param[in] entry The entry on which to get a reference * @param[in] flags One of LRU_REQ_INITIAL, or LRU_FLAG_NONE * * A flags value of LRU_REQ_INITIAL indicates an initial * reference. A non-initial reference is an "extra" reference in some call @@ -1980,35 +1996,35 @@ void mdcache_lru_insert(mdcache_entry_t *entry, mdc_reason_t reason) * and strongly influences LRU. Essentially, the first ref during a callpath * should take an LRU_REQ_INITIAL ref, and all subsequent callpaths should take * LRU_FLAG_NONE refs. * * @return FSAL status */ fsal_status_t _mdcache_lru_ref(mdcache_entry_t *entry, uint32_t flags, const char *func, int line) { -#ifdef USE_LTTNG int32_t refcnt = -#endif atomic_inc_int32_t(&entry->lru.refcnt); #ifdef USE_LTTNG tracepoint(mdcache, mdc_lru_ref, func, line, &entry->obj_handle, entry->sub_handle, refcnt); #endif /* adjust LRU on initial refs */ if (flags & LRU_REQ_INITIAL) { adjust_lru(entry); } /* initial ref */ + report_mdcache_refcount(refcnt, entry, +1); + return fsalstat(ERR_FSAL_NO_ERROR, 0); } /** * @brief Relinquish a reference * * This function relinquishes a reference on the given cache entry. * It follows the disposal/recycling lock discipline given at the * beginning of the file. * @@ -2050,20 +2066,22 @@ _mdcache_lru_unref(mdcache_entry_t *entry, uint32_t flags, const char *func, } } refcnt = atomic_dec_int32_t(&entry->lru.refcnt); #ifdef USE_LTTNG tracepoint(mdcache, mdc_lru_unref, func, line, &entry->obj_handle, entry->sub_handle, refcnt); #endif + report_mdcache_refcount(refcnt, entry, -1); + if (unlikely(refcnt == 0)) { struct lru_q *q; /* we MUST recheck that refcount is still 0 */ QLOCK(qlane); refcnt = atomic_fetch_int32_t(&entry->lru.refcnt); if (unlikely(refcnt > 0)) { QUNLOCK(qlane); -- 2.29.2.222.g5d2a92d10f8-goog