Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jul 2011 07:42:11 GMT
From:      Ilya Putsikau <ilya@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 196333 for review
Message-ID:  <201107180742.p6I7gBg2035295@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@196333?ac=10

Change 196333 by ilya@ilya_triton2011 on 2011/07/18 07:41:10

	Remove dead code. Small tweaks

Affected files ...

.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse.h#14 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_device.c#10 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_file.c#12 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_internal.c#17 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_main.c#8 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.c#17 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.h#17 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vfsops.c#21 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#39 edit

Differences ...

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse.h#14 (text+ko) ====

@@ -87,26 +87,13 @@
 
 /* misc */
 
-extern int fuse_useco;
 SYSCTL_DECL(_vfs_fuse);
 
 /* Fuse locking */
 
-#ifndef DO_GIANT_MANUALLY
-#define DO_GIANT_MANUALLY 1
-#endif
-#ifndef USE_FUSE_LOCK
-#define USE_FUSE_LOCK 1
-#endif
-
-#if USE_FUSE_LOCK
 extern struct mtx fuse_mtx;
 #define FUSE_LOCK() fuse_lck_mtx_lock(fuse_mtx)
 #define FUSE_UNLOCK() fuse_lck_mtx_unlock(fuse_mtx)
-#else
-#define FUSE_LOCK()
-#define FUSE_UNLOCK()
-#endif
 
 #define RECTIFY_TDCR(td, cred)			\
 do {						\

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_device.c#10 (text+ko) ====

@@ -51,14 +51,7 @@
 	.d_read = fuse_device_read,
 	.d_write = fuse_device_write,
 	.d_version = D_VERSION,
-#ifndef D_NEEDMINOR
-#define D_NEEDMINOR 0
-#endif
-#if ! DO_GIANT_MANUALLY
-	.d_flags = D_NEEDMINOR|D_NEEDGIANT,
-#else
 	.d_flags = D_NEEDMINOR,
-#endif
 };
 
 /*
@@ -85,36 +78,6 @@
 {
 	struct fuse_data *fdata;	
 
-	/*
-	 * We need to ensure data consistency on the main entry points
-	 * of the module (so that we won't race with module unloading).
-	 * I don't see a better way of doing this than using Giant.
-	 * The lightest reliance on Giant is realized by the 
-	 * DO_GIANT_MANUALLY == USE_FUSE_LOCK == 1 combination.
-	 *
-	 * Then the device will operate D_NEEDGIANT-less, and the only
-	 * point where Giant is used (apart from the obligatory places
-	 * like module (un)load, (un)mount, etc.) is at the beginning
-	 * of the device open routine, where destructive racing is
-	 * prevented.
-	 */
-
-#if DO_GIANT_MANUALLY 
-	fuse_lck_mtx_lock(Giant);
-#endif
-	if (fuse_useco < 0) {
-		/* Module unload is going on */
-#if DO_GIANT_MANUALLY 
-		fuse_lck_mtx_unlock(Giant);
-#endif
-		DEBUG("caught in the middle of unload\n");
-		return (ENOENT);
-	}
-#if DO_GIANT_MANUALLY && USE_FUSE_LOCK
-	fuse_useco++;
-	fuse_lck_mtx_unlock(Giant);
-#endif
-
 	if (dev->si_usecount > 1)
 		goto busy;
 
@@ -128,29 +91,16 @@
 		fdata_destroy(fdata);
 		goto busy;
 	} else {
-#if ! (DO_GIANT_MANUALLY && USE_FUSE_LOCK)
-		fuse_useco++;
-#endif
 		fdata->dataflags |= FSESS_OPENED;
 		dev->si_drv1 = fdata;
 	}	
 	FUSE_UNLOCK();
-#if DO_GIANT_MANUALLY && ! USE_FUSE_LOCK
-	fuse_lck_mtx_unlock(Giant);
-#endif
 
 	DEBUG("%s: device opened by thread %d.\n", dev->si_name, td->td_tid);
 
 	return(0);
 
 busy:
-#if DO_GIANT_MANUALLY
-#if USE_FUSE_LOCK
-	fuse_useco--;
-#else
-	fuse_lck_mtx_unlock(Giant);
-#endif
-#endif
 	return (EBUSY);
 }
 
@@ -159,9 +109,6 @@
 {
 	struct fuse_data *data;
 
-#if DO_GIANT_MANUALLY && ! USE_FUSE_LOCK
-	fuse_lck_mtx_lock(Giant);
-#endif
 	FUSE_LOCK();
 	data = fuse_get_devdata(dev);
 	if (! data)
@@ -198,11 +145,6 @@
 	fdata_destroy(data);
 
 out:
-#if DO_GIANT_MANUALLY && ! USE_FUSE_LOCK
-	fuse_lck_mtx_unlock(Giant);
-#endif
-	fuse_useco--;
-	
 	DEBUG("%s: device closed by thread %d.\n", dev->si_name, td->td_tid);
 	return(0);
 }
@@ -451,26 +393,6 @@
 		}
 	} else {
 		/* no callback at all! */
-		/*
-		 * this is BAD:
-		 *       + if unique id was generated by fuse userspace,
-		 *         that's way too bogus. Userspace should only
-		 *         pass unique ids back and forth.
-		 *       + else we generated the unique id by
-		 *         fuse_ticket_fetch() somewhere in the foggy past.
-		 *         Now that ticket is either
-		 *       	+ dropped, which means it could have been
-		 *       	  reused by now, and then this answer we work
-		 *                 with would be misdelivered (it's
-		 *                 just luck that it's not the case now)
-		 *       	+ not dropped, which means it's either
-		 *       		+ lost: will be kept on busy list for
-		 *       		  the whole lifetime
-		 *       		+ someone will drop it randomly without
-		 *       		  any event based triggering (this
-		 *       		  would be the place for such a thing),
-		 *       		   which is just nonsense.
-		 */
 		DEBUG("erhm, no handler for this response\n");
 
 		fdata_set_dead(data);
@@ -545,11 +467,7 @@
 	i = clone_create(&fuseclones, &fuse_device_cdevsw, &unit, dev, 0);
 	if (i) {
 		*dev = make_dev(&fuse_device_cdevsw,
-#if __FreeBSD_version < 800062
-				unit2minor(unit),
-#else /* __FreeBSD_version >= 800062 */
 				unit,
-#endif /* __FreeBSD_version < 800062 */
 			        UID_ROOT, GID_OPERATOR,
 		                S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP,
                                 "fuse%d", unit);

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_file.c#12 (text+ko) ====

@@ -152,7 +152,7 @@
     }
 
 out:
-    atomic_add_acq_int(&fuse_fh_count, -1);
+    atomic_subtract_acq_int(&fuse_fh_count, 1);
     fufh->fh_id = (uint64_t)-1;
     fufh->fh_type = FUFH_INVALID;
     fuse_invalidate_attr(vp);

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_internal.c#17 (text+ko) ====

@@ -470,8 +470,6 @@
     memcpy(fdip->indata, buf, bufsize);
     memcpy((char *)fdip->indata + bufsize, cnp->cn_nameptr, cnp->cn_namelen);
     ((char *)fdip->indata)[bufsize + cnp->cn_namelen] = '\0';
-
-    fdip->iosize = bufsize + cnp->cn_namelen + 1;
 }
 
 int

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_main.c#8 (text+ko) ====

@@ -25,10 +25,7 @@
 static void			 fuse_bringdown(eventhandler_tag eh_tag);
 static int			 fuse_loader(struct module *m, int what, void *arg);
 
-int fuse_useco = 0;
-#if USE_FUSE_LOCK
 struct mtx fuse_mtx;
-#endif
 
 
 extern void fuse_device_clone(void *arg, struct ucred *cred, char *name,
@@ -66,9 +63,7 @@
 	EVENTHANDLER_DEREGISTER(dev_clone, eh_tag);
 
 	clone_cleanup(&fuseclones);
-#if USE_FUSE_LOCK
 	mtx_destroy(&fuse_mtx);
-#endif
 }
 
 static int
@@ -77,26 +72,18 @@
 	static eventhandler_tag  eh_tag = NULL;
 	int err = 0;
 
-	GIANT_REQUIRED;
-
 	switch (what) {
 	case MOD_LOAD:                /* kldload */
 		fuse_pbuf_freecnt = nswbuf / 2 + 1;
 		clone_setup(&fuseclones);
-#ifdef USE_FUSE_LOCK
 		mtx_init(&fuse_mtx, "fuse_mtx", NULL, MTX_DEF);
-#endif
 		eh_tag = EVENTHANDLER_REGISTER(dev_clone, fuse_device_clone, 0,
 		                               1000);
 		if (eh_tag == NULL) {
 			clone_cleanup(&fuseclones);
-#if USE_FUSE_LOCK
 			mtx_destroy(&fuse_mtx);
-#endif
 			return (ENOMEM);
 		}
-		/* Duh, it's static... */
-		/* vfs_register(&fuse_vfsconf); */
 
 		/* vfs_modevent ignores its first arg */
 		if ((err = vfs_modevent(NULL, what, &fuse_vfsconf)))
@@ -112,27 +99,9 @@
 
 		break;
 	case MOD_UNLOAD:
-		KASSERT(fuse_useco >= 0,
-		        ("fuse_useco is negative: %d", fuse_useco));
-		if (fuse_useco > 0) {
-			DEBUGX(FUSE_DEBUG_INTERNAL,
-                            "fuse_useco %d\n", fuse_useco);
-		        return (EBUSY);
-		}
-
 		if ((err = vfs_modevent(NULL, what, &fuse_vfsconf)))
 			return (err);
-
-		/*
-		 * at this point the counter falls below zero thus new init
-		 * attempts will know that no brownie for them
-		 */
-		fuse_useco--;
-
 		fuse_bringdown(eh_tag);
-
-		/* vfs_unregister(&fuse_vfsconf); */
-
 		break;
 	default:
 		return (EINVAL);

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

@@ -65,8 +65,6 @@
     }
     vp->v_type = vtyp;
     vp->v_data = fvdat;
-    sx_init(&fvdat->nodelock, "fuse node sx lock");
-    sx_init(&fvdat->truncatelock, "fuse node truncate sx lock");
 
     for (i = 0; i < FUFH_MAXTYPE; i++)
         fvdat->fufh[i].fh_type = FUFH_INVALID;
@@ -80,11 +78,9 @@
     struct fuse_vnode_data *fvdat = vp->v_data;
 
     vp->v_data = NULL;
-    sx_destroy(&fvdat->nodelock);
-    sx_destroy(&fvdat->truncatelock);
     free(fvdat, M_FUSEVN);
 
-    atomic_add_acq_int(&fuse_node_count, -1);
+    atomic_subtract_acq_int(&fuse_node_count, 1);
 }
 
 static int
@@ -153,7 +149,7 @@
     if (err) {
         VOP_UNLOCK(*vpp, 0);
         fuse_vnode_destroy(*vpp);
-	*vpp = NULL;
+        *vpp = NULL;
         return (err);
     }
 
@@ -188,8 +184,8 @@
     }
 
     if (dvp != NULL && vnode_vtype(*vpp) == VDIR) {
-	    MPASS((cnp->cn_flags & ISDOTDOT) == 0);
-	    MPASS(!(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.'));
+        MPASS((cnp->cn_flags & ISDOTDOT) == 0);
+        MPASS(!(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.'));
 	    VTOFUD(*vpp)->parent_nid = VTOI(dvp);
     }
     if (dvp != NULL && cnp != NULL && (cnp->cn_flags & MAKEENTRY) != 0) {
@@ -235,7 +231,6 @@
     struct fuse_filehandle *fufh = NULL;
     struct fuse_dispatcher  fdi;
     struct fuse_setattr_in *fsai;
-    struct fuse_access_param facp;
     int err = 0;
 
     DEBUG("inode=%jd oldsize=%jd newsize=%jd\n",
@@ -264,10 +259,6 @@
     fsai = fdi.indata;
     fsai->valid = 0;
 
-    bzero(&facp, sizeof(facp));
-    facp.xuid = cred->cr_uid;
-    facp.xgid = cred->cr_gid;
-
     // Truncate to a new value.
     fsai->size = newsize;
     fsai->valid |= FATTR_SIZE;

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

@@ -11,7 +11,6 @@
 
 #include "fuse_file.h"
 
-#define FN_CREATING          0x00000002
 #define FN_REVOKED           0x00000020
 #define FN_FLUSHINPROG       0x00000040
 #define FN_FLUSHWANT         0x00000080
@@ -28,32 +27,14 @@
     struct     fuse_filehandle fufh[FUFH_MAXTYPE];
 
     /** flags **/
-    /* XXX: Clean up this multi-flag nonsense. Really. */
     uint32_t   flag;
-    int        flags;
-    uint32_t   c_flag;
 
     /** meta **/
-
     struct timespec   cached_attrs_valid;
     struct vattr      cached_attrs;
     off_t             filesize;
     uint64_t          nlookup;
     enum vtype        vtype;
-
-    /*
-     * The nodelock must be held when data in the FUSE node is accessed or
-     * modified. Typically, we would take this lock at the beginning of a
-     * vnop and drop it at the end of the vnop.
-     */
-    struct sx  nodelock;
-    void      *nodelockowner;
-
-    /*
-     * The truncatelock guards against the EOF changing on us (that is, a
-     * file resize) unexpectedly.
-     */
-    struct sx  truncatelock;
 };
 
 #define VTOFUD(vp) \

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vfsops.c#21 (text+ko) ====

@@ -99,10 +99,6 @@
 
     fuse_trace_printf_vfsop();
 
-    GIANT_REQUIRED;
-    KASSERT(fuse_useco >= 0,
-        ("negative fuse usecount despite Giant"));
-
     if (mp->mnt_flag & MNT_UPDATE)
         return EOPNOTSUPP;
 
@@ -295,8 +291,6 @@
 
     fuse_trace_printf_vfsop();
 
-    GIANT_REQUIRED;
-
     if (mntflags & MNT_FORCE) {
         flags |= FORCECLOSE;
     }

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

@@ -81,7 +81,6 @@
 static vop_getpages_t fuse_vnop_getpages;
 static vop_putpages_t fuse_vnop_putpages;
 static vop_print_t    fuse_vnop_print;
-static vop_unlock_t   fuse_vnop_unlock;
 
 struct vop_vector fuse_vnops = {
 	.vop_default       = &default_vnodeops,
@@ -111,7 +110,6 @@
 	.vop_getpages      = fuse_vnop_getpages,
 	.vop_putpages      = fuse_vnop_putpages,
 	.vop_print         = fuse_vnop_print,
-	.vop_unlock        = fuse_vnop_unlock,
 };
 
 static u_long fuse_lookup_cache_hits = 0;
@@ -164,7 +162,6 @@
     struct ucred *cred    = ap->a_cred;
 
     struct fuse_access_param facp;
-    struct fuse_vnode_data *fvdat = VTOFUD(vp);
     struct fuse_data *data = fuse_get_mpdata(vnode_mount(vp));
 
     int err;
@@ -194,12 +191,6 @@
 
     bzero(&facp, sizeof(facp));
 
-    if (fvdat->flags & FVP_ACCESS_NOOP) {
-        fvdat->flags &= ~FVP_ACCESS_NOOP;
-    } else {
-        facp.facc_flags |= FACCESS_DO_ACCESS;
-    }   
-
     err = fuse_internal_access(vp, accmode, &facp, ap->a_td, ap->a_cred);
     DEBUG2G("err=%d accmode=0x%x\n", err, accmode);
     return err;
@@ -348,9 +339,6 @@
     }
 
     err = fuse_vnode_get(mp, feo->nodeid, dvp, vpp, cnp, VREG, /*size*/0);
-    if (!err && !gone_good_old) {
-        VTOFUD(*vpp)->flag |= FN_CREATING;
-    }
     if (err) {
        if (gone_good_old) {
            fuse_internal_forget_send(mp, td, cred, feo->nodeid, 1, fdip);
@@ -528,25 +516,7 @@
 
     fuse_ticket_drop(fdi.tick);
 
-    if (vnode_vtype(vp) != vap->va_type) {
-        if ((vnode_vtype(vp) == VNON) && (vap->va_type != VNON)) {
-            /*
-             * We should be doing the following:
-             *
-             * vp->vtype = vap->v_type
-             */
-        } else {
-            /*
-             * STALE vnode, ditch
-             *
-             * The vnode has changed its type "behind our back". There's
-             * nothing really we can do, so let us just force an internal
-             * revocation.
-             */
-            fuse_internal_vnode_disappear(vp);
-            return EIO;
-        }
-    }
+    KASSERT(vnode_vtype(vp) == vap->va_type, ("stale vnode"));
 
     debug_printf("fuse_getattr e: returning 0\n");
 
@@ -1572,24 +1542,6 @@
 
     DEBUG2G("inode=%jd\n", VTOI(vp));
 
-    /*
-     * XXX: Locking
-     *
-     * We need to worry about the file size changing in setattr. If the call
-     * is indeed altering the size, then:
-     *
-     * lock_exclusive(truncatelock)
-     *   lock(nodelock)
-     *     set the new size
-     *   unlock(nodelock)
-     *   adjust ubc
-     *   lock(nodelock)
-     *     do cleanup
-     *   unlock(nodelock)
-     * unlock(truncatelock)
-     * ...
-     */
-
     if (fuse_isdeadfs(vp)) {
         return EBADF;
     }
@@ -2117,29 +2069,11 @@
 {
 	struct fuse_vnode_data *fvdat = VTOFUD(ap->a_vp);
 
-	printf("nodeid: %ju, parent_nid: %ju, "
-	       "nlookup: %ju, flags: %#x\n",
+	printf("nodeid: %ju, parent nodeid: %ju, "
+	       "nlookup: %ju, flag: %#x\n",
 	       VTOILLU(ap->a_vp), (uintmax_t) fvdat->parent_nid,
 	       (uintmax_t)fvdat->nlookup,
-	       fvdat->flags);
+	       fvdat->flag);
 
 	return 0;
 }
-
-/*
-    struct vnop_unlock_args {
-        struct vnode *a_vp;
-        int a_flags;
-        struct thread *a_td;
-    };
-*/
-static int
-fuse_vnop_unlock(struct vop_unlock_args *ap)
-{
-	struct vnode *vp = ap->a_vp;
-
-	if (VTOFUD(vp))
-		VTOFUD(vp)->flags &= ~FVP_ACCESS_NOOP;
-
-	return vop_stdunlock(ap);
-}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107180742.p6I7gBg2035295>