Merge git://git.kernel.org/pub/scm/linux/kernel/git/nico/orion into fixes
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / exportfs / expfs.c
index 51b304056f10fcd47c18593a9a12bf56e8633063..b05acb7961355dfb680e49f3145a11065f6ac851 100644 (file)
@@ -43,24 +43,26 @@ find_acceptable_alias(struct dentry *result,
                void *context)
 {
        struct dentry *dentry, *toput = NULL;
+       struct inode *inode;
 
        if (acceptable(context, result))
                return result;
 
-       spin_lock(&dcache_lock);
-       list_for_each_entry(dentry, &result->d_inode->i_dentry, d_alias) {
-               dget_locked(dentry);
-               spin_unlock(&dcache_lock);
+       inode = result->d_inode;
+       spin_lock(&inode->i_lock);
+       list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
+               dget(dentry);
+               spin_unlock(&inode->i_lock);
                if (toput)
                        dput(toput);
                if (dentry != result && acceptable(context, dentry)) {
                        dput(result);
                        return dentry;
                }
-               spin_lock(&dcache_lock);
+               spin_lock(&inode->i_lock);
                toput = dentry;
        }
-       spin_unlock(&dcache_lock);
+       spin_unlock(&inode->i_lock);
 
        if (toput)
                dput(toput);
@@ -318,9 +320,14 @@ static int export_encode_fh(struct dentry *dentry, struct fid *fid,
        struct inode * inode = dentry->d_inode;
        int len = *max_len;
        int type = FILEID_INO32_GEN;
-       
-       if (len < 2 || (connectable && len < 4))
+
+       if (connectable && (len < 4)) {
+               *max_len = 4;
+               return 255;
+       } else if (len < 2) {
+               *max_len = 2;
                return 255;
+       }
 
        len = 2;
        fid->i32.ino = inode->i_ino;
@@ -367,6 +374,8 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
        /*
         * Try to get any dentry for the given file handle from the filesystem.
         */
+       if (!nop || !nop->fh_to_dentry)
+               return ERR_PTR(-ESTALE);
        result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type);
        if (!result)
                result = ERR_PTR(-ESTALE);