]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - fs/xfs/xfs_dfrag.c
Merge branch 'master' into tk71
[mv-sheeva.git] / fs / xfs / xfs_dfrag.c
index 3b9582c60a225117f7b6d4180e4287b0118375ed..e60490bc00a61b6c8bc1bfbe04df4e56e536596c 100644 (file)
@@ -377,6 +377,19 @@ xfs_swap_extents(
        ip->i_d.di_format = tip->i_d.di_format;
        tip->i_d.di_format = tmp;
 
+       /*
+        * The extents in the source inode could still contain speculative
+        * preallocation beyond EOF (e.g. the file is open but not modified
+        * while defrag is in progress). In that case, we need to copy over the
+        * number of delalloc blocks the data fork in the source inode is
+        * tracking beyond EOF so that when the fork is truncated away when the
+        * temporary inode is unlinked we don't underrun the i_delayed_blks
+        * counter on that inode.
+        */
+       ASSERT(tip->i_delayed_blks == 0);
+       tip->i_delayed_blks = ip->i_delayed_blks;
+       ip->i_delayed_blks = 0;
+
        ilf_fields = XFS_ILOG_CORE;
 
        switch(ip->i_d.di_format) {