lkml.org 
[lkml]   [2012]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC PATCH 03/22] fuse: convert fuse to use iov_iter_copy_[to|from]_user
Date
Dave Kleikamp <dave.kleikamp@oracle.com> writes:

> A future patch hides the internals of struct iov_iter, so fuse should
> be using the supported interface.
>
> Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>

Acked-by: Miklos Szeredi <mszeredi@suse.cz>

Thanks,
Miklos

> Cc: Miklos Szeredi <miklos@szeredi.hu>
> Cc: fuse-devel@lists.sourceforge.net
> ---
> fs/fuse/file.c | 29 ++++++++---------------------
> 1 file changed, 8 insertions(+), 21 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 4a199fd..877cee0 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1582,30 +1582,17 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
> while (iov_iter_count(&ii)) {
> struct page *page = pages[page_idx++];
> size_t todo = min_t(size_t, PAGE_SIZE, iov_iter_count(&ii));
> - void *kaddr;
> + size_t left;
>
> - kaddr = kmap(page);
> -
> - while (todo) {
> - char __user *uaddr = ii.iov->iov_base + ii.iov_offset;
> - size_t iov_len = ii.iov->iov_len - ii.iov_offset;
> - size_t copy = min(todo, iov_len);
> - size_t left;
> -
> - if (!to_user)
> - left = copy_from_user(kaddr, uaddr, copy);
> - else
> - left = copy_to_user(uaddr, kaddr, copy);
> -
> - if (unlikely(left))
> - return -EFAULT;
> + if (!to_user)
> + left = iov_iter_copy_from_user(page, &ii, 0, todo);
> + else
> + left = iov_iter_copy_to_user(page, &ii, 0, todo);
>
> - iov_iter_advance(&ii, copy);
> - todo -= copy;
> - kaddr += copy;
> - }
> + if (unlikely(left))
> + return -EFAULT;
>
> - kunmap(page);
> + iov_iter_advance(&ii, todo);
> }
>
> return 0;


\
 
 \ /
  Last update: 2012-02-28 10:13    [W:0.121 / U:7.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site