xfs: Don't flush stale inodes
[safe/jmp/linux-2.6] / fs / xfs / xfs_rename.c
index d8063e1..fc1cda2 100644 (file)
 #include "xfs_utils.h"
 #include "xfs_trans_space.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 
 /*
- * Given an array of up to 4 inode pointers, unlock the pointed to inodes.
- * If there are fewer than 4 entries in the array, the empty entries will
- * be at the end and will have NULL pointers in them.
- */
-STATIC void
-xfs_rename_unlock4(
-       xfs_inode_t     **i_tab,
-       uint            lock_mode)
-{
-       int     i;
-
-       xfs_iunlock(i_tab[0], lock_mode);
-       for (i = 1; i < 4; i++) {
-               if (i_tab[i] == NULL)
-                       break;
-
-               /*
-                * Watch out for duplicate entries in the table.
-                */
-               if (i_tab[i] != i_tab[i-1])
-                       xfs_iunlock(i_tab[i], lock_mode);
-       }
-}
-
-/*
  * Enter all inodes for a rename transaction into a sorted array.
  */
 STATIC void
@@ -172,7 +148,7 @@ xfs_rename(
        xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip,
                                inodes, &num_inodes);
 
-       XFS_BMAP_INIT(&free_list, &first_block);
+       xfs_bmap_init(&free_list, &first_block);
        tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME);
        cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
        spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len);
@@ -191,7 +167,8 @@ xfs_rename(
        /*
         * Attach the dquots to the inodes
         */
-       if ((error = XFS_QM_DQVOPRENAME(mp, inodes))) {
+       error = xfs_qm_vop_rename_dqattach(inodes);
+       if (error) {
                xfs_trans_cancel(tp, cancel_flags);
                goto std_return;
        }
@@ -205,19 +182,6 @@ xfs_rename(
        xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL);
 
        /*
-        * If we are using project inheritance, we only allow renames
-        * into our tree when the project IDs are the same; else the
-        * tree quota mechanism would be circumvented.
-        */
-       if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
-                    (target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
-               error = XFS_ERROR(EXDEV);
-               xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
-               xfs_trans_cancel(tp, cancel_flags);
-               goto std_return;
-       }
-
-       /*
         * Join all the inodes to the transaction. From this point on,
         * we can rely on either trans_commit or trans_cancel to unlock
         * them.  Note that we need to add a vnode reference to the
@@ -242,6 +206,17 @@ xfs_rename(
        }
 
        /*
+        * If we are using project inheritance, we only allow renames
+        * into our tree when the project IDs are the same; else the
+        * tree quota mechanism would be circumvented.
+        */
+       if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
+                    (target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
+               error = XFS_ERROR(EXDEV);
+               goto error_return;
+       }
+
+       /*
         * Set up the target.
         */
        if (target_ip == NULL) {
@@ -336,22 +311,18 @@ xfs_rename(
                ASSERT(error != EEXIST);
                if (error)
                        goto abort_return;
-               xfs_ichgtime(src_ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-
-       } else {
-               /*
-                * We always want to hit the ctime on the source inode.
-                * We do it in the if clause above for the 'new_parent &&
-                * src_is_directory' case, and here we get all the other
-                * cases.  This isn't strictly required by the standards
-                * since the source inode isn't really being changed,
-                * but old unix file systems did it and some incremental
-                * backup programs won't work without it.
-                */
-               xfs_ichgtime(src_ip, XFS_ICHGTIME_CHG);
        }
 
        /*
+        * We always want to hit the ctime on the source inode.
+        *
+        * This isn't strictly required by the standards since the source
+        * inode isn't really being changed, but old unix file systems did
+        * it and some incremental backup programs won't work without it.
+        */
+       xfs_ichgtime(src_ip, XFS_ICHGTIME_CHG);
+
+       /*
         * Adjust the link count on src_dp.  This is necessary when
         * renaming a directory, either within one parent when
         * the target existed, or across two parent directories.
@@ -371,19 +342,11 @@ xfs_rename(
                                        &first_block, &free_list, spaceres);
        if (error)
                goto abort_return;
-       xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
 
-       /*
-        * Update the generation counts on all the directory inodes
-        * that we're modifying.
-        */
-       src_dp->i_gen++;
+       xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
        xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE);
-
-       if (new_parent) {
-               target_dp->i_gen++;
+       if (new_parent)
                xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE);
-       }
 
        /*
         * If this is a synchronous mount, make sure that the