summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2023-01-09 18:03:24 +0100
committerSimon Rettberg2023-01-09 18:03:24 +0100
commitb5aafc8f1bad5e90a9dbd51adb45127d2e26dd7a (patch)
tree03b6ef5c199ba82e31d001f8b13515997879d754 /src
parentFix linter issues to satisfy Linux kernel code style (diff)
downloaddnbd3-b5aafc8f1bad5e90a9dbd51adb45127d2e26dd7a.tar.gz
dnbd3-b5aafc8f1bad5e90a9dbd51adb45127d2e26dd7a.tar.xz
dnbd3-b5aafc8f1bad5e90a9dbd51adb45127d2e26dd7a.zip
[KERNEL] Update for Linux 6.1
Diffstat (limited to 'src')
-rw-r--r--src/kernel/blk.c27
-rw-r--r--src/kernel/net.c5
2 files changed, 25 insertions, 7 deletions
diff --git a/src/kernel/blk.c b/src/kernel/blk.c
index 448f62f..d16270e 100644
--- a/src/kernel/blk.c
+++ b/src/kernel/blk.c
@@ -333,7 +333,11 @@ static blk_status_t dnbd3_queue_rq(struct blk_mq_hw_ctx *hctx, const struct blk_
return BLK_STS_OK;
}
-static enum blk_eh_timer_return dnbd3_rq_timeout(struct request *req, bool reserved)
+static enum blk_eh_timer_return dnbd3_rq_timeout(struct request *req
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
+ , bool reserved
+#endif
+ )
{
unsigned long irqflags;
struct request *rq_iter;
@@ -480,16 +484,26 @@ int dnbd3_blk_add_device(dnbd3_device_t *dev, int minor)
sprintf(dev->disk->disk_name, "dnbd%d", minor);
set_capacity(dev->disk, 0);
set_disk_ro(dev->disk, 1);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
+ ret = add_disk(dev->disk);
+ if (ret != 0)
+ goto out_cleanup_queue;
+#else
add_disk(dev->disk);
+#endif
// set up sysfs
dnbd3_sysfs_init(dev);
return 0;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
out_cleanup_queue:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
blk_cleanup_queue(dev->queue);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
+ blk_cleanup_disk(dev->disk);
+#else
+ put_disk(dev->disk);
#endif
out_cleanup_tags:
blk_mq_free_tag_set(&dev->tag_set);
@@ -507,14 +521,13 @@ int dnbd3_blk_del_device(dnbd3_device_t *dev)
del_gendisk(dev->disk);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
blk_cleanup_queue(dev->queue);
-#else
+ put_disk(dev->disk);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
blk_cleanup_disk(dev->disk);
-#endif
- blk_mq_free_tag_set(&dev->tag_set);
- mutex_destroy(&dev->alt_servers_lock);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
+#else
put_disk(dev->disk);
#endif
+ blk_mq_free_tag_set(&dev->tag_set);
mutex_destroy(&dev->alt_servers_lock);
return 0;
}
diff --git a/src/kernel/net.c b/src/kernel/net.c
index 8408954..e24778f 100644
--- a/src/kernel/net.c
+++ b/src/kernel/net.c
@@ -26,6 +26,11 @@
#include <dnbd3/shared/serialize.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 14)
+#include <linux/prandom.h>
+#else
+#include <linux/random.h>
+#endif
#include <linux/time.h>
#include <linux/ktime.h>
#include <linux/tcp.h>