From: Shiyang Ruan <ruansy.fnst@fujitsu.com>
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>
Subject: [PATCH v11 1/2] xfs: fix the calculation of length and end
Date: Tue, 28 Mar 2023 09:41:45 +0000 [thread overview]
Message-ID: <1679996506-2-2-git-send-email-ruansy.fnst@fujitsu.com> (raw)
In-Reply-To: <1679996506-2-1-git-send-email-ruansy.fnst@fujitsu.com>
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 <ruansy.fnst@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/xfs_notify_failure.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/xfs_notify_failure.c b/fs/xfs/xfs_notify_failure.c
index c4078d0ec108..1e2eddb8f90f 100644
--- a/fs/xfs/xfs_notify_failure.c
+++ b/fs/xfs/xfs_notify_failure.c
@@ -61,7 +61,7 @@ xfs_failure_pgcnt(
end_notify = notify->startblock + notify->blockcount;
end_cross = min(end_rec, end_notify);
- return XFS_FSB_TO_B(mp, end_cross - start_cross) >> PAGE_SHIFT;
+ return XFS_FSB_TO_B(mp, end_cross - start_cross + 1) >> PAGE_SHIFT;
}
static int
@@ -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 = ddev_end - offset + 1;
return xfs_dax_notify_ddev_failure(mp, BTOBB(offset), BTOBB(len),
mf_flags);
--
2.39.2
next prev parent reply other threads:[~2023-03-28 9:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 9:41 [PATCH v11 0/2] mm, pmem, xfs: Introduce MF_MEM_REMOVE for unbind Shiyang Ruan
2023-03-28 9:41 ` Shiyang Ruan [this message]
2023-03-28 9:41 ` [PATCH v11 2/2] " Shiyang Ruan
2023-04-04 17:45 ` Darrick J. Wong
2023-04-05 1:28 ` Yasunori Gotou (Fujitsu)
2023-04-05 4:36 ` Dan Williams
2023-04-06 10:50 ` Shiyang Ruan
2023-04-06 14:54 ` Darrick J. Wong
2023-04-07 2:07 ` Shiyang Ruan
2023-04-12 10:52 ` [RFC PATCH v11.1 " Shiyang Ruan
2023-04-20 2:07 ` Shiyang Ruan
2023-04-20 12:09 ` Jan Kara
2023-04-25 12:47 ` Shiyang Ruan
2023-04-25 13:23 ` Jan Kara
2023-04-25 15:18 ` Darrick J. Wong
2023-04-26 2:27 ` Shiyang Ruan
2023-04-26 2:37 ` Darrick J. Wong
2023-04-04 4:33 ` [PATCH v11 0/2] " Shiyang Ruan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1679996506-2-2-git-send-email-ruansy.fnst@fujitsu.com \
--to=ruansy.fnst@fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=djwong@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.