]> err.no Git - linux-2.6/blobdiff - fs/nfs/inode.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy...
[linux-2.6] / fs / nfs / inode.c
index f2781ca42761c885a56ad2ea70effd4ca5f4599a..6391d89642144366591df7e7c0e6733b12916899 100644 (file)
@@ -1009,13 +1009,18 @@ void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx)
        spin_unlock(&inode->i_lock);
 }
 
-struct nfs_open_context *nfs_find_open_context(struct inode *inode, int mode)
+/*
+ * Given an inode, search for an open context with the desired characteristics
+ */
+struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
        struct nfs_open_context *pos, *ctx = NULL;
 
        spin_lock(&inode->i_lock);
        list_for_each_entry(pos, &nfsi->open_files, list) {
+               if (cred != NULL && pos->cred != cred)
+                       continue;
                if ((pos->mode & mode) == mode) {
                        ctx = get_nfs_open_context(pos);
                        break;
@@ -1274,14 +1279,12 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
        }
 
        if ((fattr->valid & NFS_ATTR_FATTR) == 0) {
-               spin_unlock(&inode->i_lock);
                return 0;
        }
 
        /* Has the inode gone and changed behind our back? */
        if (nfsi->fileid != fattr->fileid
                        || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) {
-               spin_unlock(&inode->i_lock);
                return -EIO;
        }
 
@@ -1685,8 +1688,7 @@ static void nfs_kill_super(struct super_block *s)
 
        rpciod_down();          /* release rpciod */
 
-       if (server->hostname != NULL)
-               kfree(server->hostname);
+       kfree(server->hostname);
        kfree(server);
 }
 
@@ -1905,8 +1907,7 @@ nfs_copy_user_string(char *dst, struct nfs_string *src, int maxlen)
                        return ERR_PTR(-ENOMEM);
        }
        if (copy_from_user(dst, src->data, maxlen)) {
-               if (p != NULL)
-                       kfree(p);
+               kfree(p);
                return ERR_PTR(-EFAULT);
        }
        dst[maxlen] = '\0';
@@ -1997,10 +1998,8 @@ static struct super_block *nfs4_get_sb(struct file_system_type *fs_type,
 out_err:
        s = (struct super_block *)p;
 out_free:
-       if (server->mnt_path)
-               kfree(server->mnt_path);
-       if (server->hostname)
-               kfree(server->hostname);
+       kfree(server->mnt_path);
+       kfree(server->hostname);
        kfree(server);
        return s;
 }
@@ -2020,8 +2019,7 @@ static void nfs4_kill_super(struct super_block *sb)
 
        destroy_nfsv4_state(server);
 
-       if (server->hostname != NULL)
-               kfree(server->hostname);
+       kfree(server->hostname);
        kfree(server);
 }