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 <auke.kok@versity.com>
This commit is contained in:
Auke Kok
2026-03-27 09:56:04 -07:00
parent 5457741672
commit bf56585559

View File

@@ -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;
}
}