Skip to content

Commit 62a8067

Browse files
author
Al Viro
committed
bio_vec-backed iov_iter
New variant of iov_iter - ITER_BVEC in iter->type, backed with bio_vec array instead of iovec one. Primitives taught to deal with such beasts, __swap_write() switched to using that kind of iov_iter. Note that bio_vec is just a <page, offset, length> triple - there's nothing block-specific about it. I've left the definition where it was, but took it from under ifdef CONFIG_BLOCK. Next target: ->splice_write()... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 81055e5 commit 62a8067

File tree

5 files changed

+385
-44
lines changed

5 files changed

+385
-44
lines changed

fs/fuse/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ static int fuse_get_user_pages(struct fuse_req *req, struct iov_iter *ii,
12881288
size_t nbytes = 0; /* # bytes already packed in req */
12891289

12901290
/* Special case for kernel I/O: can copy directly into the buffer */
1291-
if (ii->type & REQ_KERNEL) {
1291+
if (ii->type & ITER_KVEC) {
12921292
unsigned long user_addr = fuse_get_user_addr(ii);
12931293
size_t frag_size = fuse_get_frag_size(ii, *nbytesp);
12941294

include/linux/blk_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#ifndef __LINUX_BLK_TYPES_H
66
#define __LINUX_BLK_TYPES_H
77

8-
#ifdef CONFIG_BLOCK
9-
108
#include <linux/types.h>
119

1210
struct bio_set;
@@ -28,6 +26,8 @@ struct bio_vec {
2826
unsigned int bv_offset;
2927
};
3028

29+
#ifdef CONFIG_BLOCK
30+
3131
struct bvec_iter {
3232
sector_t bi_sector; /* device address in 512 byte
3333
sectors */

include/linux/uio.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ struct kvec {
1919
size_t iov_len;
2020
};
2121

22+
enum {
23+
ITER_IOVEC = 0,
24+
ITER_KVEC = 2,
25+
ITER_BVEC = 4,
26+
};
27+
2228
struct iov_iter {
2329
int type;
24-
const struct iovec *iov;
25-
unsigned long nr_segs;
2630
size_t iov_offset;
2731
size_t count;
32+
union {
33+
const struct iovec *iov;
34+
const struct bio_vec *bvec;
35+
};
36+
unsigned long nr_segs;
2837
};
2938

3039
/*
@@ -54,6 +63,7 @@ static inline struct iovec iov_iter_iovec(const struct iov_iter *iter)
5463
}
5564

5665
#define iov_for_each(iov, iter, start) \
66+
if (!((start).type & ITER_BVEC)) \
5767
for (iter = (start); \
5868
(iter).count && \
5969
((iov = iov_iter_iovec(&(iter))), 1); \

0 commit comments

Comments
 (0)