From patchwork Mon Sep 25 12:03:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 144540 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1429434vqu; Mon, 25 Sep 2023 12:18:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkQbTjV1djz7sykKvrU4tDovuzxGl3p1vaGa1lNmcE0BRsJ7hBJuW5AMDW/MHLWnzL0fGD X-Received: by 2002:a05:6a20:9496:b0:15d:50c8:22d6 with SMTP id hs22-20020a056a20949600b0015d50c822d6mr7741207pzb.34.1695669522685; Mon, 25 Sep 2023 12:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695669522; cv=none; d=google.com; s=arc-20160816; b=hQc5ToPcqJcsiaFuk6/ZvJ6aa/4zdMi+k3t3P2aznWEC3nyHWFgmJkP4xMuewrnMwI GRQnMbH/Vfzzg2pmL8bSW6uVnwzyyRi4JQ63pR4Nplpt/YLVMKVdbdRfrLoayoR33x8r ldrq4Z5TeBAuv6esa8FSDmxW+GEbqLqVvxcF+xEtzBZdyKrtUKtoqtDyEeqMX8X9oICq bM3VUjyeN/XGzhv7P5GII0WRfS7Y8AlZztBJZif3kw1aYHG22CVjPd+RShb4GtvDYWHi +x7m0or/aNqdp46QljpvXM0LIY96vBvdk4TccXy+gsJZ4r/9Db7EgXiGmEiKmnOAaGTC ge6w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4obcSyEH8f0LI+hqbulIObwIk6RPpIYigX0Ml5LHEtM=; fh=dzqEI/am1IoNVOMZmTOChre3TckBGjOgtLT35fkBuy0=; b=x3RdLvSpeXrvXuqDHFHv2T8dThEvTKANFtxWFn8BZAjApTBm5qVNxopo8QP4sVTvbM TEE2vAhj3ptCqlq0+j54xfjlI3dOyDR9EtH0MmmHrD2I5SrgeM4G4Fp5K+fnXiclQfnZ JBcxdUdwqqlP/tpk6peNC+eus6eu6yNoJT8d74okvS8S9R2D+NJU0B3PrXa/0bhY0r1a bRD0Cw4xrc7IdMFYJCjmfr3PquwwCuiRkWsmf7I9PuMUefe9f9dIt9OKo6rbww9AzzRA LuttFZsnutC2XSth9M8x1Dz2HnMkmblIWFRXwdI3fotPLw+vSzOVUZUhkXwZkwEN1aaM w51Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gDctC5YI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id mw8-20020a17090b4d0800b0027728f01512si6521126pjb.167.2023.09.25.12.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 12:18:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gDctC5YI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id ADEA4809EC94; Mon, 25 Sep 2023 05:06:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjIYMFs (ORCPT + 29 others); Mon, 25 Sep 2023 08:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231586AbjIYMFc (ORCPT ); Mon, 25 Sep 2023 08:05:32 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3298410E for ; Mon, 25 Sep 2023 05:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695643417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4obcSyEH8f0LI+hqbulIObwIk6RPpIYigX0Ml5LHEtM=; b=gDctC5YITbxq4Yuw31SKhxc0+ZoejdwlUZiw8izb1s/XLjKxDsNeNuSVm6vG/gNvGXOOHZ 1JY7iNjGvrl+NQQ94HJj/wiykyHngJDf32RGQ5yH5DvcpjH9VPeAk76DFh0ys/sYk+hR0K pt+idm3O3PHC/2HgVtUF34YKWx3WFhM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-136-cDj4weHpMsW5nB2aWNtwwg-1; Mon, 25 Sep 2023 08:03:34 -0400 X-MC-Unique: cDj4weHpMsW5nB2aWNtwwg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F33E800B35; Mon, 25 Sep 2023 12:03:33 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8F8551E3; Mon, 25 Sep 2023 12:03:31 +0000 (UTC) From: David Howells To: Jens Axboe Cc: David Howells , Al Viro , Linus Torvalds , Christoph Hellwig , Christian Brauner , David Laight , Matthew Wilcox , Jeff Layton , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 06/12] iov_iter: Derive user-backedness from the iterator type Date: Mon, 25 Sep 2023 13:03:03 +0100 Message-ID: <20230925120309.1731676-7-dhowells@redhat.com> In-Reply-To: <20230925120309.1731676-1-dhowells@redhat.com> References: <20230925120309.1731676-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 25 Sep 2023 05:06:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778038365392945632 X-GMAIL-MSGID: 1778038365392945632 Use the iterator type to determine whether an iterator is user-backed or not rather than using a special flag for it. Now that ITER_UBUF and ITER_IOVEC are 0 and 1, they can be checked with a single comparison. Signed-off-by: David Howells cc: Alexander Viro cc: Jens Axboe cc: Christoph Hellwig cc: Christian Brauner cc: Matthew Wilcox cc: Linus Torvalds cc: David Laight cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- include/linux/uio.h | 4 +--- lib/iov_iter.c | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/linux/uio.h b/include/linux/uio.h index bef8e56aa45c..65d9143f83c8 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -43,7 +43,6 @@ struct iov_iter { bool copy_mc; bool nofault; bool data_source; - bool user_backed; size_t iov_offset; /* * Hack alert: overlay ubuf_iovec with iovec + count, so @@ -140,7 +139,7 @@ static inline unsigned char iov_iter_rw(const struct iov_iter *i) static inline bool user_backed_iter(const struct iov_iter *i) { - return i->user_backed; + return iter_is_ubuf(i) || iter_is_iovec(i); } /* @@ -380,7 +379,6 @@ static inline void iov_iter_ubuf(struct iov_iter *i, unsigned int direction, *i = (struct iov_iter) { .iter_type = ITER_UBUF, .copy_mc = false, - .user_backed = true, .data_source = direction, .ubuf = buf, .count = count, diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 27234a820eeb..227c9f536b94 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -290,7 +290,6 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction, .iter_type = ITER_IOVEC, .copy_mc = false, .nofault = false, - .user_backed = true, .data_source = direction, .__iov = iov, .nr_segs = nr_segs,