Commits

Anonymous committed 57816a7

Workaround wrong putfid

  • Participants
  • Parent commits 74f3aac

Comments (0)

Files changed (7)

 /*
  * Many vnodes can refer to the same o9fid and this is accounted for in ref.
  * When ref drops to zero, the o9fid is clunked.
+ * Every change in o9fid should be checking in the cloning process in o9fs_9p.c:/^o9fs_walk
  */
 struct o9fid {
 	int32_t		fid;
 	O9FS_PBIT32(fs->outbuf + Minhd, f->fid);
 	
 	o9fs_mio(fs, 11);
-	o9fs_xputfid(fs, f);
 	DRET();
 }
 
 		newfid->mode = fid->mode;
 		newfid->qid = fid->qid;
 		newfid->offset = fid->offset;
+		newfid->parent = fid->parent;
+		newfid->ref = fid->ref;
 		nwname = 0;
 		p += Minhd + 4 + 4 + 2;		/* Advance after nwname, which will be filled later */
 	}
 		nwname = 1;
 	}
 
+	DBG("fid %p %d newfid %p %d\n", fid, fid->fid, newfid, newfid->fid);
+
 	O9FS_PBIT32(fs->outbuf + Minhd + 4, newfid->fid);
 	O9FS_PBIT16(fs->outbuf + Minhd + 4 + 4, nwname);
 
 #include "o9fs_extern.h"
 
 enum{
-	Debug = 1,
+	Debug = 0,
 };
 
 static long
 #include "o9fs_extern.h"
 
 enum{
-	Debug = 1,
+	Debug = 0,
 };
 
 enum {
 		vp->v_type = VREG;
 
 	vp->v_data = f;
-	f->ref++;
 	vp->v_flag = flag;
-
+	printvp(vp);
 	DRET();
 	return error;
 }
 {
 	struct o9fid *f;
 
-	if (vp == NULL || VTO92(vp) == NULL)
+	f = VTO92(vp);
+	if (vp == NULL || f == NULL) {
+		printf("vp %p fid %p\n",  vp, f);
 		return;
-	f = VTO92(vp);
+	}
 	printf("[%p] %p fid %d ref %d qid (%.16llx %lu %d) mode %d iounit %ld\n", vp, f, f->fid, f->ref, f->qid.path, f->qid.vers, f->qid.type, f->mode, f->iounit);
 }

File o9fs_vfsops.c

 #include "o9fs_extern.h"
 
 enum{
-	Debug = 1,
+	Debug = 0,
 };
 
 #define o9fs_init ((int (*)(struct vfsconf *))nullop)
 	struct o9fid *fid;
 
 	fs = (struct o9fs *) malloc(sizeof(struct o9fs), M_MISCFSMNT, M_WAITOK | M_ZERO);
-	if (getnewvnode(VT_O9FS, mp, &o9fs_vops, &rvp) != 0)
-		return EIO;
-
-	rvp->v_type = VDIR;
-	rvp->v_flag = VROOT;
-
-	fs->vroot = rvp;
 	fs->mp = mp;
 	fs->servfp = fp;
-
 	mp->mnt_data = (qaddr_t) fs;
 	vfs_getnewfsid(mp);	
 
 	if (fid == NULL)
 		return EIO;	
 
-	fs->vroot->v_data = fid;
 	return o9fs_allocvp(fs->mp, fid, &fs->vroot, VROOT);
 }
 	
 
 	if (mounto9fs(mp, fp) != 0)
 		return EIO;
+	printvp(VFSTOO9FS(mp)->vroot);
 
 	error = copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &len);
 	if (error)
 	DIN();
 
 	fs = VFSTOO9FS(mp);
-/*	f = o9fs_walk(fs, VTO92(fs->vroot), NULL, NULL);
+	f = o9fs_walk(fs, VTO92(fs->vroot), NULL, NULL);
 	if (f == NULL) {
 		DRET();
 		return -1;
-	}  */
+	}
 
-    DBG("root fid qid.type %d\n", VTO92(fs->vroot)->qid.type);
-	error = o9fs_allocvp(mp, VTO92(fs->vroot), vpp, VROOT);
+	error = o9fs_allocvp(mp, f, vpp, VROOT);
 	if (error) {
 		DBG("failed to alloc vnode\n");
 		DRET();
 		return error;
 	}
 	vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curproc);
-
-	DBG("cloned root to vp %p\n", *vpp); 
 	DRET();
 	return 0;
 }
 
-/* this seems weird to me. i based much of the work on
- * portal_unmount. need to check how to do it correctly.
- */
 int
 o9fs_unmount(struct mount *mp, int mntflags, struct proc *p)
 {
 		return error;
 	}
 
-/*	free(fs->rpc, M_O9FS);
 	free(fs->inbuf, M_O9FS);
 	free(fs->outbuf, M_O9FS);
-	free(fs, M_MISCFSMNT); */
+	free(fs, M_O9FS);
 	fs = mp->mnt_data = (qaddr_t)0;
-	
+
 	DRET();
 	return 0;
 }

File o9fs_vnops.c

 	}
 
 	if (o9fs_opencreate2(fs, nf, O9FS_TOPEN, ap->a_mode, 0, 0) < 0) {
+		DBG("failed open\n");
 		o9fs_xputfid(fs, nf);
 		DRET();
 		return -1;
 	}
 
 	fs = VFSTOO9FS(vp->v_mount);
-	o9fs_clunk(fs, f);
-	f->ref = 0;
 	DRET();
 	return 0;
 }
 	*vpp = NULL;
 
 	path = NULL;
-	DBG("name %s\n", cnp->cn_nameptr);
 
 	if (parf->mode != -1) {
-		DBG("fid %d already opened! parent %d\n", parf->fid, parf->parent->fid);
+		DBG("parent %d is open, moving to %d\n", parf->fid, parf->parent->fid);
+		vref(dvp);
 		f = parf;
 		parf = parf->parent;
 	}
 		strlcpy(path, cnp->cn_nameptr, cnp->cn_namelen+1);
 		nf = o9fs_xgetfid(fs);
 	}
+	printvp(dvp);
 
 	/* BUG: fid and path leakage */
 	f = o9fs_walk(fs, parf, nf, path);
 {
 	struct vop_inactive_args *ap;
 	struct vnode *vp;
+	struct o9fid *f;
 	DIN();
+
+	ap = v;
+	vp = ap->a_vp;
+	f = VTO92(vp);
+	if(!(vp->v_flag & VXLOCK))
+		vgone(vp);
 	DRET();
 	return 0;
 }
 	vp = ap->a_vp;
 	f = VTO92(vp);
 	printvp(vp);
+	o9fs_clunk(VFSTOO9FS(vp->v_mount), f);
+//	o9fs_xputfid(VFSTOO9FS(vp->v_mount), f);
 	vp->v_data = NULL;
 	DRET();
 	return 0;

File simple-test.sh

 #!/bin/sh
-# simple tests for o9fs
-# written by Iruata Souza
-# see LICENSE
-# JUL2007
 
-usage() {
-	echo "usage: $0 mountpoint"
-	exit 1
+if [[ $1 == "-v" ]]; then
+	try() {
+		$* || exit $?
+    }
+	shift
+else
+	try() {
+		$* >/dev/null 2>&1 || exit $?
+    }
+fi
+
+
+[[ -z $1 ]] && mtpt=/mnt || mtpt="$1"
+
+testdir=$mtpt/tmp/testdir
+testfile=$testdir/test0
+
+rdir() {
+	echo Reading directory
+	try ls $mtpt/net
 }
 
-[[ -z $1 ]] && mntp=/mnt || mntp="$1"
-
-testdir="$mntp/tmp/testdir"
-testfile="$testdir/test0"
-
-readdir="ls -l $mntp"
-stat="ls -ld $mntp"
+rdir
+exit 0
+	
+readdir="ls -l $mtpt"
+readdir2="(cd $mtpt; ls -l)"
+stat="ls -ld $mtpt"
 mkdir="mkdir $testdir"
 create="touch $testfile"
 write="echo test0 > $testfile"
 read="cat $testfile"
 remove="rm $testfile"
 
-echo "o9fs mounted on $mntp"
-echo "readdir(), $readdir"
+echo "o9fs mounted on $mtpt"
+echo "readdir, $readdir"
 $readdir
+echo "readdir2, $readdir2"
+$readdir2
 #echo "stat(), $stat"
 #$stat
 #echo "mkdir(), $mkdir"