From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mike Snitzer <snitzer@redhat.com>,
kernel-team@android.com, agk@redhat.com, dm-devel@redhat.com
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] dm verity: fix not aligned logical block size of RS roots IO
Date: Tue, 13 Apr 2021 10:51:14 -0700 [thread overview]
Message-ID: <YHXaEiRt8QzX8h9m@google.com> (raw)
In-Reply-To: <20210412181123.2550918-1-jaegeuk@kernel.org>
On 04/12, Jaegeuk Kim wrote:
> From: Jaegeuk Kim <jaegeuk@google.com>
>
> commit df7b59ba9245 ("dm verity: fix FEC for RS roots unaligned to block size")
> made dm_bufio->block_size 1024, if f->roots is 2. But, that gives the below 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
>
> Let's use f->roots for dm_bufio iff it's aligned to v->data_dev_block_bits.
>
> Fixes: df7b59ba9245 ("dm verity: fix FEC for RS roots unaligned to block size")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
> ---
> drivers/md/dm-verity-fec.c | 11 ++++++++---
> drivers/md/dm-verity-fec.h | 1 +
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c
> index 66f4c6398f67..cea2b3789736 100644
> --- a/drivers/md/dm-verity-fec.c
> +++ b/drivers/md/dm-verity-fec.c
> @@ -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";
> diff --git a/drivers/md/dm-verity-fec.h b/drivers/md/dm-verity-fec.h
> index 42fbd3a7fc9f..3c46c8d61883 100644
> --- a/drivers/md/dm-verity-fec.h
> +++ b/drivers/md/dm-verity-fec.h
> @@ -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 */
> --
> 2.31.1.295.g9ea45b61b8-goog
prev parent reply other threads:[~2021-04-13 17:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 18:11 [PATCH] dm verity: fix not aligned logical block size of RS roots IO Jaegeuk Kim
2021-04-13 17:51 ` Jaegeuk Kim [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YHXaEiRt8QzX8h9m@google.com \
--to=jaegeuk@kernel.org \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox