Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332526
b: refs/heads/master
c: 4e2f84e
h: refs/heads/master
v: v3
  • Loading branch information
Liu Bo authored and Chris Mason committed Oct 1, 2012
1 parent 6efde4a commit d8f53c4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 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: ca7e70f59078046db28501519308c2061b0e7a6f
refs/heads/master: 4e2f84e63dc138eca91e89ccbc34f37732ce58f7
20 changes: 20 additions & 0 deletions trunk/fs/btrfs/extent_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em)
em->block_start = merge->block_start;
merge->in_tree = 0;
if (merge->generation > em->generation) {
em->mod_start = em->start;
em->mod_len = em->len;
em->generation = merge->generation;
list_move(&em->list, &tree->modified_extents);
}
Expand All @@ -222,6 +224,7 @@ static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em)
rb_erase(&merge->rb_node, &tree->map);
merge->in_tree = 0;
if (merge->generation > em->generation) {
em->mod_len = em->len;
em->generation = merge->generation;
list_move(&em->list, &tree->modified_extents);
}
Expand All @@ -247,6 +250,7 @@ int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
{
int ret = 0;
struct extent_map *em;
bool prealloc = false;

write_lock(&tree->lock);
em = lookup_extent_mapping(tree, start, len);
Expand All @@ -259,8 +263,21 @@ int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
list_move(&em->list, &tree->modified_extents);
em->generation = gen;
clear_bit(EXTENT_FLAG_PINNED, &em->flags);
em->mod_start = em->start;
em->mod_len = em->len;

if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags)) {
prealloc = true;
clear_bit(EXTENT_FLAG_PREALLOC, &em->flags);
}

try_merge_map(tree, em);

if (prealloc) {
em->mod_start = em->start;
em->mod_len = em->len;
}

free_extent_map(em);
out:
write_unlock(&tree->lock);
Expand Down Expand Up @@ -298,6 +315,9 @@ int add_extent_mapping(struct extent_map_tree *tree,
}
atomic_inc(&em->refs);

em->mod_start = em->start;
em->mod_len = em->len;

try_merge_map(tree, em);
out:
return ret;
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/btrfs/extent_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct extent_map {
/* all of these are in bytes */
u64 start;
u64 len;
u64 mod_start;
u64 mod_len;
u64 orig_start;
u64 block_start;
u64 block_len;
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
em->block_start = disk_bytenr;
em->bdev = root->fs_info->fs_devices->latest_bdev;
set_bit(EXTENT_FLAG_PINNED, &em->flags);
set_bit(EXTENT_FLAG_PREALLOC, &em->flags);
while (1) {
write_lock(&em_tree->lock);
ret = add_extent_mapping(em_tree, em);
Expand Down
6 changes: 3 additions & 3 deletions trunk/fs/btrfs/tree-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -2833,8 +2833,8 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *log = root->log_root;
struct btrfs_file_extent_item *fi;
struct btrfs_key key;
u64 start = em->start;
u64 len = em->len;
u64 start = em->mod_start;
u64 len = em->mod_len;
u64 num_bytes;
int nritems;
int ret;
Expand Down Expand Up @@ -2970,7 +2970,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
* sequential then we need to copy the items we have and redo
* our search
*/
if (args.nr && em->start != args.next_offset) {
if (args.nr && em->mod_start != args.next_offset) {
ret = copy_items(trans, log, dst_path, args.src,
args.start_slot, args.nr,
LOG_INODE_ALL);
Expand Down

0 comments on commit d8f53c4

Please sign in to comment.