Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332576
b: refs/heads/master
c: ff44c6e
h: refs/heads/master
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Oct 4, 2012
1 parent 4f9474a commit bc4c44d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 98114659e0d467e2c0ee6f24f2429329328fc312
refs/heads/master: ff44c6e36dc9dcc02652a1105b120bdf08cea9f7
3 changes: 2 additions & 1 deletion trunk/fs/btrfs/extent_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em)

WARN_ON(test_bit(EXTENT_FLAG_PINNED, &em->flags));
rb_erase(&em->rb_node, &tree->map);
list_del_init(&em->list);
if (!test_bit(EXTENT_FLAG_LOGGING, &em->flags))
list_del_init(&em->list);
em->in_tree = 0;
return ret;
}
1 change: 1 addition & 0 deletions trunk/fs/btrfs/extent_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define EXTENT_FLAG_COMPRESSED 1
#define EXTENT_FLAG_VACANCY 2 /* no file extent item found */
#define EXTENT_FLAG_PREALLOC 3 /* pre-allocated extent */
#define EXTENT_FLAG_LOGGING 4 /* Logging this extent */

struct extent_map {
struct rb_node rb_node;
Expand Down
21 changes: 17 additions & 4 deletions trunk/fs/btrfs/tree-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -2945,6 +2945,9 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
list_del_init(&em->list);
if (em->generation <= test_gen)
continue;
/* Need a ref to keep it from getting evicted from cache */
atomic_inc(&em->refs);
set_bit(EXTENT_FLAG_LOGGING, &em->flags);
list_add_tail(&em->list, &extents);
}

Expand All @@ -2954,13 +2957,18 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
em = list_entry(extents.next, struct extent_map, list);

list_del_init(&em->list);
clear_bit(EXTENT_FLAG_LOGGING, &em->flags);

/*
* If we had an error we just need to delete everybody from our
* private list.
*/
if (ret)
if (ret) {
free_extent_map(em);
continue;
}

write_unlock(&tree->lock);

/*
* If the previous EM and the last extent we left off on aren't
Expand All @@ -2971,21 +2979,26 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
ret = copy_items(trans, inode, dst_path, args.src,
args.start_slot, args.nr,
LOG_INODE_ALL);
if (ret)
if (ret) {
free_extent_map(em);
write_lock(&tree->lock);
continue;
}
btrfs_release_path(path);
args.nr = 0;
}

ret = log_one_extent(trans, inode, root, em, path, dst_path, &args);
free_extent_map(em);
write_lock(&tree->lock);
}
WARN_ON(!list_empty(&extents));
write_unlock(&tree->lock);

if (!ret && args.nr)
ret = copy_items(trans, inode, dst_path, args.src,
args.start_slot, args.nr, LOG_INODE_ALL);
btrfs_release_path(path);
WARN_ON(!list_empty(&extents));
write_unlock(&tree->lock);
return ret;
}

Expand Down

0 comments on commit bc4c44d

Please sign in to comment.