Skip to content

Commit

Permalink
Merge remote branch 'origin/rebel' into rebel
Browse files Browse the repository at this point in the history
  • Loading branch information
unsound committed Nov 10, 2010
2 parents 32c64ed + 65f6d1a commit 453af3d
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/10.5/fusefs/common/fuse_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif /* M_MACFUSE_ENABLE_UNSUPPORTED */

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK
#define M_MACFUSE_ENABLE_HUGE_LOCK 1
#define M_MACFUSE_ENABLE_HUGE_LOCK 0
#define M_MACFUSE_ENABLE_LOCK_LOGGING 0
#define FUSE_VNOP_EXPORT __private_extern__
#else
Expand Down
6 changes: 6 additions & 0 deletions core/10.5/fusefs/fuse_biglock_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,16 @@ FUSE_VNOP_EXPORT
int
fuse_biglock_vnop_strategy(struct vnop_strategy_args *ap)
{
#if 1
/* Now trying out a locked version of strategy. We need to hold a lock
* as the underlying layers expect it. */
locked_vnop(buf_vnode(ap->a_bp), fuse_vnop_strategy, ap);
#else
/* VNOP_STRATEGY in kpi_vfs.c is completely unprotected. This seems very
* dangerous, but I don't want to do anything that kpi_vfs.c doesn't do
* without being able to motivate why. */
return fuse_vnop_strategy(ap);
#endif
}

/*
Expand Down
6 changes: 4 additions & 2 deletions core/10.5/fusefs/fuse_biglock_vnops.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define _FUSE_BIGLOCK_VNOPS_H_

#include <fuse_param.h>
#include "fuse_locking.h"

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK

Expand Down Expand Up @@ -61,17 +62,18 @@
#define fuse_biglock_lock(lock) fuse_hugelock_lock()
#define fuse_biglock_unlock(lock) fuse_hugelock_unlock()
#else
#define fuse_biglock lck_mtx_t
#define fuse_biglock_lock(lock) \
do { \
log("%s: Aquiring biglock %p...", __FUNCTION__, lock); \
fusefs_recursive_lock_lock(lock); \
lck_mtx_lock(lock); \
log("%s: biglock %p aquired!", __FUNCTION__, lock); \
} while(0)

#define fuse_biglock_unlock(lock) \
do { \
log("%s: Releasing biglock %p...", __FUNCTION__, lock); \
fusefs_recursive_lock_unlock(lock); \
lck_mtx_unlock(lock); \
log("%s: biglock %p released!", __FUNCTION__, lock); \
} while(0)
#endif
Expand Down
11 changes: 11 additions & 0 deletions core/10.5/fusefs/fuse_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "fuse_node.h"
#include "fuse_sysctl.h"

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
#include "fuse_biglock_vnops.h"
#endif

/*
* Because of the vagaries of how a filehandle can be used, we try not to
* be too smart in here (we try to be smart elsewhere). It is required that
Expand Down Expand Up @@ -90,7 +94,14 @@ fuse_filehandle_get(vnode_t vp,
}
#endif /* M_MACFUSE_ENABLE_UNSUPPORTED */
if (err == ENOENT) {
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
struct fuse_data *data = fuse_get_mpdata(vnode_mount(vp));
fuse_biglock_unlock(data->biglock);
#endif
fuse_internal_vnode_disappear(vp, context, REVOKE_SOFT);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(data->biglock);
#endif
}
return err;
}
Expand Down
17 changes: 17 additions & 0 deletions core/10.5/fusefs/fuse_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
#include "fuse_sysctl.h"
#include "fuse_kludges.h"

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
#include "fuse_biglock_vnops.h"
#endif

/* access */

__private_extern__
Expand Down Expand Up @@ -176,7 +180,13 @@ fuse_internal_access(vnode_t vp,
* unless I use REVOKE_NONE here.
*/

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_unlock(data->biglock);
#endif
fuse_internal_vnode_disappear(vp, context, REVOKE_SOFT);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(data->biglock);
#endif
}

return err;
Expand Down Expand Up @@ -891,8 +901,15 @@ fuse_internal_remove(vnode_t dvp,
*/
if (need_invalidate && !err) {
if (!vfs_busy(mp, LK_NOWAIT)) {
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
struct fuse_data *data = fuse_get_mpdata(mp);
fuse_biglock_unlock(data->biglock);
#endif
vnode_iterate(mp, 0, fuse_internal_remove_callback,
(void *)&target_nlink);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(data->biglock);
#endif
vfs_unbusy(mp);
} else {
IOLog("MacFUSE: skipping link count fixup upon remove\n");
Expand Down
6 changes: 3 additions & 3 deletions core/10.5/fusefs/fuse_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ fdata_alloc(struct proc *p)

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK
#if !M_MACFUSE_ENABLE_HUGE_LOCK
data->biglock = fusefs_recursive_lock_alloc();
data->biglock = lck_mtx_alloc_init(fuse_lock_group, fuse_lock_attr);
#endif /* !M_MACFUSE_ENABLE_HUGE_LOCK */
#endif /* M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK */

Expand Down Expand Up @@ -468,8 +468,8 @@ fdata_destroy(struct fuse_data *data)

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK
#if !M_MACFUSE_ENABLE_HUGE_LOCK
fusefs_recursive_lock_free(data->biglock);
data->biglock = NULL;
lck_mtx_free(data->biglock, fuse_lock_group);
data->biglock = NULL;
#endif /* !M_MACFUSE_ENABLE_HUGE_LOCK */
#endif /* M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK */

Expand Down
2 changes: 1 addition & 1 deletion core/10.5/fusefs/fuse_ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ struct fuse_data {
struct timespec init_timeout;
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK
#if !M_MACFUSE_ENABLE_HUGE_LOCK
fusefs_recursive_lock *biglock;
lck_mtx_t *biglock;
#endif /* !M_MACFUSE_ENABLE_HUGE_LOCK */
#endif /* M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK */
};
Expand Down
22 changes: 22 additions & 0 deletions core/10.5/fusefs/fuse_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "fuse_node.h"
#include "fuse_sysctl.h"

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
#include "fuse_biglock_vnops.h"
#endif

void
FSNodeScrub(struct fuse_vnode_data *fvdat)
{
Expand Down Expand Up @@ -167,8 +171,14 @@ FSNodeGetOrCreateFileVNodeByID(vnode_t *vnPtr,
params.vnfs_filesize = size;
params.vnfs_markroot = markroot;

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_unlock(mntdata->biglock);
#endif
err = vnode_create(VNCREATE_FLAVOR, (uint32_t)sizeof(params),
&params, &vn);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(mntdata->biglock);
#endif
}

if (err == 0) {
Expand All @@ -194,12 +204,24 @@ FSNodeGetOrCreateFileVNodeByID(vnode_t *vnPtr,
if (vnode_vtype(vn) != vtyp) {
IOLog("MacFUSE: vnode changed type behind us (old=%d, new=%d)\n",
vnode_vtype(vn), vtyp);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_unlock(mntdata->biglock);
#endif
fuse_internal_vnode_disappear(vn, context, REVOKE_SOFT);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(mntdata->biglock);
#endif
vnode_put(vn);
err = EIO;
} else if (VTOFUD(vn)->generation != generation) {
IOLog("MacFUSE: vnode changed generation\n");
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_unlock(mntdata->biglock);
#endif
fuse_internal_vnode_disappear(vn, context, REVOKE_SOFT);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(mntdata->biglock);
#endif
vnode_put(vn);
err = ESTALE;
}
Expand Down
27 changes: 26 additions & 1 deletion core/10.5/fusefs/fuse_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fuse_vfsop_mount(mount_t mp, __unused vnode_t devvp, user_addr_t udata,
struct vfsstatfs *vfsstatfsp = vfs_statfs(mp);

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fusefs_recursive_lock *biglock;
fuse_biglock *biglock;
#endif

fuse_trace_printf_vfsop();
Expand Down Expand Up @@ -669,7 +669,13 @@ fuse_vfsop_unmount(mount_t mp, int mntflags, vfs_context_t context)

fuse_rootvp = data->rootvp;

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_unlock(data->biglock);
#endif
err = vflush(mp, fuse_rootvp, flags);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(data->biglock);
#endif
if (err) {
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_unlock(data->biglock);
Expand Down Expand Up @@ -707,11 +713,23 @@ fuse_vfsop_unmount(mount_t mp, int mntflags, vfs_context_t context)
needsignal = data->dataflags & FSESS_KILL_ON_UNMOUNT;
daemonpid = data->daemonpid;

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_unlock(data->biglock);
#endif
vnode_rele(fuse_rootvp); /* We got this reference in fuse_vfsop_mount(). */
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(data->biglock);
#endif

data->rootvp = NULLVP;

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_unlock(data->biglock);
#endif
(void)vflush(mp, NULLVP, FORCECLOSE);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(data->biglock);
#endif

fuse_device_lock(fdev);

Expand Down Expand Up @@ -1251,7 +1269,14 @@ fuse_vfsop_sync(mount_t mp, int waitfor, vfs_context_t context)
args.waitfor = waitfor;
args.error = 0;

#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
struct fuse_data *data = fuse_get_mpdata(mp);
fuse_biglock_unlock(data->biglock);
#endif
vnode_iterate(mp, 0, fuse_sync_callback, (void *)&args);
#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK && !M_MACFUSE_ENABLE_HUGE_LOCK
fuse_biglock_lock(data->biglock);
#endif

if (args.error) {
allerror = args.error;
Expand Down
Loading

0 comments on commit 453af3d

Please sign in to comment.