]> 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>
Wed, 20 Aug 2025 16:36:26 +0000 (18:36 +0200)
commitea0957e8c191f10941cff0faa7135871a1df14ee
tree1e95b176addaf67b886f85610a253ae6287139bf
parent5e276e6ff9aacf8901b9c3265c3cdd2568c9fff2
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