ext4: Avoid updating the inode table bh twice in no journal mode
[safe/jmp/linux-2.6] / fs / ext4 / move_extent.c
index 1f027b1..25b6b14 100644 (file)
@@ -322,7 +322,7 @@ mext_insert_across_blocks(handle_t *handle, struct inode *orig_inode,
                        goto out;
 
                if (ext4_ext_insert_extent(handle, orig_inode,
-                                       orig_path, new_ext))
+                                       orig_path, new_ext, 0))
                        goto out;
        }
 
@@ -333,7 +333,7 @@ mext_insert_across_blocks(handle_t *handle, struct inode *orig_inode,
                        goto out;
 
                if (ext4_ext_insert_extent(handle, orig_inode,
-                                          orig_path, end_ext))
+                                          orig_path, end_ext, 0))
                        goto out;
        }
 out:
@@ -1001,14 +1001,6 @@ mext_check_arguments(struct inode *orig_inode,
                return -EINVAL;
        }
 
-       /* orig and donor should be different file */
-       if (orig_inode->i_ino == donor_inode->i_ino) {
-               ext4_debug("ext4 move extent: The argument files should not "
-                       "be same file [ino:orig %lu, donor %lu]\n",
-                       orig_inode->i_ino, donor_inode->i_ino);
-               return -EINVAL;
-       }
-
        /* Ext4 move extent supports only extent based file */
        if (!(EXT4_I(orig_inode)->i_flags & EXT4_EXTENTS_FL)) {
                ext4_debug("ext4 move extent: orig file is not extents "
@@ -1040,12 +1032,12 @@ mext_check_arguments(struct inode *orig_inode,
                return -EINVAL;
        }
 
-       if ((orig_start > MAX_DEFRAG_SIZE) ||
-           (donor_start > MAX_DEFRAG_SIZE) ||
-           (*len > MAX_DEFRAG_SIZE) ||
-           (orig_start + *len > MAX_DEFRAG_SIZE))  {
-               ext4_debug("ext4 move extent: Can't handle over [%lu] blocks "
-                       "[ino:orig %lu, donor %lu]\n", MAX_DEFRAG_SIZE,
+       if ((orig_start > EXT_MAX_BLOCK) ||
+           (donor_start > EXT_MAX_BLOCK) ||
+           (*len > EXT_MAX_BLOCK) ||
+           (orig_start + *len > EXT_MAX_BLOCK))  {
+               ext4_debug("ext4 move extent: Can't handle over [%u] blocks "
+                       "[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCK,
                        orig_inode->i_ino, donor_inode->i_ino);
                return -EINVAL;
        }
@@ -1232,6 +1224,14 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
        int block_len_in_page;
        int uninit;
 
+       /* orig and donor should be different file */
+       if (orig_inode->i_ino == donor_inode->i_ino) {
+               ext4_debug("ext4 move extent: The argument files should not "
+                       "be same file [ino:orig %lu, donor %lu]\n",
+                       orig_inode->i_ino, donor_inode->i_ino);
+               return -EINVAL;
+       }
+
        /* protect orig and donor against a truncate */
        ret1 = mext_inode_double_lock(orig_inode, donor_inode);
        if (ret1 < 0)