Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2978342pxb; Tue, 13 Apr 2021 15:21:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5e8riFLfpAw1Upu/xsffC2fey2r884+EjHM/Nihzr1FPvH5hlGOJA4Sd2zSNLsvjZjDwl X-Received: by 2002:a62:7917:0:b029:23f:594:e289 with SMTP id u23-20020a6279170000b029023f0594e289mr31634583pfc.1.1618352496653; Tue, 13 Apr 2021 15:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618352496; cv=none; d=google.com; s=arc-20160816; b=zeQ3KYCyBUpaYw116/G8IQLF5KCfzeTi8frdMNhaqs9zZNfcXsl1leTaD8fln1gJA+ 0pNggnH0jE0z5r0DA4V8yk6KJDWItC0+OCi4wm/Rsl2jMdFlQzaDr+wx6Phy2+YWxZDY kaaWh6BxMrh4oslGwPQLDo+KWBPrFASJaKeujbcpudieMPM0McFVzCM+EOoTj72nyNvt 1uILeXKVnr7hYyq5Sv49HwwUPkjryx2hl4qFzXn0C96+puRkN7+yuc4BvWgVnLCZzKzz Hnu3U2HucCP5887dTNl32YS9IwDdPUamDQW64+Ncf215ehrJTnK1ZbtGU1cSgqSCdN0a +Lbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=E7BfKUuTKu5ZRDoC5orQxuuxX0CCCX58NmJjTb4Ebgk=; b=SPoyzh3hg31NAS7Xdnd19mYVVyNeMtks/X/VWuqSbzQuVUEzcoIB8cGezFYsVSpcy8 CVIlN5K7gkQ6amN3FMNXx1h2Oa2LdzclMbE+a4Nb07RWVGjJ274xCVDMJk6cijsqweXM RVnGBh6w+MNJSRgf1PSXIieGfG7+j1jAQSLmuEYIipp2XRViUInC8yZt5PIdcGt3xcCr qlpMpVGmVo5qLm65sB21b0wfcOKDamPPHLtRhnyeiTWwHzHUkv9zW7XfPDHxDvJUJoED NqH7Lfgeitb50asc0aJPWIN04L/x157oLUXCOtf2tVG7cXjaBAPaqHZbX25almKQ6S/b 7bVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MJ9AUDis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot14si4343003pjb.55.2021.04.13.15.21.23; Tue, 13 Apr 2021 15:21:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MJ9AUDis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347276AbhDMRvm (ORCPT + 99 others); Tue, 13 Apr 2021 13:51:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:45088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347459AbhDMRvg (ORCPT ); Tue, 13 Apr 2021 13:51:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64704613BA; Tue, 13 Apr 2021 17:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618336276; bh=STlES+DYVBTDRSumr84y24f4P3BlwSVMYXdmjHd61QI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MJ9AUDisyzbLasohsX+S5wX378EXieWelcxAyTjjUgcZsHFX1kLYT/ahufc5MQg5q DVpU/Vf7wBHA095rTxe2z8Hbxj5/dm/iGjFpMyPDZAqmgGzhgMU+6TwBM7c2FkqSoK JE34CzGrl/SfKBNYu79xIICzDlciBvQaO+zs2jEmkuTm2CXmtJxdNpdOvCQSV4cbcZ h+btmBjWoOWfnF1SFcsE9+WC8GkrcO0GT2HDaKO71oq8kb3FfyAiaAPQ7fxvUwusP3 P4pJ6UtsUzkyOVjH4PnHfnQFobXC6Xn1SchNtkelgYe2a1zUSay9sD8JTYaFENRlq3 u5gfr6PFsDQyA== Date: Tue, 13 Apr 2021 10:51:14 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Mike Snitzer , 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 Message-ID: References: <20210412181123.2550918-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210412181123.2550918-1-jaegeuk@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/12, Jaegeuk Kim wrote: > From: Jaegeuk Kim > > 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 > --- > 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