struct pnfs_block_dev_map *map)
{
struct pnfs_block_dev *child;
- u64 chunk = (offset / dev->chunk_size);
- int chunk_idx = chunk % dev->nr_children;
+ u64 chunk;
+ u32 chunk_idx;
u64 disk_offset;
+ chunk = div_u64(offset, dev->chunk_size);
+ div_u64_rem(chunk, dev->nr_children, &chunk_idx);
+
if (chunk_idx > dev->nr_children) {
dprintk("%s: invalid chunk idx %d (%lld/%lld)\n",
__func__, chunk_idx, offset, dev->chunk_size);
offset = chunk * dev->chunk_size;
/* disk offset of the stripe */
- disk_offset = offset / dev->nr_children;
+ disk_offset = div_u64(offset, dev->nr_children);
child = &dev->children[chunk_idx];
child->map(child, disk_offset, map);