Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1709769pxb; Mon, 8 Mar 2021 04:37:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDqYonevDSZlCRH2h3yQpXtGt7W9oa6IaxQHIH+jnqQuUuuhKrhEr7X1WRVO1ogSWa7i9d X-Received: by 2002:a05:6402:5211:: with SMTP id s17mr22164189edd.327.1615207037681; Mon, 08 Mar 2021 04:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615207037; cv=none; d=google.com; s=arc-20160816; b=PBqbkt97PZZG3CU+TxGkM8iuOQ/wAd0bK3c2XHLum7bYVnnIgZDAGkceJI3tZDgVEY mCYpBKl+lNzTqskU7WaPtnlOOSxlM0q0FZMqIvSTpC7STL4s1SXbN9sjZky4rjX0TICX +fGxAur3SXaYbv/KzbuI9mjsmQdREdjTDmoKZXR3IM2jthyY1qTgZWuAlomEUxj5xH01 E1SWKBotZUPhQXYqL7wyRGXOCjLlIbK2/1KFZET1HZsem+/wcP+w152as14+MEhXIAuI PeJhOQ3L0paBlTa5FH1QxXK77ZeHfby3nxhSeS9d1Rnrw9ReFGt46JR4IQWyBVzlgpxT HUSw== 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=uDneoF1K4oB9TCB65ANyomq1yiAcyfdIdLatqnN+Qww=; b=kUq4XVOu1qyYs9ds6Z0+8bgeVlGxwwWvl2wEBg2rK2sxrUbSHR7vUQmUgOCZX315Zm fH8roaQ7tAnbocdMjp1VG3ZFNO4AICLROFgeh6Ul3FtttnqYVvRA7WXQMARe0/0BKgKM J8dqNvQN9BaOFLeHohpdf/9TBLY3Rht/8NnLqfnFLrcFa7zqY2QUdD09BXzvzq3N5B0e 1EqK9MCoJm6WpHQC+J7rRKd8sM/wV0iZ7/N85Sve+1h6trNjoiwhSw5xQks2YQZqv/1j czcDqENaJPS5r6N1GuNTUYlmGeIHKFxtm7JaKDZzBVhkeM2KgSvbCf59sfPk9WLMc+nc ddUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J6X6nB8E; 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 t13si6938810ejr.172.2021.03.08.04.36.54; Mon, 08 Mar 2021 04:37:17 -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=J6X6nB8E; 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 S232037AbhCHMfa (ORCPT + 99 others); Mon, 8 Mar 2021 07:35:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:44160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231154AbhCHMfB (ORCPT ); Mon, 8 Mar 2021 07:35:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E8EBA651C9; Mon, 8 Mar 2021 12:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615206901; bh=r6N5Zhyem6HwrLfimFVavGfkEULHdCoK2CqW5nji3LM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J6X6nB8EWmLv7e1AT79NZe6agIqhHfB7UBZFuhRI9v+cX1lrNeypMPMc78kji4SJr EXXbOY0mud2a05GsNVycRf6LaI49mCy3uu4idkfx1oSmVNyqKz7NYJtmcLw06ccqMz rUMlnzHfum0YcOapVA64OwPHY/j8RDfSSp29vTkA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Milan Broz , Mike Snitzer Subject: [PATCH 5.10 19/42] dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size Date: Mon, 8 Mar 2021 13:30:45 +0100 Message-Id: <20210308122719.074645706@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122718.120213856@linuxfoundation.org> References: <20210308122718.120213856@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: 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 @@ -1526,6 +1526,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