afs: Fix afs_lookup() to not clobber the version on a new dentry
[linux-2.6-microblaze.git] / fs / afs / dir.c
index cc12772..5c794f4 100644 (file)
@@ -803,7 +803,12 @@ success:
                        continue;
 
                if (cookie->inodes[i]) {
-                       afs_vnode_commit_status(&fc, AFS_FS_I(cookie->inodes[i]),
+                       struct afs_vnode *iv = AFS_FS_I(cookie->inodes[i]);
+
+                       if (test_bit(AFS_VNODE_UNSET, &iv->flags))
+                               continue;
+
+                       afs_vnode_commit_status(&fc, iv,
                                                scb->cb_break, NULL, scb);
                        continue;
                }
@@ -903,6 +908,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
                                 unsigned int flags)
 {
        struct afs_vnode *dvnode = AFS_FS_I(dir);
+       struct afs_fid fid = {};
        struct inode *inode;
        struct dentry *d;
        struct key *key;
@@ -946,21 +952,18 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
        afs_stat_v(dvnode, n_lookup);
        inode = afs_do_lookup(dir, dentry, key);
        key_put(key);
-       if (inode == ERR_PTR(-ENOENT)) {
+       if (inode == ERR_PTR(-ENOENT))
                inode = afs_try_auto_mntpt(dentry, dir);
-       } else {
-               dentry->d_fsdata =
-                       (void *)(unsigned long)dvnode->status.data_version;
-       }
+
+       if (!IS_ERR_OR_NULL(inode))
+               fid = AFS_FS_I(inode)->fid;
+
        d = d_splice_alias(inode, dentry);
        if (!IS_ERR_OR_NULL(d)) {
                d->d_fsdata = dentry->d_fsdata;
-               trace_afs_lookup(dvnode, &d->d_name,
-                                inode ? AFS_FS_I(inode) : NULL);
+               trace_afs_lookup(dvnode, &d->d_name, &fid);
        } else {
-               trace_afs_lookup(dvnode, &dentry->d_name,
-                                IS_ERR_OR_NULL(inode) ? NULL
-                                : AFS_FS_I(inode));
+               trace_afs_lookup(dvnode, &dentry->d_name, &fid);
        }
        return d;
 }