Page MenuHomeFreeBSD

D36542.1789840222.diff
No OneTemporary

Size
40 KB
Referenced Files
None
Subscribers
None

D36542.1789840222.diff

Index: sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c
===================================================================
--- sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c
+++ sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c
@@ -965,13 +965,17 @@
case RENAME:
if (error == ENOENT) {
error = EJUSTRETURN;
+#if __FreeBSD_version < 1400054
cnp->cn_flags |= SAVENAME;
+#endif
break;
}
zfs_fallthrough;
case DELETE:
+#if __FreeBSD_version < 1400054
if (error == 0)
cnp->cn_flags |= SAVENAME;
+#endif
break;
}
}
@@ -1318,7 +1322,10 @@
cnp->cn_nameptr = __DECONST(char *, name);
cnp->cn_namelen = strlen(name);
cnp->cn_nameiop = nameiop;
- cnp->cn_flags = ISLASTCN | SAVENAME;
+ cnp->cn_flags = ISLASTCN;
+#if __FreeBSD_version < 1400054
+ cnp->cn_flags |= SAVENAME;
+#endif
cnp->cn_lkflags = LK_EXCLUSIVE | LK_RETRY;
cnp->cn_cred = kcred;
#if __FreeBSD_version < 1400037
@@ -4620,7 +4627,9 @@
znode_t *zp = NULL;
int rc, mode;
+#if __FreeBSD_version < 1400054
ASSERT(cnp->cn_flags & SAVENAME);
+#endif
vattr_init_mask(vap);
mode = vap->va_mode & ALLPERMS;
@@ -4650,7 +4659,9 @@
zfs_freebsd_remove(struct vop_remove_args *ap)
{
+#if __FreeBSD_version < 1400054
ASSERT(ap->a_cnp->cn_flags & SAVENAME);
+#endif
return (zfs_remove_(ap->a_dvp, ap->a_vp, ap->a_cnp->cn_nameptr,
ap->a_cnp->cn_cred));
@@ -4672,7 +4683,9 @@
znode_t *zp = NULL;
int rc;
+#if __FreeBSD_version < 1400054
ASSERT(ap->a_cnp->cn_flags & SAVENAME);
+#endif
vattr_init_mask(vap);
*ap->a_vpp = NULL;
@@ -4698,7 +4711,9 @@
{
struct componentname *cnp = ap->a_cnp;
+#if __FreeBSD_version < 1400054
ASSERT(cnp->cn_flags & SAVENAME);
+#endif
return (zfs_rmdir_(ap->a_dvp, ap->a_vp, cnp->cn_nameptr, cnp->cn_cred));
}
@@ -4952,8 +4967,10 @@
vnode_t *tvp = ap->a_tvp;
int error;
+#if __FreeBSD_version < 1400054
ASSERT(ap->a_fcnp->cn_flags & (SAVENAME|SAVESTART));
ASSERT(ap->a_tcnp->cn_flags & (SAVENAME|SAVESTART));
+#endif
error = zfs_do_rename(fdvp, &fvp, ap->a_fcnp, tdvp, &tvp,
ap->a_tcnp, ap->a_fcnp->cn_cred);
@@ -4989,7 +5006,9 @@
#endif
int rc;
+#if __FreeBSD_version < 1400054
ASSERT(cnp->cn_flags & SAVENAME);
+#endif
vap->va_type = VLNK; /* FreeBSD: Syscall only sets va_mode. */
vattr_init_mask(vap);
@@ -5083,7 +5102,9 @@
if (tdvp->v_mount != vp->v_mount)
return (EXDEV);
+#if __FreeBSD_version < 1400054
ASSERT(cnp->cn_flags & SAVENAME);
+#endif
return (zfs_link(VTOZ(tdvp), VTOZ(vp),
cnp->cn_nameptr, cnp->cn_cred, 0));
Index: sys/fs/devfs/devfs_vnops.c
===================================================================
--- sys/fs/devfs/devfs_vnops.c
+++ sys/fs/devfs/devfs_vnops.c
@@ -1140,7 +1140,6 @@
if (de == NULL || de->de_flags & DE_WHITEOUT) {
if ((nameiop == CREATE || nameiop == RENAME) &&
(flags & (LOCKPARENT | WANTPARENT)) && (flags & ISLASTCN)) {
- cnp->cn_flags |= SAVENAME;
return (EJUSTRETURN);
}
return (ENOENT);
Index: sys/fs/ext2fs/ext2_lookup.c
===================================================================
--- sys/fs/ext2fs/ext2_lookup.c
+++ sys/fs/ext2fs/ext2_lookup.c
@@ -514,13 +514,10 @@
* We return ni_vp == NULL to indicate that the entry
* does not currently exist; we leave a pointer to
* the (locked) directory inode in ndp->ni_dvp.
- * The pathname buffer is saved so that the name
- * can be obtained later.
*
* NB - if the directory is unlocked, then this
* information cannot be used.
*/
- cnp->cn_flags |= SAVENAME;
return (EJUSTRETURN);
}
/*
@@ -631,7 +628,6 @@
&tdp)) != 0)
return (error);
*vpp = tdp;
- cnp->cn_flags |= SAVENAME;
return (0);
}
if (dd_ino != NULL)
@@ -925,10 +921,6 @@
int DIRBLKSIZ = ip->i_e2fs->e2fs_bsize;
int error;
-#ifdef INVARIANTS
- if ((cnp->cn_flags & SAVENAME) == 0)
- panic("ext2_direnter: missing name");
-#endif
dp = VTOI(dvp);
newdir.e2d_ino = htole32(ip->i_number);
if (EXT2_HAS_INCOMPAT_FEATURE(ip->i_e2fs,
Index: sys/fs/ext2fs/ext2_vnops.c
===================================================================
--- sys/fs/ext2fs/ext2_vnops.c
+++ sys/fs/ext2fs/ext2_vnops.c
@@ -709,10 +709,6 @@
struct inode *ip;
int error;
-#ifdef INVARIANTS
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("ext2_link: no name");
-#endif
ip = VTOI(vp);
if ((nlink_t)ip->i_nlink >= EXT4_LINK_MAX) {
error = EMLINK;
@@ -801,11 +797,6 @@
int error = 0;
u_char namlen;
-#ifdef INVARIANTS
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("ext2_rename: no name");
-#endif
/*
* Check for cross-device rename.
*/
@@ -1315,10 +1306,6 @@
char *buf = NULL;
int error, dmode;
-#ifdef INVARIANTS
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("ext2_mkdir: no name");
-#endif
dp = VTOI(dvp);
if ((nlink_t)dp->i_nlink >= EXT4_LINK_MAX &&
!EXT2_HAS_RO_COMPAT_FEATURE(dp->i_e2fs, EXT2F_ROCOMPAT_DIR_NLINK)) {
@@ -1946,10 +1933,6 @@
int error;
pdir = VTOI(dvp);
-#ifdef INVARIANTS
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("ext2_makeinode: no name");
-#endif
*vpp = NULL;
if ((mode & IFMT) == 0)
mode |= IFREG;
Index: sys/fs/fuse/fuse_vnops.c
===================================================================
--- sys/fs/fuse/fuse_vnops.c
+++ sys/fs/fuse/fuse_vnops.c
@@ -1391,7 +1391,6 @@
int nameiop = cnp->cn_nameiop;
int flags = cnp->cn_flags;
- int wantparent = flags & (LOCKPARENT | WANTPARENT);
int islastcn = flags & ISLASTCN;
struct mount *mp = vnode_mount(dvp);
struct fuse_data *data = fuse_get_mpdata(mp);
@@ -1533,13 +1532,6 @@
else
err = 0;
if (!err) {
- /*
- * Set the SAVENAME flag to hold onto the
- * pathname for use later in VOP_CREATE or
- * VOP_RENAME.
- */
- cnp->cn_flags |= SAVENAME;
-
err = EJUSTRETURN;
}
} else {
@@ -1619,12 +1611,6 @@
goto out;
}
}
-
- if (islastcn && (
- (nameiop == DELETE) ||
- (nameiop == RENAME && wantparent))) {
- cnp->cn_flags |= SAVENAME;
- }
}
}
out:
Index: sys/fs/msdosfs/msdosfs_lookup.c
===================================================================
--- sys/fs/msdosfs/msdosfs_lookup.c
+++ sys/fs/msdosfs/msdosfs_lookup.c
@@ -421,13 +421,10 @@
* We return ni_vp == NULL to indicate that the entry
* does not currently exist; we leave a pointer to
* the (locked) directory inode in ndp->ni_dvp.
- * The pathname buffer is saved so that the name
- * can be obtained later.
*
* NB - if the directory is unlocked, then this
* information cannot be used.
*/
- cnp->cn_flags |= SAVENAME;
return (EJUSTRETURN);
}
#if 0
@@ -554,7 +551,6 @@
if ((error = msdosfs_lookup_checker(pmp, vdp, tdp, vpp))
!= 0)
return (error);
- cnp->cn_flags |= SAVENAME;
return (0);
}
Index: sys/fs/msdosfs/msdosfs_vnops.c
===================================================================
--- sys/fs/msdosfs/msdosfs_vnops.c
+++ sys/fs/msdosfs/msdosfs_vnops.c
@@ -161,10 +161,6 @@
* use the absence of the owner write bit to make the file
* readonly.
*/
-#ifdef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("msdosfs_create: no name");
-#endif
memset(&ndirent, 0, sizeof(ndirent));
error = uniqdosname(pdep, cnp, ndirent.de_Name);
if (error)
@@ -958,11 +954,6 @@
fcnp = ap->a_fcnp;
pmp = VFSTOMSDOSFS(fdvp->v_mount);
-#ifdef DIAGNOSTIC
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("msdosfs_rename: no name");
-#endif
/*
* Check for cross-device rename.
*/
@@ -1414,10 +1405,6 @@
* cluster. This will be written to an empty slot in the parent
* directory.
*/
-#ifdef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("msdosfs_mkdir: no name");
-#endif
error = uniqdosname(pdep, cnp, ndirent.de_Name);
if (error)
goto bad;
Index: sys/fs/nfsclient/nfs_clvnops.c
===================================================================
--- sys/fs/nfsclient/nfs_clvnops.c
+++ sys/fs/nfsclient/nfs_clvnops.c
@@ -1250,10 +1250,6 @@
* associated locking bookkeeping, etc.
*/
if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
- /* XXX: Is this really correct? */
- if (cnp->cn_nameiop != LOOKUP &&
- (flags & ISLASTCN))
- cnp->cn_flags |= SAVENAME;
return (0);
}
@@ -1288,9 +1284,6 @@
VOP_GETATTR(newvp, &vattr, cnp->cn_cred) == 0 &&
timespeccmp(&vattr.va_ctime, &nctime, ==))) {
NFSINCRGLOBAL(nfsstatsv1.lookupcache_hits);
- if (cnp->cn_nameiop != LOOKUP &&
- (flags & ISLASTCN))
- cnp->cn_flags |= SAVENAME;
return (0);
}
cache_purge(newvp);
@@ -1372,7 +1365,6 @@
*/
if (mp->mnt_flag & MNT_RDONLY)
return (EROFS);
- cnp->cn_flags |= SAVENAME;
return (EJUSTRETURN);
}
@@ -1428,7 +1420,6 @@
if (attrflag)
(void) nfscl_loadattrcache(&newvp, &nfsva, NULL, 0, 1);
*vpp = newvp;
- cnp->cn_flags |= SAVENAME;
return (0);
}
@@ -1513,8 +1504,6 @@
NFSUNLOCKNODE(np);
}
}
- if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
- cnp->cn_flags |= SAVENAME;
if ((cnp->cn_flags & MAKEENTRY) && dvp != newvp &&
(cnp->cn_nameiop != DELETE || !(flags & ISLASTCN)) &&
attrflag != 0 && (newvp->v_type != VDIR || dattrflag != 0))
@@ -1881,7 +1870,6 @@
int error = 0;
struct vattr vattr;
- KASSERT((cnp->cn_flags & HASBUF) != 0, ("nfs_remove: no name"));
KASSERT(vrefcnt(vp) > 0, ("nfs_remove: bad v_usecount"));
if (vp->v_type == VDIR)
error = EPERM;
@@ -1994,8 +1982,6 @@
struct nfsv4node *newv4 = NULL;
int error;
- KASSERT((tcnp->cn_flags & HASBUF) != 0 &&
- (fcnp->cn_flags & HASBUF) != 0, ("nfs_rename: no name"));
/* Check for cross-device rename */
if ((fvp->v_mount != tdvp->v_mount) ||
(tvp && (fvp->v_mount != tvp->v_mount))) {
Index: sys/fs/nfsserver/nfs_nfsdport.c
===================================================================
--- sys/fs/nfsserver/nfs_nfsdport.c
+++ sys/fs/nfsserver/nfs_nfsdport.c
@@ -686,8 +686,6 @@
* termination occurs if no symlink encountered.
*/
if ((cnp->cn_flags & ISSYMLINK) == 0) {
- if ((cnp->cn_flags & (SAVENAME | SAVESTART)) == 0)
- nfsvno_relpathbuf(ndp);
if (ndp->ni_vp && !lockleaf)
NFSVOPUNLOCK(ndp->ni_vp);
break;
@@ -796,7 +794,7 @@
{
struct componentname *cnp = &ndp->ni_cnd;
- cnp->cn_flags |= (NOMACCHECK | HASBUF);
+ cnp->cn_flags |= (NOMACCHECK);
cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK);
if (hashpp != NULL)
*hashpp = NULL;
@@ -810,10 +808,8 @@
nfsvno_relpathbuf(struct nameidata *ndp)
{
- if ((ndp->ni_cnd.cn_flags & HASBUF) == 0)
- panic("nfsrelpath");
uma_zfree(namei_zone, ndp->ni_cnd.cn_pnbuf);
- ndp->ni_cnd.cn_flags &= ~HASBUF;
+ ndp->ni_cnd.cn_pnbuf = NULL;
}
/*
@@ -1478,8 +1474,7 @@
else
vput(ndp->ni_dvp);
vput(vp);
- if ((ndp->ni_cnd.cn_flags & SAVENAME) != 0)
- nfsvno_relpathbuf(ndp);
+ nfsvno_relpathbuf(ndp);
NFSEXITCODE(error);
return (error);
}
@@ -1519,8 +1514,7 @@
else
vput(ndp->ni_dvp);
vput(vp);
- if ((ndp->ni_cnd.cn_flags & SAVENAME) != 0)
- nfsvno_relpathbuf(ndp);
+ nfsvno_relpathbuf(ndp);
NFSEXITCODE(error);
return (error);
}
@@ -1939,8 +1933,7 @@
}
}
} else {
- if (ndp->ni_cnd.cn_flags & HASBUF)
- nfsvno_relpathbuf(ndp);
+ nfsvno_relpathbuf(ndp);
if (ndp->ni_startdir && create == NFSV4OPEN_CREATE) {
vrele(ndp->ni_startdir);
if (ndp->ni_dvp == ndp->ni_vp)
@@ -4578,7 +4571,7 @@
named.ni_cnd.cn_nameiop = DELETE;
named.ni_cnd.cn_lkflags = LK_EXCLUSIVE | LK_RETRY;
named.ni_cnd.cn_cred = tcred;
- named.ni_cnd.cn_flags = ISLASTCN | LOCKPARENT | LOCKLEAF | SAVENAME;
+ named.ni_cnd.cn_flags = ISLASTCN | LOCKPARENT | LOCKLEAF;
nfsvno_setpathbuf(&named, &bufp, &hashp);
named.ni_cnd.cn_nameptr = bufp;
named.ni_cnd.cn_namelen = strlen(fname);
@@ -6351,7 +6344,7 @@
named.ni_cnd.cn_nameiop = LOOKUP;
named.ni_cnd.cn_lkflags = LK_SHARED | LK_RETRY;
named.ni_cnd.cn_cred = tcred;
- named.ni_cnd.cn_flags = ISLASTCN | LOCKPARENT | LOCKLEAF | SAVENAME;
+ named.ni_cnd.cn_flags = ISLASTCN | LOCKPARENT | LOCKLEAF;
nfsvno_setpathbuf(&named, &bufp, &hashp);
named.ni_cnd.cn_nameptr = bufp;
named.ni_cnd.cn_namelen = strlen(pf->dsf_filename);
Index: sys/fs/nfsserver/nfs_nfsdserv.c
===================================================================
--- sys/fs/nfsserver/nfs_nfsdserv.c
+++ sys/fs/nfsserver/nfs_nfsdserv.c
@@ -1360,7 +1360,7 @@
case NFFIFO:
break;
case NFDIR:
- cnflags = (LOCKPARENT | SAVENAME);
+ cnflags = LOCKPARENT;
break;
default:
nd->nd_repstat = NFSERR_BADTYPE;
@@ -1823,8 +1823,7 @@
NFSVOPUNLOCK(dp);
}
}
- NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, CREATE,
- LOCKPARENT | SAVENAME | NOCACHE);
+ NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, CREATE, LOCKPARENT | NOCACHE);
if (!nd->nd_repstat) {
nfsvno_setpathbuf(&named, &bufp, &hashp);
error = nfsrv_parsename(nd, bufp, hashp, &named.ni_pathlen);
@@ -2018,8 +2017,7 @@
nfsrv_wcc(nd, dirfor_ret, &dirfor, diraft_ret, &diraft);
goto out;
}
- NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, CREATE,
- LOCKPARENT | SAVENAME | NOCACHE);
+ NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, CREATE, LOCKPARENT | NOCACHE);
nfsvno_setpathbuf(&named, &bufp, &hashp);
error = nfsrv_parsename(nd, bufp, hashp, &named.ni_pathlen);
if (error)
Index: sys/fs/smbfs/smbfs_vnops.c
===================================================================
--- sys/fs/smbfs/smbfs_vnops.c
+++ sys/fs/smbfs/smbfs_vnops.c
@@ -1241,8 +1241,6 @@
killit = 1;
else if (error == 0
/* && vattr.va_ctime.tv_sec == VTOSMB(vp)->n_ctime*/) {
- if (nameiop != LOOKUP && islastcn)
- cnp->cn_flags |= SAVENAME;
SMBVDEBUG("use cached vnode\n");
return (0);
}
@@ -1296,7 +1294,6 @@
error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, td);
if (error)
goto out;
- cnp->cn_flags |= SAVENAME;
error = EJUSTRETURN;
goto out;
}
@@ -1321,7 +1318,6 @@
if (error)
goto out;
*vpp = vp;
- cnp->cn_flags |= SAVENAME;
goto out;
}
if (nameiop == RENAME && islastcn) {
@@ -1336,7 +1332,6 @@
if (error)
goto out;
*vpp = vp;
- cnp->cn_flags |= SAVENAME;
goto out;
}
if (flags & ISDOTDOT) {
Index: sys/fs/tmpfs/tmpfs_subr.c
===================================================================
--- sys/fs/tmpfs/tmpfs_subr.c
+++ sys/fs/tmpfs/tmpfs_subr.c
@@ -1051,7 +1051,6 @@
struct tmpfs_node *parent;
ASSERT_VOP_ELOCKED(dvp, "tmpfs_alloc_file");
- MPASS(cnp->cn_flags & HASBUF);
tmp = VFS_TO_TMPFS(dvp->v_mount);
dnode = VP_TO_TMPFS_DIR(dvp);
Index: sys/fs/tmpfs/tmpfs_vnops.c
===================================================================
--- sys/fs/tmpfs/tmpfs_vnops.c
+++ sys/fs/tmpfs/tmpfs_vnops.c
@@ -140,12 +140,6 @@
if (error != 0)
goto out;
- /*
- * Keep the component name in the buffer for
- * future uses.
- */
- cnp->cn_flags |= SAVENAME;
-
error = EJUSTRETURN;
} else
error = ENOENT;
@@ -199,7 +193,6 @@
*vpp = NULL;
goto out;
}
- cnp->cn_flags |= SAVENAME;
} else {
error = tmpfs_alloc_vp(dvp->v_mount, tnode,
cnp->cn_lkflags, vpp);
@@ -778,7 +771,6 @@
struct tmpfs_node *node;
MPASS(VOP_ISLOCKED(dvp));
- MPASS(cnp->cn_flags & HASBUF);
MPASS(dvp != vp); /* XXX When can this be false? */
node = VP_TO_TMPFS_NODE(vp);
@@ -971,8 +963,6 @@
MPASS(VOP_ISLOCKED(tdvp));
MPASS(IMPLIES(tvp != NULL, VOP_ISLOCKED(tvp)));
- MPASS(fcnp->cn_flags & HASBUF);
- MPASS(tcnp->cn_flags & HASBUF);
want_seqc_end = false;
Index: sys/fs/unionfs/union_subr.c
===================================================================
--- sys/fs/unionfs/union_subr.c
+++ sys/fs/unionfs/union_subr.c
@@ -666,7 +666,7 @@
cn->cn_namelen = pathlen;
cn->cn_pnbuf = path;
cn->cn_nameiop = nameiop;
- cn->cn_flags = (LOCKPARENT | LOCKLEAF | HASBUF | SAVENAME | ISLASTCN);
+ cn->cn_flags = (LOCKPARENT | LOCKLEAF | ISLASTCN);
cn->cn_lkflags = LK_EXCLUSIVE;
cn->cn_cred = cnp->cn_cred;
cn->cn_nameptr = cn->cn_pnbuf;
@@ -686,10 +686,6 @@
} else
vrele(dvp);
- KASSERT((cn->cn_flags & HASBUF) != 0,
- ("%s: HASBUF cleared", __func__));
- KASSERT((cn->cn_flags & SAVENAME) != 0,
- ("%s: SAVENAME cleared", __func__));
KASSERT(cn->cn_pnbuf == path, ("%s: cn_pnbuf changed", __func__));
return (error);
@@ -716,8 +712,6 @@
udvp = UNIONFSVPTOUPPERVP(dvp);
vp = NULLVP;
- KASSERT((cnp->cn_flags & HASBUF) != 0,
- ("%s called without HASBUF", __func__));
error = unionfs_relookup(udvp, &vp, cnp, &cn, td, cnp->cn_nameptr,
cnp->cn_namelen, CREATE);
if (error)
@@ -752,8 +746,6 @@
udvp = UNIONFSVPTOUPPERVP(dvp);
vp = NULLVP;
- KASSERT((cnp->cn_flags & HASBUF) != 0,
- ("%s called without HASBUF", __func__));
error = unionfs_relookup(udvp, &vp, cnp, &cn, td, cnp->cn_nameptr,
cnp->cn_namelen, DELETE);
if (error)
@@ -788,8 +780,6 @@
udvp = UNIONFSVPTOUPPERVP(dvp);
vp = NULLVP;
- KASSERT((cnp->cn_flags & HASBUF) != 0,
- ("%s called without HASBUF", __func__));
error = unionfs_relookup(udvp, &vp, cnp, &cn, td, cnp->cn_nameptr,
cnp->cn_namelen, RENAME);
if (error)
@@ -1020,8 +1010,7 @@
nd.ni_cnd.cn_namelen = unp->un_pathlen;
nd.ni_cnd.cn_pnbuf = unp->un_path;
nd.ni_cnd.cn_nameiop = CREATE;
- nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | HASBUF | SAVENAME |
- ISLASTCN;
+ nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | ISLASTCN;
nd.ni_cnd.cn_lkflags = LK_EXCLUSIVE;
nd.ni_cnd.cn_cred = cred;
nd.ni_cnd.cn_nameptr = nd.ni_cnd.cn_pnbuf;
@@ -1061,10 +1050,6 @@
VOP_UNLOCK(udvp);
unionfs_vn_create_on_upper_free_out2:
- KASSERT((nd.ni_cnd.cn_flags & HASBUF) != 0,
- ("%s: HASBUF cleared", __func__));
- KASSERT((nd.ni_cnd.cn_flags & SAVENAME) != 0,
- ("%s: SAVENAME cleared", __func__));
KASSERT(nd.ni_cnd.cn_pnbuf == unp->un_path,
("%s: cn_pnbuf changed", __func__));
@@ -1290,8 +1275,7 @@
cn.cn_pnbuf = NULL;
cn.cn_nameptr = dp->d_name;
cn.cn_nameiop = LOOKUP;
- cn.cn_flags = LOCKPARENT | LOCKLEAF | SAVENAME |
- RDONLY | ISLASTCN;
+ cn.cn_flags = LOCKPARENT | LOCKLEAF | RDONLY | ISLASTCN;
cn.cn_lkflags = LK_EXCLUSIVE;
cn.cn_cred = cred;
@@ -1312,8 +1296,7 @@
* If it has no exist/whiteout entry in upper,
* directory is not empty.
*/
- cn.cn_flags = LOCKPARENT | LOCKLEAF | SAVENAME |
- RDONLY | ISLASTCN;
+ cn.cn_flags = LOCKPARENT | LOCKLEAF | RDONLY | ISLASTCN;
lookuperr = VOP_LOOKUP(uvp, &tvp, &cn);
if (!lookuperr)
Index: sys/fs/unionfs/union_vnops.c
===================================================================
--- sys/fs/unionfs/union_vnops.c
+++ sys/fs/unionfs/union_vnops.c
@@ -348,10 +348,6 @@
unionfs_lookup_return:
- /* Ensure subsequent vnops will get a valid pathname buffer. */
- if (nameiop != LOOKUP && (error == 0 || error == EJUSTRETURN))
- cnp->cn_flags |= SAVENAME;
-
UNIONFS_INTERNAL_DEBUG("unionfs_lookup: leave (%d)\n", error);
return (error);
@@ -1205,11 +1201,6 @@
rtvp = tvp;
needrelookup = 0;
-#ifdef DIAGNOSTIC
- if (!(fcnp->cn_flags & HASBUF) || !(tcnp->cn_flags & HASBUF))
- panic("unionfs_rename: no name");
-#endif
-
/* check for cross device rename */
if (fvp->v_mount != tdvp->v_mount ||
(tvp != NULLVP && fvp->v_mount != tvp->v_mount)) {
Index: sys/kern/kern_exec.c
===================================================================
--- sys/kern/kern_exec.c
+++ sys/kern/kern_exec.c
@@ -474,7 +474,7 @@
* pointer in ni_vp among other things.
*/
NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | LOCKSHARED | FOLLOW |
- SAVENAME | AUDITVNODE1 | WANTPARENT, UIO_SYSSPACE,
+ AUDITVNODE1 | WANTPARENT, UIO_SYSSPACE,
args->fname);
error = namei(&nd);
Index: sys/kern/uipc_mqueue.c
===================================================================
--- sys/kern/uipc_mqueue.c
+++ sys/kern/uipc_mqueue.c
@@ -941,7 +941,6 @@
error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, td);
if (error)
return (error);
- cnp->cn_flags |= SAVENAME;
return (EJUSTRETURN);
}
return (ENOENT);
@@ -997,8 +996,6 @@
if (mq == NULL)
return (EAGAIN);
sx_xlock(&mqfs->mi_lock);
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("%s: no name", __func__);
pn = mqfs_create_file(pd, cnp->cn_nameptr, cnp->cn_namelen,
cnp->cn_cred, ap->a_vap->va_mode);
if (pn == NULL) {
@@ -1492,8 +1489,6 @@
if (pd->mn_type != mqfstype_root && pd->mn_type != mqfstype_dir)
return (ENOTDIR);
sx_xlock(&mqfs->mi_lock);
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("%s: no name", __func__);
pn = mqfs_create_dir(pd, cnp->cn_nameptr, cnp->cn_namelen,
ap->a_vap->cn_cred, ap->a_vap->va_mode);
if (pn != NULL)
Index: sys/kern/uipc_usrreq.c
===================================================================
--- sys/kern/uipc_usrreq.c
+++ sys/kern/uipc_usrreq.c
@@ -593,7 +593,7 @@
buf[namelen] = 0;
restart:
- NDINIT_ATRIGHTS(&nd, CREATE, NOFOLLOW | LOCKPARENT | SAVENAME | NOCACHE,
+ NDINIT_ATRIGHTS(&nd, CREATE, NOFOLLOW | LOCKPARENT | NOCACHE,
UIO_SYSSPACE, buf, fd, cap_rights_init_one(&rights, CAP_BINDAT));
/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
error = namei(&nd);
@@ -1919,9 +1919,9 @@
else
vp = nd.ni_vp;
ASSERT_VOP_LOCKED(vp, "unp_connect");
- NDFREE_NOTHING(&nd);
if (error)
goto bad;
+ NDFREE_PNBUF(&nd);
if (vp->v_type != VSOCK) {
error = ENOTSOCK;
Index: sys/kern/vfs_cache.c
===================================================================
--- sys/kern/vfs_cache.c
+++ sys/kern/vfs_cache.c
@@ -3134,7 +3134,7 @@
if (flags != 0)
return (EINVAL);
- NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | SAVENAME | WANTPARENT | AUDITVNODE1,
+ NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | WANTPARENT | AUDITVNODE1,
pathseg, path, fd, &cap_fstat_rights);
if ((error = namei(&nd)) != 0)
return (error);
@@ -3600,9 +3600,9 @@
/*
* Resolve an arbitrary vnode to a pathname (taking care of hardlinks).
*
- * Since the namecache does not track hardlinks, the caller is
- * expected to first look up the target vnode with SAVENAME |
- * WANTPARENT flags passed to namei to get dvp and vp.
+ * Since the namecache does not track hardlinks, the caller is expected to
+ * first look up the target vnode with WANTPARENT flag passed to namei to get
+ * dvp and vp.
*
* Then we have 2 cases:
* - if the found vnode is a directory, the path can be constructed just by
@@ -3928,7 +3928,6 @@
enum cache_fpl_status status:8;
bool in_smr;
bool fsearch;
- bool savename;
struct pwd **pwd;
#ifdef INVARIANTS
struct cache_fpl_debug debug;
@@ -4166,7 +4165,6 @@
fpl->line = line;
fpl->dvp = NULL;
fpl->tvp = NULL;
- fpl->savename = false;
return (error);
}
@@ -4181,9 +4179,9 @@
#define CACHE_FPL_SUPPORTED_CN_FLAGS \
(NC_NOMAKEENTRY | NC_KEEPPOSENTRY | LOCKLEAF | LOCKPARENT | WANTPARENT | \
- FAILIFEXISTS | FOLLOW | EMPTYPATH | LOCKSHARED | SAVENAME | SAVESTART | \
- WILLBEDIR | ISOPEN | NOMACCHECK | AUDITVNODE1 | AUDITVNODE2 | NOCAPCHECK | \
- OPENREAD | OPENWRITE | WANTIOCTLCAPS)
+ FAILIFEXISTS | FOLLOW | EMPTYPATH | LOCKSHARED | SAVESTART | WILLBEDIR | \
+ ISOPEN | NOMACCHECK | AUDITVNODE1 | AUDITVNODE2 | NOCAPCHECK | OPENREAD | \
+ OPENWRITE | WANTIOCTLCAPS)
#define CACHE_FPL_INTERNAL_CN_FLAGS \
(ISDOTDOT | MAKEENTRY | ISLASTCN)
@@ -4530,14 +4528,11 @@
}
fpl->tvp = tvp;
- fpl->savename = (cnp->cn_flags & SAVENAME) != 0;
if (tvp == NULL) {
if ((cnp->cn_flags & SAVESTART) != 0) {
ndp->ni_startdir = dvp;
vrefact(ndp->ni_startdir);
- cnp->cn_flags |= SAVENAME;
- fpl->savename = true;
}
MPASS(error == EJUSTRETURN);
if ((cnp->cn_flags & LOCKPARENT) == 0) {
@@ -4598,8 +4593,6 @@
if ((cnp->cn_flags & SAVESTART) != 0) {
ndp->ni_startdir = dvp;
vrefact(ndp->ni_startdir);
- cnp->cn_flags |= SAVENAME;
- fpl->savename = true;
}
return (cache_fpl_handled(fpl));
@@ -4944,9 +4937,6 @@
}
fpl->tvp = tvp;
- if (!fpl->savename) {
- MPASS((cnp->cn_flags & SAVENAME) == 0);
- }
if (tvp == NULL) {
MPASS(error == EJUSTRETURN);
@@ -6080,7 +6070,6 @@
#endif
fpl.nulchar = &cnp->cn_nameptr[ndp->ni_pathlen - 1];
fpl.fsearch = false;
- fpl.savename = (cnp->cn_flags & SAVENAME) != 0;
fpl.tvp = NULL; /* for degenerate path handling */
fpl.pwd = pwdp;
pwd = pwd_get_smr();
@@ -6119,17 +6108,12 @@
if (__predict_true(fpl.status == CACHE_FPL_STATUS_HANDLED)) {
MPASS(error != CACHE_FPL_FAILED);
if (error != 0) {
+ cache_fpl_cleanup_cnp(fpl.cnp);
MPASS(fpl.dvp == NULL);
MPASS(fpl.tvp == NULL);
- MPASS(fpl.savename == false);
}
ndp->ni_dvp = fpl.dvp;
ndp->ni_vp = fpl.tvp;
- if (fpl.savename) {
- cnp->cn_flags |= HASBUF;
- } else {
- cache_fpl_cleanup_cnp(cnp);
- }
}
return (error);
}
Index: sys/kern/vfs_lookup.c
===================================================================
--- sys/kern/vfs_lookup.c
+++ sys/kern/vfs_lookup.c
@@ -260,10 +260,8 @@
{
uma_zfree(namei_zone, cnp->cn_pnbuf);
-#ifdef DIAGNOSTIC
cnp->cn_pnbuf = NULL;
cnp->cn_nameptr = NULL;
-#endif
}
static int
@@ -589,13 +587,6 @@
("%s: FAILIFEXISTS must be passed with LOCKPARENT and without LOCKLEAF",
__func__));
}
- /*
- * For NDVALIDATE.
- *
- * While NDINIT may seem like a more natural place to do it, there are
- * callers which directly modify flags past invoking init.
- */
- cnp->cn_origflags = cnp->cn_flags;
#endif
ndp->ni_cnd.cn_cred = td->td_ucred;
KASSERT(ndp->ni_resflags == 0, ("%s: garbage in ni_resflags: %x\n",
@@ -690,10 +681,6 @@
if ((cnp->cn_flags & ISSYMLINK) == 0) {
SDT_PROBE4(vfs, namei, lookup, return, error,
(error == 0 ? ndp->ni_vp : NULL), false, ndp);
- if ((cnp->cn_flags & (SAVENAME | SAVESTART)) == 0) {
- namei_cleanup_cnp(cnp);
- } else
- cnp->cn_flags |= HASBUF;
nameicap_cleanup(ndp);
pwd_drop(pwd);
if (error == 0)
@@ -998,9 +985,7 @@
* Search a new directory.
*
* The last component of the filename is left accessible via
- * cnp->cn_nameptr for callers that need the name. Callers needing
- * the name set the SAVENAME flag. When done, they assume
- * responsibility for freeing the pathname buffer.
+ * cnp->cn_nameptr. It has to be freed with a call to NDFREE*.
*
* Store / as a temporary sentinel so that we only have one character
* to test for. Pathnames tend to be short so this should not be
@@ -1445,10 +1430,7 @@
/*
* Search a new directory.
*
- * The last component of the filename is left accessible via
- * cnp->cn_nameptr for callers that need the name. Callers needing
- * the name set the SAVENAME flag. When done, they assume
- * responsibility for freeing the pathname buffer.
+ * See a comment in vfs_lookup for cnp->cn_nameptr.
*/
#ifdef NAMEI_DIAGNOSTIC
printf("{%s}: ", cnp->cn_nameptr);
@@ -1547,47 +1529,6 @@
return (error);
}
-/*
- * Free data allocated by namei(); see namei(9) for details.
- */
-void
-NDFREE_PNBUF(struct nameidata *ndp)
-{
-
- if ((ndp->ni_cnd.cn_flags & HASBUF) != 0) {
- MPASS((ndp->ni_cnd.cn_flags & (SAVENAME | SAVESTART)) != 0);
- uma_zfree(namei_zone, ndp->ni_cnd.cn_pnbuf);
- ndp->ni_cnd.cn_flags &= ~HASBUF;
- }
-}
-
-/*
- * NDFREE_PNBUF replacement for callers that know there is no buffer.
- *
- * This is a hack. Preferably the VFS layer would not produce anything more
- * than it was asked to do. Unfortunately several non-LOOKUP cases can add the
- * HASBUF flag to the result. Even then an interface could be implemented where
- * the caller specifies what they expected to see in the result and what they
- * are going to take care of.
- *
- * In the meantime provide this kludge as a trivial replacement for NDFREE_PNBUF
- * calls scattered throughout the kernel where we know for a fact the flag must not
- * be seen.
- */
-#ifdef INVARIANTS
-void
-NDFREE_NOTHING(struct nameidata *ndp)
-{
- struct componentname *cnp;
-
- cnp = &ndp->ni_cnd;
- KASSERT(cnp->cn_nameiop == LOOKUP, ("%s: got non-LOOKUP op %d\n",
- __func__, cnp->cn_nameiop));
- KASSERT((cnp->cn_flags & (SAVENAME | HASBUF)) == 0,
- ("%s: bad flags \%" PRIx64 "\n", __func__, cnp->cn_flags));
-}
-#endif
-
void
(NDFREE)(struct nameidata *ndp, const u_int flags)
{
@@ -1638,62 +1579,15 @@
#ifdef INVARIANTS
/*
* Validate the final state of ndp after the lookup.
- *
- * Historically filesystems were allowed to modify cn_flags. Most notably they
- * can add SAVENAME to the request, resulting in HASBUF and pushing subsequent
- * clean up to the consumer. In practice this seems to only concern != LOOKUP
- * operations.
- *
- * As a step towards stricter API contract this routine validates the state to
- * clean up. Note validation is a work in progress with the intent of becoming
- * stricter over time.
*/
-#define NDMODIFYINGFLAGS (LOCKLEAF | LOCKPARENT | WANTPARENT | SAVENAME | SAVESTART | HASBUF)
-static void
+void
NDVALIDATE(struct nameidata *ndp)
{
struct componentname *cnp;
- uint64_t used, orig;
cnp = &ndp->ni_cnd;
- orig = cnp->cn_origflags;
- used = cnp->cn_flags;
- switch (cnp->cn_nameiop) {
- case LOOKUP:
- /*
- * For plain lookup we require strict conformance -- nothing
- * to clean up if it was not requested by the caller.
- */
- orig &= NDMODIFYINGFLAGS;
- used &= NDMODIFYINGFLAGS;
- if ((orig & (SAVENAME | SAVESTART)) != 0)
- orig |= HASBUF;
- if (orig != used) {
- goto out_mismatch;
- }
- break;
- case CREATE:
- case DELETE:
- case RENAME:
- /*
- * Some filesystems set SAVENAME to provoke HASBUF, accommodate
- * for it until it gets fixed.
- */
- orig &= NDMODIFYINGFLAGS;
- orig |= (SAVENAME | HASBUF);
- used &= NDMODIFYINGFLAGS;
- used |= (SAVENAME | HASBUF);
- if (orig != used) {
- goto out_mismatch;
- }
- break;
- }
- return;
-out_mismatch:
- panic("%s: mismatched flags for op %d: added %" PRIx64 ", "
- "removed %" PRIx64" (%" PRIx64" != %" PRIx64"; stored %" PRIx64" != %" PRIx64")",
- __func__, cnp->cn_nameiop, used & ~orig, orig &~ used,
- orig, used, cnp->cn_origflags, cnp->cn_flags);
+ if (cnp->cn_pnbuf == NULL)
+ panic("%s: got no buf!", __func__);
}
#endif
Index: sys/kern/vfs_subr.c
===================================================================
--- sys/kern/vfs_subr.c
+++ sys/kern/vfs_subr.c
@@ -395,7 +395,7 @@
buf[req->newlen] = '\0';
- ndflags = LOCKLEAF | NOFOLLOW | AUDITVNODE1 | SAVENAME;
+ ndflags = LOCKLEAF | NOFOLLOW | AUDITVNODE1;
NDINIT(&nd, LOOKUP, ndflags, UIO_SYSSPACE, buf);
if ((error = namei(&nd)) != 0)
goto out;
Index: sys/kern/vfs_syscalls.c
===================================================================
--- sys/kern/vfs_syscalls.c
+++ sys/kern/vfs_syscalls.c
@@ -338,8 +338,8 @@
error = namei(&nd);
if (error != 0)
return (error);
+ NDFREE_PNBUF(&nd);
mp = vfs_ref_from_vp(nd.ni_vp);
- NDFREE_NOTHING(&nd);
vrele(nd.ni_vp);
return (kern_do_statfs(td, mp, buf));
}
@@ -957,11 +957,11 @@
return (error);
if ((error = change_dir(nd.ni_vp, td)) != 0) {
vput(nd.ni_vp);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
return (error);
}
VOP_UNLOCK(nd.ni_vp);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
pwd_chdir(td, nd.ni_vp);
return (0);
}
@@ -1012,12 +1012,12 @@
VOP_UNLOCK(nd.ni_vp);
error = pwd_chroot(td, nd.ni_vp);
vrele(nd.ni_vp);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
return (error);
e_vunlock:
vput(nd.ni_vp);
error:
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
return (error);
}
@@ -1354,8 +1354,8 @@
NDPREINIT(&nd);
restart:
bwillwrite();
- NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
- NOCACHE, pathseg, path, fd, &cap_mknodat_rights);
+ NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | AUDITVNODE1 | NOCACHE,
+ pathseg, path, fd, &cap_mknodat_rights);
if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
@@ -1462,8 +1462,8 @@
NDPREINIT(&nd);
restart:
bwillwrite();
- NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
- NOCACHE, pathseg, path, fd, &cap_mkfifoat_rights);
+ NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | AUDITVNODE1 | NOCACHE,
+ pathseg, path, fd, &cap_mkfifoat_rights);
if ((error = namei(&nd)) != 0)
return (error);
if (nd.ni_vp != NULL) {
@@ -1621,7 +1621,7 @@
return (EPERM); /* POSIX */
}
NDINIT_ATRIGHTS(&nd, CREATE,
- LOCKPARENT | SAVENAME | AUDITVNODE2 | NOCACHE, segflag, path, fd,
+ LOCKPARENT | AUDITVNODE2 | NOCACHE, segflag, path, fd,
&cap_linkat_target_rights);
if ((error = namei(&nd)) == 0) {
if (nd.ni_vp != NULL) {
@@ -1739,8 +1739,8 @@
NDPREINIT(&nd);
restart:
bwillwrite();
- NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
- NOCACHE, segflg, path2, fd, &cap_symlinkat_rights);
+ NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | AUDITVNODE1 | NOCACHE, segflg,
+ path2, fd, &cap_symlinkat_rights);
if ((error = namei(&nd)) != 0)
goto out;
if (nd.ni_vp) {
@@ -2151,7 +2151,7 @@
vp = nd.ni_vp;
error = vn_access(vp, amode, usecred, td);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
vput(vp);
out:
if (usecred != cred) {
@@ -2455,7 +2455,7 @@
hook(nd.ni_vp, sbp);
}
}
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
vput(nd.ni_vp);
#ifdef __STAT_TIME_T_EXT
sbp->st_atim_ext = 0;
@@ -2606,7 +2606,7 @@
pathseg, path);
if ((error = namei(&nd)) != 0)
return (error);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
error = VOP_PATHCONF(nd.ni_vp, name, valuep);
vput(nd.ni_vp);
@@ -2662,7 +2662,7 @@
if ((error = namei(&nd)) != 0)
return (error);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
vp = nd.ni_vp;
error = kern_readlink_vp(vp, buf, bufseg, count, td);
@@ -2813,7 +2813,7 @@
fd, &cap_fchflags_rights);
if ((error = namei(&nd)) != 0)
return (error);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
error = setfflags(td, nd.ni_vp, flags);
vrele(nd.ni_vp);
return (error);
@@ -2944,7 +2944,7 @@
fd, &cap_fchmod_rights);
if ((error = namei(&nd)) != 0)
return (error);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
error = setfmode(td, td->td_ucred, nd.ni_vp, mode);
vrele(nd.ni_vp);
return (error);
@@ -3057,7 +3057,7 @@
if ((error = namei(&nd)) != 0)
return (error);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
error = setfown(td, td->td_ucred, nd.ni_vp, uid, gid);
vrele(nd.ni_vp);
return (error);
@@ -3274,7 +3274,7 @@
if ((error = namei(&nd)) != 0)
return (error);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
error = setutimes(td, nd.ni_vp, ts, 2, tptr == NULL);
vrele(nd.ni_vp);
return (error);
@@ -3310,7 +3310,7 @@
NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, pathseg, path);
if ((error = namei(&nd)) != 0)
return (error);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
error = setutimes(td, nd.ni_vp, ts, 2, tptr == NULL);
vrele(nd.ni_vp);
return (error);
@@ -3429,7 +3429,7 @@
* "If both tv_nsec fields are UTIME_OMIT... EACCESS may be detected."
* "Search permission is denied by a component of the path prefix."
*/
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
if ((flags & UTIMENS_EXIT) == 0)
error = setutimes(td, nd.ni_vp, ts, 2, flags & UTIMENS_NULL);
vrele(nd.ni_vp);
@@ -3471,7 +3471,7 @@
if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX);
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
vn_rangelock_unlock(vp, rl_cookie);
@@ -3833,7 +3833,7 @@
NDPREINIT(&nd);
restart:
bwillwrite();
- NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
+ NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | AUDITVNODE1 |
NC_NOMAKEENTRY | NC_KEEPPOSENTRY | FAILIFEXISTS | WILLBEDIR,
segflg, path, fd, &cap_mkdirat_rights);
if ((error = namei(&nd)) != 0)
@@ -4286,7 +4286,7 @@
if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
if (vp->v_type != VCHR || vp->v_rdev == NULL) {
error = EINVAL;
goto out;
@@ -4450,7 +4450,7 @@
error = namei(&nd);
if (error != 0)
return (error);
- NDFREE_NOTHING(&nd);
+ NDFREE_PNBUF(&nd);
vp = nd.ni_vp;
bzero(&fh, sizeof(fh));
fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
Index: sys/sys/namei.h
===================================================================
--- sys/sys/namei.h
+++ sys/sys/namei.h
@@ -158,20 +158,9 @@
/*
* Namei parameter descriptors.
- *
- * SAVENAME may be set by either the callers of namei or by VOP_LOOKUP.
- * If the caller of namei sets the flag (for example execve wants to
- * know the name of the program that is being executed), then it must
- * free the buffer. If VOP_LOOKUP sets the flag, then the buffer must
- * be freed by either the commit routine or the VOP_ABORT routine.
- * SAVESTART is set only by the callers of namei. It implies SAVENAME
- * plus the addition of saving the parent directory that contains the
- * name in ni_startdir. It allows repeated calls to lookup for the
- * name being sought. The caller is responsible for releasing the
- * buffer and for vrele'ing ni_startdir.
*/
#define RDONLY 0x00000200 /* lookup with read-only semantics */
-#define SAVENAME 0x00000400 /* save pathname buffer */
+/* UNUSED 0x00000400 */
#define SAVESTART 0x00000800 /* save starting directory */
#define ISWHITEOUT 0x00001000 /* found whiteout */
#define DOWHITEOUT 0x00002000 /* do whiteouts */
@@ -185,7 +174,7 @@
#define OPENREAD 0x00200000 /* open for reading */
#define OPENWRITE 0x00400000 /* open for writing */
#define WANTIOCTLCAPS 0x00800000 /* leave ioctl caps for the caller */
-#define HASBUF 0x01000000 /* has allocated pathname buffer */
+/* UNUSED 0x01000000 */
#define NOEXECCHECK 0x02000000 /* do not perform exec check on dir */
#define MAKEENTRY 0x04000000 /* entry is to be added to name cache */
#define ISSYMLINK 0x08000000 /* symlink needs interpretation */
@@ -198,7 +187,7 @@
* Flags which must not be passed in by callers.
*/
#define NAMEI_INTERNAL_FLAGS \
- (HASBUF | NOEXECCHECK | MAKEENTRY | ISSYMLINK | ISLASTCN | ISDOTDOT | \
+ (NOEXECCHECK | MAKEENTRY | ISSYMLINK | ISLASTCN | ISDOTDOT | \
TRAILINGSLASH)
/*
@@ -293,14 +282,13 @@
struct nameidata *_ndp = (ndp); \
filecaps_free(&_ndp->ni_filecaps); \
} while (0)
-void NDFREE_PNBUF(struct nameidata *);
-void NDFREE(struct nameidata *, const u_int);
-#ifdef INVARIANTS
-void NDFREE_NOTHING(struct nameidata *);
-#else
-#define NDFREE_NOTHING(ndp) do { } while (0)
-#endif
+#define NDFREE_PNBUF(ndp) do { \
+ struct nameidata *_ndp = (ndp); \
+ uma_zfree(namei_zone, _ndp->ni_cnd.cn_pnbuf); \
+} while (0)
+
+void NDFREE(struct nameidata *, const u_int);
int namei(struct nameidata *ndp);
int vfs_lookup(struct nameidata *ndp);
Index: sys/sys/param.h
===================================================================
--- sys/sys/param.h
+++ sys/sys/param.h
@@ -76,7 +76,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1400067
+#define __FreeBSD_version 1400068
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
Index: sys/ufs/ufs/ufs_lookup.c
===================================================================
--- sys/ufs/ufs/ufs_lookup.c
+++ sys/ufs/ufs/ufs_lookup.c
@@ -524,13 +524,10 @@
* We return ni_vp == NULL to indicate that the entry
* does not currently exist; we leave a pointer to
* the (locked) directory inode in ndp->ni_dvp.
- * The pathname buffer is saved so that the name
- * can be obtained later.
*
* NB - if the directory is unlocked, then this
* information cannot be used.
*/
- cnp->cn_flags |= SAVENAME;
return (EJUSTRETURN);
}
/*
@@ -670,7 +667,6 @@
#endif
*vpp = tdp;
- cnp->cn_flags |= SAVENAME;
return (0);
}
if (dd_ino != NULL)
@@ -830,8 +826,6 @@
u_int namelen;
namelen = (unsigned)cnp->cn_namelen;
- KASSERT((cnp->cn_flags & SAVENAME) != 0,
- ("ufs_makedirentry: missing name"));
KASSERT(namelen <= UFS_MAXNAMLEN,
("ufs_makedirentry: name too long"));
newdirp->d_ino = ip->i_number;
Index: sys/ufs/ufs/ufs_vnops.c
===================================================================
--- sys/ufs/ufs/ufs_vnops.c
+++ sys/ufs/ufs/ufs_vnops.c
@@ -1099,11 +1099,6 @@
struct direct newdir;
int error;
-#ifdef INVARIANTS
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("ufs_link: no name");
-#endif
-
if (DOINGSUJ(tdvp)) {
error = softdep_prelink(tdvp, vp, cnp);
if (error != 0) {
@@ -1194,8 +1189,6 @@
case CREATE:
/* create a new directory whiteout */
#ifdef INVARIANTS
- if ((cnp->cn_flags & SAVENAME) == 0)
- panic("ufs_whiteout: missing name");
if (OFSFMT(dvp))
panic("ufs_whiteout: old format filesystem");
#endif
@@ -1283,11 +1276,6 @@
checkpath_locked = want_seqc_end = false;
-#ifdef INVARIANTS
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("ufs_rename: no name");
-#endif
endoff = 0;
mp = tdvp->v_mount;
VOP_UNLOCK(tdvp);
@@ -2020,10 +2008,6 @@
int error, dmode;
long blkoff;
-#ifdef INVARIANTS
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("ufs_mkdir: no name");
-#endif
dp = VTOI(dvp);
error = ufs_sync_nlink(dvp, NULL);
if (error != 0)
@@ -2795,10 +2779,6 @@
int error;
pdir = VTOI(dvp);
-#ifdef INVARIANTS
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("%s: no name", callfunc);
-#endif
*vpp = NULL;
if ((mode & IFMT) == 0)
mode |= IFREG;

File Metadata

Mime Type
text/plain
Expires
Sat, Sep 19, 5:50 PM (18 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29787040
Default Alt Text
D36542.1789840222.diff (40 KB)

Event Timeline