Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-5.12/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper fix from Mike Snitzer:
"Fix DM verity target FEC support's RS roots IO to always be aligned.

This fixes a previous stable@ fix that overcorrected for a different
configuration that also resulted in misaligned roots IO"

* tag 'for-5.12/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm verity fec: fix misaligned RS roots IO

+9 -3
+8 -3
drivers/md/dm-verity-fec.c
··· 65 65 u8 *res; 66 66 67 67 position = (index + rsb) * v->fec->roots; 68 - block = div64_u64_rem(position, v->fec->roots << SECTOR_SHIFT, &rem); 68 + block = div64_u64_rem(position, v->fec->io_size, &rem); 69 69 *offset = (unsigned)rem; 70 70 71 71 res = dm_bufio_read(v->fec->bufio, block, buf); ··· 154 154 155 155 /* read the next block when we run out of parity bytes */ 156 156 offset += v->fec->roots; 157 - if (offset >= v->fec->roots << SECTOR_SHIFT) { 157 + if (offset >= v->fec->io_size) { 158 158 dm_bufio_release(buf); 159 159 160 160 par = fec_read_parity(v, rsb, block_offset, &offset, &buf); ··· 742 742 return -E2BIG; 743 743 } 744 744 745 + if ((f->roots << SECTOR_SHIFT) & ((1 << v->data_dev_block_bits) - 1)) 746 + f->io_size = 1 << v->data_dev_block_bits; 747 + else 748 + f->io_size = v->fec->roots << SECTOR_SHIFT; 749 + 745 750 f->bufio = dm_bufio_client_create(f->dev->bdev, 746 - f->roots << SECTOR_SHIFT, 751 + f->io_size, 747 752 1, 0, NULL, NULL); 748 753 if (IS_ERR(f->bufio)) { 749 754 ti->error = "Cannot initialize FEC bufio client";
+1
drivers/md/dm-verity-fec.h
··· 36 36 struct dm_dev *dev; /* parity data device */ 37 37 struct dm_bufio_client *data_bufio; /* for data dev access */ 38 38 struct dm_bufio_client *bufio; /* for parity data access */ 39 + size_t io_size; /* IO size for roots */ 39 40 sector_t start; /* parity data start in blocks */ 40 41 sector_t blocks; /* number of blocks covered */ 41 42 sector_t rounds; /* number of interleaving rounds */