From c7e97eeb1f20df9d82f52d75b58bea594e67c3ca Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 7 Nov 2023 11:57:11 -0800 Subject: [PATCH] Allow srch compaction from _SAFE_BYTES Compacting sorted srch files can take multiple transactions because they can be very large. Each transaction resumes at a byte offset in a block where the previous transaction stopped. The resuming code tests that the byte offsets are sane but had a mistake in testing the offset to skip to. It returned an error if the compaction resumed from the last possible safe offset for decoding entries. If a system is unlucky enough to have a compaction transaction stop at just this offset then compaction stops making forward progress as each attempt to resume returns an error. The fix allows continuation from this last safe offset while returning errors for attempts to continue *past* that offset. This matches all the encoding code which allows encoding the last entry in the block at this offset. Signed-off-by: Zach Brown --- kmod/src/srch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kmod/src/srch.c b/kmod/src/srch.c index 7af54e82..81bc2238 100644 --- a/kmod/src/srch.c +++ b/kmod/src/srch.c @@ -1978,7 +1978,7 @@ static int kway_get_reader(struct super_block *sb, srb = rdr->bl->data; if (rdr->pos > SCOUTFS_SRCH_BLOCK_SAFE_BYTES || - rdr->skip >= SCOUTFS_SRCH_BLOCK_SAFE_BYTES || + rdr->skip > SCOUTFS_SRCH_BLOCK_SAFE_BYTES || rdr->skip >= le32_to_cpu(srb->entry_bytes)) { /* XXX inconsistency */ return -EIO;