summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2020-09-15 14:23:38 +0200
committerManuel Bentele2020-09-16 07:37:56 +0200
commit800917a21e3c34d3fbeb46bdd1901808dde89fc4 (patch)
tree47cf88de334bc1a3a55d350d9117537283a49597
parentChanged CMake minimum required version to 3.10 (diff)
downloadxloop-800917a21e3c34d3fbeb46bdd1901808dde89fc4.tar.gz
xloop-800917a21e3c34d3fbeb46bdd1901808dde89fc4.tar.xz
xloop-800917a21e3c34d3fbeb46bdd1901808dde89fc4.zip
Ported RAW file format kernel module to Linux 4.18.x
-rw-r--r--kernel/xloop_file_fmt_raw.c14
-rw-r--r--kernel/xloop_main.c8
2 files changed, 21 insertions, 1 deletions
diff --git a/kernel/xloop_file_fmt_raw.c b/kernel/xloop_file_fmt_raw.c
index c8e90ef..f963e92 100644
--- a/kernel/xloop_file_fmt_raw.c
+++ b/kernel/xloop_file_fmt_raw.c
@@ -176,11 +176,16 @@ static int __raw_file_fmt_rw_aio(struct xloop_device *xlo,
int nr_bvec = 0;
int ret;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
rq_for_each_bvec(tmp, rq, rq_iter)
nr_bvec++;
+#endif
if (rq->bio != rq->biotail) {
-
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
+ __rq_for_each_bio(bio, rq)
+ nr_bvec += bio_segments(bio);
+#endif
bvec = kmalloc_array(nr_bvec, sizeof(struct bio_vec),
GFP_NOIO);
if (!bvec)
@@ -193,7 +198,11 @@ static int __raw_file_fmt_rw_aio(struct xloop_device *xlo,
* copy bio->bi_iov_vec to new bvec. The rq_for_each_bvec
* API will take care of all details for us.
*/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
rq_for_each_bvec(tmp, rq, rq_iter) {
+#else
+ rq_for_each_segment(tmp, rq, rq_iter) {
+#endif
*bvec = tmp;
bvec++;
}
@@ -207,6 +216,9 @@ static int __raw_file_fmt_rw_aio(struct xloop_device *xlo,
*/
offset = bio->bi_iter.bi_bvec_done;
bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
+ nr_bvec = bio_segments(bio);
+#endif
}
atomic_set(&cmd->ref, 2);
diff --git a/kernel/xloop_main.c b/kernel/xloop_main.c
index c6a6c83..703044f 100644
--- a/kernel/xloop_main.c
+++ b/kernel/xloop_main.c
@@ -1471,7 +1471,11 @@ static int xlo_ioctl(struct block_device *bdev, fmode_t mode,
case XLOOP_SET_BLOCK_SIZE:
if (!(mode & FMODE_WRITE) && !capable(CAP_SYS_ADMIN))
return -EPERM;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
fallthrough;
+#else
+ /* fall through */
+#endif
default:
err = xlo_simple_ioctl(xlo, cmd, arg);
break;
@@ -1623,7 +1627,11 @@ static int xlo_compat_ioctl(struct block_device *bdev, fmode_t mode,
case XLOOP_SET_STATUS64:
case XLOOP_CONFIGURE:
arg = (unsigned long) compat_ptr(arg);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
fallthrough;
+#else
+ /* fall through */
+#endif
case XLOOP_SET_FD:
case XLOOP_CHANGE_FD:
case XLOOP_SET_BLOCK_SIZE: