Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2023719pxb; Sat, 21 Nov 2020 06:18:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyk57NXI9rt5FbLzcfr9TuecUPNThAWhTnCk7BrQkS2zZnne8RoozvprrOz+I/wmeIVNVR5 X-Received: by 2002:a50:abe6:: with SMTP id u93mr40839183edc.277.1605968298524; Sat, 21 Nov 2020 06:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605968298; cv=none; d=google.com; s=arc-20160816; b=AmBND0yAg4qXqXwMWf8KqOYuhi5mnpRoM6hQZIU6rqalTpXV/B0cdTkL2g2ACwd7da q/Zti+jljlB1GowEx9wAv850Uyi5JT0fANMlLFiJyAYjclhRHyfTPF/7Z5OV4J5BG16C Qeq0kEU3qm3zmYOtBtJRQ5iP18vq/B9jxgelmKs9zF1bMMYw/fPHXMSEU8TDCGFaLI90 OAcEVC5jVcniDxPv1kMNK0wHbN9pi9dU2ZGpKqm5tq8hf+7+JYq4stjB///vp3MdML9Z iphf+WjQjAFFVp31caOY3OTrdsu/YWVO9LJIZt9Tb/C5bGNRNQL6dOl2uc0/iVXPPXvk roUQ== 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=24lXXSwLkr6iyJf1PKmI6Pby4jsOo+WBOkmoFqT5dpA=; b=m0URobfDAgApNzuiPu8U9lnx6kpZFFJnSMXEhMcy/Uc9kuys0KI68ptsC3UTHGoYSx DHuay1rppG7LkfQocU/X38hsvDMpQUFeAKvAuJogh05RlBxuBrbBbbdsaUHFXZgZ14U4 E6WbgPXHh62zIceVoDGsYaCjj6QIose7p/7p2A62AR8+st8k7oPa28WRtegDfatFsKYk tBknfxZMx5AsChGDbRv26F0gJ4GZh5uUA8hBu3/x59+JCu405j37Gt/4hyskn8hUCWzc pq/gHUAsnvrTT7WmEmFXujwPyNOYOHFCwZ6h9CzEoBOXhhuKonE4E2Y3bZa1i96p26xc UPkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=II+W4i72; 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 i5si3474247edg.592.2020.11.21.06.17.55; Sat, 21 Nov 2020 06:18:18 -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=II+W4i72; 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 S1728204AbgKUOPU (ORCPT + 99 others); Sat, 21 Nov 2020 09:15:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34628 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728178AbgKUOPT (ORCPT ); Sat, 21 Nov 2020 09:15:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605968117; 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=24lXXSwLkr6iyJf1PKmI6Pby4jsOo+WBOkmoFqT5dpA=; b=II+W4i72DIHr9E76INVgjoTx13UC5hEVT6fXM4BXta1lkXaocLenBGjDmFE177y/kplVMP 638r63ggOOlGWKW5NIfBCH7VrhK2q92WzpVv4Xv9Tm3pICDDdLJ0WOZQuA/IN6gc1VXOVy ogVzgwhwFpyUjvfk5zkHVudXm0qa7Oo= 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-456-sZqBLL8mPSWhZLjZCn95iQ-1; Sat, 21 Nov 2020 09:15:15 -0500 X-MC-Unique: sZqBLL8mPSWhZLjZCn95iQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C4B31005D65; Sat, 21 Nov 2020 14:15:14 +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 C6F915D6BA; Sat, 21 Nov 2020 14:15:12 +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 14/29] iov_iter: Split iov_iter_zero() 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:15:12 +0000 Message-ID: <160596811200.154728.9144901939425608415.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.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split iov_iter_zero() by type. Signed-off-by: David Howells --- lib/iov_iter.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 54029aeab3ec..9a167f53ecff 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1168,16 +1168,30 @@ static size_t pipe_zero(size_t bytes, struct iov_iter *i) return bytes; } -static size_t xxx_zero(size_t bytes, struct iov_iter *i) +static size_t iovec_zero(size_t bytes, struct iov_iter *i) { - if (unlikely(iov_iter_is_pipe(i))) - return pipe_zero(bytes, i); - iterate_and_advance(i, bytes, v, - clear_user(v.iov_base, v.iov_len), - memzero_page(v.bv_page, v.bv_offset, v.bv_len), - memset(v.iov_base, 0, v.iov_len) - ) + iterate_and_advance_iovec(i, bytes, v, + clear_user(v.iov_base, v.iov_len)); + return bytes; +} +static size_t bvec_zero(size_t bytes, struct iov_iter *i) +{ + iterate_and_advance_bvec(i, bytes, v, + memzero_page(v.bv_page, v.bv_offset, v.bv_len)); + return bytes; +} + +static size_t kvec_zero(size_t bytes, struct iov_iter *i) +{ + iterate_and_advance_kvec(i, bytes, v, + memset(v.iov_base, 0, v.iov_len)); + return bytes; +} + +static size_t discard_zero(size_t bytes, struct iov_iter *i) +{ + iterate_and_advance_discard(i, bytes); return bytes; } @@ -2054,7 +2068,7 @@ static const struct iov_iter_ops iovec_iter_ops = { .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, .csum_and_copy_from_iter_full = xxx_csum_and_copy_from_iter_full, - .zero = xxx_zero, + .zero = iovec_zero, .alignment = xxx_alignment, .gap_alignment = xxx_gap_alignment, .get_pages = xxx_get_pages, @@ -2088,7 +2102,7 @@ static const struct iov_iter_ops kvec_iter_ops = { .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, .csum_and_copy_from_iter_full = xxx_csum_and_copy_from_iter_full, - .zero = xxx_zero, + .zero = kvec_zero, .alignment = xxx_alignment, .gap_alignment = xxx_gap_alignment, .get_pages = xxx_get_pages, @@ -2122,7 +2136,7 @@ static const struct iov_iter_ops bvec_iter_ops = { .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, .csum_and_copy_from_iter_full = xxx_csum_and_copy_from_iter_full, - .zero = xxx_zero, + .zero = bvec_zero, .alignment = xxx_alignment, .gap_alignment = xxx_gap_alignment, .get_pages = xxx_get_pages, @@ -2156,7 +2170,7 @@ static const struct iov_iter_ops pipe_iter_ops = { .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, .csum_and_copy_from_iter_full = xxx_csum_and_copy_from_iter_full, - .zero = xxx_zero, + .zero = pipe_zero, .alignment = xxx_alignment, .gap_alignment = xxx_gap_alignment, .get_pages = xxx_get_pages, @@ -2190,7 +2204,7 @@ static const struct iov_iter_ops discard_iter_ops = { .csum_and_copy_from_iter = xxx_csum_and_copy_from_iter, .csum_and_copy_from_iter_full = xxx_csum_and_copy_from_iter_full, - .zero = xxx_zero, + .zero = discard_zero, .alignment = xxx_alignment, .gap_alignment = xxx_gap_alignment, .get_pages = xxx_get_pages,