From 9395360324be5fdf1a632c613ad5d1da8cc7371f Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 1 Dec 2020 09:56:45 -0800 Subject: [PATCH] scoutfs: add srch entry inc/dec We're going to need to increment and decrement srch entries in coming fixes. Signed-off-by: Zach Brown --- kmod/src/srch.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kmod/src/srch.c b/kmod/src/srch.c index aac56dc6..cb25c5b5 100644 --- a/kmod/src/srch.c +++ b/kmod/src/srch.c @@ -94,6 +94,28 @@ static int sre_cmp(const struct scoutfs_srch_entry *a, scoutfs_cmp_u64s(le64_to_cpu(a->id), le64_to_cpu(b->id)); } +static void sre_inc(struct scoutfs_srch_entry *sre) +{ + le64_add_cpu(&sre->id, 1); + if (sre->id != 0) + return; + le64_add_cpu(&sre->ino, 1); + if (sre->ino != 0) + return; + le64_add_cpu(&sre->hash, 1); +} + +static void sre_dec(struct scoutfs_srch_entry *sre) +{ + le64_add_cpu(&sre->id, -1); + if (sre->id != cpu_to_le64(U64_MAX)) + return; + le64_add_cpu(&sre->ino, -1); + if (sre->ino != cpu_to_le64(U64_MAX)) + return; + le64_add_cpu(&sre->hash, -1); +} + /* * srch items are first grouped by type and we have log files, sorted * files, and busy compactions.