aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-01-01 02:25:19 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-01-03 06:50:06 +0000
commit7220a10b5b343f0528612c62072f80458076a061 (patch)
tree1dc04a36aaea809b0461ee7e565f5e9b269c1eba
parent30a2fc91fa5a0fa8717da788cc18073cca786c05 (diff)
downloadsrc-7220a10b5b343f0528612c62072f80458076a061.tar.gz
src-7220a10b5b343f0528612c62072f80458076a061.zip
cache: predict on no spurious slashes in cache_fpl_handle_root
This is a step towards speculatively not handling them.
-rw-r--r--sys/kern/vfs_cache.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index b4882079790d..396969bb10ec 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -3623,9 +3623,15 @@ cache_fpl_handle_root(struct cache_fpl *fpl)
ndp = fpl->ndp;
cnp = fpl->cnp;
- while (*(cnp->cn_nameptr) == '/') {
- cnp->cn_nameptr++;
- ndp->ni_pathlen--;
+ MPASS(*(cnp->cn_nameptr) == '/');
+ cnp->cn_nameptr++;
+ ndp->ni_pathlen--;
+
+ if (__predict_false(*(cnp->cn_nameptr) == '/')) {
+ do {
+ cnp->cn_nameptr++;
+ ndp->ni_pathlen--;
+ } while (*(cnp->cn_nameptr) == '/');
}
return (ndp->ni_rootdir);