]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/os/linux/zfs/vdev_disk.c
Linux 6.9 compat: bdev handles are now struct file
[mirror_zfs.git] / module / os / linux / zfs / vdev_disk.c
index df5fa067797a9b807c3fcc92a07586f1695b3d63..a710bb91004ed9aae79291e72aa77844cfaf0412 100644 (file)
 /*
  * Linux 6.8.x uses a bdev_handle as an instance/refcount for an underlying
  * block_device. Since it carries the block_device inside, its convenient to
- * just use the handle as a proxy. For pre-6.8, we just emulate this with
- * a cast, since we don't need any of the other fields inside the handle.
+ * just use the handle as a proxy.
+ *
+ * Linux 6.9.x uses a file for the same purpose.
+ *
+ * For pre-6.8, we just emulate this with a cast, since we don't need any of
+ * the other fields inside the handle.
  */
-#ifdef HAVE_BDEV_OPEN_BY_PATH
+#if defined(HAVE_BDEV_OPEN_BY_PATH)
 typedef struct bdev_handle zfs_bdev_handle_t;
 #define        BDH_BDEV(bdh)           ((bdh)->bdev)
 #define        BDH_IS_ERR(bdh)         (IS_ERR(bdh))
 #define        BDH_PTR_ERR(bdh)        (PTR_ERR(bdh))
 #define        BDH_ERR_PTR(err)        (ERR_PTR(err))
+#elif defined(HAVE_BDEV_FILE_OPEN_BY_PATH)
+typedef struct file zfs_bdev_handle_t;
+#define        BDH_BDEV(bdh)           (file_bdev(bdh))
+#define        BDH_IS_ERR(bdh)         (IS_ERR(bdh))
+#define        BDH_PTR_ERR(bdh)        (PTR_ERR(bdh))
+#define        BDH_ERR_PTR(err)        (ERR_PTR(err))
 #else
 typedef void zfs_bdev_handle_t;
 #define        BDH_BDEV(bdh)           ((struct block_device *)bdh)
@@ -242,7 +252,9 @@ vdev_blkdev_get_by_path(const char *path, spa_mode_t smode, void *holder)
 {
        vdev_bdev_mode_t bmode = vdev_bdev_mode(smode);
 
-#if defined(HAVE_BDEV_OPEN_BY_PATH)
+#if defined(HAVE_BDEV_FILE_OPEN_BY_PATH)
+       return (bdev_file_open_by_path(path, bmode, holder, NULL));
+#elif defined(HAVE_BDEV_OPEN_BY_PATH)
        return (bdev_open_by_path(path, bmode, holder, NULL));
 #elif defined(HAVE_BLKDEV_GET_BY_PATH_4ARG)
        return (blkdev_get_by_path(path, bmode, holder, NULL));
@@ -258,8 +270,10 @@ vdev_blkdev_put(zfs_bdev_handle_t *bdh, spa_mode_t smode, void *holder)
        return (bdev_release(bdh));
 #elif defined(HAVE_BLKDEV_PUT_HOLDER)
        return (blkdev_put(BDH_BDEV(bdh), holder));
-#else
+#elif defined(HAVE_BLKDEV_PUT)
        return (blkdev_put(BDH_BDEV(bdh), vdev_bdev_mode(smode)));
+#else
+       fput(bdh);
 #endif
 }