akiradeveloper / dm-writeboost

Log-structured Caching for Linux
GNU General Public License v2.0
120 stars 18 forks source link

module build fails for Linux 6.10 #256

Open anbe42 opened 1 month ago

anbe42 commented 1 month ago
/var/lib/dkms/dm-writeboost/2.2.17/build/dm-writeboost-target.c: In function 'dm_devsize':
/var/lib/dkms/dm-writeboost/2.2.17/build/dm-writeboost-target.c:119:37: error: 'struct block_device' has no member named 'bd_inode'
  119 |         return i_size_read(dev->bdev->bd_inode) >> 9;
      |                                     ^~

The corresponding Linux commit is https://github.com/torvalds/linux/commit/203c1ce0bb063d1620698e39637b64f2d09c1368 "RIP ->bd_inode" in v6.10-rc1.

akiradeveloper commented 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;
akiradeveloper commented 1 month ago

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