PERFORCE change 197036 for review
Ilya Putsikau
ilya at FreeBSD.org
Mon Aug 1 21:37:34 UTC 2011
http://p4web.freebsd.org/@@197036?ac=10
Change 197036 by ilya at 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);
}
More information about the p4-projects
mailing list