mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
Linux 5.11 compat: bdev_whole()
The bd_contains member was removed from the block_device structure. Callers needing to determine if a vdev is a whole block device should use the new bdev_whole() wrapper. For older kernels we provide our own bdev_whole() wrapper which relies on bd_contains for compatibility. Reviewed-by: Rafael Kitover <rkitover@gmail.com> Reviewed-by: Coleman Kane <ckane@colemankane.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #11387 Closes #11390
This commit is contained in:
parent
a970f0594e
commit
72ba4b2a4c
@ -271,6 +271,29 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_LOGICAL_BLOCK_SIZE], [
|
||||
])
|
||||
])
|
||||
|
||||
dnl #
|
||||
dnl # 5.11 API change
|
||||
dnl # Added bdev_whole() helper.
|
||||
dnl #
|
||||
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE], [
|
||||
ZFS_LINUX_TEST_SRC([bdev_whole], [
|
||||
#include <linux/blkdev.h>
|
||||
],[
|
||||
struct block_device *bdev = NULL;
|
||||
bdev = bdev_whole(bdev);
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE], [
|
||||
AC_MSG_CHECKING([whether bdev_whole() is available])
|
||||
ZFS_LINUX_TEST_RESULT([bdev_whole], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_BDEV_WHOLE, 1, [bdev_whole() is available])
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
|
||||
ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
|
||||
ZFS_AC_KERNEL_SRC_BLKDEV_PUT
|
||||
@ -281,6 +304,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [
|
||||
ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
|
||||
ZFS_AC_KERNEL_SRC_BLKDEV_CHECK_DISK_CHANGE
|
||||
ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
|
||||
ZFS_AC_KERNEL_SRC_BLKDEV_BDEV_WHOLE
|
||||
])
|
||||
|
||||
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
|
||||
@ -293,4 +317,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [
|
||||
ZFS_AC_KERNEL_BLKDEV_BDEV_PHYSICAL_BLOCK_SIZE
|
||||
ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE
|
||||
ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE
|
||||
ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE
|
||||
])
|
||||
|
@ -94,6 +94,14 @@ bdev_capacity(struct block_device *bdev)
|
||||
return (i_size_read(bdev->bd_inode));
|
||||
}
|
||||
|
||||
#if !defined(HAVE_BDEV_WHOLE)
|
||||
static inline struct block_device *
|
||||
bdev_whole(struct block_device *bdev)
|
||||
{
|
||||
return (bdev->bd_contains);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Returns the maximum expansion capacity of the block device (in bytes).
|
||||
*
|
||||
@ -118,7 +126,7 @@ bdev_max_capacity(struct block_device *bdev, uint64_t wholedisk)
|
||||
uint64_t psize;
|
||||
int64_t available;
|
||||
|
||||
if (wholedisk && bdev->bd_part != NULL && bdev != bdev->bd_contains) {
|
||||
if (wholedisk && bdev != bdev_whole(bdev)) {
|
||||
/*
|
||||
* When reporting maximum expansion capacity for a wholedisk
|
||||
* deduct any capacity which is expected to be lost due to
|
||||
@ -132,7 +140,7 @@ bdev_max_capacity(struct block_device *bdev, uint64_t wholedisk)
|
||||
* "reserved" EFI partition: in such cases return the device
|
||||
* usable capacity.
|
||||
*/
|
||||
available = i_size_read(bdev->bd_contains->bd_inode) -
|
||||
available = i_size_read(bdev_whole(bdev)->bd_inode) -
|
||||
((EFI_MIN_RESV_SIZE + NEW_START_BLOCK +
|
||||
PARTITION_END_ALIGNMENT) << SECTOR_BITS);
|
||||
psize = MAX(available, bdev_capacity(bdev));
|
||||
@ -192,8 +200,8 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize,
|
||||
vd->vd_bdev = NULL;
|
||||
|
||||
if (bdev) {
|
||||
if (v->vdev_expanding && bdev != bdev->bd_contains) {
|
||||
bdevname(bdev->bd_contains, disk_name + 5);
|
||||
if (v->vdev_expanding && bdev != bdev_whole(bdev)) {
|
||||
bdevname(bdev_whole(bdev), disk_name + 5);
|
||||
/*
|
||||
* If userland has BLKPG_RESIZE_PARTITION,
|
||||
* then it should have updated the partition
|
||||
|
Loading…
Reference in New Issue
Block a user