[PATCH V9 10/33] iov_iter: let callers extract iovecs and bio_vecs
From: Dave Kleikamp
Date: Wed Oct 16 2013 - 10:05:56 EST
From: Zach Brown <zab@xxxxxxxxx>
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 abstraction 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 <zab@xxxxxxxxx>
Signed-off-by: Dave Kleikamp <dave.kleikamp@xxxxxxxxxx>
Tested-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>
---
include/linux/fs.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index fbe02cc..e717b47 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -372,6 +372,17 @@ 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;
+}
#endif
extern struct iov_iter_ops ii_iovec_ops;
@@ -389,8 +400,14 @@ 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;
}
--
1.8.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/