From patchwork Fri Nov 17 21:15: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: 13459381 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 E482EC5AE4A for ; Fri, 17 Nov 2023 21:16:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 757588D0016; Fri, 17 Nov 2023 16:16:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 707B48D0012; Fri, 17 Nov 2023 16:16:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 582078D0016; Fri, 17 Nov 2023 16:16:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 45DB38D0012 for ; Fri, 17 Nov 2023 16:16:33 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1DD8E1CB1AB for ; Fri, 17 Nov 2023 21:16:33 +0000 (UTC) X-FDA: 81468705066.26.52ED1D7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 757B780012 for ; Fri, 17 Nov 2023 21:16:31 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZBWIxiEj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700255791; 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=k3JiidRzkKBvkLp798rxmXLVnzVJoyLEMATfdNMMsEo=; b=5nOPbKOJ3YSWTe1Aa6emJunxBd08XN2WwE0ir0jBkSxU8waSReHv4dGUvbgtB0/Z56vxsN YX7XRg/hMMce2SAh8AQoiaVgqKhQ5dcR3+uzLITYzO86Bb63X+gCH4Mbtpq/0her22COVZ cnFcLO9jqFYui5bx6f5PX8DbkcuWfG0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZBWIxiEj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700255791; a=rsa-sha256; cv=none; b=qPSM4dseSYxVYpf1dmd0NDVVotmUI6/It4NuCg01dKG4QeMNTdW3KlUuLTsOm1mRuO1dpK viCK6tGOs6d/NYoHL0qg2uMDiVqK9UqqPJzuS9vKONVXowatNMPesKTop3uiLCNsrs58BQ Uik33Wg1c6vwOLPy1lxPU3Ye4Z94zh8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700255790; 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=k3JiidRzkKBvkLp798rxmXLVnzVJoyLEMATfdNMMsEo=; b=ZBWIxiEjuK7Kp+wWTCkyszX/d9uUyU4AkAJZToY4a1rHfuP8m1mP1uJjRcnfUUkY8mkpN/ 43P55sOKjke5J3+HGI1xEze2+tun2FHxBvnnEw3QMmdxKwjlmAxOC44vHvlxRomfOHYpQU t6E3KOlD/8ZW6+z6WCafw45dwEsfHNs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-bttf1UYjO3iFrszJ99mhvQ-1; Fri, 17 Nov 2023 16:16:27 -0500 X-MC-Unique: bttf1UYjO3iFrszJ99mhvQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 749A628040B3; Fri, 17 Nov 2023 21:16:26 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE580C15881; Fri, 17 Nov 2023 21:16:23 +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 , 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 v2 11/51] netfs: Add bounce buffering support Date: Fri, 17 Nov 2023 21:15:03 +0000 Message-ID: <20231117211544.1740466-12-dhowells@redhat.com> In-Reply-To: <20231117211544.1740466-1-dhowells@redhat.com> References: <20231117211544.1740466-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Queue-Id: 757B780012 X-Rspam-User: X-Rspamd-Server: rspam02 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IMn0GKlBUE82mAUB4+NZ+DI2XSQTp4IRD46TfkrmYXz7V2JD5EMGxTrMhz2I8JCwsP1m9sy7QHZQ5CJN65zxizJ+ryCE8sdRF22/CD5a+wPaebq7KiqWCK6H0jmBsGoonTKGHH3vulWJP32bfHd6WUtROssYSzgBtmlTMqLGpxpSBSIGZgkddlitZbkYkjyroRCtqp3c9MtScyzX+zgIdF0aN1F1zRCXkTZLtjYHG7tKokD67qZL0ilsJHovZNORFV9nNHMWbu+li3s= 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 47270f5d9e89..0bc90c4035a2 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -196,6 +196,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[] */ @@ -218,6 +219,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; };