From: Zach Brown Date: Fri, 3 Sep 2010 21:12:09 +0000 (-0700) Subject: iov_iter: let callers extract iovecs and bio_vecs X-Git-Tag: v2.6.39-400.9.0~594^2~16 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=230eb11ca261bd53102389fa8eaa88521320806f;p=users%2Fjedix%2Flinux-maple.git iov_iter: let callers extract iovecs and bio_vecs direct IO treats memory from user iovecs and memory from arrays of kernel pages very differently. User memory is pinned and worked with in batches while kernel pages are always pinned and don't require additional processing. Rather than try and provide an absctraction that includes these different behaviours we let direct IO extract the memory structs and hand them to the existing code. Signed-off-by: Zach Brown --- diff --git a/include/linux/fs.h b/include/linux/fs.h index a1d6f84587fa..5587363596eb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -600,6 +600,15 @@ static inline void iov_iter_init_bvec(struct iov_iter *i, iov_iter_advance(i, written); } +static inline int iov_iter_has_bvec(struct iov_iter *i) +{ + return i->ops == &ii_bvec_ops; +} +static inline struct bio_vec *iov_iter_bvec(struct iov_iter *i) +{ + BUG_ON(!iov_iter_has_bvec(i)); + return (struct bio_vec *)i->data; +} extern struct iov_iter_ops ii_iovec_ops; @@ -615,6 +624,15 @@ static inline void iov_iter_init(struct iov_iter *i, iov_iter_advance(i, written); } +static inline int iov_iter_has_iovec(struct iov_iter *i) +{ + return i->ops == &ii_iovec_ops; +} +static inline struct iovec *iov_iter_iovec(struct iov_iter *i) +{ + BUG_ON(!iov_iter_has_iovec(i)); + return (struct iovec *)i->data; +} static inline size_t iov_iter_count(struct iov_iter *i) {