From bf565855598fda2aa1db3e2186ded4e69051f958 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 27 Mar 2026 09:56:04 -0700 Subject: [PATCH] Drop a non-zero totl key if it has no contributing xattrs. The expected case is when the last xattr with a totl key is removed that the count and value both reach zero. In case of a mismatch or corrupted value, we have several different failure modes: - count zero, value non-zero - value zero, count non-zero - both non-zero The first case is the easiest to resolve, which is what this patch does - it drops it and prints an error. The other cases are more difficult and need a manual method to erase the stale key, and one would have to scan the entire namespace to make sure that the xattrs are indeed all removed. Signed-off-by: Auke Kok --- kmod/src/wkic.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kmod/src/wkic.c b/kmod/src/wkic.c index 44eef494..8ae3bb06 100644 --- a/kmod/src/wkic.c +++ b/kmod/src/wkic.c @@ -30,6 +30,7 @@ #include "counters.h" #include "scoutfs_trace.h" #include "wkic.h" +#include "msg.h" /* * This weaker item cache differs from the core item cache in item.c: @@ -746,6 +747,16 @@ static void fill_page_items(struct super_block *sb, struct wkic_page *wpage, str rb_erase(&witem->node, root); kfree(witem); continue; + } else if (tval->count == 0) { + /* + * BUG: there are no contributing items but count != 0, + * which shouldn't happen - we've gone off kilt. + */ + scoutfs_err(sb, "non-zero value for zero count totl "SK_FMT", dropping item", + SK_ARG(&witem->key)); + rb_erase(&witem->node, root); + kfree(witem); + continue; } }