Skip to content

Commit 5cf32f6

Browse files
iridesDarrick J. Wong
authored andcommitted
xfs: fix the calculation for "end" and "length"
The value of "end" should be "start + length - 1". Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
1 parent 75dc034 commit 5cf32f6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/xfs/xfs_notify_failure.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ xfs_dax_notify_ddev_failure(
114114
int error = 0;
115115
xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, daddr);
116116
xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp, fsbno);
117-
xfs_fsblock_t end_fsbno = XFS_DADDR_TO_FSB(mp, daddr + bblen);
117+
xfs_fsblock_t end_fsbno = XFS_DADDR_TO_FSB(mp,
118+
daddr + bblen - 1);
118119
xfs_agnumber_t end_agno = XFS_FSB_TO_AGNO(mp, end_fsbno);
119120

120121
error = xfs_trans_alloc_empty(mp, &tp);
@@ -210,7 +211,7 @@ xfs_dax_notify_failure(
210211
ddev_end = ddev_start + bdev_nr_bytes(mp->m_ddev_targp->bt_bdev) - 1;
211212

212213
/* Ignore the range out of filesystem area */
213-
if (offset + len < ddev_start)
214+
if (offset + len - 1 < ddev_start)
214215
return -ENXIO;
215216
if (offset > ddev_end)
216217
return -ENXIO;
@@ -222,8 +223,8 @@ xfs_dax_notify_failure(
222223
len -= ddev_start - offset;
223224
offset = 0;
224225
}
225-
if (offset + len > ddev_end)
226-
len -= ddev_end - offset;
226+
if (offset + len - 1 > ddev_end)
227+
len = ddev_end - offset + 1;
227228

228229
return xfs_dax_notify_ddev_failure(mp, BTOBB(offset), BTOBB(len),
229230
mf_flags);

0 commit comments

Comments
 (0)