Skip to content

Commit

Permalink
compat: fix compat for bdev_nr_sectors
Browse files Browse the repository at this point in the history
Fixup for commit ba8c076 ("compat: test and compat patch for
bdev_nr_sectors"). This was broken on all platforms that used the
compat implementation (i.e. all kernels <5.10, which is most of the
kernels we build for).

get_capacity actually returns the size of part0, which is why this is
fine for non-partioned backing devices (the size of part0 is equivalent
to the size of the whole device then). If the backing device is a
partition, however, it will read the wrong size and detach the DRBD
device.

So just fall back to the slightly uglier open-coded version in the
compat implementation.
  • Loading branch information
chrboe committed Aug 18, 2022
1 parent 8d0e479 commit d7d76aa
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -2,4 +2,4 @@
struct block_device *bd;
@@
- bdev_nr_sectors(bd)
+ get_capacity(bd->bd_disk)
+ i_size_read(bd->bd_inode) >> 9

0 comments on commit d7d76aa

Please sign in to comment.