From owner-p4-projects@FreeBSD.ORG Mon Aug 1 21:37:34 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 76FF4106566C; Mon, 1 Aug 2011 21:37:34 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38D43106564A for ; Mon, 1 Aug 2011 21:37:34 +0000 (UTC) (envelope-from ilya@FreeBSD.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 1D6D68FC0A for ; Mon, 1 Aug 2011 21:37:34 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p71LbYIU066545 for ; Mon, 1 Aug 2011 21:37:34 GMT (envelope-from ilya@FreeBSD.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p71LbXxZ066542 for perforce@freebsd.org; Mon, 1 Aug 2011 21:37:33 GMT (envelope-from ilya@FreeBSD.org) Date: Mon, 1 Aug 2011 21:37:33 GMT Message-Id: <201108012137.p71LbXxZ066542@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to ilya@FreeBSD.org using -f From: Ilya Putsikau To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 197036 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2011 21:37:34 -0000 http://p4web.freebsd.org/@@197036?ac=10 Change 197036 by ilya@ilya_triton2011 on 2011/08/01 21:36:33 Use per file system rename lock Print 'filehandle not valid' message only if it's meaningful Correct setparent in rename, clear node parent reference Invalidate buffers for revoked vnode, flush buffers only for files Add reclaim_revoked sysctl Affected files ... .. //depot/projects/soc2011/ilya_fuse/fuse/fuse_file.c#2 edit .. //depot/projects/soc2011/ilya_fuse/fuse/fuse_io.c#2 edit .. //depot/projects/soc2011/ilya_fuse/fuse/fuse_ipc.c#2 edit .. //depot/projects/soc2011/ilya_fuse/fuse/fuse_ipc.h#2 edit .. //depot/projects/soc2011/ilya_fuse/fuse/fuse_node.c#2 edit .. //depot/projects/soc2011/ilya_fuse/fuse/fuse_node.h#2 edit .. //depot/projects/soc2011/ilya_fuse/fuse/fuse_vnops.c#2 edit Differences ... ==== //depot/projects/soc2011/ilya_fuse/fuse/fuse_file.c#2 (text+ko) ==== @@ -50,11 +50,11 @@ int oflags = 0; int op = FUSE_OPEN; - fuse_trace_printf("fuse_filehandle_get(vp=%p, fufh_type=%d)\n", + fuse_trace_printf("fuse_filehandle_open(vp=%p, fufh_type=%d)\n", vp, fufh_type); if (fuse_filehandle_valid(vp, fufh_type)) { - panic("FUSE: filehandle_get called despite valid fufh (type=%d)", + panic("FUSE: filehandle_open called despite valid fufh (type=%d)", fufh_type); /* NOTREACHED */ } @@ -173,10 +173,8 @@ struct fuse_filehandle *fufh; fufh = &(fvdat->fufh[fufh_type]); - if (!FUFH_IS_VALID(fufh)) { - printf("FUSE: filehandle is not valid (type=%d)\n", fufh_type); + if (!FUFH_IS_VALID(fufh)) return EBADF; - } if (fufhp != NULL) *fufhp = fufh; return 0; ==== //depot/projects/soc2011/ilya_fuse/fuse/fuse_io.c#2 (text+ko) ==== @@ -65,7 +65,7 @@ err = fuse_filehandle_getrw(vp, (uio->uio_rw == UIO_READ) ? FUFH_RDONLY : FUFH_WRONLY, &fufh); if (err) { - DEBUG("fetching filehandle failed\n"); + printf("FUSE: io dispatch: filehandles are closed\n"); return err; } @@ -562,7 +562,7 @@ error = fuse_filehandle_getrw(vp, (bp->b_iocmd == BIO_READ) ? FUFH_RDONLY : FUFH_WRONLY, &fufh); if (error) { - DEBUG("fetching filehandle failed\n"); + printf("FUSE: strategy: filehandles are closed\n"); bp->b_ioflags |= BIO_ERROR; bp->b_error = error; return (error); ==== //depot/projects/soc2011/ilya_fuse/fuse/fuse_ipc.c#2 (text+ko) ==== @@ -346,10 +346,7 @@ TAILQ_INIT(&data->aw_head); data->daemoncred = crhold(cred); data->daemon_timeout = FUSE_DEFAULT_DAEMON_TIMEOUT; - -#ifdef FUSE_EXPLICIT_RENAME_LOCK sx_init(&data->rename_lock, "fuse rename lock"); -#endif return data; } @@ -376,9 +373,7 @@ /* Driving off stage all that stuff thrown at device... */ mtx_destroy(&data->ms_mtx); mtx_destroy(&data->aw_mtx); -#ifdef FUSE_EXPLICIT_RENAME_LOCK sx_destroy(&data->rename_lock); -#endif crfree(data->daemoncred); ==== //depot/projects/soc2011/ilya_fuse/fuse/fuse_ipc.h#2 (text+ko) ==== @@ -138,9 +138,7 @@ u_long ticketer; -#ifdef FUSE_EXPLICIT_RENAME_LOCK struct sx rename_lock; -#endif uint32_t fuse_libabi_major; uint32_t fuse_libabi_minor; ==== //depot/projects/soc2011/ilya_fuse/fuse/fuse_node.c#2 (text+ko) ==== @@ -192,7 +192,7 @@ return err; } - if (dvp != NULL && vnode_vtype(*vpp) == VDIR) { + if (dvp != NULL) { MPASS((cnp->cn_flags & ISDOTDOT) == 0); MPASS(!(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.')); fuse_vnode_setparent(*vpp, dvp); ==== //depot/projects/soc2011/ilya_fuse/fuse/fuse_node.h#2 (text+ko) ==== @@ -76,7 +76,7 @@ static __inline void fuse_vnode_setparent(struct vnode *vp, struct vnode *dvp) { - if (vp->v_type == VDIR) { + if (dvp != NULL && vp->v_type == VDIR) { MPASS(dvp->v_type == VDIR); VTOFUD(vp)->parent_nid = VTOI(dvp); } ==== //depot/projects/soc2011/ilya_fuse/fuse/fuse_vnops.c#2 (text+ko) ==== @@ -122,6 +122,10 @@ SYSCTL_INT(_vfs_fuse, OID_AUTO, lookup_cache_enable, CTLFLAG_RW, &fuse_lookup_cache_enable, 0, ""); +static int fuse_reclaim_revoked = 1; +SYSCTL_INT(_vfs_fuse, OID_AUTO, reclaim_revoked, CTLFLAG_RW, + &fuse_reclaim_revoked, 0, ""); + int fuse_pbuf_freecnt = -1; #if __FreeBSD_version >= 900011 @@ -551,11 +555,12 @@ for (type = 0; type < FUFH_MAXTYPE; type++) { fufh = &(fvdat->fufh[type]); if (FUFH_IS_VALID(fufh)) { - if (need_flush) { + if (need_flush && vp->v_type == VREG) { if ((VTOFUD(vp)->flag & FN_SIZECHANGE) != 0) { fuse_vnode_savesize(vp, NULL); } - if (fuse_data_cache_invalidate) + if (fuse_data_cache_invalidate || + (fvdat->flag & FN_REVOKED) != 0) fuse_io_invalbuf(vp, td); else fuse_io_flushbuf(vp, MNT_WAIT, td); @@ -565,7 +570,7 @@ } } - if ((fvdat->flag & FN_REVOKED) != 0) { + if ((fvdat->flag & FN_REVOKED) != 0 && fuse_reclaim_revoked) { vrecycle(vp, td); } @@ -935,9 +940,7 @@ if (err) { goto out; } - if (vnode_vtype(vp) == VDIR) { - fuse_vnode_setparent(vp, dvp); - } + fuse_vnode_setparent(vp, dvp); *vpp = vp; } @@ -1349,6 +1352,7 @@ fvdat->nlookup); } + fuse_vnode_setparent(vp, NULL); cache_purge(vp); vfs_hash_remove(vp); vnode_destroy_vobject(vp); @@ -1415,6 +1419,7 @@ struct vnode *tdvp = ap->a_tdvp; struct vnode *tvp = ap->a_tvp; struct componentname *tcnp = ap->a_tcnp; + struct fuse_data *data; int err = 0; @@ -1442,17 +1447,21 @@ * under the source directory in the file system tree. * Linux performs this check at VFS level. */ + data = fuse_get_mpdata(vnode_mount(tdvp)); + sx_xlock(&data->rename_lock); err = fuse_internal_rename(fdvp, fcnp, tdvp, tcnp); - if (err == 0) { fuse_invalidate_attr(fdvp); if (tdvp != fdvp) { + fuse_vnode_setparent(fvp, tdvp); fuse_invalidate_attr(tdvp); } + if (tvp != NULL) + fuse_vnode_setparent(tvp, NULL); } + sx_unlock(&data->rename_lock); if (tvp != NULL && tvp != fvp) { - fuse_vnode_setparent(tvp, tdvp); cache_purge(tvp); }