History

Btrfs: Add properly locking around add_root_to_dirty_list

add_root_to_dirty_list happens once at the very beginning of the transaction, but it is still racey.

Chris Mason committed 14 years ago

Commit e5846fc1 parent dc7fdde1 file · +2 −0Browse files

Unified · Split

fs/btrfs/ctree.c+2−0
@@ -220,10 +220,12 @@ struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root) · 219 unmodified lines
220220 */
221221 static void add_root_to_dirty_list(struct btrfs_root *root)
222222 {
223+ spin_lock(&root->fs_info->trans_lock);
223224 if (root->track_dirty && list_empty(&root->dirty_list)) {
224225 list_add(&root->dirty_list,
225226 &root->fs_info->dirty_cowonly_roots);
226227 }
228+ spin_unlock(&root->fs_info->trans_lock);
227229 }
228230
229231 /*