Skip to content

Commit a73447f

Browse files
Eric Biggersgregkh
authored andcommitted
dm-verity-fec: fix corrected block count stat
commit 48640c8 upstream. dm_verity_fec::corrected seems to have been intended to count the number of corrected blocks. However, it actually counted the number of calls to fec_decode_bufs() that corrected at least one error. That's not the same thing. For example, in low-memory situations correcting a single block can require many calls to fec_decode_bufs(). Fix it to count corrected blocks instead. Fixes: ae97648 ("dm verity fec: Expose corrected block count via status") Cc: Shubhankar Mishra <shubhankarm@google.com> Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 02ac7ae commit a73447f

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/md/dm-verity-fec.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,9 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_io *io,
163163
if (r < 0 && neras)
164164
DMERR_LIMIT("%s: FEC %llu: failed to correct: %d",
165165
v->data_dev->name, (unsigned long long)rsb, r);
166-
else if (r > 0) {
166+
else if (r > 0)
167167
DMWARN_LIMIT("%s: FEC %llu: corrected %d errors",
168168
v->data_dev->name, (unsigned long long)rsb, r);
169-
atomic64_inc(&v->fec->corrected);
170-
}
171169

172170
return r;
173171
}
@@ -439,6 +437,7 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io,
439437
}
440438

441439
memcpy(dest, fio->output, 1 << v->data_dev_block_bits);
440+
atomic64_inc(&v->fec->corrected);
442441

443442
done:
444443
fio->level--;

0 commit comments

Comments
 (0)