]> www.infradead.org Git - users/hch/misc.git/commit
xfs: fix off-by-one error in fsmap's end_daddr usage
authorDarrick J. Wong <djwong@kernel.org>
Mon, 2 Dec 2024 18:57:24 +0000 (10:57 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 13 Dec 2024 01:45:08 +0000 (17:45 -0800)
commita440a28ddbdcb861150987b4d6e828631656b92f
tree7e5d2215aa6c3769c52ecadab54b38149c9a027a
parentf92f4749861b06fed908d336b4dee1326003291b
xfs: fix off-by-one error in fsmap's end_daddr usage

In commit ca6448aed4f10a, we created an "end_daddr" variable to fix
fsmap reporting when the end of the range requested falls in the middle
of an unknown (aka free on the rmapbt) region.  Unfortunately, I didn't
notice that the the code sets end_daddr to the last sector of the device
but then uses that quantity to compute the length of the synthesized
mapping.

Zizhi Wo later observed that when end_daddr isn't set, we still don't
report the last fsblock on a device because in that case (aka when
info->last is true), the info->high mapping that we pass to
xfs_getfsmap_group_helper has a startblock that points to the last
fsblock.  This is also wrong because the code uses startblock to
compute the length of the synthesized mapping.

Fix the second problem by setting end_daddr unconditionally, and fix the
first problem by setting start_daddr to one past the end of the range to
query.

Cc: <stable@vger.kernel.org> # v6.11
Fixes: ca6448aed4f10a ("xfs: Fix missing interval for missing_owner in xfs fsmap")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reported-by: Zizhi Wo <wozizhi@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_fsmap.c