Skip to content

Commit ae97648

Browse files
Shubhankar MishraMikulas Patocka
authored andcommitted
dm verity fec: Expose corrected block count via status
Enhance visibility into dm-verity Forward Error Correction (FEC) activity. While FEC can correct on-disk corruptions, the number of successful correction events is not readily exposed through a standard interface. This change integrates FEC statistics into the verity target's .status handler for STATUSTYPE_INFO. The info output now includes count of corrected block by FEC. The counter is a per-device instance atomic64_t, maintained within the struct dm_verity_fec, tracking blocks successfully repaired by FEC on this specific device instance since it was created. This approach aligns with the standard Device Mapper mechanism for targets to report runtime information, as used by other targets like dm-integrity. This patch also updates Documentation/admin-guide/device-mapper/verity.rst to reflect the new status information. Tested: Induced single-bit errors on a block device protected by dm-verity with FEC on android phone. Confirmed 'dmctl status <device>' on Android reports an incrementing 'fec_corrected_blocks' count after the corrupted blocks were accessed. Signed-off-by: Shubhankar Mishra <shubhankarm@google.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
1 parent c82faa8 commit ae97648

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

Documentation/admin-guide/device-mapper/verity.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@ is available at the cryptsetup project's wiki page
236236

237237
Status
238238
======
239-
V (for Valid) is returned if every check performed so far was valid.
240-
If any check failed, C (for Corruption) is returned.
239+
1. V (for Valid) is returned if every check performed so far was valid.
240+
If any check failed, C (for Corruption) is returned.
241+
2. Number of corrected blocks by Forward Error Correction.
242+
'-' if Forward Error Correction is not enabled.
241243

242244
Example
243245
=======

drivers/md/dm-verity-fec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_io *io,
177177
if (r < 0 && neras)
178178
DMERR_LIMIT("%s: FEC %llu: failed to correct: %d",
179179
v->data_dev->name, (unsigned long long)rsb, r);
180-
else if (r > 0)
180+
else if (r > 0) {
181181
DMWARN_LIMIT("%s: FEC %llu: corrected %d errors",
182182
v->data_dev->name, (unsigned long long)rsb, r);
183+
atomic64_inc(&v->fec->corrected);
184+
}
183185

184186
return r;
185187
}

drivers/md/dm-verity-fec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct dm_verity_fec {
4848
mempool_t extra_pool; /* mempool for extra buffers */
4949
mempool_t output_pool; /* mempool for output */
5050
struct kmem_cache *cache; /* cache for buffers */
51+
atomic64_t corrected; /* corrected errors */
5152
};
5253

5354
/* per-bio data */

drivers/md/dm-verity-target.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,10 @@ static void verity_status(struct dm_target *ti, status_type_t type,
848848
switch (type) {
849849
case STATUSTYPE_INFO:
850850
DMEMIT("%c", v->hash_failed ? 'C' : 'V');
851+
if (verity_fec_is_enabled(v))
852+
DMEMIT(" %lld", atomic64_read(&v->fec->corrected));
853+
else
854+
DMEMIT(" -");
851855
break;
852856
case STATUSTYPE_TABLE:
853857
DMEMIT("%u %s %s %u %u %llu %llu %s ",

0 commit comments

Comments
 (0)