nfs_clvnops.c (235891a1273d99b86784f935d2d6c554ce189559) | nfs_clvnops.c (b4a58fbf640409a1e507d9f7b411c83a3f83a2f3) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Rick Macklem at The University of Guelph. --- 1151 unchanged lines hidden (view full) --- 1160 struct vnode *dvp = ap->a_dvp; 1161 struct vnode **vpp = ap->a_vpp; 1162 struct mount *mp = dvp->v_mount; 1163 int flags = cnp->cn_flags; 1164 struct vnode *newvp; 1165 struct nfsmount *nmp; 1166 struct nfsnode *np, *newnp; 1167 int error = 0, attrflag, dattrflag, ltype, ncticks; | 1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Rick Macklem at The University of Guelph. --- 1151 unchanged lines hidden (view full) --- 1160 struct vnode *dvp = ap->a_dvp; 1161 struct vnode **vpp = ap->a_vpp; 1162 struct mount *mp = dvp->v_mount; 1163 int flags = cnp->cn_flags; 1164 struct vnode *newvp; 1165 struct nfsmount *nmp; 1166 struct nfsnode *np, *newnp; 1167 int error = 0, attrflag, dattrflag, ltype, ncticks; |
1168 struct thread *td = cnp->cn_thread; | 1168 struct thread *td = curthread; |
1169 struct nfsfh *nfhp; 1170 struct nfsvattr dnfsva, nfsva; 1171 struct vattr vattr; 1172 struct timespec nctime; 1173 uint32_t openmode; 1174 1175 *vpp = NULLVP; 1176 if ((flags & ISLASTCN) && (mp->mnt_flag & MNT_RDONLY) && --- 414 unchanged lines hidden (view full) --- 1591 rdev = vap->va_rdev; 1592 else if (vap->va_type == VFIFO || vap->va_type == VSOCK) 1593 rdev = 0xffffffff; 1594 else 1595 return (EOPNOTSUPP); 1596 if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred))) 1597 return (error); 1598 error = nfsrpc_mknod(dvp, cnp->cn_nameptr, cnp->cn_namelen, vap, | 1169 struct nfsfh *nfhp; 1170 struct nfsvattr dnfsva, nfsva; 1171 struct vattr vattr; 1172 struct timespec nctime; 1173 uint32_t openmode; 1174 1175 *vpp = NULLVP; 1176 if ((flags & ISLASTCN) && (mp->mnt_flag & MNT_RDONLY) && --- 414 unchanged lines hidden (view full) --- 1591 rdev = vap->va_rdev; 1592 else if (vap->va_type == VFIFO || vap->va_type == VSOCK) 1593 rdev = 0xffffffff; 1594 else 1595 return (EOPNOTSUPP); 1596 if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred))) 1597 return (error); 1598 error = nfsrpc_mknod(dvp, cnp->cn_nameptr, cnp->cn_namelen, vap, |
1599 rdev, vap->va_type, cnp->cn_cred, cnp->cn_thread, &dnfsva, | 1599 rdev, vap->va_type, cnp->cn_cred, curthread, &dnfsva, |
1600 &nfsva, &nfhp, &attrflag, &dattrflag, NULL); 1601 if (!error) { 1602 if (!nfhp) 1603 (void) nfsrpc_lookup(dvp, cnp->cn_nameptr, | 1600 &nfsva, &nfhp, &attrflag, &dattrflag, NULL); 1601 if (!error) { 1602 if (!nfhp) 1603 (void) nfsrpc_lookup(dvp, cnp->cn_nameptr, |
1604 cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, | 1604 cnp->cn_namelen, cnp->cn_cred, curthread, |
1605 &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, 1606 NULL, 0); 1607 if (nfhp) 1608 error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, | 1605 &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, 1606 NULL, 0); 1607 if (nfhp) 1608 error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, |
1609 cnp->cn_thread, &np, NULL, LK_EXCLUSIVE); | 1609 curthread, &np, NULL, LK_EXCLUSIVE); |
1610 } 1611 if (dattrflag) 1612 (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); 1613 if (!error) { 1614 newvp = NFSTOV(np); 1615 if (attrflag != 0) { 1616 error = nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 1617 0, 1); 1618 if (error != 0) 1619 vput(newvp); 1620 } 1621 } 1622 if (!error) { 1623 *vpp = newvp; 1624 } else if (NFS_ISV4(dvp)) { | 1610 } 1611 if (dattrflag) 1612 (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); 1613 if (!error) { 1614 newvp = NFSTOV(np); 1615 if (attrflag != 0) { 1616 error = nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 1617 0, 1); 1618 if (error != 0) 1619 vput(newvp); 1620 } 1621 } 1622 if (!error) { 1623 *vpp = newvp; 1624 } else if (NFS_ISV4(dvp)) { |
1625 error = nfscl_maperr(cnp->cn_thread, error, vap->va_uid, | 1625 error = nfscl_maperr(curthread, error, vap->va_uid, |
1626 vap->va_gid); 1627 } 1628 dnp = VTONFS(dvp); 1629 NFSLOCKNODE(dnp); 1630 dnp->n_flag |= NMODIFIED; 1631 if (!dattrflag) { 1632 dnp->n_attrstamp = 0; 1633 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); --- 73 unchanged lines hidden (view full) --- 1707 while (NFSHASNFSV4(nmp) && (dnp->n_flag & NREMOVEINPROG)) { 1708 dnp->n_flag |= NREMOVEWANT; 1709 (void) msleep((caddr_t)dnp, &dnp->n_mtx, PZERO, "nfscrt", 0); 1710 } 1711 NFSUNLOCKNODE(dnp); 1712 1713 cverf = nfs_get_cverf(); 1714 error = nfsrpc_create(dvp, cnp->cn_nameptr, cnp->cn_namelen, | 1626 vap->va_gid); 1627 } 1628 dnp = VTONFS(dvp); 1629 NFSLOCKNODE(dnp); 1630 dnp->n_flag |= NMODIFIED; 1631 if (!dattrflag) { 1632 dnp->n_attrstamp = 0; 1633 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); --- 73 unchanged lines hidden (view full) --- 1707 while (NFSHASNFSV4(nmp) && (dnp->n_flag & NREMOVEINPROG)) { 1708 dnp->n_flag |= NREMOVEWANT; 1709 (void) msleep((caddr_t)dnp, &dnp->n_mtx, PZERO, "nfscrt", 0); 1710 } 1711 NFSUNLOCKNODE(dnp); 1712 1713 cverf = nfs_get_cverf(); 1714 error = nfsrpc_create(dvp, cnp->cn_nameptr, cnp->cn_namelen, |
1715 vap, cverf, fmode, cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, | 1715 vap, cverf, fmode, cnp->cn_cred, curthread, &dnfsva, &nfsva, |
1716 &nfhp, &attrflag, &dattrflag, NULL); 1717 if (!error) { 1718 if (nfhp == NULL) 1719 (void) nfsrpc_lookup(dvp, cnp->cn_nameptr, | 1716 &nfhp, &attrflag, &dattrflag, NULL); 1717 if (!error) { 1718 if (nfhp == NULL) 1719 (void) nfsrpc_lookup(dvp, cnp->cn_nameptr, |
1720 cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, | 1720 cnp->cn_namelen, cnp->cn_cred, curthread, |
1721 &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, 1722 NULL, 0); 1723 if (nfhp != NULL) 1724 error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, | 1721 &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, 1722 NULL, 0); 1723 if (nfhp != NULL) 1724 error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, |
1725 cnp->cn_thread, &np, NULL, LK_EXCLUSIVE); | 1725 curthread, &np, NULL, LK_EXCLUSIVE); |
1726 } 1727 if (dattrflag) 1728 (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); 1729 if (!error) { 1730 newvp = NFSTOV(np); 1731 if (attrflag == 0) 1732 error = nfsrpc_getattr(newvp, cnp->cn_cred, | 1726 } 1727 if (dattrflag) 1728 (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); 1729 if (!error) { 1730 newvp = NFSTOV(np); 1731 if (attrflag == 0) 1732 error = nfsrpc_getattr(newvp, cnp->cn_cred, |
1733 cnp->cn_thread, &nfsva, NULL); | 1733 curthread, &nfsva, NULL); |
1734 if (error == 0) 1735 error = nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 1736 0, 1); 1737 } 1738 if (error) { 1739 if (newvp != NULL) { 1740 vput(newvp); 1741 newvp = NULL; 1742 } 1743 if (NFS_ISV34(dvp) && (fmode & O_EXCL) && 1744 error == NFSERR_NOTSUPP) { 1745 fmode &= ~O_EXCL; 1746 goto again; 1747 } 1748 } else if (NFS_ISV34(dvp) && (fmode & O_EXCL)) { 1749 if (nfscl_checksattr(vap, &nfsva)) { 1750 error = nfsrpc_setattr(newvp, vap, NULL, cnp->cn_cred, | 1734 if (error == 0) 1735 error = nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 1736 0, 1); 1737 } 1738 if (error) { 1739 if (newvp != NULL) { 1740 vput(newvp); 1741 newvp = NULL; 1742 } 1743 if (NFS_ISV34(dvp) && (fmode & O_EXCL) && 1744 error == NFSERR_NOTSUPP) { 1745 fmode &= ~O_EXCL; 1746 goto again; 1747 } 1748 } else if (NFS_ISV34(dvp) && (fmode & O_EXCL)) { 1749 if (nfscl_checksattr(vap, &nfsva)) { 1750 error = nfsrpc_setattr(newvp, vap, NULL, cnp->cn_cred, |
1751 cnp->cn_thread, &nfsva, &attrflag, NULL); | 1751 curthread, &nfsva, &attrflag, NULL); |
1752 if (error && (vap->va_uid != (uid_t)VNOVAL || 1753 vap->va_gid != (gid_t)VNOVAL)) { 1754 /* try again without setting uid/gid */ 1755 vap->va_uid = (uid_t)VNOVAL; 1756 vap->va_gid = (uid_t)VNOVAL; 1757 error = nfsrpc_setattr(newvp, vap, NULL, | 1752 if (error && (vap->va_uid != (uid_t)VNOVAL || 1753 vap->va_gid != (gid_t)VNOVAL)) { 1754 /* try again without setting uid/gid */ 1755 vap->va_uid = (uid_t)VNOVAL; 1756 vap->va_gid = (uid_t)VNOVAL; 1757 error = nfsrpc_setattr(newvp, vap, NULL, |
1758 cnp->cn_cred, cnp->cn_thread, &nfsva, | 1758 cnp->cn_cred, curthread, &nfsva, |
1759 &attrflag, NULL); 1760 } 1761 if (attrflag) 1762 (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, 1763 NULL, 0, 1); 1764 if (error != 0) 1765 vput(newvp); 1766 } --- 4 unchanged lines hidden (view full) --- 1771 cache_enter_time(dvp, newvp, cnp, 1772 &nfsva.na_ctime, NULL); 1773 else 1774 printf("nfs_create: bogus NFS server returned " 1775 "the directory as the new file object\n"); 1776 } 1777 *ap->a_vpp = newvp; 1778 } else if (NFS_ISV4(dvp)) { | 1759 &attrflag, NULL); 1760 } 1761 if (attrflag) 1762 (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, 1763 NULL, 0, 1); 1764 if (error != 0) 1765 vput(newvp); 1766 } --- 4 unchanged lines hidden (view full) --- 1771 cache_enter_time(dvp, newvp, cnp, 1772 &nfsva.na_ctime, NULL); 1773 else 1774 printf("nfs_create: bogus NFS server returned " 1775 "the directory as the new file object\n"); 1776 } 1777 *ap->a_vpp = newvp; 1778 } else if (NFS_ISV4(dvp)) { |
1779 error = nfscl_maperr(cnp->cn_thread, error, vap->va_uid, | 1779 error = nfscl_maperr(curthread, error, vap->va_uid, |
1780 vap->va_gid); 1781 } 1782 NFSLOCKNODE(dnp); 1783 dnp->n_flag |= NMODIFIED; 1784 if (!dattrflag) { 1785 dnp->n_attrstamp = 0; 1786 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); 1787 } --- 36 unchanged lines hidden (view full) --- 1824 * that an I/O op returns ESTALE, but since you get this if 1825 * another host removes the file.. 1826 */ 1827 cache_purge(vp); 1828 /* 1829 * throw away biocache buffers, mainly to avoid 1830 * unnecessary delayed writes later. 1831 */ | 1780 vap->va_gid); 1781 } 1782 NFSLOCKNODE(dnp); 1783 dnp->n_flag |= NMODIFIED; 1784 if (!dattrflag) { 1785 dnp->n_attrstamp = 0; 1786 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); 1787 } --- 36 unchanged lines hidden (view full) --- 1824 * that an I/O op returns ESTALE, but since you get this if 1825 * another host removes the file.. 1826 */ 1827 cache_purge(vp); 1828 /* 1829 * throw away biocache buffers, mainly to avoid 1830 * unnecessary delayed writes later. 1831 */ |
1832 error = ncl_vinvalbuf(vp, 0, cnp->cn_thread, 1); | 1832 error = ncl_vinvalbuf(vp, 0, curthread, 1); |
1833 if (error != EINTR && error != EIO) 1834 /* Do the rpc */ 1835 error = nfs_removerpc(dvp, vp, cnp->cn_nameptr, | 1833 if (error != EINTR && error != EIO) 1834 /* Do the rpc */ 1835 error = nfs_removerpc(dvp, vp, cnp->cn_nameptr, |
1836 cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread); | 1836 cnp->cn_namelen, cnp->cn_cred, curthread); |
1837 /* 1838 * Kludge City: If the first reply to the remove rpc is lost.. 1839 * the reply to the retransmitted request will be ENOENT 1840 * since the file was in fact removed 1841 * Therefore, we cheat and return success. 1842 */ 1843 if (error == ENOENT) 1844 error = 0; --- 103 unchanged lines hidden (view full) --- 1948 * ( as far as I can tell ) it flushes dirty buffers more 1949 * often. 1950 * 1951 * Skip the rename operation if the fsync fails, this can happen 1952 * due to the server's volume being full, when we pushed out data 1953 * that was written back to our cache earlier. Not checking for 1954 * this condition can result in potential (silent) data loss. 1955 */ | 1837 /* 1838 * Kludge City: If the first reply to the remove rpc is lost.. 1839 * the reply to the retransmitted request will be ENOENT 1840 * since the file was in fact removed 1841 * Therefore, we cheat and return success. 1842 */ 1843 if (error == ENOENT) 1844 error = 0; --- 103 unchanged lines hidden (view full) --- 1948 * ( as far as I can tell ) it flushes dirty buffers more 1949 * often. 1950 * 1951 * Skip the rename operation if the fsync fails, this can happen 1952 * due to the server's volume being full, when we pushed out data 1953 * that was written back to our cache earlier. Not checking for 1954 * this condition can result in potential (silent) data loss. 1955 */ |
1956 error = VOP_FSYNC(fvp, MNT_WAIT, fcnp->cn_thread); | 1956 error = VOP_FSYNC(fvp, MNT_WAIT, curthread); |
1957 NFSVOPUNLOCK(fvp); 1958 if (!error && tvp) | 1957 NFSVOPUNLOCK(fvp); 1958 if (!error && tvp) |
1959 error = VOP_FSYNC(tvp, MNT_WAIT, tcnp->cn_thread); | 1959 error = VOP_FSYNC(tvp, MNT_WAIT, curthread); |
1960 if (error) 1961 goto out; 1962 1963 /* 1964 * If the tvp exists and is in use, sillyrename it before doing the 1965 * rename of the new file over it. 1966 * XXX Can't sillyrename a directory. 1967 */ 1968 if (tvp && vrefcnt(tvp) > 1 && !VTONFS(tvp)->n_sillyrename && 1969 tvp->v_type != VDIR && !nfs_sillyrename(tdvp, tvp, tcnp)) { 1970 vput(tvp); 1971 tvp = NULL; 1972 } 1973 1974 error = nfs_renamerpc(fdvp, fvp, fcnp->cn_nameptr, fcnp->cn_namelen, 1975 tdvp, tvp, tcnp->cn_nameptr, tcnp->cn_namelen, tcnp->cn_cred, | 1960 if (error) 1961 goto out; 1962 1963 /* 1964 * If the tvp exists and is in use, sillyrename it before doing the 1965 * rename of the new file over it. 1966 * XXX Can't sillyrename a directory. 1967 */ 1968 if (tvp && vrefcnt(tvp) > 1 && !VTONFS(tvp)->n_sillyrename && 1969 tvp->v_type != VDIR && !nfs_sillyrename(tdvp, tvp, tcnp)) { 1970 vput(tvp); 1971 tvp = NULL; 1972 } 1973 1974 error = nfs_renamerpc(fdvp, fvp, fcnp->cn_nameptr, fcnp->cn_namelen, 1975 tdvp, tvp, tcnp->cn_nameptr, tcnp->cn_namelen, tcnp->cn_cred, |
1976 tcnp->cn_thread); | 1976 curthread); |
1977 1978 if (error == 0 && NFS_ISV4(tdvp)) { 1979 /* 1980 * For NFSv4, check to see if it is the same name and 1981 * replace the name, if it is different. 1982 */ 1983 newv4 = malloc( 1984 sizeof (struct nfsv4node) + --- 60 unchanged lines hidden (view full) --- 2045 */ 2046static int 2047nfs_renameit(struct vnode *sdvp, struct vnode *svp, struct componentname *scnp, 2048 struct sillyrename *sp) 2049{ 2050 2051 return (nfs_renamerpc(sdvp, svp, scnp->cn_nameptr, scnp->cn_namelen, 2052 sdvp, NULL, sp->s_name, sp->s_namlen, scnp->cn_cred, | 1977 1978 if (error == 0 && NFS_ISV4(tdvp)) { 1979 /* 1980 * For NFSv4, check to see if it is the same name and 1981 * replace the name, if it is different. 1982 */ 1983 newv4 = malloc( 1984 sizeof (struct nfsv4node) + --- 60 unchanged lines hidden (view full) --- 2045 */ 2046static int 2047nfs_renameit(struct vnode *sdvp, struct vnode *svp, struct componentname *scnp, 2048 struct sillyrename *sp) 2049{ 2050 2051 return (nfs_renamerpc(sdvp, svp, scnp->cn_nameptr, scnp->cn_namelen, 2052 sdvp, NULL, sp->s_name, sp->s_namlen, scnp->cn_cred, |
2053 scnp->cn_thread)); | 2053 curthread)); |
2054} 2055 2056/* 2057 * Do an nfs rename rpc. Called from nfs_rename() and nfs_renameit(). 2058 */ 2059static int 2060nfs_renamerpc(struct vnode *fdvp, struct vnode *fvp, char *fnameptr, 2061 int fnamelen, struct vnode *tdvp, struct vnode *tvp, char *tnameptr, --- 45 unchanged lines hidden (view full) --- 2107 struct nfsvattr nfsva, dnfsva; 2108 int error = 0, attrflag, dattrflag; 2109 2110 /* 2111 * Push all writes to the server, so that the attribute cache 2112 * doesn't get "out of sync" with the server. 2113 * XXX There should be a better way! 2114 */ | 2054} 2055 2056/* 2057 * Do an nfs rename rpc. Called from nfs_rename() and nfs_renameit(). 2058 */ 2059static int 2060nfs_renamerpc(struct vnode *fdvp, struct vnode *fvp, char *fnameptr, 2061 int fnamelen, struct vnode *tdvp, struct vnode *tvp, char *tnameptr, --- 45 unchanged lines hidden (view full) --- 2107 struct nfsvattr nfsva, dnfsva; 2108 int error = 0, attrflag, dattrflag; 2109 2110 /* 2111 * Push all writes to the server, so that the attribute cache 2112 * doesn't get "out of sync" with the server. 2113 * XXX There should be a better way! 2114 */ |
2115 VOP_FSYNC(vp, MNT_WAIT, cnp->cn_thread); | 2115 VOP_FSYNC(vp, MNT_WAIT, curthread); |
2116 2117 error = nfsrpc_link(tdvp, vp, cnp->cn_nameptr, cnp->cn_namelen, | 2116 2117 error = nfsrpc_link(tdvp, vp, cnp->cn_nameptr, cnp->cn_namelen, |
2118 cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, &attrflag, | 2118 cnp->cn_cred, curthread, &dnfsva, &nfsva, &attrflag, |
2119 &dattrflag, NULL); 2120 tdnp = VTONFS(tdvp); 2121 NFSLOCKNODE(tdnp); 2122 tdnp->n_flag |= NMODIFIED; 2123 if (dattrflag != 0) { 2124 NFSUNLOCKNODE(tdnp); 2125 (void) nfscl_loadattrcache(&tdvp, &dnfsva, NULL, NULL, 0, 1); 2126 } else { --- 20 unchanged lines hidden (view full) --- 2147 (cnp->cn_flags & MAKEENTRY) && attrflag != 0 && error == 0) { 2148 if (tdvp != vp) 2149 cache_enter_time(tdvp, vp, cnp, &nfsva.na_ctime, NULL); 2150 else 2151 printf("nfs_link: bogus NFS server returned " 2152 "the directory as the new link\n"); 2153 } 2154 if (error && NFS_ISV4(vp)) | 2119 &dattrflag, NULL); 2120 tdnp = VTONFS(tdvp); 2121 NFSLOCKNODE(tdnp); 2122 tdnp->n_flag |= NMODIFIED; 2123 if (dattrflag != 0) { 2124 NFSUNLOCKNODE(tdnp); 2125 (void) nfscl_loadattrcache(&tdvp, &dnfsva, NULL, NULL, 0, 1); 2126 } else { --- 20 unchanged lines hidden (view full) --- 2147 (cnp->cn_flags & MAKEENTRY) && attrflag != 0 && error == 0) { 2148 if (tdvp != vp) 2149 cache_enter_time(tdvp, vp, cnp, &nfsva.na_ctime, NULL); 2150 else 2151 printf("nfs_link: bogus NFS server returned " 2152 "the directory as the new link\n"); 2153 } 2154 if (error && NFS_ISV4(vp)) |
2155 error = nfscl_maperr(cnp->cn_thread, error, (uid_t)0, | 2155 error = nfscl_maperr(curthread, error, (uid_t)0, |
2156 (gid_t)0); 2157 return (error); 2158} 2159 2160/* 2161 * nfs symbolic link create call 2162 */ 2163static int --- 5 unchanged lines hidden (view full) --- 2169 struct nfsvattr nfsva, dnfsva; 2170 struct nfsfh *nfhp; 2171 struct nfsnode *np = NULL, *dnp; 2172 struct vnode *newvp = NULL; 2173 int error = 0, attrflag, dattrflag, ret; 2174 2175 vap->va_type = VLNK; 2176 error = nfsrpc_symlink(dvp, cnp->cn_nameptr, cnp->cn_namelen, | 2156 (gid_t)0); 2157 return (error); 2158} 2159 2160/* 2161 * nfs symbolic link create call 2162 */ 2163static int --- 5 unchanged lines hidden (view full) --- 2169 struct nfsvattr nfsva, dnfsva; 2170 struct nfsfh *nfhp; 2171 struct nfsnode *np = NULL, *dnp; 2172 struct vnode *newvp = NULL; 2173 int error = 0, attrflag, dattrflag, ret; 2174 2175 vap->va_type = VLNK; 2176 error = nfsrpc_symlink(dvp, cnp->cn_nameptr, cnp->cn_namelen, |
2177 ap->a_target, vap, cnp->cn_cred, cnp->cn_thread, &dnfsva, | 2177 ap->a_target, vap, cnp->cn_cred, curthread, &dnfsva, |
2178 &nfsva, &nfhp, &attrflag, &dattrflag, NULL); 2179 if (nfhp) { | 2178 &nfsva, &nfhp, &attrflag, &dattrflag, NULL); 2179 if (nfhp) { |
2180 ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread, | 2180 ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, curthread, |
2181 &np, NULL, LK_EXCLUSIVE); 2182 if (!ret) 2183 newvp = NFSTOV(np); 2184 else if (!error) 2185 error = ret; 2186 } 2187 if (newvp != NULL) { 2188 if (attrflag) 2189 (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 2190 0, 1); 2191 } else if (!error) { 2192 /* 2193 * If we do not have an error and we could not extract the 2194 * newvp from the response due to the request being NFSv2, we 2195 * have to do a lookup in order to obtain a newvp to return. 2196 */ 2197 error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen, | 2181 &np, NULL, LK_EXCLUSIVE); 2182 if (!ret) 2183 newvp = NFSTOV(np); 2184 else if (!error) 2185 error = ret; 2186 } 2187 if (newvp != NULL) { 2188 if (attrflag) 2189 (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 2190 0, 1); 2191 } else if (!error) { 2192 /* 2193 * If we do not have an error and we could not extract the 2194 * newvp from the response due to the request being NFSv2, we 2195 * have to do a lookup in order to obtain a newvp to return. 2196 */ 2197 error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen, |
2198 cnp->cn_cred, cnp->cn_thread, &np); | 2198 cnp->cn_cred, curthread, &np); |
2199 if (!error) 2200 newvp = NFSTOV(np); 2201 } 2202 if (error) { 2203 if (newvp) 2204 vput(newvp); 2205 if (NFS_ISV4(dvp)) | 2199 if (!error) 2200 newvp = NFSTOV(np); 2201 } 2202 if (error) { 2203 if (newvp) 2204 vput(newvp); 2205 if (NFS_ISV4(dvp)) |
2206 error = nfscl_maperr(cnp->cn_thread, error, | 2206 error = nfscl_maperr(curthread, error, |
2207 vap->va_uid, vap->va_gid); 2208 } else { 2209 *ap->a_vpp = newvp; 2210 } 2211 2212 dnp = VTONFS(dvp); 2213 NFSLOCKNODE(dnp); 2214 dnp->n_flag |= NMODIFIED; --- 38 unchanged lines hidden (view full) --- 2253 struct nfsfh *nfhp; 2254 struct nfsvattr nfsva, dnfsva; 2255 int error = 0, attrflag, dattrflag, ret; 2256 2257 if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) != 0) 2258 return (error); 2259 vap->va_type = VDIR; 2260 error = nfsrpc_mkdir(dvp, cnp->cn_nameptr, cnp->cn_namelen, | 2207 vap->va_uid, vap->va_gid); 2208 } else { 2209 *ap->a_vpp = newvp; 2210 } 2211 2212 dnp = VTONFS(dvp); 2213 NFSLOCKNODE(dnp); 2214 dnp->n_flag |= NMODIFIED; --- 38 unchanged lines hidden (view full) --- 2253 struct nfsfh *nfhp; 2254 struct nfsvattr nfsva, dnfsva; 2255 int error = 0, attrflag, dattrflag, ret; 2256 2257 if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)) != 0) 2258 return (error); 2259 vap->va_type = VDIR; 2260 error = nfsrpc_mkdir(dvp, cnp->cn_nameptr, cnp->cn_namelen, |
2261 vap, cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, &nfhp, | 2261 vap, cnp->cn_cred, curthread, &dnfsva, &nfsva, &nfhp, |
2262 &attrflag, &dattrflag, NULL); 2263 dnp = VTONFS(dvp); 2264 NFSLOCKNODE(dnp); 2265 dnp->n_flag |= NMODIFIED; 2266 if (dattrflag != 0) { 2267 NFSUNLOCKNODE(dnp); 2268 (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); 2269 } else { 2270 dnp->n_attrstamp = 0; 2271 NFSUNLOCKNODE(dnp); 2272 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); 2273 } 2274 if (nfhp) { | 2262 &attrflag, &dattrflag, NULL); 2263 dnp = VTONFS(dvp); 2264 NFSLOCKNODE(dnp); 2265 dnp->n_flag |= NMODIFIED; 2266 if (dattrflag != 0) { 2267 NFSUNLOCKNODE(dnp); 2268 (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); 2269 } else { 2270 dnp->n_attrstamp = 0; 2271 NFSUNLOCKNODE(dnp); 2272 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); 2273 } 2274 if (nfhp) { |
2275 ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread, | 2275 ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, curthread, |
2276 &np, NULL, LK_EXCLUSIVE); 2277 if (!ret) { 2278 newvp = NFSTOV(np); 2279 if (attrflag) 2280 (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, 2281 NULL, 0, 1); 2282 } else if (!error) 2283 error = ret; 2284 } 2285 if (!error && newvp == NULL) { 2286 error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen, | 2276 &np, NULL, LK_EXCLUSIVE); 2277 if (!ret) { 2278 newvp = NFSTOV(np); 2279 if (attrflag) 2280 (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, 2281 NULL, 0, 1); 2282 } else if (!error) 2283 error = ret; 2284 } 2285 if (!error && newvp == NULL) { 2286 error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen, |
2287 cnp->cn_cred, cnp->cn_thread, &np); | 2287 cnp->cn_cred, curthread, &np); |
2288 if (!error) { 2289 newvp = NFSTOV(np); 2290 if (newvp->v_type != VDIR) 2291 error = EEXIST; 2292 } 2293 } 2294 if (error) { 2295 if (newvp) 2296 vput(newvp); 2297 if (NFS_ISV4(dvp)) | 2288 if (!error) { 2289 newvp = NFSTOV(np); 2290 if (newvp->v_type != VDIR) 2291 error = EEXIST; 2292 } 2293 } 2294 if (error) { 2295 if (newvp) 2296 vput(newvp); 2297 if (NFS_ISV4(dvp)) |
2298 error = nfscl_maperr(cnp->cn_thread, error, | 2298 error = nfscl_maperr(curthread, error, |
2299 vap->va_uid, vap->va_gid); 2300 } else { 2301 /* 2302 * If negative lookup caching is enabled, I might as well 2303 * add an entry for this node. Not necessary for correctness, 2304 * but if negative caching is enabled, then the system 2305 * must care about lookup caching hit rate, so... 2306 */ --- 24 unchanged lines hidden (view full) --- 2331 struct componentname *cnp = ap->a_cnp; 2332 struct nfsnode *dnp; 2333 struct nfsvattr dnfsva; 2334 int error, dattrflag; 2335 2336 if (dvp == vp) 2337 return (EINVAL); 2338 error = nfsrpc_rmdir(dvp, cnp->cn_nameptr, cnp->cn_namelen, | 2299 vap->va_uid, vap->va_gid); 2300 } else { 2301 /* 2302 * If negative lookup caching is enabled, I might as well 2303 * add an entry for this node. Not necessary for correctness, 2304 * but if negative caching is enabled, then the system 2305 * must care about lookup caching hit rate, so... 2306 */ --- 24 unchanged lines hidden (view full) --- 2331 struct componentname *cnp = ap->a_cnp; 2332 struct nfsnode *dnp; 2333 struct nfsvattr dnfsva; 2334 int error, dattrflag; 2335 2336 if (dvp == vp) 2337 return (EINVAL); 2338 error = nfsrpc_rmdir(dvp, cnp->cn_nameptr, cnp->cn_namelen, |
2339 cnp->cn_cred, cnp->cn_thread, &dnfsva, &dattrflag, NULL); | 2339 cnp->cn_cred, curthread, &dnfsva, &dattrflag, NULL); |
2340 dnp = VTONFS(dvp); 2341 NFSLOCKNODE(dnp); 2342 dnp->n_flag |= NMODIFIED; 2343 if (dattrflag != 0) { 2344 NFSUNLOCKNODE(dnp); 2345 (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); 2346 } else { 2347 dnp->n_attrstamp = 0; 2348 NFSUNLOCKNODE(dnp); 2349 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); 2350 } 2351 2352 cache_purge(dvp); 2353 cache_purge(vp); 2354 if (error && NFS_ISV4(dvp)) | 2340 dnp = VTONFS(dvp); 2341 NFSLOCKNODE(dnp); 2342 dnp->n_flag |= NMODIFIED; 2343 if (dattrflag != 0) { 2344 NFSUNLOCKNODE(dnp); 2345 (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); 2346 } else { 2347 dnp->n_attrstamp = 0; 2348 NFSUNLOCKNODE(dnp); 2349 KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); 2350 } 2351 2352 cache_purge(dvp); 2353 cache_purge(vp); 2354 if (error && NFS_ISV4(dvp)) |
2355 error = nfscl_maperr(cnp->cn_thread, error, (uid_t)0, | 2355 error = nfscl_maperr(curthread, error, (uid_t)0, |
2356 (gid_t)0); 2357 /* 2358 * Kludge: Map ENOENT => 0 assuming that you have a reply to a retry. 2359 */ 2360 if (error == ENOENT) 2361 error = 0; 2362 return (error); 2363} --- 222 unchanged lines hidden (view full) --- 2586 2587 /* 2588 * Fudge together a funny name. 2589 * Changing the format of the funny name to accommodate more 2590 * sillynames per directory. 2591 * The name is now changed to .nfs.<ticks>.<pid>.4, where ticks is 2592 * CPU ticks since boot. 2593 */ | 2356 (gid_t)0); 2357 /* 2358 * Kludge: Map ENOENT => 0 assuming that you have a reply to a retry. 2359 */ 2360 if (error == ENOENT) 2361 error = 0; 2362 return (error); 2363} --- 222 unchanged lines hidden (view full) --- 2586 2587 /* 2588 * Fudge together a funny name. 2589 * Changing the format of the funny name to accommodate more 2590 * sillynames per directory. 2591 * The name is now changed to .nfs.<ticks>.<pid>.4, where ticks is 2592 * CPU ticks since boot. 2593 */ |
2594 pid = cnp->cn_thread->td_proc->p_pid; | 2594 pid = curthread->td_proc->p_pid; |
2595 lticks = (unsigned int)ticks; 2596 for ( ; ; ) { 2597 sp->s_namlen = sprintf(sp->s_name, 2598 ".nfs.%08x.%04x4.4", lticks, 2599 pid); 2600 if (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, | 2595 lticks = (unsigned int)ticks; 2596 for ( ; ; ) { 2597 sp->s_namlen = sprintf(sp->s_name, 2598 ".nfs.%08x.%04x4.4", lticks, 2599 pid); 2600 if (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, |
2601 cnp->cn_thread, NULL)) | 2601 curthread, NULL)) |
2602 break; 2603 lticks++; 2604 } 2605 error = nfs_renameit(dvp, vp, cnp, sp); 2606 if (error) 2607 goto bad; 2608 error = nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, | 2602 break; 2603 lticks++; 2604 } 2605 error = nfs_renameit(dvp, vp, cnp, sp); 2606 if (error) 2607 goto bad; 2608 error = nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, |
2609 cnp->cn_thread, &np); | 2609 curthread, &np); |
2610 np->n_sillyrename = sp; 2611 return (0); 2612bad: 2613 vrele(sp->s_dvp); 2614 crfree(sp->s_cred); 2615 free(sp, M_NEWNFSREQ); 2616 return (error); 2617} --- 1829 unchanged lines hidden --- | 2610 np->n_sillyrename = sp; 2611 return (0); 2612bad: 2613 vrele(sp->s_dvp); 2614 crfree(sp->s_cred); 2615 free(sp, M_NEWNFSREQ); 2616 return (error); 2617} --- 1829 unchanged lines hidden --- |