From patchwork Thu Oct 24 14:05:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13849279 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 9F23CCE8E7A for ; Thu, 24 Oct 2024 14:08:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F0186B009C; Thu, 24 Oct 2024 10:08:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A1076B00AE; Thu, 24 Oct 2024 10:08:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11AAA6B00AD; Thu, 24 Oct 2024 10:08:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DC4DB8D0003 for ; Thu, 24 Oct 2024 10:08:44 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BEECDC0C95 for ; Thu, 24 Oct 2024 14:08:24 +0000 (UTC) X-FDA: 82708676400.14.7B4C291 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 33958C0027 for ; Thu, 24 Oct 2024 14:08:19 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P6jLtIXB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.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=1729778810; a=rsa-sha256; cv=none; b=VPHcogCH7ekrcorwFHikiKlZ6CkpZsm8d6Ln+Ir4c9dtkjrEZ3nFClB2lw1SndEHVqMO/6 tqL7zQgigR8JdHasC4IyGCwutvsEUeXKm4vCfTTNo/ha58/N7teYJ9mJ02C1wmyrLunH9E ZBmLdCeQsyx4O+QXc/g0KJKGCINaBjg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P6jLtIXB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.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=1729778810; 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=wtHva+d4WNXS6cmRMPmY20pQBxnNvjfNzYFeUJedmTknoqlRpET/Y6U5kYdyYPviNZCFWP M0mCC7iXfs1/usuJQtJp7CmQ9IlSdOfMGbkvFYnu59XyrGt02KVoTImOKHAFQLRcZysoAt ql26OV50zNGXabaDw64HyyMa/RICP0c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729778922; 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=P6jLtIXBDEiiSUep4V/dEnf0Bv+N598UTLBYPYReLO0llf007cAnaxjdML0qw7tYZbsfAF g6LFXFvXfEU+ufncHo3j8MBA+xh+EfPGKxFfBy552eZXEWdt+u2uQecy7qO6Ppzi2AaoHS m6pzzrPy6/+BqRRgihKddeVI4Dw5Gco= Received: from mx-prod-mc-03.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-400-s2xcwJiqNh2AsSay-NhpDA-1; Thu, 24 Oct 2024 10:08:35 -0400 X-MC-Unique: s2xcwJiqNh2AsSay-NhpDA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 768DE1955BC7; Thu, 24 Oct 2024 14:08:32 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.231]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E2EBB1955F43; Thu, 24 Oct 2024 14:08:26 +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 21/27] afs: Make afs_init_request() get a key if not given a file Date: Thu, 24 Oct 2024 15:05:19 +0100 Message-ID: <20241024140539.3828093-22-dhowells@redhat.com> In-Reply-To: <20241024140539.3828093-1-dhowells@redhat.com> References: <20241024140539.3828093-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Queue-Id: 33958C0027 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ybspduzawur8az8n5pkakrdmdbzn6ekk X-HE-Tag: 1729778899-672519 X-HE-Meta: U2FsdGVkX1+aQadMTTV8T4+dGjmUYageh/Jf+HbvZF07WQMhJHVbAxkWWgDeOqkteTPwz6YNHrNp6rTTG4esd4v2Xrt0EuLos8sJGkTKtnFa2oVhvEFE4tm+RoqvMf1yNBTQ6nOfGt9K908DtvLOAef7QJ14nrI/IZbQq9AckX0Vz7yHLRjwbuDl7jgNQCMn5Vb5jvEkOfWYZguRK+mmFuixQcTiNCRKkZFFyxIL37ccx5fLNYaZAI8vkxNCdYzJ1Dfc3iShDYTL+KcKicJxpiffMpw2rYovJbrn6QCDAQ+ObUKIM0uutgfl+8HM2enRKZxAr0OqUx2/agj5hJY5KFtGuA7nRx8rgWKyAUfAusq8qJ62Lu/ZN+bHfVLOZ6mRa6BYVOohIpApcGeZMpw9mezsdJq8S24cvRMpmhPZb5sBleYM+prjs+4QijxsGfe396CQfJupjOt19ULxCu9BDyClMBVL6J8B9QTzNXSPb9ciNva+md59E3YAd1YZaKKcRQ0Ak3zKCR9U5hfWbuBKM87Fz0t2a8YH4TGdgCzqiIganOvxdnZ6Gzzn77p98k8dUFP1gb+BQgz+Hhe3L3gSNDrLmRWxEzkoHMpPHXGJP9YmBvpTm2f27IXYrC8hrg1qJM//vEs1I8ADzmSL04OBeiwGiJWxG2yOCOmkWKp4MXwHMckGK9i+X8+IKjuW/qOa0DWceV8pr9OKuiMfu8GWBS+0mfbP6CVl1U+3DAZm3aSdoL7ip1gtHVxEkCvnqwYTpknRd/kuW2nvzPOmfpCnt8VpMgJZBmqh4nIovLIGNhE9+xOCzdgGE5uiiKFojjsV802qgSQPCoM2fpJw5J+uMJDx5/0H3lnQj8KRyeY4xLZZ2J4lIm+7h7ex1GxA3c9dUVpsmv4k4uKZw5mJ4JuamZff+0nhWKHiCX8S73bKKZi1dMrNF4Gll3HuFPUhCikBjqMrXqsDODnLUCQeu3b kiVXkV76 M334u10iSAED1mWCZIeQR/wiROvh+rNjWQb1muoQcK7XiFK0cZGjYRSoNcZeTJbjSC1cZau3QJOwk7QZPFDD6nBcpOJReCqkNnoSpJhSTn1R2to9sA5eCLn9OPmnmWFM1hAkk9q273meSW50Kt6d13EL9TSTZm2nsLNcb3NQl+q2lTSzOdMOvIHMkA2DVBCiA59fGqiazhV7cztjOAy7lF/9raDZmtvBIxrtm1ZmNxBIlTBrVwZdLmjhWrkuPrvw9tcG7GexxPMSrQXDzJE3dEvlhFHx4Aeq+Qlf9JnDA+IE4KG90eQj82Fj9R5oKXl+VatO2B/1GyFhTelB1gHuifl7apsVyy+uxnCJkrkZOnMvm4K+z338M5ENvsDWuDIoKQjZK3U8842eFmu+fzr6x6gsYM0zYSjOOy9WCA+ibLbXUhft5NLg2S9HAPD2pTUjn4qZN805g1cG+tUXtKoh4+pqOgYyknRxlWXPq68ux4wvsSeBokaKyHDkWhLJ/aRCafUIiMF0yNSNl3Rs= 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; }