summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/kernel/blk.c35
-rw-r--r--src/kernel/sysfs.c14
2 files changed, 33 insertions, 16 deletions
diff --git a/src/kernel/blk.c b/src/kernel/blk.c
index 69e4583..381db88 100644
--- a/src/kernel/blk.c
+++ b/src/kernel/blk.c
@@ -110,15 +110,17 @@ static int dnbd3_blk_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
dev->use_server_provided_alts = msg->use_server_provided_alts;
dev_info(dnbd3_device_to_dev(dev), "opening device.\n");
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
+ /* nothing to do here, set at creation time */
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
// set optimal request size for the queue to half the read-ahead
blk_queue_io_opt(dev->queue, (msg->read_ahead_kb * 512));
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0) \
+# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0) \
&& !RHEL_CHECK_VERSION(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 0))
// set readahead from optimal request size of the queue
// ra_pages are calculated by following formula: queue_io_opt() * 2 / PAGE_SIZE
blk_queue_update_readahead(dev->queue);
-#endif
+# endif
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
if (blk_queue->backing_dev_info != NULL)
blk_queue->backing_dev_info->ra_pages = (msg->read_ahead_kb * 1024) / PAGE_SIZE;
@@ -386,6 +388,7 @@ struct blk_mq_ops dnbd3_mq_ops = {
.timeout = dnbd3_rq_timeout,
};
+#define ONE_MEG (1048576)
int dnbd3_blk_add_device(dnbd3_device_t *dev, int minor)
{
int ret;
@@ -429,7 +432,21 @@ int dnbd3_blk_add_device(dnbd3_device_t *dev, int minor)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
// set up blk-mq and disk
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
+ do {
+ struct queue_limits lim = {
+ .logical_block_size = DNBD3_BLOCK_SIZE, // in bytes
+ .physical_block_size = DNBD3_BLOCK_SIZE, // in bytes
+ .io_opt = ONE_MEG >> 2, // 256kb
+ .max_hw_sectors = ONE_MEG >> SECTOR_SHIFT, // in 512byte sectors
+ .max_segments = USHRT_MAX,
+ .max_segment_size = UINT_MAX,
+ };
+ dev->disk = blk_mq_alloc_disk(&dev->tag_set, &lim, dev);
+ } while (0);
+# else
dev->disk = blk_mq_alloc_disk(&dev->tag_set, dev);
+# endif
if (IS_ERR(dev->disk)) {
dev_err(dnbd3_device_to_dev(dev), "blk_mq_alloc_disk failed\n");
ret = PTR_ERR(dev->disk);
@@ -447,20 +464,19 @@ int dnbd3_blk_add_device(dnbd3_device_t *dev, int minor)
dev->queue->queuedata = dev;
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
blk_queue_logical_block_size(dev->queue, DNBD3_BLOCK_SIZE);
blk_queue_physical_block_size(dev->queue, DNBD3_BLOCK_SIZE);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
blk_queue_flag_set(QUEUE_FLAG_NONROT, dev->queue);
blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, dev->queue);
-#else
+# else
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, dev->queue);
-#endif
-#define ONE_MEG (1048576)
+# endif
blk_queue_max_segment_size(dev->queue, ONE_MEG);
blk_queue_max_segments(dev->queue, 0xffff);
blk_queue_max_hw_sectors(dev->queue, ONE_MEG / DNBD3_BLOCK_SIZE);
- dev->queue->limits.max_sectors = 256;
-#undef ONE_MEG
+#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
// set up disk
@@ -517,6 +533,7 @@ out:
mutex_destroy(&dev->alt_servers_lock);
return ret;
}
+#undef ONE_MEG
int dnbd3_blk_del_device(dnbd3_device_t *dev)
{
diff --git a/src/kernel/sysfs.c b/src/kernel/sysfs.c
index 9deba96..9a1c443 100644
--- a/src/kernel/sysfs.c
+++ b/src/kernel/sysfs.c
@@ -30,7 +30,7 @@
/**
* Print currently connected server IP:PORT
*/
-ssize_t show_cur_server_addr(char *buf, dnbd3_device_t *dev)
+static ssize_t show_cur_server_addr(char *buf, dnbd3_device_t *dev)
{
ssize_t ret;
@@ -44,7 +44,7 @@ ssize_t show_cur_server_addr(char *buf, dnbd3_device_t *dev)
* List alt servers. One line per server, format is:
* IP:PORT RTT consecutive_failures best_count
*/
-ssize_t show_alt_servers(char *buf, dnbd3_device_t *dev)
+static ssize_t show_alt_servers(char *buf, dnbd3_device_t *dev)
{
int i, size = PAGE_SIZE;
ssize_t ret;
@@ -78,7 +78,7 @@ ssize_t show_alt_servers(char *buf, dnbd3_device_t *dev)
/**
* Show name of image in use
*/
-ssize_t show_image_name(char *buf, dnbd3_device_t *dev)
+static ssize_t show_image_name(char *buf, dnbd3_device_t *dev)
{
ssize_t ret;
@@ -91,13 +91,13 @@ ssize_t show_image_name(char *buf, dnbd3_device_t *dev)
/**
* Show rid of image in use
*/
-ssize_t show_rid(char *buf, dnbd3_device_t *dev)
+static ssize_t show_rid(char *buf, dnbd3_device_t *dev)
{
// No locking here, primitive type, no pointer to allocated memory
return MIN(snprintf(buf, PAGE_SIZE, "%d\n", dev->rid), PAGE_SIZE);
}
-ssize_t show_update_available(char *buf, dnbd3_device_t *dev)
+static ssize_t show_update_available(char *buf, dnbd3_device_t *dev)
{
// Same story
return MIN(snprintf(buf, PAGE_SIZE, "%d\n", dev->update_available), PAGE_SIZE);
@@ -133,7 +133,7 @@ device_attr_t update_available = {
.store = NULL,
};
-ssize_t device_show(struct kobject *kobj, struct attribute *attr, char *buf)
+static ssize_t device_show(struct kobject *kobj, struct attribute *attr, char *buf)
{
device_attr_t *device_attr = container_of(attr, device_attr_t, attr);
dnbd3_device_t *dev = container_of(kobj, dnbd3_device_t, kobj);
@@ -157,7 +157,7 @@ const struct sysfs_ops device_ops = {
.show = device_show,
};
-void release(struct kobject *kobj)
+static void release(struct kobject *kobj)
{
kobj->state_initialized = 0;
}