dm-bow: Use bdev_nr_sector to get the length of secstor 70/317470/1
authorJaehoon Chung <jh80.chung@samsung.com>
Thu, 2 Jan 2025 10:13:18 +0000 (19:13 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 2 Jan 2025 10:13:18 +0000 (19:13 +0900)
In Android Common kernel, bdev_nr_sectors() is using since v6.1 kernel.

Refer to https://android.googlesource.com/kernel/common
- android14-5.15 : i_size_read() >> SECTOR_SHIFT
- android14-6.1 / android15-6.6 / android16-6.12 : bdev_br_sectors()

Change-Id: Iecce56d6b98ee7f4714ccdd6dacb31f828795545
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
kernel/dm-bow.c

index 3d577a3364547fe5ded195cac2b01a581de31111..2713b2295b67880ce08770db4fee1431fef4005e 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/crc32.h>
 #include <linux/dm-bufio.h>
 #include <linux/module.h>
+#include <linux/version.h>
 
 #define DM_MSG_PREFIX "bow"
 
@@ -1263,7 +1264,11 @@ int dm_bow_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
 
        *bdev = dev->bdev;
        /* Only pass ioctls through if the device sizes match exactly. */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,1,0))
        return ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT;
+#else
+       return ti->len != bdev_nr_sectors(dev->bdev);
+#endif
 }
 
 static int dm_bow_iterate_devices(struct dm_target *ti,