Message ID | 20231207212206.1379128-40-dhowells@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 3A88AC10DCE for <linux-mm@archiver.kernel.org>; Thu, 7 Dec 2023 21:24:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C62346B00C7; Thu, 7 Dec 2023 16:24:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C10FD6B00C8; Thu, 7 Dec 2023 16:24:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8E876B00C9; Thu, 7 Dec 2023 16:24:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 92EC86B00C7 for <linux-mm@kvack.org>; Thu, 7 Dec 2023 16:24:34 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 702571A01F5 for <linux-mm@kvack.org>; Thu, 7 Dec 2023 21:24:34 +0000 (UTC) X-FDA: 81541301268.21.D774C5B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id ABCF52001A for <linux-mm@kvack.org>; Thu, 7 Dec 2023 21:24:32 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X1gVWpgi; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1701984272; 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=5weY3TAEZXAYDCmBDEVYygYM1kFM1iNPdRbIVf5ORpg=; b=AcCaVD2Kd973tRgeM5VqlHFeoZIyD9EHcGM8nZ9RUDHDT5lhVsu+GK5XBacbj+8q3M9LnY /WBiPtuKKxnHWlAFNaQzxL6yGdXUEZwD7EnPyA3ZScsafUfOo99AHObW5BJx9VoJcELCw0 BN4MyL568DRg85/2A4HbRgXTeEzNnXk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X1gVWpgi; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701984272; a=rsa-sha256; cv=none; b=kkbp4eg9EYjibdYYVXN+1PM3Hy34wW6VYClc/VhMgiDOs9bmzdIiWvb+837zH/k/fRyrC4 Suz4l1ibTUFb1Y6l5iVaDQ5cmThAXBnpBBF9W2tRrD9QKOu9MsRxa7iP7IaoQFmROINUp9 nSGhQxLhm++ZTaIBg7PqpTqJcjDJLiE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701984271; 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=5weY3TAEZXAYDCmBDEVYygYM1kFM1iNPdRbIVf5ORpg=; b=X1gVWpgibeqsPSEu4QBGk0Sq1toyysbNyUYGuZ2D+kUCJWXk+CYpu4/lxzefaDBnPd3IyY Ikdn04AeNoIvTyHkcuV1Tf1L/W5jk1aRQ4udRsBN7SFBqAET0oJUvA3nu0gI/XB6f46eJk J6dWoT8ZxPEWaoXqNR1spTPCn2fqFK0= 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-641-qyXwTIyJO_uXXDNIGmcfsw-1; Thu, 07 Dec 2023 16:24:26 -0500 X-MC-Unique: qyXwTIyJO_uXXDNIGmcfsw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 A05CA870820; Thu, 7 Dec 2023 21:24:25 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id 096233C2E; Thu, 7 Dec 2023 21:24:22 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: Jeff Layton <jlayton@kernel.org>, Steve French <smfrench@gmail.com> Cc: David Howells <dhowells@redhat.com>, Matthew Wilcox <willy@infradead.org>, Marc Dionne <marc.dionne@auristor.com>, Paulo Alcantara <pc@manguebit.com>, Shyam Prasad N <sprasad@microsoft.com>, Tom Talpey <tom@talpey.com>, Dominique Martinet <asmadeus@codewreck.org>, Eric Van Hensbergen <ericvh@kernel.org>, Ilya Dryomov <idryomov@gmail.com>, Christian Brauner <christian@brauner.io>, 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 39/59] netfs: Support decryption on ubuffered/DIO read Date: Thu, 7 Dec 2023 21:21:46 +0000 Message-ID: <20231207212206.1379128-40-dhowells@redhat.com> In-Reply-To: <20231207212206.1379128-1-dhowells@redhat.com> References: <20231207212206.1379128-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Rspamd-Queue-Id: ABCF52001A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 478y51i1aab68xfweeh6wc4mtjq9ojsd X-HE-Tag: 1701984272-975629 X-HE-Meta: U2FsdGVkX18aN13ji+TNlWMCumFIQOv2jxGAowdlPhnv/dRToNCTkCTBt0eaWIcE0OYF4RxJI9P4wOOWMDGWiFnof3mOdyWm1+exx3bIg6zzGEhQXxM+jVOrNNBUcr+is00dHZaogX+r3YsPUxorfKN1pYr8S9IjLrxD8q/9Lkf4sIbDnDstf7SRCDfHc/R5hiQ+dZ3WAvQUZdBkGcndbaQ8eNizawIR4HitumaDw26Aw8XV9UfryDynNe/mZvXB/0oNLM8CvNmcctwhZlakV9EMTf8G5gm1mMaDlnZoLBNaZRtuL51S975Y3c87v7quoeYJP5zLgkvigIbjmdS0XTDrzpn9cZWX+4qwCWu15uC34PV4J7OSsmBM9DSMn0aTXgFzzuy+wDlsP8hM32zytErBcrkmB2cqUc9ubRvdbBBhLuYQu9pBkDpYMzVXECTlYw1y+Nu20Uy9nxrZUYgeehEwdAu3orBkjSU3K/p/N1Gr9Fcaxl3zZmidk7fxxZqvxYCwTZpdZJl5BQBJKAj0EMCX/v51RCIDuwIxdCibttxDQZOyzRDmwkaZDSGQE5O4qpWjcXgzBSJA0AsrF2+dJCfFV+d3HEeqMUTBZJTceCBmxiHtspMjbhE1KxnHX6uEht+TeexFgyw8iyf+lVwGF26v5sFVS5QNwOntP/9lFhQQ78NZ82M7Wt9FdAxztYQNGUVBwYDY2U4eQ3BBRlo3wvNGoGEjWcu/VPuFm2nNJuJCMTpbO45Pr4SOmZ9AWUCNTBo/pX24ZdYMjx/AvQzJ3sC9RbEJTx3gHn15wVxGwLEgHgtydEXw/rAZ27oLc2ZOfzwa2nIUGXsXjF9cTI1KFFEfaXbStLG3H1RY9AB4NpdL4e04bl3fiZGS7s66sD2NYUccvYvMcLtta07ncG9CvX0wqPDQV4En9sppnC0ahC3x1KR0m94cMDCadWeOh/lx5SyP7MzZ56BKMZrQpB9 WDf+H99/ iVYCzISqu8MxziIUNMQg5V2LR36lpHU8kRH4N6MtYpvWnGnzPoQwrs8cC/VRXiS2+0UgKcy6Ei0UWFQoNE1WFcsUBBs9PYdI0DZBBe1PmmsliG+g/GyphFi29KKD0WRzIaMoCtJOx/D/aP6S6xF75fKcjdTLByYv4+Ou9jcML8zMraD8xX3lhZ+V+z5gMvpr17i94JBw0AQEJsVN77OtVqPbOIXFC6EFP8vIMsDTk7Y8A4Ibei52LplWTgSM8OtyYYq8Avj/nzxx99hbVSzG1+4/BOoPsF9WNe26619jI2TCQV00= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
netfs, afs, 9p, cifs: Delegate high-level I/O to netfslib
|
expand
|
diff --git a/fs/netfs/direct_read.c b/fs/netfs/direct_read.c index 52ad8fa66dd5..158719b56900 100644 --- a/fs/netfs/direct_read.c +++ b/fs/netfs/direct_read.c @@ -181,6 +181,16 @@ static ssize_t netfs_unbuffered_read_iter_locked(struct kiocb *iocb, struct iov_ iov_iter_advance(iter, orig_count); } + /* If we're going to do decryption or decompression, we're going to + * need a bounce buffer - and if the data is misaligned for the crypto + * algorithm, we decrypt in place and then copy. + */ + if (test_bit(NETFS_RREQ_CONTENT_ENCRYPTION, &rreq->flags)) { + if (!netfs_is_crypto_aligned(rreq, iter)) + __set_bit(NETFS_RREQ_CRYPT_IN_PLACE, &rreq->flags); + __set_bit(NETFS_RREQ_USE_BOUNCE_BUFFER, &rreq->flags); + } + /* If we're going to use a bounce buffer, we need to set it up. We * will then need to pad the request out to the minimum block size. */ diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h index b6c142ef996a..7180e2931189 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -198,6 +198,23 @@ static inline void netfs_put_group_many(struct netfs_group *netfs_group, int nr) netfs_group->free(netfs_group); } +/* + * Check to see if a buffer aligns with the crypto unit block size. If it + * doesn't the crypto layer is going to copy all the data - in which case + * relying on the crypto op for a free copy is pointless. + */ +static inline bool netfs_is_crypto_aligned(struct netfs_io_request *rreq, + struct iov_iter *iter) +{ + struct netfs_inode *ctx = netfs_inode(rreq->inode); + unsigned long align, mask = (1UL << ctx->min_bshift) - 1; + + if (!ctx->min_bshift) + return true; + align = iov_iter_alignment(iter); + return (align & mask) == 0; +} + /* * fscache-cache.c */
Support unbuffered and direct I/O reads from an encrypted file. This may require making a larger read than is required into a bounce buffer and copying out the required bits. We don't decrypt in-place in the user buffer lest userspace interfere and muck up the decryption. Signed-off-by: David Howells <dhowells@redhat.com> cc: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/direct_read.c | 10 ++++++++++ fs/netfs/internal.h | 17 +++++++++++++++++ 2 files changed, 27 insertions(+)