Skip to content

Commit b260431

Browse files
dhowellsbrauner
authored andcommitted
afs: Make afs_init_request() get a key if not given a file
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] cc: Marc Dionne <[email protected]> cc: [email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 49866ce commit b260431

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

fs/afs/file.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,26 @@ static int afs_symlink_read_folio(struct file *file, struct folio *folio)
372372

373373
static int afs_init_request(struct netfs_io_request *rreq, struct file *file)
374374
{
375+
struct afs_vnode *vnode = AFS_FS_I(rreq->inode);
376+
375377
if (file)
376378
rreq->netfs_priv = key_get(afs_file_key(file));
377379
rreq->rsize = 256 * 1024;
378380
rreq->wsize = 256 * 1024 * 1024;
381+
382+
switch (rreq->origin) {
383+
case NETFS_READ_SINGLE:
384+
if (!file) {
385+
struct key *key = afs_request_key(vnode->volume->cell);
386+
387+
if (IS_ERR(key))
388+
return PTR_ERR(key);
389+
rreq->netfs_priv = key;
390+
}
391+
break;
392+
default:
393+
break;
394+
}
379395
return 0;
380396
}
381397

0 commit comments

Comments
 (0)