From patchwork Sat Feb 4 14:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13128726 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21DB9C61DA4 for ; Sat, 4 Feb 2023 14:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233705AbjBDO7a (ORCPT ); Sat, 4 Feb 2023 09:59:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233373AbjBDO7V (ORCPT ); Sat, 4 Feb 2023 09:59:21 -0500 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EDA534C0D; Sat, 4 Feb 2023 06:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1675522744; i=@fujitsu.com; bh=dHPfdcvntcTuGRB7mplma0aCs7gQGflhDCMIDJ2bzmY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YvKFAEuatpTlK2jH5ZJqXLuKX8BrnMDOBfHPEFXj1DUIRTutS30RX0fV4Pgyv6V4I tIORfVl+merggHc1RDq6ey44Iw4vBD8PfpRiVNqOgQ7q5HXzfGpE3kZIpgTtJ3U5l+ uq++2wxdNGRvqFbuKZeFftMzMr4YVzKEFXradHCbGkx1XwVYl9kqi3QwpuYnBbjX43 Jf3ZhEfgMcLFPMUrnmWFswYzLDQU8MYNWswHU++bzIlpBw0frMiT1dgPI/ozGRT6mH zKC1F2jCG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xzNFO2MNouc2/TgV6GX0t9fuxUEDF4se6ZY 5b/297FzB7kSmO1Mb80uCFSNOZ3tc8DjwLbgc7YJU2MOneTRt9isEql0IN2W78WbPSXK327xW kbKhEiJ6D2//1VNzPH89M2sAVHTOT7HaIisjGNsZjP5WJf1tSBrm6vcKyWW4oxEQy3mouJEAL S5mr6xAwAA X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-7.tower-571.messagelabs.com!1675522742!175014!1 X-Originating-IP: [62.60.8.98] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.102.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25318 invoked from network); 4 Feb 2023 14:59:02 -0000 Received: from unknown (HELO n03ukasimr03.n03.fujitsu.local) (62.60.8.98) by server-7.tower-571.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 4 Feb 2023 14:59:02 -0000 Received: from n03ukasimr03.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTP id E6A831AD; Sat, 4 Feb 2023 14:59:01 +0000 (GMT) Received: from R01UKEXCASM223.r01.fujitsu.local (R01UKEXCASM223 [10.182.185.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTPS id D98EF1AC; Sat, 4 Feb 2023 14:59:01 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM223.r01.fujitsu.local (10.182.185.121) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 4 Feb 2023 14:58:57 +0000 From: Shiyang Ruan To: , , , , CC: , , , , Subject: [PATCH v9 1/3] xfs: fix the calculation of length and end Date: Sat, 4 Feb 2023 14:58:36 +0000 Message-ID: <1675522718-88-2-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1675522718-88-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1675522718-88-1-git-send-email-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM223.r01.fujitsu.local (10.182.185.121) X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The end should be start + length - 1. Also fix the calculation of the length when seeking for intersection of notify range and device. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_notify_failure.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c index c4078d0ec108..3830f908e215 100644 --- a/fs/xfs/xfs_notify_failure.c +++ b/fs/xfs/xfs_notify_failure.c @@ -114,7 +114,7 @@ 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 +210,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 +222,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 -= offset + len - 1 - ddev_end; return xfs_dax_notify_ddev_failure(mp, BTOBB(offset), BTOBB(len), mf_flags);