]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
pNFS: Fix stripe mapping in block/scsi layout
authorSergey Bashirov <sergeybashirov@gmail.com>
Tue, 1 Jul 2025 12:21:48 +0000 (15:21 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:28:30 +0000 (16:28 +0200)
commitcf949a960653bfeabb4d6c48a09c4a4e47b43c82
tree9f1b90c4f5a44489ff93ddfe425e47f33f005987
parent3b9d69f0e68aa6b0acd9791c45d445154a8c66e9
pNFS: Fix stripe mapping in block/scsi layout

[ Upstream commit 81438498a285759f31e843ac4800f82a5ce6521f ]

Because of integer division, we need to carefully calculate the
disk offset. Consider the example below for a stripe of 6 volumes,
a chunk size of 4096, and an offset of 70000.

chunk = div_u64(offset, dev->chunk_size) = 70000 / 4096 = 17
offset = chunk * dev->chunk_size = 17 * 4096 = 69632
disk_offset_wrong = div_u64(offset, dev->nr_children) = 69632 / 6 = 11605
disk_chunk = div_u64(chunk, dev->nr_children) = 17 / 6 = 2
disk_offset = disk_chunk * dev->chunk_size = 2 * 4096 = 8192

Signed-off-by: Sergey Bashirov <sergeybashirov@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250701122341.199112-1-sergeybashirov@gmail.com
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/blocklayout/dev.c