aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse/inode.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-10-17 03:10:11 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-17 11:18:45 -0400
commitd2a85164aaa8d514ef5efbf5d05746e85dd13ddd (patch)
tree82a10eff007860a9bfc515d037cc2fea6c999bc0 /fs/fuse/inode.c
parent265126ba9e1f8e217e61d1017c6609f76828aa7a (diff)
[PATCH] fuse: fix handling of moved directory
Fuse considered it an error (EIO) if lookup returned a directory inode, to which a dentry already refered. This is because directory aliases are not allowed. But in a network filesystem this could happen legitimately, if a directory is moved on a remote client. This patch attempts to relax the restriction by trying to first evict the offending alias from the cache. If this fails, it still returns an error (EBUSY). A rarer situation is if an mkdir races with an indenpendent lookup, which finds the newly created directory already moved. In this situation the mkdir should return success, but that would be incorrect, since the dentry cannot be instantiated, so return EBUSY. Previously checking for a directory alias and instantiation of the dentry weren't done atomically in lookup/mkdir, hence two such calls racing with each other could create aliased directories. To prevent this introduce a new per-connection mutex: fuse_conn->inst_mutex, which is taken for instantiations with a directory inode. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/fuse/inode.c')
-rw-r--r--fs/fuse/inode.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 4ee8f72e6380..fc4203570370 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -379,6 +379,7 @@ static struct fuse_conn *new_conn(void)
379 fc = kzalloc(sizeof(*fc), GFP_KERNEL); 379 fc = kzalloc(sizeof(*fc), GFP_KERNEL);
380 if (fc) { 380 if (fc) {
381 spin_lock_init(&fc->lock); 381 spin_lock_init(&fc->lock);
382 mutex_init(&fc->inst_mutex);
382 atomic_set(&fc->count, 1); 383 atomic_set(&fc->count, 1);
383 init_waitqueue_head(&fc->waitq); 384 init_waitqueue_head(&fc->waitq);
384 init_waitqueue_head(&fc->blocked_waitq); 385 init_waitqueue_head(&fc->blocked_waitq);
@@ -398,8 +399,10 @@ static struct fuse_conn *new_conn(void)
398 399
399void fuse_conn_put(struct fuse_conn *fc) 400void fuse_conn_put(struct fuse_conn *fc)
400{ 401{
401 if (atomic_dec_and_test(&fc->count)) 402 if (atomic_dec_and_test(&fc->count)) {
403 mutex_destroy(&fc->inst_mutex);
402 kfree(fc); 404 kfree(fc);
405 }
403} 406}
404 407
405struct fuse_conn *fuse_conn_get(struct fuse_conn *fc) 408struct fuse_conn *fuse_conn_get(struct fuse_conn *fc)