Btrfs: fix unprotected extent map operation when logging file extents
authorMiao Xie <miaox@cn.fujitsu.com>
Thu, 1 Nov 2012 07:34:54 +0000 (07:34 +0000)
committerJosef Bacik <jbacik@fusionio.com>
Wed, 12 Dec 2012 22:15:22 +0000 (17:15 -0500)
We forget to protect the modified_extents list, fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/tree-log.c

index bcf0e48b193287e265b42dcd34229c51dfe76760..d1947af67bcd2a40dfd3e0fa09de6b02caea3cc4 100644 (file)
@@ -3526,8 +3526,10 @@ next_slot:
                struct extent_map_tree *tree = &BTRFS_I(inode)->extent_tree;
                struct extent_map *em, *n;
 
+               write_lock(&tree->lock);
                list_for_each_entry_safe(em, n, &tree->modified_extents, list)
                        list_del_init(&em->list);
+               write_unlock(&tree->lock);
        }
 
        if (inode_only == LOG_INODE_ALL && S_ISDIR(inode->i_mode)) {