PERFORCE change 194960 for review

Ilya Putsikau ilya at FreeBSD.org
Sun Jun 19 09:37:48 UTC 2011


http://p4web.freebsd.org/@@194960?ac=10

Change 194960 by ilya at ilya_triton2011 on 2011/06/19 09:37:19

	Change node creator to thread id, use &fvdat->creator as msleep ident
	Set create flags to O_CREAT | O_RDWR
	Cache name if MAKEENTRY flag set

Affected files ...

.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.c#5 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.h#7 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#18 edit

Differences ...

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.c#5 (text+ko) ====

@@ -46,6 +46,7 @@
     }
     vp->v_type = vtyp;
     vp->v_data = fvdat;
+    fvdat->creator = curthread->td_tid;
     mtx_init(&fvdat->createlock, "fuse node create mutex", NULL, MTX_DEF);
     sx_init(&fvdat->nodelock, "fuse node sx lock");
     sx_init(&fvdat->truncatelock, "fuse node truncate sx lock");
@@ -165,10 +166,9 @@
 	    MPASS(!(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.'));
 	    VTOFUD(*vpp)->parent_nid = VTOI(dvp);
     }
-    if (cnp != NULL) {
+    if (cnp != NULL && (cnp->cn_flags & MAKEENTRY) != 0) {
         cache_enter(dvp, *vpp, cnp);
     }
-
     VTOFUD(*vpp)->nlookup++;
 
     return 0;

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.h#7 (text+ko) ====

@@ -21,7 +21,7 @@
     uint64_t   parent_nid;
 
     struct mtx createlock;
-    void      *creator;
+    lwpid_t    creator;
     /* XXX: Clean up this multi-flag nonsense. Really. */
     int        flag;
     int        flags;

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#18 (text+ko) ====

@@ -254,7 +254,7 @@
 
     foi = fdip->indata;
     foi->mode = mode;
-    foi->flags = O_RDWR; // XXX: We /always/ creat() like this.
+    foi->flags = O_CREAT | O_RDWR;
 
     memcpy((char *)fdip->indata + sizeof(*foi), cnp->cn_nameptr,
            cnp->cn_namelen);
@@ -342,8 +342,6 @@
 #endif
     }
 
-    cache_enter(dvp, *vpp, cnp);
-
     return (0);
 
 undo:
@@ -1114,7 +1112,7 @@
         mtx_lock(&fvdat->createlock);
 
         if (fvdat->flag & FN_CREATING) { // check again
-            if (fvdat->creator == curthread) {
+            if (fvdat->creator == curthread->td_tid) {
 
                 /*
                  * For testing the race condition we want to prevent here,
@@ -1141,11 +1139,11 @@
                 fvdat->flag &= ~FN_CREATING;
 
                 mtx_unlock(&fvdat->createlock);
-                wakeup((caddr_t)fvdat->creator); // wake up all
+                wakeup((caddr_t)&fvdat->creator); // wake up all
                 goto ok; /* return 0 */
             } else {
                 printf("contender going to sleep\n");
-                error = msleep(fvdat->creator, &fvdat->createlock,
+                error = msleep(&fvdat->creator, &fvdat->createlock,
                                PDROP | PINOD | PCATCH, "fuse_open", 0);
                 /*
                  * msleep will drop the mutex. since we have PDROP specified,


More information about the p4-projects mailing list