Commit d7133114 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Linus Torvalds

[PATCH] fuse: use a per-mount spinlock

Remove the global spinlock in favor of a per-mount one.

This patch is basically find & replace.  The difficult part has already been
done by the previous patch.
Signed-off-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0720b315
This diff is collapsed.
/* /*
FUSE: Filesystem in Userspace FUSE: Filesystem in Userspace
Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu> Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU GPL. This program can be distributed under the terms of the GNU GPL.
See the file COPYING. See the file COPYING.
...@@ -144,7 +144,7 @@ struct fuse_req { ...@@ -144,7 +144,7 @@ struct fuse_req {
/* /*
* The following bitfields are either set once before the * The following bitfields are either set once before the
* request is queued or setting/clearing them is protected by * request is queued or setting/clearing them is protected by
* fuse_lock * fuse_conn->lock
*/ */
/** True if the request has reply */ /** True if the request has reply */
...@@ -213,6 +213,9 @@ struct fuse_req { ...@@ -213,6 +213,9 @@ struct fuse_req {
* unmounted. * unmounted.
*/ */
struct fuse_conn { struct fuse_conn {
/** Lock protecting accessess to members of this structure */
spinlock_t lock;
/** The user id for this mount */ /** The user id for this mount */
uid_t user_id; uid_t user_id;
...@@ -351,21 +354,6 @@ static inline u64 get_node_id(struct inode *inode) ...@@ -351,21 +354,6 @@ static inline u64 get_node_id(struct inode *inode)
/** Device operations */ /** Device operations */
extern const struct file_operations fuse_dev_operations; extern const struct file_operations fuse_dev_operations;
/**
* This is the single global spinlock which protects FUSE's structures
*
* The following data is protected by this lock:
*
* - the private_data field of the device file
* - the s_fs_info field of the super block
* - unused_list, pending, processing lists in fuse_conn
* - background list in fuse_conn
* - the unique request ID counter reqctr in fuse_conn
* - the sb (super_block) field in fuse_conn
* - the file (device file) field in fuse_conn
*/
extern spinlock_t fuse_lock;
/** /**
* Get a filled in inode * Get a filled in inode
*/ */
...@@ -490,7 +478,7 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req); ...@@ -490,7 +478,7 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req);
/** /**
* Release inodes and file associated with background request * Release inodes and file associated with background request
*/ */
void fuse_release_background(struct fuse_req *req); void fuse_release_background(struct fuse_conn *fc, struct fuse_req *req);
/* Abort all requests */ /* Abort all requests */
void fuse_abort_conn(struct fuse_conn *fc); void fuse_abort_conn(struct fuse_conn *fc);
......
/* /*
FUSE: Filesystem in Userspace FUSE: Filesystem in Userspace
Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu> Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU GPL. This program can be distributed under the terms of the GNU GPL.
See the file COPYING. See the file COPYING.
...@@ -22,7 +22,6 @@ MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>"); ...@@ -22,7 +22,6 @@ MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
MODULE_DESCRIPTION("Filesystem in Userspace"); MODULE_DESCRIPTION("Filesystem in Userspace");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
spinlock_t fuse_lock;
static kmem_cache_t *fuse_inode_cachep; static kmem_cache_t *fuse_inode_cachep;
static struct subsystem connections_subsys; static struct subsystem connections_subsys;
...@@ -207,13 +206,14 @@ static void fuse_put_super(struct super_block *sb) ...@@ -207,13 +206,14 @@ static void fuse_put_super(struct super_block *sb)
down_write(&fc->sbput_sem); down_write(&fc->sbput_sem);
while (!list_empty(&fc->background)) while (!list_empty(&fc->background))
fuse_release_background(list_entry(fc->background.next, fuse_release_background(fc,
list_entry(fc->background.next,
struct fuse_req, bg_entry)); struct fuse_req, bg_entry));
spin_lock(&fuse_lock); spin_lock(&fc->lock);
fc->mounted = 0; fc->mounted = 0;
fc->connected = 0; fc->connected = 0;
spin_unlock(&fuse_lock); spin_unlock(&fc->lock);
up_write(&fc->sbput_sem); up_write(&fc->sbput_sem);
/* Flush all readers on this fs */ /* Flush all readers on this fs */
kill_fasync(&fc->fasync, SIGIO, POLL_IN); kill_fasync(&fc->fasync, SIGIO, POLL_IN);
...@@ -388,6 +388,7 @@ static struct fuse_conn *new_conn(void) ...@@ -388,6 +388,7 @@ static struct fuse_conn *new_conn(void)
fc = kzalloc(sizeof(*fc), GFP_KERNEL); fc = kzalloc(sizeof(*fc), GFP_KERNEL);
if (fc) { if (fc) {
int i; int i;
spin_lock_init(&fc->lock);
init_waitqueue_head(&fc->waitq); init_waitqueue_head(&fc->waitq);
INIT_LIST_HEAD(&fc->pending); INIT_LIST_HEAD(&fc->pending);
INIT_LIST_HEAD(&fc->processing); INIT_LIST_HEAD(&fc->processing);
...@@ -734,7 +735,6 @@ static int __init fuse_init(void) ...@@ -734,7 +735,6 @@ static int __init fuse_init(void)
printk("fuse init (API version %i.%i)\n", printk("fuse init (API version %i.%i)\n",
FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION); FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
spin_lock_init(&fuse_lock);
res = fuse_fs_init(); res = fuse_fs_init();
if (res) if (res)
goto err; goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment