Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp241911pxf; Wed, 10 Mar 2021 05:28:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgFzbaAbwgvgR5iHfof7bQloYfO3ti+py94+goKj8yHM7aPEpSeRSwLtTkZ1ESIW+tgo0t X-Received: by 2002:aa7:da98:: with SMTP id q24mr3355536eds.84.1615382925587; Wed, 10 Mar 2021 05:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615382925; cv=none; d=google.com; s=arc-20160816; b=ePNu6wn7wpsD8VkIDWjZbraNXcDfwcgBf0cWuxbNw3aME8lsqbu27udYsH9sXcwu1I Su43RcKm7loeSF5PO+kVClSmdLBdNELMl8gkazp1B3Wj/K1Lrv4DFR5pcC9Egba6QCR4 4CCgwj7OD5kppuxvJiTdvL30JIG5qLo0CXSVm5soIAHrz9fLmg6i9ldJdofUGeUF34K5 U8Tv8n1mmbNTA7U9COP1LE4gRYjnVXeeM6e3CiMHLEslDOq7VF4J2g4yP77jehP1Jo5Z 0X1WhFKSbHu6Y2taAKhx7Nw5XyePkiZpRZuGgR6t/JhqKPZO9hNSoSXRD542NhshBEUs w2sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZHWPYR//YndroKSM8Vhk+CRL+o8Mjsn751w01b/sWxU=; b=YvhRA32tFKZKdrkV7pl798DelZh5tRwXT7pHkO1Mg3Aox7ky3qq61d77lY2UOK/1RD 287Ph8zaN1W5Utl6EVK7CQDoaakdISiGXkPe8ICXDjIOXkmBWdSU7DPC2PhRFMUaYI/u S2Ir818wosu4mUHvnhL6+WVaxGQCFGoDJBhGkAux/ViohXuO79FquSfqUKhByQPZv8vt 96UMnWArTFyv7gIEyEH21rUeAvoJkeP8xk1XssQhBKmofo84hK6O6K/HLeX0NXnWnCCw bLONJCTW6SthbX872Y9icO4MR8oPItXkWo5NLl7q8FlMWqZE0MHEI80UUq2PATQigEGI KYnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0V3QUjy3; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t8si12499462edd.473.2021.03.10.05.28.21; Wed, 10 Mar 2021 05:28:45 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=0V3QUjy3; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233960AbhCJN1n (ORCPT + 99 others); Wed, 10 Mar 2021 08:27:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:46628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233199AbhCJNZF (ORCPT ); Wed, 10 Mar 2021 08:25:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6030B64FF7; Wed, 10 Mar 2021 13:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382704; bh=+jYzso4KsiU++9EzFHM5uujqnJ/+C8P3LTIVaK+Enx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0V3QUjy3w10AtX2FJg4ismLwO0+ccClfpYwV4xHuJrkJxUgVyOEFpOn/3xWXv7QIq I9XpIZNwPgSqvqeRziywdPJUmhja4Mr4hoimsF/YtdlZPy9jkcO03NThkPzyIPcXiV 4OuKPyEStiKv/OPGKoO461Au7VHP5CAhSoL0FZZU= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Milan Broz , Mike Snitzer Subject: [PATCH 4.19 07/39] dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size Date: Wed, 10 Mar 2021 14:24:15 +0100 Message-Id: <20210310132319.964034941@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132319.708237392@linuxfoundation.org> References: <20210310132319.708237392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Mikulas Patocka commit a14e5ec66a7a66e57b24e2469f9212a78460207e upstream. dm_bufio_get_device_size returns the device size in blocks. Before returning the value, we must subtract the nubmer of starting sectors. The number of starting sectors may not be divisible by block size. Note that currently, no target is using dm_bufio_set_sector_offset and dm_bufio_get_device_size simultaneously, so this change has no effect. However, an upcoming dm-verity-fec fix needs this change. Signed-off-by: Mikulas Patocka Reviewed-by: Milan Broz Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-bufio.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -1463,6 +1463,10 @@ EXPORT_SYMBOL_GPL(dm_bufio_get_block_siz sector_t dm_bufio_get_device_size(struct dm_bufio_client *c) { sector_t s = i_size_read(c->bdev->bd_inode) >> SECTOR_SHIFT; + if (s >= c->start) + s -= c->start; + else + s = 0; if (likely(c->sectors_per_block_bits >= 0)) s >>= c->sectors_per_block_bits; else