Skip to content

Commit

Permalink
dm: fix to_sector() for 32bit
Browse files Browse the repository at this point in the history
A dm-raid array with devices larger than 4GB won't assemble on
a 32 bit host since _check_data_dev_sectors() was added in 4.16.
This is because to_sector() treats its argument as an "unsigned long"
which is 32bits (4GB) on a 32bit host.  Using "unsigned long long"
is more correct.

Kernels as early as 4.2 can have other problems due to to_sector()
being used on the size of a device.

Fixes: 0cf4503 ("dm raid: add support for the MD RAID0 personality")
cc: stable@vger.kernel.org (v4.2+)
Reported-and-tested-by: Guillaume Perréal <gperreal@free.fr>
Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
NeilBrown authored and Mike Snitzer committed Mar 5, 2019
1 parent d283237 commit 0bdb50c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/device-mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ do { \
*/
#define dm_target_offset(ti, sector) ((sector) - (ti)->begin)

static inline sector_t to_sector(unsigned long n)
static inline sector_t to_sector(unsigned long long n)
{
return (n >> SECTOR_SHIFT);
}
Expand Down

0 comments on commit 0bdb50c

Please sign in to comment.