Btrfs: cleanup extents after we finish logging inode
authorLiu Bo <bo.li.liu@oracle.com>
Mon, 27 Aug 2012 16:52:19 +0000 (10:52 -0600)
committerChris Mason <chris.mason@fusionio.com>
Mon, 1 Oct 2012 19:19:04 +0000 (15:19 -0400)
This is based on Josef's "Btrfs: turbo charge fsync".

We should cleanup those extents after we've finished logging inode,
otherwise we may do redundant work on them.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
fs/btrfs/tree-log.c

index 94db438494df22d9c8804ef70ba6125d75cddb92..58075d711d240f7916f9674918a49fa1679a80c0 100644 (file)
@@ -3167,6 +3167,12 @@ next_slot:
                        err = ret;
                        goto out_unlock;
                }
+       } else {
+               struct extent_map_tree *tree = &BTRFS_I(inode)->extent_tree;
+               struct extent_map *em, *n;
+
+               list_for_each_entry_safe(em, n, &tree->modified_extents, list)
+                       list_del_init(&em->list);
        }
 
        if (inode_only == LOG_INODE_ALL && S_ISDIR(inode->i_mode)) {