Commit 4d1c4404 authored by Mike Marshall's avatar Mike Marshall

Orangefs: use iov_iter interface

replace opencoded pvfs_bufmap_copy_to_kernel_iovec,
pvfs_bufmap_copy_to_user_iovec, pvfs_bufmap_copy_iovec_from_kernel,
and pvfs_bufmap_copy_iovec_from_user with pvfs_bufmap_copy_to_iovec
and pvfs_bufmap_copy_from_iovec, which both use the iov_iter
interface.
Signed-off-by: default avatarMike Marshall <hubcap@omnibond.com>
parent 81b784b1
...@@ -33,31 +33,30 @@ static int precopy_buffers(struct pvfs2_bufmap *bufmap, ...@@ -33,31 +33,30 @@ static int precopy_buffers(struct pvfs2_bufmap *bufmap,
int buffer_index, int buffer_index,
const struct iovec *vec, const struct iovec *vec,
unsigned long nr_segs, unsigned long nr_segs,
size_t total_size, size_t total_size)
int from_user)
{ {
int ret = 0; int ret = 0;
struct iov_iter iter;
/* /*
* copy data from application/kernel by pulling it out * copy data from application/kernel by pulling it out
* of the iovec. * of the iovec.
*/ */
/* Are we copying from User Virtual Addresses? */
if (from_user)
ret = pvfs_bufmap_copy_iovec_from_user( if (total_size) {
bufmap, iov_iter_init(&iter, WRITE, vec, nr_segs, total_size);
buffer_index, ret = pvfs_bufmap_copy_from_iovec(bufmap,
vec, &iter,
nr_segs, buffer_index,
total_size); total_size);
/* Are we copying from Kernel Virtual Addresses? */ if (ret < 0)
else gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n",
ret = pvfs_bufmap_copy_iovec_from_kernel( __func__,
bufmap, (long)ret);
buffer_index,
vec, }
nr_segs,
total_size);
if (ret < 0) if (ret < 0)
gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n", gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n",
__func__, __func__,
...@@ -76,35 +75,24 @@ static int postcopy_buffers(struct pvfs2_bufmap *bufmap, ...@@ -76,35 +75,24 @@ static int postcopy_buffers(struct pvfs2_bufmap *bufmap,
int buffer_index, int buffer_index,
const struct iovec *vec, const struct iovec *vec,
int nr_segs, int nr_segs,
size_t total_size, size_t total_size)
int to_user)
{ {
int ret = 0; int ret = 0;
struct iov_iter iter;
/* /*
* copy data to application/kernel by pushing it out to * copy data to application/kernel by pushing it out to
* the iovec. NOTE; target buffers can be addresses or * the iovec. NOTE; target buffers can be addresses or
* struct page pointers. * struct page pointers.
*/ */
if (total_size) { if (total_size) {
/* Are we copying to User Virtual Addresses? */ iov_iter_init(&iter, READ, vec, nr_segs, total_size);
if (to_user) ret = pvfs_bufmap_copy_to_iovec(bufmap,
ret = pvfs_bufmap_copy_to_user_iovec( &iter,
bufmap, buffer_index);
buffer_index,
vec,
nr_segs,
total_size);
/* Are we copying to Kern Virtual Addresses? */
else
ret = pvfs_bufmap_copy_to_kernel_iovec(
bufmap,
buffer_index,
vec,
nr_segs,
total_size);
if (ret < 0) if (ret < 0)
gossip_err("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n", gossip_err("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n",
__func__, __func__,
(long)ret); (long)ret);
} }
...@@ -116,7 +104,7 @@ static int postcopy_buffers(struct pvfs2_bufmap *bufmap, ...@@ -116,7 +104,7 @@ static int postcopy_buffers(struct pvfs2_bufmap *bufmap,
*/ */
static ssize_t wait_for_direct_io(enum PVFS_io_type type, struct inode *inode, static ssize_t wait_for_direct_io(enum PVFS_io_type type, struct inode *inode,
loff_t *offset, struct iovec *vec, unsigned long nr_segs, loff_t *offset, struct iovec *vec, unsigned long nr_segs,
size_t total_size, loff_t readahead_size, int to_user) size_t total_size, loff_t readahead_size)
{ {
struct pvfs2_inode_s *pvfs2_inode = PVFS2_I(inode); struct pvfs2_inode_s *pvfs2_inode = PVFS2_I(inode);
struct pvfs2_khandle *handle = &pvfs2_inode->refn.khandle; struct pvfs2_khandle *handle = &pvfs2_inode->refn.khandle;
...@@ -158,10 +146,9 @@ static ssize_t wait_for_direct_io(enum PVFS_io_type type, struct inode *inode, ...@@ -158,10 +146,9 @@ static ssize_t wait_for_direct_io(enum PVFS_io_type type, struct inode *inode,
new_op->upcall.req.io.offset = *offset; new_op->upcall.req.io.offset = *offset;
gossip_debug(GOSSIP_FILE_DEBUG, gossip_debug(GOSSIP_FILE_DEBUG,
"%s(%pU): copy_to_user %d nr_segs %lu, offset: %llu total_size: %zd\n", "%s(%pU): nr_segs %lu, offset: %llu total_size: %zd\n",
__func__, __func__,
handle, handle,
to_user,
nr_segs, nr_segs,
llu(*offset), llu(*offset),
total_size); total_size);
...@@ -174,8 +161,7 @@ static ssize_t wait_for_direct_io(enum PVFS_io_type type, struct inode *inode, ...@@ -174,8 +161,7 @@ static ssize_t wait_for_direct_io(enum PVFS_io_type type, struct inode *inode,
buffer_index, buffer_index,
vec, vec,
nr_segs, nr_segs,
total_size, total_size);
to_user);
if (ret < 0) if (ret < 0)
goto out; goto out;
} }
...@@ -239,8 +225,7 @@ static ssize_t wait_for_direct_io(enum PVFS_io_type type, struct inode *inode, ...@@ -239,8 +225,7 @@ static ssize_t wait_for_direct_io(enum PVFS_io_type type, struct inode *inode,
buffer_index, buffer_index,
vec, vec,
nr_segs, nr_segs,
new_op->downcall.resp.io.amt_complete, new_op->downcall.resp.io.amt_complete);
to_user);
if (ret < 0) { if (ret < 0) {
/* /*
* put error codes in downcall so that handle_io_error() * put error codes in downcall so that handle_io_error()
...@@ -606,7 +591,7 @@ static ssize_t do_readv_writev(enum PVFS_io_type type, struct file *file, ...@@ -606,7 +591,7 @@ static ssize_t do_readv_writev(enum PVFS_io_type type, struct file *file,
(int)*offset); (int)*offset);
ret = wait_for_direct_io(type, inode, offset, ptr, ret = wait_for_direct_io(type, inode, offset, ptr,
seg_array[seg], each_count, 0, 1); seg_array[seg], each_count, 0);
gossip_debug(GOSSIP_FILE_DEBUG, gossip_debug(GOSSIP_FILE_DEBUG,
"%s(%pU): return from wait_for_io:%d\n", "%s(%pU): return from wait_for_io:%d\n",
__func__, __func__,
...@@ -699,7 +684,7 @@ ssize_t pvfs2_inode_read(struct inode *inode, ...@@ -699,7 +684,7 @@ ssize_t pvfs2_inode_read(struct inode *inode,
llu(*offset)); llu(*offset));
ret = wait_for_direct_io(PVFS_IO_READ, inode, offset, &vec, 1, ret = wait_for_direct_io(PVFS_IO_READ, inode, offset, &vec, 1,
count, readahead_size, 0); count, readahead_size);
if (ret > 0) if (ret > 0)
*offset += ret; *offset += ret;
......
This diff is collapsed.
...@@ -42,29 +42,14 @@ int readdir_index_get(struct pvfs2_bufmap **mapp, int *buffer_index); ...@@ -42,29 +42,14 @@ int readdir_index_get(struct pvfs2_bufmap **mapp, int *buffer_index);
void readdir_index_put(struct pvfs2_bufmap *bufmap, int buffer_index); void readdir_index_put(struct pvfs2_bufmap *bufmap, int buffer_index);
int pvfs_bufmap_copy_iovec_from_user(struct pvfs2_bufmap *bufmap, int pvfs_bufmap_copy_from_iovec(struct pvfs2_bufmap *bufmap,
int buffer_index, struct iov_iter *iter,
const struct iovec *iov, int buffer_index,
unsigned long nr_segs, size_t size);
size_t size);
int pvfs_bufmap_copy_to_iovec(struct pvfs2_bufmap *bufmap,
int pvfs_bufmap_copy_iovec_from_kernel(struct pvfs2_bufmap *bufmap, struct iov_iter *iter,
int buffer_index, int buffer_index);
const struct iovec *iov,
unsigned long nr_segs,
size_t size);
int pvfs_bufmap_copy_to_user_iovec(struct pvfs2_bufmap *bufmap,
int buffer_index,
const struct iovec *iov,
unsigned long nr_segs,
size_t size);
int pvfs_bufmap_copy_to_kernel_iovec(struct pvfs2_bufmap *bufmap,
int buffer_index,
const struct iovec *iov,
unsigned long nr_segs,
size_t size);
size_t pvfs_bufmap_copy_to_user_task_iovec(struct task_struct *tsk, size_t pvfs_bufmap_copy_to_user_task_iovec(struct task_struct *tsk,
struct iovec *iovec, struct iovec *iovec,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment