From patchwork Thu Nov 17 14:54:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 1835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp450307wrr; Thu, 17 Nov 2022 07:07:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5gzjI5zoLOlWVIpPmao1rYRGpXSCQt8hg2CcFE/kwde2y571739U8GFWYjcrebGx4uraN8 X-Received: by 2002:a17:906:114b:b0:7ab:1b4c:ac6e with SMTP id i11-20020a170906114b00b007ab1b4cac6emr2518427eja.669.1668697650619; Thu, 17 Nov 2022 07:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668697650; cv=none; d=google.com; s=arc-20160816; b=CPTLY4cUvRIIb+nt573SdP4FDVlj2M+c8+s7nS6hP1WvI9NAE1ikgTjj8EkrLe1BWU 9zxHn3UfKPsjPIIeAIfZRZNKmfbpTqSgm1j97eOqqRQJ81EqrHd5lSkH3ewLPKu3xOz6 kzdX4g56onKe/IBR0jsQ/YgawUmeT27ywTi8qPbOT7DhBG14Dp0NE7KqXQlS8eSi08oQ DtRzp5GRpkFPiG+TzKSjnj7+dsFa0XawXr7yYU+lB7OgEah5IiQyXAw47U3Ncpkau8jw PUKQozGJTOxwcLr43cUwbmHpI5hckuIyXnLvaFsH42PIX/gUlHsfD7+C7D1iui7Mih+m fusg== 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:message-id:date:cc:to:from:subject:dkim-signature; bh=9lCfrN2ZrVC3HhD8dAZKIdUEJSs195bbqf/UyReD6xk=; b=q3W0XBjk1WVKbo3x2/2TQuhX8qy4u9MkSUAj6M2mPPvxX4RvNpJMWCvr0G1GE1vWPP dW2yLAKTA1Pb5zeag1GWAjKmz82+1nb/d+KTSO56lAtlP1gAK/MTWbUhmqo85bvzKjEw pxT/J6RszoD18MoRYOyiH2JKqso9tPeLzYYVuXNeHHBHFjW6nJrkBn2YY0tyGbTPSG4R 0jyhrfZB9BV2OR5Xs5Xwh2dx0SERngyYSkt7jjDfPD7mtIvpl2VGwARdrIIT3VkbAlRg q4kUsUwsPPeC77vuAybQfMnCN8ANFpKgTd0Tn+8kCtLEVtDGBDfZgtmTnDHzJx78TnHW 17rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AfWj4Boi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du14-20020a17090772ce00b0078decbc3f73si870187ejc.460.2022.11.17.07.06.44; Thu, 17 Nov 2022 07:07:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AfWj4Boi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234943AbiKQOzn (ORCPT + 99 others); Thu, 17 Nov 2022 09:55:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbiKQOzi (ORCPT ); Thu, 17 Nov 2022 09:55:38 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32ADB1C40C for ; Thu, 17 Nov 2022 06:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668696884; 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; bh=9lCfrN2ZrVC3HhD8dAZKIdUEJSs195bbqf/UyReD6xk=; b=AfWj4BoieaJEZeM1nO4e4W/ymNMp00jY7CDystgOwOQYpxx033iL3qmp8nuiJjgMYldVWV /BEFlSN6PNu161Y3TvAIQefPWgNNODa92KX1wNr6KFoiYoEKAlP5EihMfKhd216jbqwuqH uPJk82Wis7/pmTSAZ8suz4umlPjFTmU= 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-435-50OXq3sqNMC63084Kb6QkQ-1; Thu, 17 Nov 2022 09:54:41 -0500 X-MC-Unique: 50OXq3sqNMC63084Kb6QkQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 42EE7862FEC; Thu, 17 Nov 2022 14:54:40 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B1DB2028E8F; Thu, 17 Nov 2022 14:54:38 +0000 (UTC) Subject: [RFC PATCH 0/4] iov_iter: Add extraction helpers From: David Howells To: Al Viro Cc: linux-cachefs@redhat.com, Matthew Wilcox , Jeff Layton , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Steve French , Shyam Prasad N , linux-cifs@vger.kernel.org, Rohith Surabattula , John Hubbard , Christoph Hellwig , dhowells@redhat.com, Christoph Hellwig , Matthew Wilcox , Jeff Layton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 17 Nov 2022 14:54:35 +0000 Message-ID: <166869687556.3723671.10061142538708346995.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749756307288508746?= X-GMAIL-MSGID: =?utf-8?q?1749756307288508746?= Hi Al, Here are four patches to provide support for extracting pages from an iov_iter, where such a thing makes sense, if you could take a look? The first couple of patches provide iov_iter general stuff: (1) Move the FOLL_* flags to linux/mm_types.h so that linux/uio.h can make use of them. (2) Add a function to list-only, get or pin pages from an iterator as a future replacement for iov_iter_get_pages*(). Pointers to the pages are placed into an array (which will get allocated if not provided) and, depending on the iterator type and direction, the pages will have a ref or a pin get on them, or left untouched (on the assumption that the caller manages their lifetime). The determination is: UBUF/IOVEC + READ -> pin UBUF/IOVEC + WRITE -> get PIPE + READ -> list-only BVEC/XARRAY -> list-only Anything else -> EFAULT It also adds a function by which the caller can determine which of "list only, get or pin" the extraction function will actually do to aid in cleaning up (returning 0, FOLL_GET or FOLL_PIN as appropriate). Then there are a couple of patches that add stuff to netfslib that I want to use there as well as in cifs: (3) Add a netfslib function to use (2) to extract pages from an ITER_IOBUF or ITER_UBUF iterator into an ITER_BVEC iterator. This will get or pin the pages as appropriate. (4) Add a netfslib function to extract pages from an iterator that's of type ITER_UBUF/IOVEC/BVEC/KVEC/XARRAY and add them to a scatterlist. The function in (2) is used for a UBUF and IOVEC iterators, so those need cleaning up afterwards. BVEC and XARRAY iterators are ungot and unpinned and may be rendered into elements that span multiple pages, for example if large folios are present. I've pushed the patches here also: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=iov-extract David Link: https://lore.kernel.org/r/166697254399.61150.1256557652599252121.stgit@warthog.procyon.org.uk/ --- David Howells (4): mm: Move FOLL_* defs to mm_types.h iov_iter: Add a function to extract a page list from an iterator netfs: Add a function to extract a UBUF or IOVEC into a BVEC iterator netfs: Add a function to extract an iterator into a scatterlist fs/netfs/Makefile | 1 + fs/netfs/iterator.c | 346 +++++++++++++++++++++++++++++++++++++++ include/linux/mm.h | 74 --------- include/linux/mm_types.h | 73 +++++++++ include/linux/netfs.h | 5 + include/linux/uio.h | 29 ++++ lib/iov_iter.c | 333 +++++++++++++++++++++++++++++++++++++ mm/vmalloc.c | 1 + 8 files changed, 788 insertions(+), 74 deletions(-) create mode 100644 fs/netfs/iterator.c