aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-02-09 16:06:27 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-04-10 05:57:55 +0000
commit4cb1b49b3c985e97933a6194646bab47ece82400 (patch)
treed52dbbe489e84da51cdfbe375d4b7d7213370a15
parentc3437848d8683f6ad03a15bde201c4ead541378e (diff)
downloadsrc-4cb1b49b3c985e97933a6194646bab47ece82400.tar.gz
src-4cb1b49b3c985e97933a6194646bab47ece82400.zip
cache: assorted comment fixups
(cherry picked from commit 39e0c3f686387605591f8f646ceec53613619525)
-rw-r--r--sys/kern/vfs_cache.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 21eb436681fc..fef1e31d197b 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -5268,6 +5268,10 @@ cache_fplookup_parse(struct cache_fpl *fpl)
cache_fpl_pathlen_sub(fpl, cnp->cn_namelen);
#ifdef INVARIANTS
+ /*
+ * cache_get_hash only accepts lengths up to NAME_MAX. This is fine since
+ * we are going to fail this lookup with ENAMETOOLONG (see below).
+ */
if (cnp->cn_namelen <= NAME_MAX) {
if (fpl->hash != cache_get_hash(cnp->cn_nameptr, cnp->cn_namelen, dvp)) {
panic("%s: mismatched hash for [%s] len %ld", __func__,
@@ -5359,7 +5363,7 @@ cache_fplookup_skip_slashes(struct cache_fpl *fpl)
* manner relying on an invariant that a non-directory vnode will get a miss.
* In this case cn_nameptr[0] == '\0' and cn_namelen == 0.
*
- * Thus for a path like "foo/bar/" the code unwinds the state back to 'bar/'
+ * Thus for a path like "foo/bar/" the code unwinds the state back to "bar/"
* and denotes this is the last path component, which avoids looping back.
*
* Only plain lookups are supported for now to restrict corner cases to handle.
@@ -5454,14 +5458,14 @@ cache_fplookup_trailingslash(struct cache_fpl *fpl)
#endif
/*
- * The previous directory is this one.
+ * If this was a "./" lookup the parent directory is already correct.
*/
if (cnp->cn_nameptr[0] == '.' && cnp->cn_namelen == 1) {
return (0);
}
/*
- * The previous directory is something else.
+ * Otherwise we need to look it up.
*/
tvp = fpl->tvp;
ncp = atomic_load_consume_ptr(&tvp->v_cache_dd);
@@ -5495,10 +5499,11 @@ cache_fplookup_failed_vexec(struct cache_fpl *fpl, int error)
dvp_seqc = fpl->dvp_seqc;
/*
- * TODO: Due to ignoring slashes lookup will perform a permission check
- * on the last dir when it should not have. If it fails, we get here.
- * It is possible possible to fix it up fully without resorting to
- * regular lookup, but for now just abort.
+ * TODO: Due to ignoring trailing slashes lookup will perform a
+ * permission check on the last dir when it should not be doing it. It
+ * may fail, but said failure should be ignored. It is possible to fix
+ * it up fully without resorting to regular lookup, but for now just
+ * abort.
*/
if (cache_fpl_istrailingslash(fpl)) {
return (cache_fpl_aborted(fpl));