Skip to content

Commit

Permalink
bio_vec-backed iov_iter
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro committed May 6, 2014
1 parent 81055e5 commit 62a8067
Show file tree
Hide file tree
Showing 5 changed files with 385 additions and 44 deletions.
2 changes: 1 addition & 1 deletion fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ static int fuse_get_user_pages(struct fuse_req *req, struct iov_iter *ii,
size_t nbytes = 0; /* # bytes already packed in req */

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

Expand Down
4 changes: 2 additions & 2 deletions include/linux/blk_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#ifndef __LINUX_BLK_TYPES_H
#define __LINUX_BLK_TYPES_H

#ifdef CONFIG_BLOCK

#include <linux/types.h>

struct bio_set;
Expand All @@ -28,6 +26,8 @@ struct bio_vec {
unsigned int bv_offset;
};

#ifdef CONFIG_BLOCK

struct bvec_iter {
sector_t bi_sector; /* device address in 512 byte
sectors */
Expand Down
14 changes: 12 additions & 2 deletions include/linux/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ struct kvec {
size_t iov_len;
};

enum {
ITER_IOVEC = 0,
ITER_KVEC = 2,
ITER_BVEC = 4,
};

struct iov_iter {
int type;
const struct iovec *iov;
unsigned long nr_segs;
size_t iov_offset;
size_t count;
union {
const struct iovec *iov;
const struct bio_vec *bvec;
};
unsigned long nr_segs;
};

/*
Expand Down Expand Up @@ -54,6 +63,7 @@ static inline struct iovec iov_iter_iovec(const struct iov_iter *iter)
}

#define iov_for_each(iov, iter, start) \
if (!((start).type & ITER_BVEC)) \
for (iter = (start); \
(iter).count && \
((iov = iov_iter_iovec(&(iter))), 1); \
Expand Down
Loading

0 comments on commit 62a8067

Please sign in to comment.