From patchwork Wed Nov 6 12:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13864790 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 CD230D44D58 for ; Wed, 6 Nov 2024 12:39:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66DF96B00AB; Wed, 6 Nov 2024 07:39:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 61CF76B00BA; Wed, 6 Nov 2024 07:39:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BDF46B00CA; Wed, 6 Nov 2024 07:39:06 -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 2717E6B00AB for ; Wed, 6 Nov 2024 07:39:06 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D1B0DADCD3 for ; Wed, 6 Nov 2024 12:39:05 +0000 (UTC) X-FDA: 82755623496.08.5005C0E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 2DB2D140011 for ; Wed, 6 Nov 2024 12:38:40 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UhRLgZpb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1730896620; a=rsa-sha256; cv=none; b=m96TkXDiEsyIIZucdjILHNjfznN2lPoNCd9EA+FJbEpMWOFjCPN1hmHpnt0EfN+XciEeLH eOefw664RhxB8oqwHYTN25HhAwWmtfznJMcG03v+agHHTzlzKhA/Ch5AuuPN9Ncrmym2a+ xfp3xcsCkyJQWW0fgo6IwW/qxQEQO8o= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UhRLgZpb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1730896620; 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=u3/1sOVuQqHpfo8UyVSOFEz4LX0EnJcfMGVnlE5mJ3g=; b=JDa2Yckin727k4sI1YfyeJy8oJUX+HnlB5KBiuKme++NKlIdz94mAQMNSqrfKt8+zyF69z oH1YHgDvzF0uwQtUfgLkfPd3JiaszCyPdcQ4hBbGkEiAIDcpyLqtjjeEh2rDhd5ZB5koEX OUE7+rcUrz2dsZH9/GSNLuahX9yxuVE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730896743; 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=u3/1sOVuQqHpfo8UyVSOFEz4LX0EnJcfMGVnlE5mJ3g=; b=UhRLgZpbGKNfQjSkcgOPa93WaauMq4tg8AoR39m75SfznzAxiyvhYaF4RJ9pIF1pMoEaYV dba+ZegntTD/5OIy3UOULHnGUqlzqKMcM9WEcSMnq8hwyeHm8o9aau1RTXQEgJF85g4CPS 1n9Q0sN3HCx2RjrViSccM20DxGjrmjo= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-zIalLRNpOfSaC24x3As0zw-1; Wed, 06 Nov 2024 07:38:58 -0500 X-MC-Unique: zIalLRNpOfSaC24x3As0zw-1 X-Mimecast-MFC-AGG-ID: zIalLRNpOfSaC24x3As0zw Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 26C951955D50; Wed, 6 Nov 2024 12:38:54 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.231]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9BB6119541A5; Wed, 6 Nov 2024 12:38:48 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, 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-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 22/33] afs: Make afs_init_request() get a key if not given a file Date: Wed, 6 Nov 2024 12:35:46 +0000 Message-ID: <20241106123559.724888-23-dhowells@redhat.com> In-Reply-To: <20241106123559.724888-1-dhowells@redhat.com> References: <20241106123559.724888-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspamd-Queue-Id: 2DB2D140011 X-Stat-Signature: pwcx76zkjjrb87rtwhnrbu39e33m9nzt X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1730896720-238265 X-HE-Meta: U2FsdGVkX1/cY5036bsnkvcZgPohCsTmjyo3Un4djILKc9kE7b2otVNYdOICWLxWp+WRUzTAjsjRgHiYLjY5gk2WRu6+ss7Uu0Q/frKhc4BVd6t7YfP8pi78BjS3QiSHZqDQ/u1AT+Bhj/Ocojpjrnke0X003+oOkHeIhetsgBLRFMj3zMRhI/zA/LQcyls2xFZdUZTh9DEgSL/FRW0+Xps8tDK/tOY7gO2VX2hV0JhcIrJWqEZz/CIbd6t+SRmVUO3+PxCYQ4Id3zkOt4kyi9FRORFSPz7B4ZS+Vi09SRomBmjgzC2MpFAjiOnQy4TkoGPtSH6RODp3Zu93tec069O9eIthhmLHI4cDvPuljxSaVYwuZmo9nMf1gRlA+VTSMH9CfhJlLH+n3wPwZVKB8Gpod1oUkvUXjXlfOGKW8va3fliQ/8Id29gU7m5uySh7XLgkQjyAmM1C+j5wtYKjCxiy686D4HrF7WBDgJL32GJ0wyykVeT+XHyuvXMze/KGkPnQQN+ggs732NJoLyoILWgw42GkaMOpXM0DxtavhbkYNbQsi4m1uc/j4yz6U53ElDn8qBGOzzD68H/1JdCie3EjJYe0gZhK84re1IgHl+AGNS+DrthPVaGudK/AEZeg6LWebAYlDsWmc/99dQKHu0N//T1YSfaFzLIpQfojPS8gpkjn+hLS8YifZ65c8K/8HaAePcDE3yvOuQEfQblqQfG6pq15eD0YorOaojoTRA2uTY+tYfXd2Jn+3koko1KYZK8Axm+aMtgbeDqQino3bVtYyuTLI2gdzOuoTLpyXYUPOJxD2XL/UjxdaWz4ZwJ+dBQBhKCUVY8peGl1D9dFxeH6sI7hO4lt5OkRIAGFi6pOsCaD6AkP9xbWUqbm09vFPgqWuYDV28PYm5TWMiIJlOm2dkqzQeHHVbxoApFEl58l5yCgk399iXnY+UkO5A0mJsCxACblsRVXInRZW1m 7U2MiVrZ 1VLf63el7iGMaRw10JZI4aEIP0Cd6c/jY5iNM/zjr1d5PCtPjCwLOSBwZAYMsflIFdm7SO7GyML2y/1w3ZC3IC1CUb9aiV67MZGiE/LMzhTdXADfFu4GKMQs/ZKF+U0zuLdDmHxmKS7yWLMtZeu6U+8ZzdO5HfoIokQPN1GaNM6/hm2SoduHAAtVHTm57aXylxoxmE49U4QVunU44xjhvIcqm2IV29yhZ4wE3yCLTqAjV+Ubqyy2KhC9eVur0VJ0jPMfRMBh79io9M/zQEnGCPnhQ0FKNPLeJSr+fl31d7OI9BNNEq5uPOSyRu0nXWAXapz2y6LmaQAB7ihcNMi+BGV/Lb0PjWfH80CJTgvGvjVPCKDMZ12LHg2hg79blyndYCk6xJc873gUC1Dv6APe8LBeanzNa1RrUI6rZFA/d/FclgAmWximIL1WONDNfrU1TR+V3vq6xDE0kPZjLr4I5HxhZx/1JRi+CqBL7ahHwtpiIY8h1V5TsufFfwvCT80LorlmwBw7W27Hm6ZgASlAXDsPi0wWuNFhA02J5sCBsFB2smbCm0k3GIdYZ1LVReQwgDbOA+llxTwMMbCiiifvYMjIQ8A== 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: In a future patch, AFS directory caching will go through netfslib and this will involve, at times, running on behalf of ->lookup(), which doesn't provide us with a file from which we can get an authentication key. If a file isn't provided, make afs_init_request() get a key from the process's keyrings instead when setting up a read. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/file.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/afs/file.c b/fs/afs/file.c index f717168da4ab..a9d98d18407c 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -372,10 +372,26 @@ static int afs_symlink_read_folio(struct file *file, struct folio *folio) static int afs_init_request(struct netfs_io_request *rreq, struct file *file) { + struct afs_vnode *vnode = AFS_FS_I(rreq->inode); + if (file) rreq->netfs_priv = key_get(afs_file_key(file)); rreq->rsize = 256 * 1024; rreq->wsize = 256 * 1024 * 1024; + + switch (rreq->origin) { + case NETFS_READ_SINGLE: + if (!file) { + struct key *key = afs_request_key(vnode->volume->cell); + + if (IS_ERR(key)) + return PTR_ERR(key); + rreq->netfs_priv = key; + } + break; + default: + break; + } return 0; }