From d5c699c3b432ed06a5cf49a791b1e32823e830cd Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 6 Nov 2023 14:02:08 -0800 Subject: [PATCH] Don't respond with ENOENT for no srch compaction The srch compaction request building function and the srch compaction worker both have logic to recognize a valid response with no input files indicating that there's no work to do. The server unfortunately translated nr == 0 into ENOENT and send that error response to the client. This caused the client to increment error counters in the common case when there's no compaction work to perform. We'd like the error counter to reflect actual errors, we're about to check it in a test, so let's fix this up to the server sends a sucessful response with nr == 0 to indicate that there's no work to do. Signed-off-by: Zach Brown --- kmod/src/server.c | 4 +--- kmod/src/srch.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/kmod/src/server.c b/kmod/src/server.c index 46d50b54..2593ef1a 100644 --- a/kmod/src/server.c +++ b/kmod/src/server.c @@ -1966,9 +1966,7 @@ static int server_srch_get_compact(struct super_block *sb, ret = scoutfs_srch_get_compact(sb, &server->alloc, &server->wri, &super->srch_root, rid, sc); mutex_unlock(&server->srch_mutex); - if (ret == 0 && sc->nr == 0) - ret = -ENOENT; - if (ret < 0) + if (ret < 0 || (ret == 0 && sc->nr == 0)) goto apply; mutex_lock(&server->alloc_mutex); diff --git a/kmod/src/srch.c b/kmod/src/srch.c index 36385ad9..49eb27b7 100644 --- a/kmod/src/srch.c +++ b/kmod/src/srch.c @@ -2179,7 +2179,7 @@ out: scoutfs_block_writer_forget_all(sb, &wri); if (!atomic_read(&srinf->shutdown)) { - delay = ret == 0 ? 0 : msecs_to_jiffies(SRCH_COMPACT_DELAY_MS); + delay = (sc->nr > 0 && ret == 0) ? 0 : msecs_to_jiffies(SRCH_COMPACT_DELAY_MS); queue_delayed_work(srinf->workq, &srinf->compact_dwork, delay); }