summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-01-09 18:08:16 +0100
committerSimon Rettberg2023-01-09 18:08:16 +0100
commit3ccfe2d4042e84195f7db9645f9f3c3326bc0c04 (patch)
tree2c7d15ac2c163c1b692861901d03f4d59e64d6a2
parent[KERNEL] Fix a copy/paste error acessing wrong variable in sanity check (diff)
downloadxloop-3ccfe2d4042e84195f7db9645f9f3c3326bc0c04.tar.gz
xloop-3ccfe2d4042e84195f7db9645f9f3c3326bc0c04.tar.xz
xloop-3ccfe2d4042e84195f7db9645f9f3c3326bc0c04.zip
[KERNEL] Update for Linux 6.1
-rw-r--r--src/kernel/xloop_file_fmt_raw.c12
-rw-r--r--src/kernel/xloop_main_5.15.c20
2 files changed, 25 insertions, 7 deletions
diff --git a/src/kernel/xloop_file_fmt_raw.c b/src/kernel/xloop_file_fmt_raw.c
index 52d879a..17c5274 100644
--- a/src/kernel/xloop_file_fmt_raw.c
+++ b/src/kernel/xloop_file_fmt_raw.c
@@ -360,20 +360,20 @@ static int __raw_file_fmt_fallocate(struct xloop_device *xlo, struct request *rq
* information.
*/
struct file *file = xlo->xlo_backing_file;
- struct request_queue *q = xlo->xlo_queue;
int ret;
mode |= FALLOC_FL_KEEP_SIZE;
- if (!blk_queue_discard(q)) {
- ret = -EOPNOTSUPP;
- goto out;
- }
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
+ if (!bdev_max_discard_sectors(xlo->xlo_device))
+#else
+ if (!blk_queue_discard(xlo->xlo_queue))
+#endif
+ return -EOPNOTSUPP;
ret = file->f_op->fallocate(file, mode, pos, blk_rq_bytes(rq));
if (unlikely(ret && ret != -EINVAL && ret != -EOPNOTSUPP))
ret = -EIO;
-out:
return ret;
}
diff --git a/src/kernel/xloop_main_5.15.c b/src/kernel/xloop_main_5.15.c
index 7ed2a56..eb181c2 100644
--- a/src/kernel/xloop_main_5.15.c
+++ b/src/kernel/xloop_main_5.15.c
@@ -667,12 +667,16 @@ static void xloop_config_discard(struct xloop_device *xlo)
q->limits.discard_granularity = granularity;
blk_queue_max_discard_sectors(q, max_discard_sectors);
blk_queue_max_write_zeroes_sectors(q, max_discard_sectors);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0)
blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
+#endif
} else {
q->limits.discard_granularity = 0;
blk_queue_max_discard_sectors(q, 0);
blk_queue_max_write_zeroes_sectors(q, 0);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0)
blk_queue_flag_clear(QUEUE_FLAG_DISCARD, q);
+#endif
}
q->limits.discard_alignment = 0;
}
@@ -1894,7 +1898,11 @@ static blk_status_t xloop_queue_rq(struct blk_mq_hw_ctx *hctx,
cmd->memcg_css = NULL;
#ifdef CONFIG_BLK_CGROUP
if (rq->bio && rq->bio->bi_blkg) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
+ cmd->blkcg_css = bio_blkcg_css(rq->bio);
+#else
cmd->blkcg_css = &bio_blkcg(rq->bio)->css;
+#endif
#ifdef CONFIG_MEMCG
cmd->memcg_css =
cgroup_get_e_css(cmd->blkcg_css->cgroup,
@@ -2133,7 +2141,9 @@ static int xloop_add(int i)
disk->event_flags = DISK_EVENT_FLAG_UEVENT;
sprintf(disk->disk_name, "xloop%d", i);
/* Make this xloop device reachable from pathname. */
- add_disk(disk);
+ err = add_disk(disk);
+ if (err != 0)
+ goto out_free_file_fmt;
/* Show this xloop device. */
mutex_lock(&xloop_ctl_mutex);
xlo->idr_visible = true;
@@ -2161,7 +2171,11 @@ static int xloop_add(int i)
out_free_file_fmt:
xloop_file_fmt_free(xlo->xlo_fmt);
out_cleanup_disk:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
+ put_disk(xlo->xlo_disk);
+#else
blk_cleanup_disk(xlo->xlo_disk);
+#endif
out_cleanup_tags:
blk_mq_free_tag_set(&xlo->tag_set);
out_free_idr:
@@ -2180,7 +2194,11 @@ static void xloop_remove(struct xloop_device *xlo)
debugfs_remove(xlo->xlo_dbgfs_dir);
/* Make this xloop device unreachable from pathname. */
del_gendisk(xlo->xlo_disk);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
+ put_disk(xlo->xlo_disk);
+#else
blk_cleanup_disk(xlo->xlo_disk);
+#endif
blk_mq_free_tag_set(&xlo->tag_set);
mutex_lock(&xloop_ctl_mutex);
idr_remove(&xloop_index_idr, xlo->xlo_number);