nilfs2: fix lock order reversal in nilfs_clean_segments ioctl
[safe/jmp/linux-2.6] / fs / fuse / control.c
index 46fe60b..99c99df 100644 (file)
@@ -1,6 +1,6 @@
 /*
   FUSE: Filesystem in Userspace
-  Copyright (C) 2001-2006  Miklos Szeredi <miklos@szeredi.hu>
+  Copyright (C) 2001-2008  Miklos Szeredi <miklos@szeredi.hu>
 
   This program can be distributed under the terms of the GNU GPL.
   See the file COPYING.
@@ -23,7 +23,7 @@ static struct fuse_conn *fuse_ctl_file_conn_get(struct file *file)
 {
        struct fuse_conn *fc;
        mutex_lock(&fuse_mutex);
-       fc = file->f_dentry->d_inode->u.generic_ip;
+       fc = file->f_path.dentry->d_inode->i_private;
        if (fc)
                fc = fuse_conn_get(fc);
        mutex_unlock(&fuse_mutex);
@@ -48,11 +48,13 @@ static ssize_t fuse_conn_waiting_read(struct file *file, char __user *buf,
        size_t size;
 
        if (!*ppos) {
+               long value;
                struct fuse_conn *fc = fuse_ctl_file_conn_get(file);
                if (!fc)
                        return 0;
 
-               file->private_data=(void *)(long)atomic_read(&fc->num_waiting);
+               value = atomic_read(&fc->num_waiting);
+               file->private_data = (void *)value;
                fuse_conn_put(fc);
        }
        size = sprintf(tmp, "%ld\n", (long)file->private_data);
@@ -73,7 +75,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
                                          struct fuse_conn *fc,
                                          const char *name,
                                          int mode, int nlink,
-                                         struct inode_operations *iop,
+                                         const struct inode_operations *iop,
                                          const struct file_operations *fop)
 {
        struct dentry *dentry;
@@ -98,7 +100,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
                inode->i_op = iop;
        inode->i_fop = fop;
        inode->i_nlink = nlink;
-       inode->u.generic_ip = fc;
+       inode->i_private = fc;
        d_add(dentry, inode);
        return dentry;
 }
@@ -116,8 +118,8 @@ int fuse_ctl_add_conn(struct fuse_conn *fc)
                return 0;
 
        parent = fuse_control_sb->s_root;
-       parent->d_inode->i_nlink++;
-       sprintf(name, "%llu", (unsigned long long) fc->id);
+       inc_nlink(parent->d_inode);
+       sprintf(name, "%u", fc->dev);
        parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2,
                                     &simple_dir_inode_operations,
                                     &simple_dir_operations);
@@ -150,7 +152,7 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc)
 
        for (i = fc->ctl_ndents - 1; i >= 0; i--) {
                struct dentry *dentry = fc->ctl_dentry[i];
-               dentry->d_inode->u.generic_ip = NULL;
+               dentry->d_inode->i_private = NULL;
                d_drop(dentry);
                dput(dentry);
        }
@@ -193,8 +195,12 @@ static int fuse_ctl_get_sb(struct file_system_type *fs_type, int flags,
 
 static void fuse_ctl_kill_sb(struct super_block *sb)
 {
+       struct fuse_conn *fc;
+
        mutex_lock(&fuse_mutex);
        fuse_control_sb = NULL;
+       list_for_each_entry(fc, &fuse_conn_list, entry)
+               fc->ctl_ndents = 0;
        mutex_unlock(&fuse_mutex);
 
        kill_litter_super(sb);