From patchwork Thu Dec 7 21:21:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13484035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A92AC4167B for ; Thu, 7 Dec 2023 21:23:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EC826B00A0; Thu, 7 Dec 2023 16:23:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 274C76B00A1; Thu, 7 Dec 2023 16:23:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1159D6B00A2; Thu, 7 Dec 2023 16:23:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EACD36B00A0 for ; Thu, 7 Dec 2023 16:23:11 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C2C90120265 for ; Thu, 7 Dec 2023 21:23:11 +0000 (UTC) X-FDA: 81541297782.21.5B3E598 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id D996F1A0014 for ; Thu, 7 Dec 2023 21:23:09 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PNa688uo; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701984190; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TyeDCrkCzlrF45NKmRnzOuDvS9hPtHcwk1ZYplID5CE=; b=tfXg/X1SezEOu6v7czPWDAJohSk7pkTIzq511XyRcAWAQDqN2JTGQcRkzcdD0xsykgbx4k CMeV2cQA+tQOcInPrCEFzGLiysv8ewT8AJ1jui/wtSUddk5PsvzEGOnNFEk7exIbSfSBw4 xkgT2ezeHFFSZGJC8ufR+PFW6mg8xt0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701984190; a=rsa-sha256; cv=none; b=6eYrrL7xbyl2dm+ybQOYZ9LTmXHCkxqXTRWbhXIAIFjbOv4/yqfe4VMFNEpf+DzbamjL7Y OfG2Uhsl0vZPNAUBTq9L35N+pgai6Z2nzjOurYwPfpcnnoGYT8KUnMS5o2tQkluvF623ge etbs8EHuGfobLDEPp70jruwNJPJhQ3k= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PNa688uo; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701984189; 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=TyeDCrkCzlrF45NKmRnzOuDvS9hPtHcwk1ZYplID5CE=; b=PNa688uodZLuUwDsEQOJkENSC5cFIjCW+MAtB2oXnOLvgufJ0OuMNHdLhq7ygkHZ3q/HgN twSWWidM5By8T1E4Mct4JgnXGCjrkIpapgXzVBdk3QpYbs/oncCnRgs46IEB5og2U/dNkH WbNN0+7zEjORRgtLWx5F+nJwq7/Q7mE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-tekyEpVMNmyWOXzplX7Log-1; Thu, 07 Dec 2023 16:23:05 -0500 X-MC-Unique: tekyEpVMNmyWOXzplX7Log-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55B0985A58C; Thu, 7 Dec 2023 21:23:04 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3B7F492C29; Thu, 7 Dec 2023 21:22:59 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Dominique Martinet , Eric Van Hensbergen , Ilya Dryomov , Christian Brauner , linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 15/59] netfs: Add bounce buffering support Date: Thu, 7 Dec 2023 21:21:22 +0000 Message-ID: <20231207212206.1379128-16-dhowells@redhat.com> In-Reply-To: <20231207212206.1379128-1-dhowells@redhat.com> References: <20231207212206.1379128-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Rspamd-Queue-Id: D996F1A0014 X-Rspam-User: X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cLHoApNihUvIjZdUW5+Inih+Cp8W6LkQhLcSfBugS6Yh9VelO7FnXsFh+tGXd20jdnrIkFaKT3PKIJe6nSlixykfCzyz73zIwyeeFfXTQjcqSlw8lVZiqWH+9INhFyU6BV5nDK3gw2U3FgX6WKVwKfCUjwLExyzOrA+5s6Beu0VRu5zhaIYp6XfKaOeQS+fsMWXAtsYB2yVetaTHKA/L76RTERO8kUuELCIqEuaFn3/gs1+L8Uo5PxV88lJeGnBGzkDFMU005PbEhGGBKndAcnPs3n+vO7sP3rV+MZCd/NU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a second xarray struct to netfs_io_request for the purposes of holding a bounce buffer for when we have to deal with encrypted/compressed data or if we have to up/download data in blocks larger than we were asked for. Signed-off-by: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/io.c | 6 +++++- fs/netfs/objects.c | 3 +++ include/linux/netfs.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/netfs/io.c b/fs/netfs/io.c index e9d408e211b8..d8e9cd6ce338 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -643,7 +643,11 @@ int netfs_begin_read(struct netfs_io_request *rreq, bool sync) return -EIO; } - rreq->io_iter = rreq->iter; + if (test_bit(NETFS_RREQ_USE_BOUNCE_BUFFER, &rreq->flags)) + iov_iter_xarray(&rreq->io_iter, ITER_DEST, &rreq->bounce, + rreq->start, rreq->len); + else + rreq->io_iter = rreq->iter; INIT_WORK(&rreq->work, netfs_rreq_work); diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index 4df5e5eeada6..9f3f33c93317 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -35,12 +35,14 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, rreq->inode = inode; rreq->i_size = i_size_read(inode); rreq->debug_id = atomic_inc_return(&debug_ids); + xa_init(&rreq->bounce); INIT_LIST_HEAD(&rreq->subrequests); refcount_set(&rreq->ref, 1); __set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags); if (rreq->netfs_ops->init_request) { ret = rreq->netfs_ops->init_request(rreq, file); if (ret < 0) { + xa_destroy(&rreq->bounce); kfree(rreq); return ERR_PTR(ret); } @@ -94,6 +96,7 @@ static void netfs_free_request(struct work_struct *work) } kvfree(rreq->direct_bv); } + netfs_clear_buffer(&rreq->bounce); kfree_rcu(rreq, rcu); netfs_stat_d(&netfs_n_rh_rreq); } diff --git a/include/linux/netfs.h b/include/linux/netfs.h index c05150f51beb..8a5b8e7bc358 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -194,6 +194,7 @@ struct netfs_io_request { struct iov_iter iter; /* Unencrypted-side iterator */ struct iov_iter io_iter; /* I/O (Encrypted-side) iterator */ void *netfs_priv; /* Private data for the netfs */ + struct xarray bounce; /* Bounce buffer (eg. for crypto/compression) */ struct bio_vec *direct_bv /* DIO buffer list (when handling iovec-iter) */ __counted_by(direct_bv_count); unsigned int direct_bv_count; /* Number of elements in direct_bv[] */ @@ -216,6 +217,7 @@ struct netfs_io_request { #define NETFS_RREQ_DONT_UNLOCK_FOLIOS 3 /* Don't unlock the folios on completion */ #define NETFS_RREQ_FAILED 4 /* The request failed */ #define NETFS_RREQ_IN_PROGRESS 5 /* Unlocked when the request completes */ +#define NETFS_RREQ_USE_BOUNCE_BUFFER 6 /* Use bounce buffer */ const struct netfs_request_ops *netfs_ops; };