From patchwork Sat Dec 20 03:18:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 5521951 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C9CCDBEEA8 for ; Sat, 20 Dec 2014 03:20:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E83DD20154 for ; Sat, 20 Dec 2014 03:20:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D720D2014A for ; Sat, 20 Dec 2014 03:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752885AbaLTDUL (ORCPT ); Fri, 19 Dec 2014 22:20:11 -0500 Received: from mail-pd0-f179.google.com ([209.85.192.179]:64786 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbaLTDSn (ORCPT ); Fri, 19 Dec 2014 22:18:43 -0500 Received: by mail-pd0-f179.google.com with SMTP id fp1so2328905pdb.24 for ; Fri, 19 Dec 2014 19:18:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=WJSDC0rNpSqVrlF59OggiawgRU7/4OMkfYLjJHxEpjI=; b=LO9qiD3Q8baGOAmhIOL7x75g04YP/MCFzBbP0B9YLDrwqTy8+7kTtaIsTV5gd/ZrXS XSmgZ0YXUGw3rBrR0WWn1gvM6d8VHOBvkqpb0X+BA0PBAVKVHyhQidfOOwIg5cY6uasR gQbHPFpwSV6kHvMP3+GsyaMC/4thKfSP9OQ5B3wEEFzJG+zXgQyB/XZ9S00vlEyYaK8E oxgN1QS7ZDXiPSDtTlbKw8xKs5IdrPUBrgsxrbcmLl9qBg1CbOKWYiAC5cdWeJ4KmbuV KjVPH27B2TqgEGJLuNu28RdmSXakOh1xolxWZnjENtns87rdgDXXPKvCyPKokNqKmuCK HT9A== X-Gm-Message-State: ALoCoQldcxlUmxlgM1cN3Xtor3cwQ8uEL7Xu4bBxVcEPQEPnyJtIzAJkTNnIeuslYf8tzMOPT+KW X-Received: by 10.68.236.67 with SMTP id us3mr16970541pbc.121.1419045523203; Fri, 19 Dec 2014 19:18:43 -0800 (PST) Received: from mew.localdomain ([72.192.100.38]) by mx.google.com with ESMTPSA id uq15sm10972638pab.8.2014.12.19.19.18.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Dec 2014 19:18:42 -0800 (PST) From: Omar Sandoval To: Alexander Viro , Andrew Morton , Trond Myklebust , Christoph Hellwig , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Omar Sandoval Subject: [PATCH v2 1/5] iov_iter: add ITER_BVEC helpers Date: Fri, 19 Dec 2014 19:18:25 -0800 Message-Id: <9523f2373dd40ac35760f3fb926a81a321fa4139.1419044605.git.osandov@osandov.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add iov_iter_is_bvec and iov_iter_bvec and convert callers. Signed-off-by: Omar Sandoval --- fs/splice.c | 7 ++----- include/linux/uio.h | 7 +++++++ mm/iov_iter.c | 12 ++++++++++++ mm/page_io.c | 14 +++++--------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 75c6058..7c7176f 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1006,11 +1006,8 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, } /* ... iov_iter */ - from.type = ITER_BVEC | WRITE; - from.bvec = array; - from.nr_segs = n; - from.count = sd.total_len - left; - from.iov_offset = 0; + iov_iter_bvec(&from, ITER_BVEC | WRITE, array, n, + sd.total_len - left); /* ... and iocb */ init_sync_kiocb(&kiocb, out); diff --git a/include/linux/uio.h b/include/linux/uio.h index 1c5e453..23bb5e4 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -63,6 +63,11 @@ static inline struct iovec iov_iter_iovec(const struct iov_iter *iter) }; } +static inline int iov_iter_is_bvec(const struct iov_iter *iter) +{ + return (iter->type & ITER_BVEC) != 0; +} + #define iov_for_each(iov, iter, start) \ if (!((start).type & ITER_BVEC)) \ for (iter = (start); \ @@ -90,6 +95,8 @@ void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov, unsigned long nr_segs, size_t count); void iov_iter_kvec(struct iov_iter *i, int direction, const struct kvec *iov, unsigned long nr_segs, size_t count); +void iov_iter_bvec(struct iov_iter *i, int direction, const struct bio_vec *bv, + unsigned long nr_segs, size_t count); ssize_t iov_iter_get_pages(struct iov_iter *i, struct page **pages, size_t maxsize, unsigned maxpages, size_t *start); ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, struct page ***pages, diff --git a/mm/iov_iter.c b/mm/iov_iter.c index a1599ca..c975bc4 100644 --- a/mm/iov_iter.c +++ b/mm/iov_iter.c @@ -513,6 +513,18 @@ void iov_iter_kvec(struct iov_iter *i, int direction, } EXPORT_SYMBOL(iov_iter_kvec); +void iov_iter_bvec(struct iov_iter *i, int direction, const struct bio_vec *bv, + unsigned long nr_segs, size_t count) +{ + BUG_ON(!(direction & ITER_BVEC)); + i->type = direction; + i->bvec = bv; + i->nr_segs = nr_segs; + i->iov_offset = 0; + i->count = count; +} +EXPORT_SYMBOL(iov_iter_bvec); + unsigned long iov_iter_alignment(const struct iov_iter *i) { unsigned long res = 0; diff --git a/mm/page_io.c b/mm/page_io.c index 955db8b..532a39b 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -264,18 +264,14 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, struct kiocb kiocb; struct file *swap_file = sis->swap_file; struct address_space *mapping = swap_file->f_mapping; + struct iov_iter from; struct bio_vec bv = { .bv_page = page, - .bv_len = PAGE_SIZE, - .bv_offset = 0 + .bv_len = PAGE_SIZE, + .bv_offset = 0, }; - struct iov_iter from = { - .type = ITER_BVEC | WRITE, - .count = PAGE_SIZE, - .iov_offset = 0, - .nr_segs = 1, - }; - from.bvec = &bv; /* older gcc versions are broken */ + + iov_iter_bvec(&from, ITER_BVEC | WRITE, &bv, 1, PAGE_SIZE); init_sync_kiocb(&kiocb, swap_file); kiocb.ki_pos = page_file_offset(page);