diff mbox

[4/5] Btrfs: fix unprotected extent map operation when logging file extents

Message ID 5092261E.2020702@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Miao Xie Nov. 1, 2012, 7:34 a.m. UTC
We forget to protect the modified_extents list, fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/tree-log.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Liu Bo Nov. 1, 2012, 8:14 a.m. UTC | #1
On Thu, Nov 01, 2012 at 03:34:54PM +0800, Miao Xie wrote:
> We forget to protect the modified_extents list, fix it.
> 

Looks good to me.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

thanks,
liubo

> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
>  fs/btrfs/tree-log.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index cbb544e..f7e9387 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -3525,8 +3525,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)) {
> -- 
> 1.7.6.5
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index cbb544e..f7e9387 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3525,8 +3525,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)) {