From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Kleikamp Subject: [PATCH V9 05/33] fuse: convert fuse to use iov_iter_copy_[to|from]_user Date: Wed, 16 Oct 2013 09:04:18 -0500 Message-ID: <1381932286-14978-6-git-send-email-dave.kleikamp@oracle.com> References: <1381932286-14978-1-git-send-email-dave.kleikamp@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: fuse-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Christoph Hellwig , Dave Kleikamp , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrew Morton , Zach Brown , "Maxim V. Patlasov" To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Return-path: In-Reply-To: <1381932286-14978-1-git-send-email-dave.kleikamp-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fuse-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org A future patch hides the internals of struct iov_iter, so fuse should be using the supported interface. Signed-off-by: Dave Kleikamp Acked-by: Miklos Szeredi Tested-by: Sedat Dilek Cc: fuse-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org --- 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 4598345..606ff63 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1868,30 +1868,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; -- 1.8.4 ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk