From d8b54249d9630f64b0b5864c2e785841a85c7cf5 Mon Sep 17 00:00:00 2001 From: Tobias Klausmann Date: Tue, 2 Jun 2026 13:16:30 +0200 Subject: [PATCH] File scan: run is_block_zeroed() on the correct block When using `--skip-zeroes`, we check the wrong block. We are hashing (using process_block) the block #`i` (at offdset `i * blocksize`), but run `is_block_zeroed()` on `buffer->buf + buffer->dl_offset`, which is always the same block. The kernel won't damage data since it has its own check, but we basically are uanble to ever dedupe anything correctly here and create pointless work. --- file_scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file_scan.c b/file_scan.c index 0760b9cd9ee8..b6ed3e1ee561 100644 --- a/file_scan.c +++ b/file_scan.c @@ -832,7 +832,7 @@ static ssize_t process_blocks(struct scan_ctxt *ctxt, struct buffer *buffer, for (unsigned int i = 0; i < nb_blocks; i++) { if (!is_block_ignored(ctxt->fiemap, curr_file_off) && !(options.skip_zeroes && - is_block_zeroed(buffer->buf + buffer->dl_offset))) { + is_block_zeroed(buffer->buf + i * blocksize))) { ret = process_block(buffer->buf + i * blocksize, blocksize, curr_file_off, hashes); if (ret)