nfsd: fix possible read-ahead cache and export table corruption
[safe/jmp/linux-2.6] / fs / nfsd / nfs4recover.c
index e35d7e5..ebd03cc 100644 (file)
@@ -45,7 +45,7 @@
 #include <asm/uaccess.h>
 #include <asm/scatterlist.h>
 #include <linux/crypto.h>
-
+#include <linux/sched.h>
 
 #define NFSDDBG_FACILITY                NFSDDBG_PROC
 
@@ -83,13 +83,13 @@ md5_to_hex(char *out, char *md5)
        *out = '\0';
 }
 
-int
+__be32
 nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
 {
        struct xdr_netobj cksum;
        struct hash_desc desc;
        struct scatterlist sg[1];
-       int status = nfserr_resource;
+       __be32 status = nfserr_resource;
 
        dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
                        clname->len, clname->data);
@@ -184,7 +184,7 @@ struct dentry_list_arg {
 
 static int
 nfsd4_build_dentrylist(void *arg, const char *name, int namlen,
-               loff_t offset, ino_t ino, unsigned int d_type)
+               loff_t offset, u64 ino, unsigned int d_type)
 {
        struct dentry_list_arg *dla = arg;
        struct list_head *dentries = &dla->dentries;
@@ -193,7 +193,7 @@ nfsd4_build_dentrylist(void *arg, const char *name, int namlen,
        struct dentry_list *child;
 
        if (name && isdotent(name, namlen))
-               return nfs_ok;
+               return 0;
        dentry = lookup_one_len(name, parent, namlen);
        if (IS_ERR(dentry))
                return PTR_ERR(dentry);
@@ -259,7 +259,7 @@ nfsd4_remove_clid_file(struct dentry *dir, struct dentry *dentry)
                printk("nfsd4: non-file found in client recovery directory\n");
                return -EINVAL;
        }
-       mutex_lock(&dir->d_inode->i_mutex);
+       mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
        status = vfs_unlink(dir->d_inode, dentry);
        mutex_unlock(&dir->d_inode->i_mutex);
        return status;
@@ -274,7 +274,7 @@ nfsd4_clear_clid_dir(struct dentry *dir, struct dentry *dentry)
         * any regular files anyway, just in case the directory was created by
         * a kernel from the future.... */
        nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
-       mutex_lock(&dir->d_inode->i_mutex);
+       mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
        status = vfs_rmdir(dir->d_inode, dentry);
        mutex_unlock(&dir->d_inode->i_mutex);
        return status;
@@ -333,14 +333,14 @@ purge_old(struct dentry *parent, struct dentry *child)
        int status;
 
        if (nfs4_has_reclaimed_state(child->d_name.name))
-               return nfs_ok;
+               return 0;
 
        status = nfsd4_clear_clid_dir(parent, child);
        if (status)
                printk("failed to remove client recovery directory %s\n",
                                child->d_name.name);
        /* Keep trying, success or failure: */
-       return nfs_ok;
+       return 0;
 }
 
 void
@@ -365,10 +365,10 @@ load_recdir(struct dentry *parent, struct dentry *child)
                printk("nfsd4: illegal name %s in recovery directory\n",
                                child->d_name.name);
                /* Keep trying; maybe the others are OK: */
-               return nfs_ok;
+               return 0;
        }
        nfs4_client_to_reclaim(child->d_name.name);
-       return nfs_ok;
+       return 0;
 }
 
 int