Skip to contentSkip to conversation

dm: fix to_sector() for 32bit

PATCH New NeilBrown 1 participant 1 message Jan 6, 2019 Device mapper

lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 dm: fix to_sector() for 32bit

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 0cf4503174c1 ("dm raid: add support for the MD RAID0 personality")
---
 include/linux/device-mapper.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/device-mapper.h +1 -1
index e528baebad69..bee4bb9f81bc 100644
@@ -609,7 +609,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);
 }
Signature · 1 line
2.14.0.rc0.dirty