dm verity fec: fix misaligned RS roots IO
Subsystems (2)
PATCH 1/1 dm verity fec: fix misaligned RS roots IO
From: Jaegeuk Kim <[email protected]>
commit df7b59ba9245 ("dm verity: fix FEC for RS roots unaligned to block size") introduced the possibility for misaligned roots IO relative to the underlying device's logical block size. E.g. Android's default RS roots=2 results in dm_bufio->block_size=1024, which causes the following EIO if the logical block size of the device is 4096, given v->data_dev_block_bits=12:
E sd 0 : 0:0:0: [sda] tag#30 request not aligned to the logical block size
E blk_update_request: I/O error, dev sda, sector 10368424 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 E device-mapper: verity-fec: 254:8: FEC 9244672: parity read failed (block 18056): -5
Fix this by onlu using f->roots for dm_bufio blocksize IFF it is aligned to v->data_dev_block_bits.
--- drivers/md/dm-verity-fec.c | 11 ++++++++--- drivers/md/dm-verity-fec.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/md/dm-verity-fec.c +8 -3
@@ -65,7 +65,7 @@ static u8 *fec_read_parity(struct dm_verity *v, u64 rsb, int index,u8 *res; position = (index + rsb) * v->fec->roots; - block =div64_u64_rem (position, v->fec->roots <<SECTOR_SHIFT , &rem); + block =div64_u64_rem (position, v->fec->io_size, &rem); *offset = (unsigned )rem; res =dm_bufio_read (v->fec->bufio, block, buf);
@@ -154,7 +154,7 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio,/* read the next block when we run out of parity bytes */ offset += v->fec->roots; -if (offset >= v->fec->roots <<SECTOR_SHIFT ) { +if (offset >= v->fec->io_size) {dm_bufio_release (buf); par =fec_read_parity (v, rsb, block_offset, &offset, &buf);
@@ -742,8 +742,13 @@ int verity_fec_ctr(struct dm_verity *v)return -E2BIG ; } +if ((f->roots <<SECTOR_SHIFT ) & ((1 << v->data_dev_block_bits) -1 )) + f->io_size =1 << v->data_dev_block_bits; +else + f->io_size = v->fec->roots <<SECTOR_SHIFT ; + f->bufio =dm_bufio_client_create (f->dev->bdev, - f->roots <<SECTOR_SHIFT , + f->io_size,1 ,0 ,NULL ,NULL );if (IS_ERR (f->bufio)) { ti->error ="Cannot initialize FEC bufio client" ;
drivers/md/dm-verity-fec.h +1 -0
@@ -36,6 +36,7 @@ struct dm_verity_fec {struct dm_dev *dev;/* parity data device */ struct dm_bufio_client *data_bufio;/* for data dev access */ struct dm_bufio_client *bufio;/* for parity data access */ +size_t io_size;/* IO size for roots */ sector_t start;/* parity data start in blocks */ sector_t blocks;/* number of blocks covered */ sector_t rounds;/* number of interleaving rounds */
Signature · 1 line
2.31.1
Hi All,
Quoted 10 lines · Anand Moon
From: Jaegeuk Kim <[email protected]>
commit
df7b59ba9245("dm verity: fix FEC for RS roots unaligned to block size") introduced the possibility for misaligned roots IO relative to the underlying device's logical block size. E.g. Android's default RS roots=2 results in dm_bufio->block_size=1024, which causes the following EIO if the logical block size of the device is 4096, given v->data_dev_block_bits=12:
Oops. Please ignore this email, I was just testing my git send-email setting.
Thanks
-Anand