diff options
author | Simon Rettberg | 2022-06-14 17:22:46 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-06-14 17:22:46 +0200 |
commit | 98c5770cd76b965b01496dcdb9529c7c2456c258 (patch) | |
tree | 6703a93567b7184aaff3abd531c6b5555d4c9001 | |
parent | rhel8.5: Remove duplicate blkdev_register (diff) | |
download | xloop-98c5770cd76b965b01496dcdb9529c7c2456c258.tar.gz xloop-98c5770cd76b965b01496dcdb9529c7c2456c258.tar.xz xloop-98c5770cd76b965b01496dcdb9529c7c2456c258.zip |
Adapt to Linux 5.18
-rw-r--r-- | src/kernel/xloop_file_fmt_qcow_main.c | 23 | ||||
-rw-r--r-- | src/kernel/xloop_file_fmt_raw.c | 9 | ||||
-rw-r--r-- | src/kernel/xloop_main_5.15.c | 14 |
3 files changed, 35 insertions, 11 deletions
diff --git a/src/kernel/xloop_file_fmt_qcow_main.c b/src/kernel/xloop_file_fmt_qcow_main.c index fb70f9a..d80a074 100644 --- a/src/kernel/xloop_file_fmt_qcow_main.c +++ b/src/kernel/xloop_file_fmt_qcow_main.c @@ -39,6 +39,15 @@ #ifdef CONFIG_ZSTD_DECOMPRESS #define ZSTD_WINDOWLOG_LIMIT_DEFAULT 27 #define ZSTD_MAXWINDOWSIZE ((U32_C(1) << ZSTD_WINDOWLOG_LIMIT_DEFAULT) + 1) + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#define zstd_dstream_workspace_bound ZSTD_DStreamWorkspaceBound +#define zstd_init_dstream ZSTD_initDStream +#define zstd_reset_dstream ZSTD_resetDStream +#define zstd_decompress_stream ZSTD_decompressStream +#define zstd_is_error ZSTD_isError +#endif + #endif typedef ssize_t (*qcow_file_fmt_decompress_fn)(struct xloop_file_fmt *xlo_fmt, void *dest, size_t dest_size, @@ -172,7 +181,7 @@ static int __qcow_file_fmt_compression_init(struct xloop_file_fmt *xlo_fmt) #ifdef CONFIG_ZSTD_DECOMPRESS /* create workspace for ZSTD decompression stream */ - workspace_size = ZSTD_DStreamWorkspaceBound(ZSTD_MAXWINDOWSIZE); + workspace_size = zstd_dstream_workspace_bound(ZSTD_MAXWINDOWSIZE); qcow_data->zstd_dworkspace = vzalloc(workspace_size); if (!qcow_data->zstd_dworkspace) { ret = -ENOMEM; @@ -180,7 +189,7 @@ static int __qcow_file_fmt_compression_init(struct xloop_file_fmt *xlo_fmt) } /* set up ZSTD decompression stream */ - qcow_data->zstd_dstrm = ZSTD_initDStream(ZSTD_MAXWINDOWSIZE, qcow_data->zstd_dworkspace, workspace_size); + qcow_data->zstd_dstrm = zstd_init_dstream(ZSTD_MAXWINDOWSIZE, qcow_data->zstd_dworkspace, workspace_size); if (!qcow_data->zstd_dstrm) { ret = -EINVAL; goto out_free_zstd_dworkspace; @@ -860,9 +869,9 @@ static ssize_t __qcow_file_fmt_zstd_decompress(struct xloop_file_fmt *xlo_fmt, v ZSTD_inBuffer input = { .src = src, .size = src_size, .pos = 0 }; - zstd_ret = ZSTD_resetDStream(qcow_data->zstd_dstrm); + zstd_ret = zstd_reset_dstream(qcow_data->zstd_dstrm); - if (ZSTD_isError(zstd_ret)) { + if (zstd_is_error(zstd_ret)) { dev_err(xloop_file_fmt_to_dev(xlo_fmt), "zstd reset error: %d\n", (int)zstd_ret); ret = -EINVAL; goto out; @@ -883,9 +892,9 @@ static ssize_t __qcow_file_fmt_zstd_decompress(struct xloop_file_fmt *xlo_fmt, v size_t last_in_pos = input.pos; size_t last_out_pos = output.pos; - zstd_ret = ZSTD_decompressStream(qcow_data->zstd_dstrm, &output, &input); + zstd_ret = zstd_decompress_stream(qcow_data->zstd_dstrm, &output, &input); - if (ZSTD_isError(zstd_ret)) + if (zstd_is_error(zstd_ret)) break; /* @@ -908,7 +917,7 @@ static ssize_t __qcow_file_fmt_zstd_decompress(struct xloop_file_fmt *xlo_fmt, v * greater then the cluster size, possibly because of its * damage. */ - if (ZSTD_isError(zstd_ret)) { + if (zstd_is_error(zstd_ret)) { dev_err(xloop_file_fmt_to_dev(xlo_fmt), "zstd decompress error: %d\n", (int)zstd_ret); ret = -EIO; } if (zstd_ret) { diff --git a/src/kernel/xloop_file_fmt_raw.c b/src/kernel/xloop_file_fmt_raw.c index 8a53c11..52d879a 100644 --- a/src/kernel/xloop_file_fmt_raw.c +++ b/src/kernel/xloop_file_fmt_raw.c @@ -148,7 +148,11 @@ static void __raw_file_fmt_rw_aio_do_completion(struct xloop_cmd *cmd) #endif } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) static void __raw_file_fmt_rw_aio_complete(struct kiocb *iocb, long ret, long ret2) +#else +static void __raw_file_fmt_rw_aio_complete(struct kiocb *iocb, long ret) +#endif { struct xloop_cmd *cmd = container_of(iocb, struct xloop_cmd, iocb); @@ -241,8 +245,13 @@ static int __raw_file_fmt_rw_aio(struct xloop_device *xlo, struct xloop_cmd *cmd kthread_associate_blkcg(NULL); #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) if (ret != -EIOCBQUEUED) cmd->iocb.ki_complete(&cmd->iocb, ret, 0); +#else + if (ret != -EIOCBQUEUED) + cmd->iocb.ki_complete(&cmd->iocb, ret); +#endif return 0; } diff --git a/src/kernel/xloop_main_5.15.c b/src/kernel/xloop_main_5.15.c index 9866c2b..7ed2a56 100644 --- a/src/kernel/xloop_main_5.15.c +++ b/src/kernel/xloop_main_5.15.c @@ -97,6 +97,10 @@ #define XLOOP_IDLE_WORKER_TIMEOUT (60 * HZ) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) +#define GENHD_FL_NO_PART GENHD_FL_NO_PART_SCAN +#endif + static DEFINE_IDR(xloop_index_idr); static DEFINE_MUTEX(xloop_ctl_mutex); static DEFINE_MUTEX(xloop_validate_mutex); @@ -1011,7 +1015,7 @@ static int xloop_configure(struct xloop_device *xlo, fmode_t mode, xlo->xlo_flags |= XLO_FLAGS_PARTSCAN; partscan = xlo->xlo_flags & XLO_FLAGS_PARTSCAN; if (partscan) - xlo->xlo_disk->flags &= ~GENHD_FL_NO_PART_SCAN; + xlo->xlo_disk->flags &= ~GENHD_FL_NO_PART; xloop_global_unlock(xlo, is_xloop); if (partscan) @@ -1158,7 +1162,7 @@ out_unlock: mutex_lock(&xlo->xlo_mutex); xlo->xlo_flags = 0; if (!part_shift) - xlo->xlo_disk->flags |= GENHD_FL_NO_PART_SCAN; + xlo->xlo_disk->flags |= GENHD_FL_NO_PART; xlo->xlo_state = Xlo_unbound; mutex_unlock(&xlo->xlo_mutex); @@ -1286,7 +1290,7 @@ out_unfreeze: if (!err && (xlo->xlo_flags & XLO_FLAGS_PARTSCAN) && !(prev_xlo_flags & XLO_FLAGS_PARTSCAN)) { - xlo->xlo_disk->flags &= ~GENHD_FL_NO_PART_SCAN; + xlo->xlo_disk->flags &= ~GENHD_FL_NO_PART; partscan = true; } out_unlock: @@ -2110,8 +2114,10 @@ static int xloop_add(int i) * userspace tools. Parameters like this in general should be avoided. */ if (!part_shift) - disk->flags |= GENHD_FL_NO_PART_SCAN; + disk->flags |= GENHD_FL_NO_PART; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) disk->flags |= GENHD_FL_EXT_DEVT; +#endif atomic_set(&xlo->xlo_refcnt, 0); mutex_init(&xlo->xlo_mutex); xlo->xlo_number = i; |