Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libperfuse Rework puffs_framebuf management toremove lea...
details: https://anonhg.NetBSD.org/src/rev/f4283e91f479
branches: trunk
changeset: 772058:f4283e91f479
user: manu <manu%NetBSD.org@localhost>
date: Fri Dec 16 05:34:54 2011 +0000
description:
Rework puffs_framebuf management toremove leaks and abusive reuses. On
exchange error, the puffs_framebuf is now freed immediatly, before
requeuing outstanding requests.
diffstat:
lib/libperfuse/ops.c | 213 ++++++++++++++++++++------------------------------
1 files changed, 85 insertions(+), 128 deletions(-)
diffs (truncated from 653 to 300 lines):
diff -r 3abe89d71bb5 -r f4283e91f479 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c Fri Dec 16 03:05:23 2011 +0000
+++ b/lib/libperfuse/ops.c Fri Dec 16 05:34:54 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ops.c,v 1.47 2011/11/28 05:33:33 manu Exp $ */
+/* $NetBSD: ops.c,v 1.48 2011/12/16 05:34:54 manu Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -187,21 +187,14 @@
if ((error = xchg_msg(pu, opc, pm,
NO_PAYLOAD_REPLY_LEN, wait_reply)) != 0)
- goto out;
+ DERRX(EX_SOFTWARE, "%s: freed fh = 0x%"PRIx64" but filesystem "
+ "returned error = %d", __func__, fh, error);
ps->ps_destroy_msg(pm);
- error = 0;
-
-out:
- if (error != 0)
- DERRX(EX_SOFTWARE, "%s: freed fh = 0x%"PRIx64" but filesystem "
- "returned error = %d", __func__, fh, error);
-
- return error;
+ return 0;
}
-/* ARGSUSED1 */
static int
xchg_msg(pu, opc, pm, len, wait)
struct puffs_usermount *pu;
@@ -229,7 +222,8 @@
if (pnd)
pnd->pnd_flags |= PND_INXCHG;
- error = ps->ps_xchg_msg(pu, pm, len, wait);
+ if ((error = ps->ps_xchg_msg(pu, pm, len, wait)) != 0)
+ ps->ps_destroy_msg(pm);
if (pnd) {
pnd->pnd_flags &= ~PND_INXCHG;
@@ -523,7 +517,7 @@
}
/* FALLTHROUGH */
default:
- goto out;
+ return error;
/* NOTREACHED */
break;
}
@@ -534,7 +528,9 @@
if (oldpnd->pnd_nodeid == feo->nodeid) {
oldpnd->pnd_nlookup++;
*pnp = oldpnd->pnd_pn;
- goto out;
+
+ ps->ps_destroy_msg(pm);
+ return 0;
} else {
oldpnd->pnd_flags |= PND_REMOVED;
#ifdef PERFUSE_DEBUG
@@ -563,10 +559,9 @@
(void *)opc, pn, feo->nodeid, path);
#endif
-out:
ps->ps_destroy_msg(pm);
- return error;
+ return 0;
}
@@ -592,7 +587,7 @@
ps = puffs_getspecific(pu);
if ((error = xchg_msg(pu, opc, pm, sizeof(*feo), wait_reply)) != 0)
- goto out;
+ return error;
feo = GET_OUTPAYLOAD(ps, pm, fuse_entry_out);
if (feo->nodeid == PERFUSE_UNKNOWN_NODEID)
@@ -617,11 +612,6 @@
ps->ps_destroy_msg(pm);
return node_mk_common_final(pu, opc, pn, pcn);
-
-out:
- ps->ps_destroy_msg(pm);
-
- return error;
}
/*
@@ -664,7 +654,7 @@
if ((error = xchg_msg(pu, (puffs_cookie_t)pn, pm,
sizeof(*fao), wait_reply)) != 0)
- goto out;
+ return error;
fao = GET_OUTPAYLOAD(ps, pm, fuse_attr_out);
fuse_attr_to_vap(ps, &pn->pn_va, &fao->attr);
@@ -675,11 +665,9 @@
*/
PERFUSE_NODE_DATA(opc)->pnd_flags |= PND_DIRTY;
-out:
- if (pm != NULL)
- ps->ps_destroy_msg(pm);
-
- return error;
+ ps->ps_destroy_msg(pm);
+
+ return 0;
}
static uint64_t
@@ -1022,7 +1010,11 @@
if ((error = xchg_msg(pu, opc, pm, UNSPEC_REPLY_LEN, wait_reply)) != 0){
DWARN("unmount %s", ps->ps_target);
if (!(flags & MNT_FORCE))
- goto out;
+ return error;
+ else
+ error = 0;
+ } else {
+ ps->ps_destroy_msg(pm);
}
ps->ps_umount(pu);
@@ -1031,10 +1023,6 @@
DPRINTF("%s unmounted, exit\n", ps->ps_target);
return 0;
-out:
- ps->ps_destroy_msg(pm);
-
- return error;
}
int
@@ -1058,7 +1046,7 @@
pm = ps->ps_new_msg(pu, opc, FUSE_STATFS, 0, NULL);
if ((error = xchg_msg(pu, opc, pm, sizeof(*fso), wait_reply)) != 0)
- goto out;
+ return error;
fso = GET_OUTPAYLOAD(ps, pm, fuse_statfs_out);
svfsb->f_flag = ps->ps_mountflags;
@@ -1097,10 +1085,10 @@
strlcpy(svfsb->f_mntfromname, ps->ps_source, _VFS_NAMELEN);
else
strlcpy(svfsb->f_mntfromname, _PATH_FUSE, _VFS_NAMELEN);
-out:
+
ps->ps_destroy_msg(pm);
-
- return error;
+
+ return 0;
}
int
@@ -1338,8 +1326,18 @@
(void)strlcpy((char*)(void *)(fci + 1), name, namelen);
len = sizeof(*feo) + sizeof(*foo);
- if ((error = xchg_msg(pu, opc, pm, len, wait_reply)) != 0)
- goto out;
+ if ((error = xchg_msg(pu, opc, pm, len, wait_reply)) != 0) {
+ /*
+ * create is unimplmented, remember it for later,
+ * and start over using mknod and open instead.
+ */
+ if (error == ENOSYS) {
+ ps->ps_flags |= PS_NO_CREAT;
+ return perfuse_node_create(pu, opc, pni, pcn, vap);
+ }
+
+ return error;
+ }
feo = GET_OUTPAYLOAD(ps, pm, fuse_entry_out);
foo = (struct fuse_open_out *)(void *)(feo + 1);
@@ -1372,20 +1370,6 @@
ps->ps_destroy_msg(pm);
return node_mk_common_final(pu, opc, pn, pcn);
-
-out:
- ps->ps_destroy_msg(pm);
-
- /*
- * create is unimplmented, remember it for later,
- * and start over using mknod and open instead.
- */
- if (error == ENOSYS) {
- ps->ps_flags |= PS_NO_CREAT;
- return perfuse_node_create(pu, opc, pni, pcn, vap);
- }
-
- return error;
}
@@ -1463,7 +1447,6 @@
ps = puffs_getspecific(pu);
pn = (struct puffs_node *)opc;
pnd = PERFUSE_NODE_DATA(opc);
- pm = NULL;
error = 0;
if (pnd->pnd_flags & PND_REMOVED)
@@ -1492,10 +1475,8 @@
*/
if (((mode & FREAD) && (pnd->pnd_flags & PND_RFH)) ||
((mode & FREAD) && (pnd->pnd_flags & PND_WFH)) ||
- ((mode & FWRITE) && (pnd->pnd_flags & PND_WFH))) {
- error = 0;
+ ((mode & FWRITE) && (pnd->pnd_flags & PND_WFH)))
goto out;
- }
/*
* Queue open on a node so that we do not open
@@ -1538,9 +1519,8 @@
mode & FWRITE ? "w" : "", foo->fh);
#endif
+ ps->ps_destroy_msg(pm);
out:
- if (pm != NULL)
- ps->ps_destroy_msg(pm);
pnd->pnd_flags &= ~PND_INOPEN;
(void)dequeue_requests(ps, opc, PCQ_OPEN, DEQUEUE_ALL);
@@ -1703,9 +1683,8 @@
fuse_attr_to_vap(ps, vap, &fao->attr);
set_expire(opc, NULL, fao);
+ ps->ps_destroy_msg(pm);
out:
- if (pm != NULL)
- ps->ps_destroy_msg(pm);
pnd->pnd_flags &= ~PND_INRESIZE;
(void)dequeue_requests(ps, opc, PCQ_RESIZE, DEQUEUE_ALL);
@@ -1735,7 +1714,6 @@
ps = puffs_getspecific(pu);
pnd = PERFUSE_NODE_DATA(opc);
- pm = NULL;
/*
* The only operation we can do once the file is removed
@@ -1922,10 +1900,9 @@
fuse_attr_to_vap(ps, old_va, &fao->attr);
set_expire(opc, NULL, fao);
+ ps->ps_destroy_msg(pm);
+
out:
- if (pm != NULL)
- ps->ps_destroy_msg(pm);
-
if (pnd->pnd_flags & PND_INRESIZE) {
pnd->pnd_flags &= ~PND_INRESIZE;
(void)dequeue_requests(ps, opc, PCQ_RESIZE, DEQUEUE_ALL);
@@ -1966,19 +1943,19 @@
#ifdef PERFUSE_DEBUG
if (perfuse_diagflags & PDF_FH)
- DPRINTF("%s: opc = %p, nodeid = 0x%"PRIx64", fh = 0x%"PRIx64"\n",
- __func__, (void *)opc,
+ DPRINTF("%s: opc = %p, nodeid = 0x%"PRIx64", "
+ "fh = 0x%"PRIx64"\n", __func__, (void *)opc,
PERFUSE_NODE_DATA(opc)->pnd_nodeid, fpi->fh);
#endif
if ((error = xchg_msg(pu, opc, pm, sizeof(*fpo), wait_reply)) != 0)
- goto out;
+ return error;
fpo = GET_OUTPAYLOAD(ps, pm, fuse_poll_out);
*events = fpo->revents;
-out:
+
ps->ps_destroy_msg(pm);
- return error;
+ return 0;
}
/* ARGSUSED0 */
@@ -2098,6 +2075,8 @@
__func__, (void*)opc, perfuse_node_path(opc));
Home |
Main Index |
Thread Index |
Old Index