Merge branch 'nfs-for-2.6.35' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
[safe/jmp/linux-2.6] / fs / fat / namei_msdos.c
index e92e815..bbc94ae 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/module.h>
 #include <linux/time.h>
 #include <linux/buffer_head.h>
-#include <linux/smp_lock.h>
 #include "fat.h"
 
 /* Characters that are undesirable in an MS-DOS file name */
@@ -188,7 +187,7 @@ old_compare:
        goto out;
 }
 
-static struct dentry_operations msdos_dentry_operations = {
+static const struct dentry_operations msdos_dentry_operations = {
        .d_hash         = msdos_hash,
        .d_compare      = msdos_cmp,
 };
@@ -203,33 +202,37 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
 {
        struct super_block *sb = dir->i_sb;
        struct fat_slot_info sinfo;
-       struct inode *inode = NULL;
-       int res;
-
-       dentry->d_op = &msdos_dentry_operations;
+       struct inode *inode;
+       int err;
 
        lock_super(sb);
-       res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
-       if (res == -ENOENT)
-               goto add;
-       if (res < 0)
-               goto out;
+
+       err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
+       if (err) {
+               if (err == -ENOENT) {
+                       inode = NULL;
+                       goto out;
+               }
+               goto error;
+       }
+
        inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
        brelse(sinfo.bh);
        if (IS_ERR(inode)) {
-               res = PTR_ERR(inode);
-               goto out;
+               err = PTR_ERR(inode);
+               goto error;
        }
-add:
-       res = 0;
+out:
+       unlock_super(sb);
+       dentry->d_op = &msdos_dentry_operations;
        dentry = d_splice_alias(inode, dentry);
        if (dentry)
                dentry->d_op = &msdos_dentry_operations;
-out:
+       return dentry;
+
+error:
        unlock_super(sb);
-       if (!res)
-               return dentry;
-       return ERR_PTR(res);
+       return ERR_PTR(err);
 }
 
 /***** Creates a directory entry (name is already formatted). */
@@ -540,7 +543,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
                int start = MSDOS_I(new_dir)->i_logstart;
                dotdot_de->start = cpu_to_le16(start);
                dotdot_de->starthi = cpu_to_le16(start >> 16);
-               mark_buffer_dirty(dotdot_bh);
+               mark_buffer_dirty_inode(dotdot_bh, old_inode);
                if (IS_DIRSYNC(new_dir)) {
                        err = sync_dirty_buffer(dotdot_bh);
                        if (err)
@@ -582,7 +585,7 @@ error_dotdot:
                int start = MSDOS_I(old_dir)->i_logstart;
                dotdot_de->start = cpu_to_le16(start);
                dotdot_de->starthi = cpu_to_le16(start >> 16);
-               mark_buffer_dirty(dotdot_bh);
+               mark_buffer_dirty_inode(dotdot_bh, old_inode);
                corrupt |= sync_dirty_buffer(dotdot_bh);
        }
 error_inode:
@@ -604,7 +607,7 @@ error_inode:
                sinfo.bh = NULL;
        }
        if (corrupt < 0) {
-               fat_fs_panic(new_dir->i_sb,
+               fat_fs_error(new_dir->i_sb,
                             "%s: Filesystem corrupted (i_pos %lld)",
                             __func__, sinfo.i_pos);
        }