summaryrefslogtreecommitdiffstats
path: root/kernel/xloop_file_fmt_raw.c
diff options
context:
space:
mode:
authorManuel Bentele2020-09-15 14:23:38 +0200
committerManuel Bentele2020-09-16 07:37:56 +0200
commit800917a21e3c34d3fbeb46bdd1901808dde89fc4 (patch)
tree47cf88de334bc1a3a55d350d9117537283a49597 /kernel/xloop_file_fmt_raw.c
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
Diffstat (limited to 'kernel/xloop_file_fmt_raw.c')
-rw-r--r--kernel/xloop_file_fmt_raw.c14
1 files changed, 13 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);