Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: add support for LOOKUP_CACHED

io_uring always punts opens to async context, since there's no control
over whether the lookup blocks or not. Add LOOKUP_CACHED to support
just doing the fast RCU based lookups, which we know will not block. If
we can do a cached path resolution of the filename, then we don't have
to always punt lookups for a worker.

During path resolution, we always do LOOKUP_RCU first. If that fails and
we terminate LOOKUP_RCU, then fail a LOOKUP_CACHED attempt as well.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Jens Axboe and committed by
Al Viro
6c6ec2b0 ae66db45

+10
+9
fs/namei.c
··· 686 686 BUG_ON(!(nd->flags & LOOKUP_RCU)); 687 687 688 688 nd->flags &= ~LOOKUP_RCU; 689 + if (nd->flags & LOOKUP_CACHED) 690 + goto out1; 689 691 if (unlikely(!legitimize_links(nd))) 690 692 goto out1; 691 693 if (unlikely(!legitimize_path(nd, &nd->path, nd->seq))) ··· 724 722 BUG_ON(!(nd->flags & LOOKUP_RCU)); 725 723 726 724 nd->flags &= ~LOOKUP_RCU; 725 + if (nd->flags & LOOKUP_CACHED) 726 + goto out2; 727 727 if (unlikely(!legitimize_links(nd))) 728 728 goto out2; 729 729 if (unlikely(!legitimize_mnt(nd->path.mnt, nd->m_seq))) ··· 796 792 */ 797 793 if (!(nd->flags & (LOOKUP_ROOT | LOOKUP_IS_SCOPED))) 798 794 nd->root.mnt = NULL; 795 + nd->flags &= ~LOOKUP_CACHED; 799 796 if (!try_to_unlazy(nd)) 800 797 return -ECHILD; 801 798 } ··· 2208 2203 { 2209 2204 int error; 2210 2205 const char *s = nd->name->name; 2206 + 2207 + /* LOOKUP_CACHED requires RCU, ask caller to retry */ 2208 + if ((flags & (LOOKUP_RCU | LOOKUP_CACHED)) == LOOKUP_CACHED) 2209 + return ERR_PTR(-EAGAIN); 2211 2210 2212 2211 if (!*s) 2213 2212 flags &= ~LOOKUP_RCU;
+1
include/linux/namei.h
··· 46 46 #define LOOKUP_NO_XDEV 0x040000 /* No mountpoint crossing. */ 47 47 #define LOOKUP_BENEATH 0x080000 /* No escaping from starting point. */ 48 48 #define LOOKUP_IN_ROOT 0x100000 /* Treat dirfd as fs root. */ 49 + #define LOOKUP_CACHED 0x200000 /* Only do cached lookup */ 49 50 /* LOOKUP_* flags which do scope-related checks based on the dirfd. */ 50 51 #define LOOKUP_IS_SCOPED (LOOKUP_BENEATH | LOOKUP_IN_ROOT) 51 52