Open anbe42 opened 1 month ago
We should use bdev_nr_sectors
instead.
static int linear_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
{
struct linear_c *lc = ti->private;
struct dm_dev *dev = lc->dev;
*bdev = dev->bdev;
/*
* Only pass ioctls through if the device sizes match exactly.
*/
if (lc->start || ti->len != bdev_nr_sectors(dev->bdev))
return 1;
return 0;
}
The same fix was done back in Oct. 2021 https://lists.openwall.net/linux-ext4/2021/10/13/22
- sbi->direct_inode->i_size = i_size_read(sb->s_bdev->bd_inode);
+ sbi->direct_inode->i_size = bdev_nr_sectors(sb->s_bdev) << SECTOR_SHIFT;
I think the function was introduced in 5.11. So if I may give up any supports before 5.11. The fix will be easy. But considering 5.5 is still used in bullseye, this is not wise. I would suggest inserting version switch.
https://elixir.bootlin.com/linux/v5.11-rc1/A/ident/bdev_nr_sectors
The corresponding Linux commit is https://github.com/torvalds/linux/commit/203c1ce0bb063d1620698e39637b64f2d09c1368 "RIP ->bd_inode" in v6.10-rc1.