From patchwork Mon Dec 16 20:41:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13910502 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 38503E77180 for ; Mon, 16 Dec 2024 20:44:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B609E6B00AC; Mon, 16 Dec 2024 15:44:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B101E6B00B9; Mon, 16 Dec 2024 15:44:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B0EC6B00DB; Mon, 16 Dec 2024 15:44:15 -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 7EF446B00AC for ; Mon, 16 Dec 2024 15:44:15 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 37B1280143 for ; Mon, 16 Dec 2024 20:44:15 +0000 (UTC) X-FDA: 82901998746.10.5447040 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 4758D1C0004 for ; Mon, 16 Dec 2024 20:43:42 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WbPY1WpW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.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=1734381839; 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=znJAk1jLZ73zxj0xZHulmBniFwpPnzoIXjkOeZTxzgcCa84Fyvi8yZKwCOJ2MWUzDOtzo/ l7VopAEJKRyc436qSURRxkeKr7C2QiIsYD8zXNfz0fkhSd6L/G0ZYFFA/XynU9vZZht27r nu0OumIGtU6sNapCYueZqPLiveebOQ4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734381839; a=rsa-sha256; cv=none; b=rly7HCAFyDY1fNV4+XIJHyosvGSdh+kmBoouhWDb3dzlUf/sq5jUyqquWjBO55J4sO8oAI bDtk3KPoyCHWAFONzSNEu1Xz/WmRM+adMsDjMV1C9iJpK99+LmsfhU+ekYYFAMlRIeIBcf Z+sNcUotplb3Zpcfl9wcZHwrpkNEEZw= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WbPY1WpW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734381852; 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=WbPY1WpWPxoBYjBm/bKf2bnLFa6WkhEgNMxDIDP3aOBEN9jPTz1DnwM/jFyvrxOLviwK2b zoGc3obGeFYmeO5bmWE+3BH99atKPudMJJH2R7/P06FnEQZpqjfpfbarVkxd2H/yxpEHZH ShuRSnN5ZxRSsk7A1GXXBxfTHDpEGQk= 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-212-FSMi43-SNXSWMNkiuFpBFg-1; Mon, 16 Dec 2024 15:44:07 -0500 X-MC-Unique: FSMi43-SNXSWMNkiuFpBFg-1 X-Mimecast-MFC-AGG-ID: FSMi43-SNXSWMNkiuFpBFg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 54C011955F3E; Mon, 16 Dec 2024 20:44:03 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.48]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BE50F19560A2; Mon, 16 Dec 2024 20:43:57 +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 v5 20/32] afs: Make afs_init_request() get a key if not given a file Date: Mon, 16 Dec 2024 20:41:10 +0000 Message-ID: <20241216204124.3752367-21-dhowells@redhat.com> In-Reply-To: <20241216204124.3752367-1-dhowells@redhat.com> References: <20241216204124.3752367-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: tq5tq5bm3hrpusxoynwp4u3egn7jm6y7 X-Rspamd-Queue-Id: 4758D1C0004 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734381822-167637 X-HE-Meta: U2FsdGVkX1+rCyF8xg1NDFzjuqBI56EBmo5wteGlukBQlh0OFBd73f91YGxPONsvAf9NhlaqWrAkHE09poPHMDywbogltEym2Fw1pRg0fXaTY8Vlzl1oRAAaFXRqd2k4bJ6wiqeYp9vScoDlrNqzqsp317IHJrLf/EfNY1i75LN/HGyBIpcPFNv8kPOc1GqfUj6H+Nk8+Y3976nKGEIyh9Fnkm+XY8LAwmZPfQ7rcruMpxEzwH4U++AWvGJw0IMR2zoqBOeP+fNBlhINDEw/wWs2siSPDODMdL+U5yRME9cYi8OV/81mRxndMw9ehZHHUSVvZ6MWPSx4GYwNFShgskzUpOqiGsAzbbI2Q3TF6LRYmtO5J/m55N30GwhVfCBqIrOiyDtnoTdT1/bxGUy37I2aHRzUXuXYulsriaFM72ZJDbPFeh6vcyh9/6r1QehkJcija+txliT2xWjrf7V8L3wRhamoeWuC0V3gD2w5WwzTBOt35BWLBatFqew0x3With9whGfWqqVQtNC8qypARrhyfNB9/2t1mG6uqMMJA0VdOj9sfwqOM3pMc3oO4+NbGL9UEK4hlykRkYBLkHetLy3AdZsEbqAibnLiYs4GpM1EbU+7u3FN0yZ6v2tUakUCmFe8owtF0+G9CGfv3wpZVxYuu/GaV0jkiEeZOlWn0KgRSvd6Sl4KNaHXM96l3BYkZgB7hVSVwkQ5hgJ1NEAHdC+V9qiCPcf6IkyE+hEsHqLPhWI2VwqwCwjkd9//rw+XnODog16wtgUoMX0pka2gok0gdMLudSvPQUK1HBiwgJ56UZz3PhI32uviNtqnDdMtNO1DpqwYzRLPDdkjKrd7IGA0Vd/tpw/1rvUku4wyBek7t6FrGj3QLt5AV0cEEwVBKebtV+AAaKEz4G8fTw+lKwGrsAwvFG+fgnrAHeH5/pYmpU/s7clJOcda8NiJArZ5GMBQqxo9taCBfW4z1rP EzltGbcP mdHLhpoHBAY6FNssHDP4vgyLNPihaq4g3rtyXHEI0eepas+XCCE55iuhZ7Quf8sBwWhGJboiykLmG7s9QVHvOAwvg5J8ztqQqyq+FTtf5OF/cmUKCrG+F8SsG8gtYiZylCd5EJmlXAR8otZz1RqHIK3qYt5zsWwP8/NcFvzAr5pv/WbaLs0rxuXWQpnA1Gny06SlsHnsuzKhd8LPj8wt86S6NfJmO8aeKDeFRQ2V6K8hAABLnPj0a8VTR4WfGDBGqGWUaXY++ui8i0GOTrZUM+QHyk63F1gmSf74QMnaqf68pAv56qJhog4U21wxns6i09g1EhexqhZp86wPoQYRnETAaK9nfqlfylTCNfgld9YJErH7rAPzTm7rSabSbmEz68BeUNaOeQhqeYSgRYP35yidKGkvtFaox62Jj3XGLcKi8BJH7yWh1ncJSg+s0WMAljjF57cq39iRaLbXKNFRztMDtmWFcDb+9h7CnjFOwO4DnKQckJDETb8l4UOPvhdDkGPxY8BSRdY89wIRDQN7FnzeSHPVX+FkPP0Ka2J4ZQqbEpn0= 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; }