]> err.no Git - linux-2.6/blobdiff - fs/nfs/dir.c
Merge master.kernel.org:/home/rmk/linux-2.6-mmc
[linux-2.6] / fs / nfs / dir.c
index ac331d2d4c4ae047eec5bc00b7c5df303c9c1386..e9255198f767b8af7b964a66f66e8be39fc597c6 100644 (file)
@@ -532,6 +532,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
        my_entry.eof = 0;
        my_entry.fh = &fh;
        my_entry.fattr = &fattr;
+       nfs_fattr_init(&fattr);
        desc->entry = &my_entry;
 
        while(!desc->entry->eof) {
@@ -801,6 +802,7 @@ static int nfs_dentry_delete(struct dentry *dentry)
  */
 static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
 {
+       nfs_inode_return_delegation(inode);
        if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
                lock_kernel();
                inode->i_nlink--;
@@ -851,12 +853,6 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
        dentry->d_op = NFS_PROTO(dir)->dentry_ops;
 
        lock_kernel();
-       /* Revalidate parent directory attribute cache */
-       error = nfs_revalidate_inode(NFS_SERVER(dir), dir);
-       if (error < 0) {
-               res = ERR_PTR(error);
-               goto out_unlock;
-       }
 
        /* If we're doing an exclusive create, optimize away the lookup */
        if (nfs_is_exclusive_create(dir, nd))
@@ -1261,6 +1257,9 @@ dentry->d_parent->d_name.name, dentry->d_name.name);
        sprintf(silly, ".nfs%*.*lx",
                i_inosize, i_inosize, dentry->d_inode->i_ino);
 
+       /* Return delegation in anticipation of the rename */
+       nfs_inode_return_delegation(dentry->d_inode);
+
        sdentry = NULL;
        do {
                char *suffix = silly + slen - countersize;
@@ -1288,6 +1287,7 @@ dentry->d_parent->d_name.name, dentry->d_name.name);
                nfs_begin_data_update(dentry->d_inode);
                error = NFS_PROTO(dir)->rename(dir, &dentry->d_name,
                                dir, &qsilly);
+               nfs_mark_for_revalidate(dentry->d_inode);
                nfs_end_data_update(dentry->d_inode);
        } else
                error = NFS_PROTO(dir)->rename(dir, &dentry->d_name,
@@ -1329,11 +1329,13 @@ static int nfs_safe_remove(struct dentry *dentry)
 
        nfs_begin_data_update(dir);
        if (inode != NULL) {
+               nfs_inode_return_delegation(inode);
                nfs_begin_data_update(inode);
                error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
                /* The VFS may want to delete this inode */
                if (error == 0)
                        inode->i_nlink--;
+               nfs_mark_for_revalidate(inode);
                nfs_end_data_update(inode);
        } else
                error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
@@ -1435,17 +1437,14 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
                old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
                dentry->d_parent->d_name.name, dentry->d_name.name);
 
-       /*
-        * Drop the dentry in advance to force a new lookup.
-        * Since nfs_proc_link doesn't return a file handle,
-        * we can't use the existing dentry.
-        */
        lock_kernel();
-       d_drop(dentry);
-
        nfs_begin_data_update(dir);
        nfs_begin_data_update(inode);
        error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name);
+       if (error == 0) {
+               atomic_inc(&inode->i_count);
+               d_instantiate(dentry, inode);
+       }
        nfs_end_data_update(inode);
        nfs_end_data_update(dir);
        unlock_kernel();
@@ -1509,9 +1508,11 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
         */
        if (!new_inode)
                goto go_ahead;
-       if (S_ISDIR(new_inode->i_mode))
-               goto out;
-       else if (atomic_read(&new_dentry->d_count) > 2) {
+       if (S_ISDIR(new_inode->i_mode)) {
+               error = -EISDIR;
+               if (!S_ISDIR(old_inode->i_mode))
+                       goto out;
+       } else if (atomic_read(&new_dentry->d_count) > 2) {
                int err;
                /* copy the target dentry's name */
                dentry = d_alloc(new_dentry->d_parent,
@@ -1547,15 +1548,19 @@ go_ahead:
                nfs_wb_all(old_inode);
                shrink_dcache_parent(old_dentry);
        }
+       nfs_inode_return_delegation(old_inode);
 
-       if (new_inode)
+       if (new_inode != NULL) {
+               nfs_inode_return_delegation(new_inode);
                d_delete(new_dentry);
+       }
 
        nfs_begin_data_update(old_dir);
        nfs_begin_data_update(new_dir);
        nfs_begin_data_update(old_inode);
        error = NFS_PROTO(old_dir)->rename(old_dir, &old_dentry->d_name,
                                           new_dir, &new_dentry->d_name);
+       nfs_mark_for_revalidate(old_inode);
        nfs_end_data_update(old_inode);
        nfs_end_data_update(new_dir);
        nfs_end_data_update(old_dir);