Deleted Added
sdiff udiff text old ( 118047 ) new ( 119832 )
full compact
1/*
2 * Coda: an Experimental Distributed File System
3 * Release 3.1
4 *
5 * Copyright (c) 1987-1998 Carnegie Mellon University
6 * All Rights Reserved
7 *
8 * Permission to use, copy, modify and distribute this software and its

--- 28 unchanged lines hidden (view full) ---

37
38/*
39 * This code was written for the Coda filesystem at Carnegie Mellon
40 * University. Contributers include David Steere, James Kistler, and
41 * M. Satyanarayanan.
42 */
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: head/sys/fs/coda/coda_vnops.c 118047 2003-07-26 07:32:23Z phk $");
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/acct.h>
50#include <sys/errno.h>
51#include <sys/fcntl.h>
52#include <sys/kernel.h>
53#include <sys/lock.h>

--- 430 unchanged lines hidden (view full) ---

484 MARK_INT_FAIL(CODA_RDWR_STATS);
485 return(error);
486 }
487 cfvp = cp->c_ovp;
488 }
489 }
490
491 /* Have UFS handle the call. */
492 CODADEBUG(CODA_RDWR, myprintf(("indirect rdwr: fid = (%lx.%lx.%lx), refcnt = %d\n",
493 cp->c_fid.Volume, cp->c_fid.Vnode,
494 cp->c_fid.Unique, vrefcnt(CTOV(cp)))); )
495
496 if (rw == UIO_READ) {
497 error = VOP_READ(cfvp, uiop, ioflag, cred);
498 } else {
499 error = VOP_WRITE(cfvp, uiop, ioflag, cred);
500 /* ufs_write updates the vnode_pager_setsize for the vnode/object */
501
502 { struct vattr attr;
503

--- 130 unchanged lines hidden (view full) ---

634 /* Check for getattr of control object. */
635 if (IS_CTL_VP(vp)) {
636 MARK_INT_FAIL(CODA_GETATTR_STATS);
637 return(ENOENT);
638 }
639
640 /* Check to see if the attributes have already been cached */
641 if (VALID_VATTR(cp)) {
642 CODADEBUG(CODA_GETATTR, { myprintf(("attr cache hit: (%lx.%lx.%lx)\n",
643 cp->c_fid.Volume,
644 cp->c_fid.Vnode,
645 cp->c_fid.Unique));});
646 CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
647 print_vattr(&cp->c_vattr); );
648
649 *vap = cp->c_vattr;
650 MARK_INT_SAT(CODA_GETATTR_STATS);
651 return(0);
652 }
653
654 error = venus_getattr(vtomi(vp), &cp->c_fid, cred, td->td_proc, vap);
655
656 if (!error) {
657 CODADEBUG(CODA_GETATTR, myprintf(("getattr miss (%lx.%lx.%lx): result %d\n",
658 cp->c_fid.Volume,
659 cp->c_fid.Vnode,
660 cp->c_fid.Unique,
661 error)); )
662
663 CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
664 print_vattr(vap); );
665
666 { int size = vap->va_size;
667 struct vnode *convp = cp->c_ovp;
668 if (convp != (struct vnode *)0) {
669 vnode_pager_setsize(convp, size);

--- 230 unchanged lines hidden (view full) ---

900 /* We don't need to send inactive to venus - DCS */
901 MARK_ENTRY(CODA_INACTIVE_STATS);
902
903 if (IS_CTL_VP(vp)) {
904 MARK_INT_SAT(CODA_INACTIVE_STATS);
905 return 0;
906 }
907
908 CODADEBUG(CODA_INACTIVE, myprintf(("in inactive, %lx.%lx.%lx. vfsp %p\n",
909 cp->c_fid.Volume, cp->c_fid.Vnode,
910 cp->c_fid.Unique, vp->v_mount));)
911
912 /* If an array has been allocated to hold the symlink, deallocate it */
913 if ((coda_symlink_cache) && (VALID_SYMLINK(cp))) {
914 if (cp->c_symlink == NULL)
915 panic("coda_inactive: null symlink pointer in cnode");
916
917 CODA_FREE(cp->c_symlink, cp->c_symlen);
918 cp->c_flags &= ~C_SYMLINK;
919 cp->c_symlen = 0;

--- 55 unchanged lines hidden (view full) ---

975 */
976 struct componentname *cnp = ap->a_cnp;
977 struct ucred *cred = cnp->cn_cred;
978 struct thread *td = cnp->cn_thread;
979/* locals */
980 struct cnode *cp;
981 const char *nm = cnp->cn_nameptr;
982 int len = cnp->cn_namelen;
983 ViceFid VFid;
984 int vtype;
985 int error = 0;
986
987 MARK_ENTRY(CODA_LOOKUP_STATS);
988
989 CODADEBUG(CODA_LOOKUP, myprintf(("lookup: %s in %lx.%lx.%lx\n",
990 nm, dcp->c_fid.Volume,
991 dcp->c_fid.Vnode, dcp->c_fid.Unique)););
992
993 /* Check for lookup of control object. */
994 if (IS_CTL_NAME(dvp, nm, len)) {
995 *vpp = coda_ctlvp;
996 vref(*vpp);
997 MARK_INT_SAT(CODA_LOOKUP_STATS);
998 goto exit;
999 }
1000
1001 if (len+1 > CODA_MAXNAMLEN) {
1002 MARK_INT_FAIL(CODA_LOOKUP_STATS);
1003 CODADEBUG(CODA_LOOKUP, myprintf(("name too long: lookup, %lx.%lx.%lx(%s)\n",
1004 dcp->c_fid.Volume, dcp->c_fid.Vnode,
1005 dcp->c_fid.Unique, nm)););
1006 *vpp = (struct vnode *)0;
1007 error = EINVAL;
1008 goto exit;
1009 }
1010 /* First try to look the file up in the cfs name cache */
1011 /* lock the parent vnode? */
1012 cp = coda_nc_lookup(dcp, nm, len, cred);
1013 if (cp) {
1014 *vpp = CTOV(cp);
1015 vref(*vpp);
1016 CODADEBUG(CODA_LOOKUP,
1017 myprintf(("lookup result %d vpp %p\n",error,*vpp));)
1018 } else {
1019
1020 /* The name wasn't cached, so we need to contact Venus */
1021 error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc, &VFid, &vtype);
1022
1023 if (error) {
1024 MARK_INT_FAIL(CODA_LOOKUP_STATS);
1025 CODADEBUG(CODA_LOOKUP, myprintf(("lookup error on %lx.%lx.%lx(%s)%d\n",
1026 dcp->c_fid.Volume, dcp->c_fid.Vnode, dcp->c_fid.Unique, nm, error));)
1027 *vpp = (struct vnode *)0;
1028 } else {
1029 MARK_INT_SAT(CODA_LOOKUP_STATS);
1030 CODADEBUG(CODA_LOOKUP,
1031 myprintf(("lookup: vol %lx vno %lx uni %lx type %o result %d\n",
1032 VFid.Volume, VFid.Vnode, VFid.Unique, vtype,
1033 error)); )
1034
1035 cp = make_coda_node(&VFid, dvp->v_mount, vtype);
1036 *vpp = CTOV(cp);
1037
1038 /* enter the new vnode in the Name Cache only if the top bit isn't set */
1039 /* And don't enter a new vnode for an invalid one! */
1040 if (!(vtype & CODA_NOCACHE))
1041 coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
1042 }

--- 93 unchanged lines hidden (view full) ---

1136 struct componentname *cnp = ap->a_cnp;
1137 struct ucred *cred = cnp->cn_cred;
1138 struct thread *td = cnp->cn_thread;
1139/* locals */
1140 int error;
1141 struct cnode *cp;
1142 const char *nm = cnp->cn_nameptr;
1143 int len = cnp->cn_namelen;
1144 ViceFid VFid;
1145 struct vattr attr;
1146
1147 MARK_ENTRY(CODA_CREATE_STATS);
1148
1149 /* All creates are exclusive XXX */
1150 /* I'm assuming the 'mode' argument is the file mode bits XXX */
1151
1152 /* Check for create of control object. */

--- 28 unchanged lines hidden (view full) ---

1181
1182 /* Invalidate the parent's attr cache, the modification time has changed */
1183 VTOC(dvp)->c_flags &= ~C_VATTR;
1184
1185 /* enter the new vnode in the Name Cache */
1186 coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
1187
1188 CODADEBUG(CODA_CREATE,
1189 myprintf(("create: (%lx.%lx.%lx), result %d\n",
1190 VFid.Volume, VFid.Vnode, VFid.Unique, error)); )
1191 } else {
1192 *vpp = (struct vnode *)0;
1193 CODADEBUG(CODA_CREATE, myprintf(("create error %d\n", error));)
1194 }
1195
1196 if (!error) {
1197 if (cnp->cn_flags & LOCKLEAF) {
1198 if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) {

--- 24 unchanged lines hidden (view full) ---

1223/* locals */
1224 int error;
1225 const char *nm = cnp->cn_nameptr;
1226 int len = cnp->cn_namelen;
1227 struct cnode *tp;
1228
1229 MARK_ENTRY(CODA_REMOVE_STATS);
1230
1231 CODADEBUG(CODA_REMOVE, myprintf(("remove: %s in %lx.%lx.%lx\n",
1232 nm, cp->c_fid.Volume, cp->c_fid.Vnode,
1233 cp->c_fid.Unique)););
1234
1235 /* Remove the file's entry from the CODA Name Cache */
1236 /* We're being conservative here, it might be that this person
1237 * doesn't really have sufficient access to delete the file
1238 * but we feel zapping the entry won't really hurt anyone -- dcs
1239 */
1240 /* I'm gonna go out on a limb here. If a file and a hardlink to it
1241 * exist, and one is removed, the link count on the other will be
1242 * off by 1. We could either invalidate the attrs if cached, or

--- 42 unchanged lines hidden (view full) ---

1285/* locals */
1286 int error;
1287 const char *nm = cnp->cn_nameptr;
1288 int len = cnp->cn_namelen;
1289
1290 MARK_ENTRY(CODA_LINK_STATS);
1291
1292 if (codadebug & CODADBGMSK(CODA_LINK)) {
1293
1294 myprintf(("nb_link: vp fid: (%lx.%lx.%lx)\n",
1295 cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
1296 myprintf(("nb_link: tdvp fid: (%lx.%lx.%lx)\n",
1297 tdcp->c_fid.Volume, tdcp->c_fid.Vnode, tdcp->c_fid.Unique));
1298
1299 }
1300 if (codadebug & CODADBGMSK(CODA_LINK)) {
1301 myprintf(("link: vp fid: (%lx.%lx.%lx)\n",
1302 cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
1303 myprintf(("link: tdvp fid: (%lx.%lx.%lx)\n",
1304 tdcp->c_fid.Volume, tdcp->c_fid.Vnode, tdcp->c_fid.Unique));
1305
1306 }
1307
1308 /* Check for link to/from control object. */
1309 if (IS_CTL_NAME(tdvp, nm, len) || IS_CTL_VP(vp)) {
1310 MARK_INT_FAIL(CODA_LINK_STATS);
1311 return(EACCES);
1312 }
1313

--- 116 unchanged lines hidden (view full) ---

1430 struct vnode **vpp = ap->a_vpp;
1431 struct ucred *cred = cnp->cn_cred;
1432 struct thread *td = cnp->cn_thread;
1433/* locals */
1434 int error;
1435 const char *nm = cnp->cn_nameptr;
1436 int len = cnp->cn_namelen;
1437 struct cnode *cp;
1438 ViceFid VFid;
1439 struct vattr ova;
1440
1441 MARK_ENTRY(CODA_MKDIR_STATS);
1442
1443 /* Check for mkdir of target object. */
1444 if (IS_CTL_NAME(dvp, nm, len)) {
1445 *vpp = (struct vnode *)0;
1446 MARK_INT_FAIL(CODA_MKDIR_STATS);

--- 26 unchanged lines hidden (view full) ---

1473 if (coda_attr_cache) {
1474 VTOC(*vpp)->c_vattr = ova; /* update the attr cache */
1475 VTOC(*vpp)->c_flags |= C_VATTR; /* Valid attributes in cnode */
1476 }
1477
1478 /* Invalidate the parent's attr cache, the modification time has changed */
1479 VTOC(dvp)->c_flags &= ~C_VATTR;
1480
1481 CODADEBUG( CODA_MKDIR, myprintf(("mkdir: (%lx.%lx.%lx) result %d\n",
1482 VFid.Volume, VFid.Vnode, VFid.Unique, error)); )
1483 } else {
1484 *vpp = (struct vnode *)0;
1485 CODADEBUG(CODA_MKDIR, myprintf(("mkdir error %d\n",error));)
1486 }
1487
1488 return(error);
1489}
1490
1491int

--- 166 unchanged lines hidden (view full) ---

1658 printf("coda_readdir: vfs_object_create() returns %d\n", error);
1659 vput(vp);
1660 }
1661 }
1662 if (error) return(error);
1663 }
1664
1665 /* Have UFS handle the call. */
1666 CODADEBUG(CODA_READDIR, myprintf(("indirect readdir: fid = (%lx.%lx.%lx), refcnt = %d\n",cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique, vrefcnt(vp))); )
1667 error = VOP_READDIR(cp->c_ovp, uiop, cred, eofflag, ncookies,
1668 cookies);
1669
1670 if (error)
1671 MARK_INT_FAIL(CODA_READDIR_STATS);
1672 else
1673 MARK_INT_SAT(CODA_READDIR_STATS);
1674

--- 94 unchanged lines hidden (view full) ---

1769 struct cnode *cp = VTOC(vp);
1770 struct thread *td = ap->a_td;
1771/* upcall decl */
1772/* locals */
1773
1774 ENTRY;
1775
1776 if (coda_lockdebug) {
1777 myprintf(("Attempting lock on %lx.%lx.%lx\n",
1778 cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
1779 }
1780
1781#ifndef DEBUG_LOCKS
1782 return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td));
1783#else
1784 return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td,
1785 "coda_lock", vp->filename, vp->line));
1786#endif

--- 8 unchanged lines hidden (view full) ---

1795 struct vnode *vp = ap->a_vp;
1796 struct cnode *cp = VTOC(vp);
1797 struct thread *td = ap->a_td;
1798/* upcall decl */
1799/* locals */
1800
1801 ENTRY;
1802 if (coda_lockdebug) {
1803 myprintf(("Attempting unlock on %lx.%lx.%lx\n",
1804 cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
1805 }
1806
1807 return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, td));
1808}
1809
1810int
1811coda_islocked(v)
1812 void *v;

--- 102 unchanged lines hidden (view full) ---

1915 myprintf(("\tgroup %d: (%d)\n",i,cred->cr_groups[i]));
1916 myprintf(("\n"));
1917
1918}
1919
1920/*
1921 * Return a vnode for the given fid.
1922 * If no cnode exists for this fid create one and put it
1923 * in a table hashed by fid.Volume and fid.Vnode. If the cnode for
1924 * this fid is already in the table return it (ref count is
1925 * incremented by coda_find. The cnode will be flushed from the
1926 * table when coda_inactive calls coda_unsave.
1927 */
1928struct cnode *
1929make_coda_node(fid, vfsp, type)
1930 ViceFid *fid; struct mount *vfsp; short type;
1931{
1932 struct cnode *cp;
1933 int err;
1934
1935 if ((cp = coda_find(fid)) == NULL) {
1936 struct vnode *vp;
1937
1938 cp = coda_alloc();

--- 45 unchanged lines hidden ---