Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2023427pxb; Sat, 21 Nov 2020 06:17:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvflgxPpWw1Rp5YKCVPeo3bmELQIHPlmIZlJme0AGiQ+WVWCRKVZdO181BxMPA3KqHn43f X-Received: by 2002:a17:906:dbf4:: with SMTP id yd20mr36043838ejb.53.1605968269874; Sat, 21 Nov 2020 06:17:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605968269; cv=none; d=google.com; s=arc-20160816; b=Evz+w5N9nXo3CE1s7bkeR4+NebfZ1nJYfDTwVg1G5PpDxnJPnQe0KqGJylUnd+OrpD MSVrQWVJkRcVy3s3kTFWiqOyPHmWMpPYfWxXNWN6mZsipYqdDedqyXjsqzerA6izEOOK 8untlN9nJx195xjNEfEf9dw+iWrdCnaC1kxItNruV7ewP9lvEIkcDmY0iaMqzuTioe80 ATIQ375Lx1o4E3kqEOO0hiNU3bwjQweMo2nD8UYLATzqTSAWTe5IOiua3r7mcr7HEDuw aPxHbrjFWrF38pvRg72nFZ1jRg82FYTw1RtaqtS1CL5O0oKXINQYCacLDbMifV/XVfct F3FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=Cts/UysbCeke0SRrY+6cxZefIvVJUV/6NiBfhTcZI1c=; b=nGCSi+eAI2rU3m+K0MKNvQZ9JaotdHEjHekuli/z7KYZpLNryy+gCTEiPYWqsVehlm 6Gnihp/RaMJWQiZU9spcjXQmPHiC1QI1PpJKYXs9LpytP4xoUywenYTfxgQ2zbwoenN6 uARXlxRZ19OR8EeZ2hJxrGyAbVGz1PEkFO+0DC0hki1KG1y5wixg7i4AAp6T4POP9SNl LDp3yFUqG4s9zh+gryQyG3n7r8bPwnviMeH7H8O//G9SYBowUW4t8nhH4FtRzVMofnHA LRvw1A20CCFfS+2RM5aiAYh3J6xXrYRSz7XoJQuJ5G6jTBITn/lLocFEOTvWFvMEzgMY g9wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="AisNYH/7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si3957439ejg.660.2020.11.21.06.17.27; Sat, 21 Nov 2020 06:17:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="AisNYH/7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728067AbgKUOOS (ORCPT + 99 others); Sat, 21 Nov 2020 09:14:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26027 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728048AbgKUOOR (ORCPT ); Sat, 21 Nov 2020 09:14:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605968056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cts/UysbCeke0SRrY+6cxZefIvVJUV/6NiBfhTcZI1c=; b=AisNYH/7xCgNWFQlIX0gMCYrpvKq2XJYDc0K1+fs864hyt5hBiyv24yQGsgvqeUMrVNMGC CWnTllZdZwdgMJ/B1toMlTpG9Eg0VlSufeV9pfOrubnZgDJcR/8wJLWESnIV6G9jRBTBhg NR7V6TQJJqNnNbfVYIqVM/yharCNuz0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-05YIL5MQOp25jyuwwWcgug-1; Sat, 21 Nov 2020 09:14:13 -0500 X-MC-Unique: 05YIL5MQOp25jyuwwWcgug-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BD94804766; Sat, 21 Nov 2020 14:14:12 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-246.rdu2.redhat.com [10.10.112.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59C9D5C253; Sat, 21 Nov 2020 14:14:10 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 06/29] iov_iter: Split copy_mc_to_iter() From: David Howells To: Pavel Begunkov , Matthew Wilcox , Jens Axboe , Alexander Viro Cc: dhowells@redhat.com, Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 21 Nov 2020 14:14:09 +0000 Message-ID: <160596804951.154728.12388891412575059303.stgit@warthog.procyon.org.uk> In-Reply-To: <160596800145.154728.7192318545120181269.stgit@warthog.procyon.org.uk> References: <160596800145.154728.7192318545120181269.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split copy_mc_to_iter() by type. Signed-off-by: David Howells --- lib/iov_iter.c | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 0865e0b6eee9..7c1d92f7d020 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -758,7 +758,7 @@ static unsigned long copy_mc_to_page(struct page *page, size_t offset, return ret; } -static size_t copy_mc_pipe_to_iter(const void *addr, size_t bytes, +static size_t pipe_copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i) { struct pipe_inode_info *pipe = i->pipe; @@ -815,18 +815,23 @@ static size_t copy_mc_pipe_to_iter(const void *addr, size_t bytes, * Compare to copy_to_iter() where only ITER_IOVEC attempts might return * a short copy. */ -static size_t xxx_copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i) +static size_t iovec_copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i) { const char *from = addr; - unsigned long rem, curr_addr, s_addr = (unsigned long) addr; - if (unlikely(iov_iter_is_pipe(i))) - return copy_mc_pipe_to_iter(addr, bytes, i); - if (iter_is_iovec(i)) - might_fault(); - iterate_and_advance(i, bytes, v, + might_fault(); + iterate_and_advance_iovec(i, bytes, v, copyout_mc(v.iov_base, (from += v.iov_len) - v.iov_len, - v.iov_len), + v.iov_len)); + return bytes; +} + +static size_t bvec_copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i) +{ + const char *from = addr; + unsigned long rem, curr_addr, s_addr = (unsigned long) addr; + + iterate_and_advance_bvec(i, bytes, v, ({ rem = copy_mc_to_page(v.bv_page, v.bv_offset, (from += v.bv_len) - v.bv_len, v.bv_len); @@ -835,18 +840,25 @@ static size_t xxx_copy_mc_to_iter(const void *addr, size_t bytes, struct iov_ite bytes = curr_addr - s_addr - rem; return bytes; } - }), - ({ - rem = copy_mc_to_kernel(v.iov_base, (from += v.iov_len) - - v.iov_len, v.iov_len); + })) + return bytes; +} + +static size_t kvec_copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i) +{ + const char *from = addr; + unsigned long rem, curr_addr, s_addr = (unsigned long) addr; + + iterate_and_advance_kvec(i, bytes, v, ({ + rem = copy_mc_to_kernel(v.iov_base, + (from += v.iov_len) - v.iov_len, + v.iov_len); if (rem) { curr_addr = (unsigned long) from; bytes = curr_addr - s_addr - rem; return bytes; } - }) - ) - + })); return bytes; } #endif /* CONFIG_ARCH_HAS_COPY_MC */ @@ -1939,7 +1951,7 @@ static const struct iov_iter_ops iovec_iter_ops = { .copy_from_iter_flushcache = xxx_copy_from_iter_flushcache, #endif #ifdef CONFIG_ARCH_HAS_COPY_MC - .copy_mc_to_iter = xxx_copy_mc_to_iter, + .copy_mc_to_iter = iovec_copy_mc_to_iter, #endif .csum_and_copy_to_iter = xxx_csum_and_copy_to_iter, .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, @@ -1973,7 +1985,7 @@ static const struct iov_iter_ops kvec_iter_ops = { .copy_from_iter_flushcache = xxx_copy_from_iter_flushcache, #endif #ifdef CONFIG_ARCH_HAS_COPY_MC - .copy_mc_to_iter = xxx_copy_mc_to_iter, + .copy_mc_to_iter = kvec_copy_mc_to_iter, #endif .csum_and_copy_to_iter = xxx_csum_and_copy_to_iter, .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, @@ -2007,7 +2019,7 @@ static const struct iov_iter_ops bvec_iter_ops = { .copy_from_iter_flushcache = xxx_copy_from_iter_flushcache, #endif #ifdef CONFIG_ARCH_HAS_COPY_MC - .copy_mc_to_iter = xxx_copy_mc_to_iter, + .copy_mc_to_iter = bvec_copy_mc_to_iter, #endif .csum_and_copy_to_iter = xxx_csum_and_copy_to_iter, .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, @@ -2041,7 +2053,7 @@ static const struct iov_iter_ops pipe_iter_ops = { .copy_from_iter_flushcache = xxx_copy_from_iter_flushcache, #endif #ifdef CONFIG_ARCH_HAS_COPY_MC - .copy_mc_to_iter = xxx_copy_mc_to_iter, + .copy_mc_to_iter = pipe_copy_mc_to_iter, #endif .csum_and_copy_to_iter = xxx_csum_and_copy_to_iter, .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, @@ -2075,7 +2087,7 @@ static const struct iov_iter_ops discard_iter_ops = { .copy_from_iter_flushcache = xxx_copy_from_iter_flushcache, #endif #ifdef CONFIG_ARCH_HAS_COPY_MC - .copy_mc_to_iter = xxx_copy_mc_to_iter, + .copy_mc_to_iter = discard_copy_to_iter, #endif .csum_and_copy_to_iter = xxx_csum_and_copy_to_iter, .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter,