From patchwork Thu Jun 29 08:16:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13296744 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E0C9EB64D9 for ; Thu, 29 Jun 2023 08:18:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00EF78D0003; Thu, 29 Jun 2023 04:18:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F00E88D0001; Thu, 29 Jun 2023 04:18:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D547B8D0003; Thu, 29 Jun 2023 04:18:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C32588D0001 for ; Thu, 29 Jun 2023 04:18:18 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9CC7BAFA21 for ; Thu, 29 Jun 2023 08:18:18 +0000 (UTC) X-FDA: 80955083076.16.F76CCA0 Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) by imf01.hostedemail.com (Postfix) with ESMTP id 50A1B4001B for ; Thu, 29 Jun 2023 08:18:16 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 68.232.139.117 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688026696; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bPb20kjst8cwktvs1Y/dIK8l3Bb2XJb1iTWC3J4Kbk4=; b=oPCdjHlh/lvhm6SSxWGJC68nMXCd4OcqH3DSwsHo01YxNEh1L/Qz6Ts1Pb+8nBhP9LMvwz UBGrmM9pZjkdVrbAw1Z7uPZpZXLEfYGbM3L5XXeFiacU5eR6L+m7l/2NhL9rZK0AD3uC06 ZCpFe53EI3Er/MxEj8NdjcKTLQwX6Qk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of ruansy.fnst@fujitsu.com designates 68.232.139.117 as permitted sender) smtp.mailfrom=ruansy.fnst@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688026696; a=rsa-sha256; cv=none; b=CsWaKpQytgVfFUiXCI2wDGBI0kn58hWETf7UO221clnbFSv3vCX0kPtqyo2+8peHQwmrIB pV1vcnAcCyvFpX2WjQEOaXxzBYqTCMQINQgLu+GVcmwnDVkt1FN3BzNBhr3zX36iLOg2NT W6T1ComGHeVkLiVMWckEaVvsMYSFKNs= X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="122688753" X-IronPort-AV: E=Sophos;i="6.01,168,1684767600"; d="scan'208";a="122688753" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2023 17:18:16 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 0D1F7C68E2 for ; Thu, 29 Jun 2023 17:18:13 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 48531D67C8 for ; Thu, 29 Jun 2023 17:18:12 +0900 (JST) Received: from irides.g08.fujitsu.local (unknown [10.167.234.230]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id E62E36C9C4; Thu, 29 Jun 2023 17:18:05 +0900 (JST) From: Shiyang Ruan To: linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org Cc: dan.j.williams@intel.com, willy@infradead.org, jack@suse.cz, akpm@linux-foundation.org, djwong@kernel.org, mcgrof@kernel.org Subject: [PATCH v12 1/2] xfs: fix the calculation for "end" and "length" Date: Thu, 29 Jun 2023 16:16:50 +0800 Message-Id: <20230629081651.253626-2-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230629081651.253626-1-ruansy.fnst@fujitsu.com> References: <20230629081651.253626-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-27720.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-27720.006 X-TMASE-Result: 10--2.821700-10.000000 X-TMASE-MatchedRID: EXd9akoenk2hhjsqgSuNbxF4zyLyne+ATJDl9FKHbrm/XSsQNWtCeMJ0 8DtUl59d4vM1YF6AJbbieYV7J8ae4wtuKBGekqUpnH7sbImOEBSyUkKnsigAVUOq1cc3wR7p3qY uO0eYbQA38/3PGuNu2whL582BEnpEUGPLb8eYNh9sPkQVQvEczTS8aTKeU4mx11kmIvi83kKbDR BqS2n66yzP5xAyz9Oenvkw4sh/+PcMX5CwH5DTUmgGZNLBHGNe X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-R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9VkPj3MQGHxWuBnq7qAyqT4Mzzv A9x3sAE7 IFVUr9+4tHGtnyulZkBFV513MRe7RBHHAqXezi0eM7UW+KsfswVTVfSH7kBkpmHdsArI8IHsBKdCFfzZrDHJ43/QJxn9sQczQg+8lyXazC7YfflNwJcRT/VA+XUSvSBvAP1PONCnT9FmyKfxaWgfmdfU+7qrFQZlf1vaxc8L0qkiVQhNiXs7zX6tlKeLuzgRibUAegNi9ediNevMiprBmF0R7s54//stbO1dM X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The value of "end" should be "start + length - 1". Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_notify_failure.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c index c4078d0ec108..4a9bbd3fe120 100644 --- a/fs/xfs/xfs_notify_failure.c +++ b/fs/xfs/xfs_notify_failure.c @@ -114,7 +114,8 @@ xfs_dax_notify_ddev_failure( int error = 0; xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, daddr); xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp, fsbno); - xfs_fsblock_t end_fsbno = XFS_DADDR_TO_FSB(mp, daddr + bblen); + xfs_fsblock_t end_fsbno = XFS_DADDR_TO_FSB(mp, + daddr + bblen - 1); xfs_agnumber_t end_agno = XFS_FSB_TO_AGNO(mp, end_fsbno); error = xfs_trans_alloc_empty(mp, &tp); @@ -210,7 +211,7 @@ xfs_dax_notify_failure( ddev_end = ddev_start + bdev_nr_bytes(mp->m_ddev_targp->bt_bdev) - 1; /* Ignore the range out of filesystem area */ - if (offset + len < ddev_start) + if (offset + len - 1 < ddev_start) return -ENXIO; if (offset > ddev_end) return -ENXIO; @@ -222,8 +223,8 @@ xfs_dax_notify_failure( len -= ddev_start - offset; offset = 0; } - if (offset + len > ddev_end) - len -= ddev_end - offset; + if (offset + len - 1 > ddev_end) + len = ddev_end - offset + 1; return xfs_dax_notify_ddev_failure(mp, BTOBB(offset), BTOBB(len), mf_flags);