Commit 5d4f98a2 authored by Yan Zheng's avatar Yan Zheng Committed by Chris Mason

Btrfs: Mixed back reference (FORWARD ROLLING FORMAT CHANGE)

This commit introduces a new kind of back reference for btrfs metadata.
Once a filesystem has been mounted with this commit, IT WILL NO LONGER
BE MOUNTABLE BY OLDER KERNELS.

When a tree block in subvolume tree is cow'd, the reference counts of all
extents it points to are increased by one.  At transaction commit time,
the old root of the subvolume is recorded in a "dead root" data structure,
and the btree it points to is later walked, dropping reference counts
and freeing any blocks where the reference count goes to 0.

The increments done during cow and decrements done after commit cancel out,
and the walk is a very expensive way to go about freeing the blocks that
are no longer referenced by the new btree root.  This commit reduces the
transaction overhead by avoiding the need for dead root records.

When a non-shared tree block is cow'd, we free the old block at once, and the
new block inherits old block's references. When a tree block with reference
count > 1 is cow'd, we increase the reference counts of all extents
the new block points to by one, and decrease the old block's reference count by
one.

This dead tree avoidance code removes the need to modify the reference
counts of lower level extents when a non-shared tree block is cow'd.
But we still need to update back ref for all pointers in the block.
This is because the location of the block is recorded in the back ref
item.

We can solve this by introducing a new type of back ref. The new
back ref provides information about pointer's key, level and in which
tree the pointer lives. This information allow us to find the pointer
by searching the tree. The shortcoming of the new back ref is that it
only works for pointers in tree blocks referenced by their owner trees.

This is mostly a problem for snapshots, where resolving one of these
fuzzy back references would be O(number_of_snapshots) and quite slow.
The solution used here is to use the fuzzy back references in the common
case where a given tree block is only referenced by one root,
and use the full back references when multiple roots have a reference
on a given block.

This commit adds per subvolume red-black tree to keep trace of cached
inodes. The red-black tree helps the balancing code to find cached
inodes whose inode numbers within a given range.

This commit improves the balancing code by introducing several data
structures to keep the state of balancing. The most important one
is the back ref cache. It caches how the upper level tree blocks are
referenced. This greatly reduce the overhead of checking back ref.

The improved balancing code scales significantly better with a large
number of snapshots.

This is a very large commit and was written in a number of
pieces.  But, they depend heavily on the disk format change and were
squashed together to make sure git bisect didn't end up in a
bad state wrt space balancing or the format change.
Signed-off-by: default avatarYan Zheng <zheng.yan@oracle.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 5c939df5
...@@ -6,5 +6,5 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \ ...@@ -6,5 +6,5 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
transaction.o inode.o file.o tree-defrag.o \ transaction.o inode.o file.o tree-defrag.o \
extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \ extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \
extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \ extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \
ref-cache.o export.o tree-log.o acl.o free-space-cache.o zlib.o \ export.o tree-log.o acl.o free-space-cache.o zlib.o \
compression.o delayed-ref.o compression.o delayed-ref.o relocation.o
...@@ -72,6 +72,9 @@ struct btrfs_inode { ...@@ -72,6 +72,9 @@ struct btrfs_inode {
*/ */
struct list_head ordered_operations; struct list_head ordered_operations;
/* node for the red-black tree that links inodes in subvolume root */
struct rb_node rb_node;
/* the space_info for where this inode's data allocations are done */ /* the space_info for where this inode's data allocations are done */
struct btrfs_space_info *space_info; struct btrfs_space_info *space_info;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -30,9 +30,6 @@ struct btrfs_delayed_ref_node { ...@@ -30,9 +30,6 @@ struct btrfs_delayed_ref_node {
/* the starting bytenr of the extent */ /* the starting bytenr of the extent */
u64 bytenr; u64 bytenr;
/* the parent our backref will point to */
u64 parent;
/* the size of the extent */ /* the size of the extent */
u64 num_bytes; u64 num_bytes;
...@@ -50,10 +47,21 @@ struct btrfs_delayed_ref_node { ...@@ -50,10 +47,21 @@ struct btrfs_delayed_ref_node {
*/ */
int ref_mod; int ref_mod;
unsigned int action:8;
unsigned int type:8;
/* is this node still in the rbtree? */ /* is this node still in the rbtree? */
unsigned int is_head:1;
unsigned int in_tree:1; unsigned int in_tree:1;
}; };
struct btrfs_delayed_extent_op {
struct btrfs_disk_key key;
u64 flags_to_set;
unsigned int update_key:1;
unsigned int update_flags:1;
unsigned int is_data:1;
};
/* /*
* the head refs are used to hold a lock on a given extent, which allows us * the head refs are used to hold a lock on a given extent, which allows us
* to make sure that only one process is running the delayed refs * to make sure that only one process is running the delayed refs
...@@ -71,6 +79,7 @@ struct btrfs_delayed_ref_head { ...@@ -71,6 +79,7 @@ struct btrfs_delayed_ref_head {
struct list_head cluster; struct list_head cluster;
struct btrfs_delayed_extent_op *extent_op;
/* /*
* when a new extent is allocated, it is just reserved in memory * when a new extent is allocated, it is just reserved in memory
* The actual extent isn't inserted into the extent allocation tree * The actual extent isn't inserted into the extent allocation tree
...@@ -84,27 +93,26 @@ struct btrfs_delayed_ref_head { ...@@ -84,27 +93,26 @@ struct btrfs_delayed_ref_head {
* the free has happened. * the free has happened.
*/ */
unsigned int must_insert_reserved:1; unsigned int must_insert_reserved:1;
unsigned int is_data:1;
}; };
struct btrfs_delayed_ref { struct btrfs_delayed_tree_ref {
struct btrfs_delayed_ref_node node; struct btrfs_delayed_ref_node node;
union {
u64 root;
u64 parent;
};
int level;
};
/* the root objectid our ref will point to */ struct btrfs_delayed_data_ref {
u64 root; struct btrfs_delayed_ref_node node;
union {
/* the generation for the backref */ u64 root;
u64 generation; u64 parent;
};
/* owner_objectid of the backref */ u64 objectid;
u64 owner_objectid; u64 offset;
/* operation done by this entry in the rbtree */
u8 action;
/* if pin == 1, when the extent is freed it will be pinned until
* transaction commit
*/
unsigned int pin:1;
}; };
struct btrfs_delayed_ref_root { struct btrfs_delayed_ref_root {
...@@ -143,17 +151,25 @@ static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref) ...@@ -143,17 +151,25 @@ static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref)
} }
} }
int btrfs_add_delayed_ref(struct btrfs_trans_handle *trans, int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
u64 bytenr, u64 num_bytes, u64 parent, u64 ref_root, u64 bytenr, u64 num_bytes, u64 parent,
u64 ref_generation, u64 owner_objectid, int action, u64 ref_root, int level, int action,
int pin); struct btrfs_delayed_extent_op *extent_op);
int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
u64 bytenr, u64 num_bytes,
u64 parent, u64 ref_root,
u64 owner, u64 offset, int action,
struct btrfs_delayed_extent_op *extent_op);
int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans,
u64 bytenr, u64 num_bytes,
struct btrfs_delayed_extent_op *extent_op);
struct btrfs_delayed_ref_head * struct btrfs_delayed_ref_head *
btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr); btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr);
int btrfs_delayed_ref_pending(struct btrfs_trans_handle *trans, u64 bytenr); int btrfs_delayed_ref_pending(struct btrfs_trans_handle *trans, u64 bytenr);
int btrfs_lookup_extent_ref(struct btrfs_trans_handle *trans, int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 bytenr, struct btrfs_root *root, u64 bytenr,
u64 num_bytes, u32 *refs); u64 num_bytes, u64 *refs, u64 *flags);
int btrfs_update_delayed_ref(struct btrfs_trans_handle *trans, int btrfs_update_delayed_ref(struct btrfs_trans_handle *trans,
u64 bytenr, u64 num_bytes, u64 orig_parent, u64 bytenr, u64 num_bytes, u64 orig_parent,
u64 parent, u64 orig_ref_root, u64 ref_root, u64 parent, u64 orig_ref_root, u64 ref_root,
...@@ -169,18 +185,24 @@ int btrfs_find_ref_cluster(struct btrfs_trans_handle *trans, ...@@ -169,18 +185,24 @@ int btrfs_find_ref_cluster(struct btrfs_trans_handle *trans,
*/ */
static int btrfs_delayed_ref_is_head(struct btrfs_delayed_ref_node *node) static int btrfs_delayed_ref_is_head(struct btrfs_delayed_ref_node *node)
{ {
return node->parent == (u64)-1; return node->is_head;
} }
/* /*
* helper functions to cast a node into its container * helper functions to cast a node into its container
*/ */
static inline struct btrfs_delayed_ref * static inline struct btrfs_delayed_tree_ref *
btrfs_delayed_node_to_ref(struct btrfs_delayed_ref_node *node) btrfs_delayed_node_to_tree_ref(struct btrfs_delayed_ref_node *node)
{ {
WARN_ON(btrfs_delayed_ref_is_head(node)); WARN_ON(btrfs_delayed_ref_is_head(node));
return container_of(node, struct btrfs_delayed_ref, node); return container_of(node, struct btrfs_delayed_tree_ref, node);
}
static inline struct btrfs_delayed_data_ref *
btrfs_delayed_node_to_data_ref(struct btrfs_delayed_ref_node *node)
{
WARN_ON(btrfs_delayed_ref_is_head(node));
return container_of(node, struct btrfs_delayed_data_ref, node);
} }
static inline struct btrfs_delayed_ref_head * static inline struct btrfs_delayed_ref_head *
...@@ -188,6 +210,5 @@ btrfs_delayed_node_to_head(struct btrfs_delayed_ref_node *node) ...@@ -188,6 +210,5 @@ btrfs_delayed_node_to_head(struct btrfs_delayed_ref_node *node)
{ {
WARN_ON(!btrfs_delayed_ref_is_head(node)); WARN_ON(!btrfs_delayed_ref_is_head(node));
return container_of(node, struct btrfs_delayed_ref_head, node); return container_of(node, struct btrfs_delayed_ref_head, node);
} }
#endif #endif
This diff is collapsed.
...@@ -78,7 +78,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, ...@@ -78,7 +78,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
key.offset = 0; key.offset = 0;
inode = btrfs_iget(sb, &key, root, NULL); inode = btrfs_iget(sb, &key, root);
if (IS_ERR(inode)) if (IS_ERR(inode))
return (void *)inode; return (void *)inode;
...@@ -192,7 +192,7 @@ static struct dentry *btrfs_get_parent(struct dentry *child) ...@@ -192,7 +192,7 @@ static struct dentry *btrfs_get_parent(struct dentry *child)
btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
key.offset = 0; key.offset = 0;
return d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root, NULL)); return d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root));
} }
const struct export_operations btrfs_export_ops = { const struct export_operations btrfs_export_ops = {
......
This diff is collapsed.
...@@ -291,16 +291,12 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -291,16 +291,12 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans,
{ {
u64 extent_end = 0; u64 extent_end = 0;
u64 search_start = start; u64 search_start = start;
u64 leaf_start;
u64 ram_bytes = 0; u64 ram_bytes = 0;
u64 orig_parent = 0;
u64 disk_bytenr = 0; u64 disk_bytenr = 0;
u64 orig_locked_end = locked_end; u64 orig_locked_end = locked_end;
u8 compression; u8 compression;
u8 encryption; u8 encryption;
u16 other_encoding = 0; u16 other_encoding = 0;
u64 root_gen;
u64 root_owner;
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct btrfs_file_extent_item *extent; struct btrfs_file_extent_item *extent;
struct btrfs_path *path; struct btrfs_path *path;
...@@ -340,9 +336,6 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -340,9 +336,6 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans,
bookend = 0; bookend = 0;
found_extent = 0; found_extent = 0;
found_inline = 0; found_inline = 0;
leaf_start = 0;
root_gen = 0;
root_owner = 0;
compression = 0; compression = 0;
encryption = 0; encryption = 0;
extent = NULL; extent = NULL;
...@@ -417,9 +410,6 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -417,9 +410,6 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans,
if (found_extent) { if (found_extent) {
read_extent_buffer(leaf, &old, (unsigned long)extent, read_extent_buffer(leaf, &old, (unsigned long)extent,
sizeof(old)); sizeof(old));
root_gen = btrfs_header_generation(leaf);
root_owner = btrfs_header_owner(leaf);
leaf_start = leaf->start;
} }
if (end < extent_end && end >= key.offset) { if (end < extent_end && end >= key.offset) {
...@@ -443,14 +433,14 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -443,14 +433,14 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans,
} }
locked_end = extent_end; locked_end = extent_end;
} }
orig_parent = path->nodes[0]->start;
disk_bytenr = le64_to_cpu(old.disk_bytenr); disk_bytenr = le64_to_cpu(old.disk_bytenr);
if (disk_bytenr != 0) { if (disk_bytenr != 0) {
ret = btrfs_inc_extent_ref(trans, root, ret = btrfs_inc_extent_ref(trans, root,
disk_bytenr, disk_bytenr,
le64_to_cpu(old.disk_num_bytes), le64_to_cpu(old.disk_num_bytes), 0,
orig_parent, root->root_key.objectid, root->root_key.objectid,
trans->transid, inode->i_ino); key.objectid, key.offset -
le64_to_cpu(old.offset));
BUG_ON(ret); BUG_ON(ret);
} }
} }
...@@ -568,17 +558,6 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -568,17 +558,6 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(path->nodes[0]); btrfs_mark_buffer_dirty(path->nodes[0]);
btrfs_set_lock_blocking(path->nodes[0]); btrfs_set_lock_blocking(path->nodes[0]);
if (disk_bytenr != 0) {
ret = btrfs_update_extent_ref(trans, root,
disk_bytenr,
le64_to_cpu(old.disk_num_bytes),
orig_parent,
leaf->start,
root->root_key.objectid,
trans->transid, ins.objectid);
BUG_ON(ret);
}
path->leave_spinning = 0; path->leave_spinning = 0;
btrfs_release_path(root, path); btrfs_release_path(root, path);
if (disk_bytenr != 0) if (disk_bytenr != 0)
...@@ -594,8 +573,9 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -594,8 +573,9 @@ noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans,
ret = btrfs_free_extent(trans, root, ret = btrfs_free_extent(trans, root,
old_disk_bytenr, old_disk_bytenr,
le64_to_cpu(old.disk_num_bytes), le64_to_cpu(old.disk_num_bytes),
leaf_start, root_owner, 0, root->root_key.objectid,
root_gen, key.objectid, 0); key.objectid, key.offset -
le64_to_cpu(old.offset));
BUG_ON(ret); BUG_ON(ret);
*hint_byte = old_disk_bytenr; *hint_byte = old_disk_bytenr;
} }
...@@ -664,12 +644,11 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -664,12 +644,11 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
u64 bytenr; u64 bytenr;
u64 num_bytes; u64 num_bytes;
u64 extent_end; u64 extent_end;
u64 extent_offset; u64 orig_offset;
u64 other_start; u64 other_start;
u64 other_end; u64 other_end;
u64 split = start; u64 split = start;
u64 locked_end = end; u64 locked_end = end;
u64 orig_parent;
int extent_type; int extent_type;
int split_end = 1; int split_end = 1;
int ret; int ret;
...@@ -703,7 +682,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -703,7 +682,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
bytenr = btrfs_file_extent_disk_bytenr(leaf, fi); bytenr = btrfs_file_extent_disk_bytenr(leaf, fi);
num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi); num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi);
extent_offset = btrfs_file_extent_offset(leaf, fi); orig_offset = key.offset - btrfs_file_extent_offset(leaf, fi);
if (key.offset == start) if (key.offset == start)
split = end; split = end;
...@@ -711,8 +690,6 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -711,8 +690,6 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
if (key.offset == start && extent_end == end) { if (key.offset == start && extent_end == end) {
int del_nr = 0; int del_nr = 0;
int del_slot = 0; int del_slot = 0;
u64 leaf_owner = btrfs_header_owner(leaf);
u64 leaf_gen = btrfs_header_generation(leaf);
other_start = end; other_start = end;
other_end = 0; other_end = 0;
if (extent_mergeable(leaf, path->slots[0] + 1, inode->i_ino, if (extent_mergeable(leaf, path->slots[0] + 1, inode->i_ino,
...@@ -721,8 +698,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -721,8 +698,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
del_slot = path->slots[0] + 1; del_slot = path->slots[0] + 1;
del_nr++; del_nr++;
ret = btrfs_free_extent(trans, root, bytenr, num_bytes, ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
leaf->start, leaf_owner, 0, root->root_key.objectid,
leaf_gen, inode->i_ino, 0); inode->i_ino, orig_offset);
BUG_ON(ret); BUG_ON(ret);
} }
other_start = 0; other_start = 0;
...@@ -733,8 +710,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -733,8 +710,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
del_slot = path->slots[0]; del_slot = path->slots[0];
del_nr++; del_nr++;
ret = btrfs_free_extent(trans, root, bytenr, num_bytes, ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
leaf->start, leaf_owner, 0, root->root_key.objectid,
leaf_gen, inode->i_ino, 0); inode->i_ino, orig_offset);
BUG_ON(ret); BUG_ON(ret);
} }
split_end = 0; split_end = 0;
...@@ -768,13 +745,12 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -768,13 +745,12 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
locked_end = extent_end; locked_end = extent_end;
} }
btrfs_set_file_extent_num_bytes(leaf, fi, split - key.offset); btrfs_set_file_extent_num_bytes(leaf, fi, split - key.offset);
extent_offset += split - key.offset;
} else { } else {
BUG_ON(key.offset != start); BUG_ON(key.offset != start);
btrfs_set_file_extent_offset(leaf, fi, extent_offset +
split - key.offset);
btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - split);
key.offset = split; key.offset = split;
btrfs_set_file_extent_offset(leaf, fi, key.offset -
orig_offset);
btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - split);
btrfs_set_item_key_safe(trans, root, path, &key); btrfs_set_item_key_safe(trans, root, path, &key);
extent_end = split; extent_end = split;
} }
...@@ -793,7 +769,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -793,7 +769,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
struct btrfs_file_extent_item); struct btrfs_file_extent_item);
key.offset = split; key.offset = split;
btrfs_set_item_key_safe(trans, root, path, &key); btrfs_set_item_key_safe(trans, root, path, &key);
btrfs_set_file_extent_offset(leaf, fi, extent_offset); btrfs_set_file_extent_offset(leaf, fi, key.offset -
orig_offset);
btrfs_set_file_extent_num_bytes(leaf, fi, btrfs_set_file_extent_num_bytes(leaf, fi,
other_end - split); other_end - split);
goto done; goto done;
...@@ -815,10 +792,9 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -815,10 +792,9 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
orig_parent = leaf->start; ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0,
ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, root->root_key.objectid,
orig_parent, root->root_key.objectid, inode->i_ino, orig_offset);
trans->transid, inode->i_ino);
BUG_ON(ret); BUG_ON(ret);
btrfs_release_path(root, path); btrfs_release_path(root, path);
...@@ -833,20 +809,12 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -833,20 +809,12 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
btrfs_set_file_extent_type(leaf, fi, extent_type); btrfs_set_file_extent_type(leaf, fi, extent_type);
btrfs_set_file_extent_disk_bytenr(leaf, fi, bytenr); btrfs_set_file_extent_disk_bytenr(leaf, fi, bytenr);
btrfs_set_file_extent_disk_num_bytes(leaf, fi, num_bytes); btrfs_set_file_extent_disk_num_bytes(leaf, fi, num_bytes);
btrfs_set_file_extent_offset(leaf, fi, extent_offset); btrfs_set_file_extent_offset(leaf, fi, key.offset - orig_offset);
btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - key.offset); btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - key.offset);
btrfs_set_file_extent_ram_bytes(leaf, fi, num_bytes); btrfs_set_file_extent_ram_bytes(leaf, fi, num_bytes);
btrfs_set_file_extent_compression(leaf, fi, 0); btrfs_set_file_extent_compression(leaf, fi, 0);
btrfs_set_file_extent_encryption(leaf, fi, 0); btrfs_set_file_extent_encryption(leaf, fi, 0);
btrfs_set_file_extent_other_encoding(leaf, fi, 0); btrfs_set_file_extent_other_encoding(leaf, fi, 0);
if (orig_parent != leaf->start) {
ret = btrfs_update_extent_ref(trans, root, bytenr, num_bytes,
orig_parent, leaf->start,
root->root_key.objectid,
trans->transid, inode->i_ino);
BUG_ON(ret);
}
done: done:
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include "ordered-data.h" #include "ordered-data.h"
#include "xattr.h" #include "xattr.h"
#include "tree-log.h" #include "tree-log.h"
#include "ref-cache.h"
#include "compression.h" #include "compression.h"
#include "locking.h" #include "locking.h"
...@@ -944,6 +943,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, ...@@ -944,6 +943,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
u64 cow_start; u64 cow_start;
u64 cur_offset; u64 cur_offset;
u64 extent_end; u64 extent_end;
u64 extent_offset;
u64 disk_bytenr; u64 disk_bytenr;
u64 num_bytes; u64 num_bytes;
int extent_type; int extent_type;
...@@ -1005,6 +1005,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, ...@@ -1005,6 +1005,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
if (extent_type == BTRFS_FILE_EXTENT_REG || if (extent_type == BTRFS_FILE_EXTENT_REG ||
extent_type == BTRFS_FILE_EXTENT_PREALLOC) { extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi); disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi);
extent_offset = btrfs_file_extent_offset(leaf, fi);
extent_end = found_key.offset + extent_end = found_key.offset +
btrfs_file_extent_num_bytes(leaf, fi); btrfs_file_extent_num_bytes(leaf, fi);
if (extent_end <= start) { if (extent_end <= start) {
...@@ -1022,9 +1023,10 @@ static noinline int run_delalloc_nocow(struct inode *inode, ...@@ -1022,9 +1023,10 @@ static noinline int run_delalloc_nocow(struct inode *inode,
if (btrfs_extent_readonly(root, disk_bytenr)) if (btrfs_extent_readonly(root, disk_bytenr))
goto out_check; goto out_check;
if (btrfs_cross_ref_exist(trans, root, inode->i_ino, if (btrfs_cross_ref_exist(trans, root, inode->i_ino,
disk_bytenr)) found_key.offset -
extent_offset, disk_bytenr))
goto out_check; goto out_check;
disk_bytenr += btrfs_file_extent_offset(leaf, fi); disk_bytenr += extent_offset;
disk_bytenr += cur_offset - found_key.offset; disk_bytenr += cur_offset - found_key.offset;
num_bytes = min(end + 1, extent_end) - cur_offset; num_bytes = min(end + 1, extent_end) - cur_offset;
/* /*
...@@ -1489,9 +1491,9 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, ...@@ -1489,9 +1491,9 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
ins.objectid = disk_bytenr; ins.objectid = disk_bytenr;
ins.offset = disk_num_bytes; ins.offset = disk_num_bytes;
ins.type = BTRFS_EXTENT_ITEM_KEY; ins.type = BTRFS_EXTENT_ITEM_KEY;
ret = btrfs_alloc_reserved_extent(trans, root, leaf->start, ret = btrfs_alloc_reserved_file_extent(trans, root,
root->root_key.objectid, root->root_key.objectid,
trans->transid, inode->i_ino, &ins); inode->i_ino, file_pos, &ins);
BUG_ON(ret); BUG_ON(ret);
btrfs_free_path(path); btrfs_free_path(path);
...@@ -1956,23 +1958,13 @@ void btrfs_orphan_cleanup(struct btrfs_root *root) ...@@ -1956,23 +1958,13 @@ void btrfs_orphan_cleanup(struct btrfs_root *root)
* crossing root thing. we store the inode number in the * crossing root thing. we store the inode number in the
* offset of the orphan item. * offset of the orphan item.
*/ */
inode = btrfs_iget_locked(root->fs_info->sb, found_key.objectid = found_key.offset;
found_key.offset, root); found_key.type = BTRFS_INODE_ITEM_KEY;
if (!inode) found_key.offset = 0;
inode = btrfs_iget(root->fs_info->sb, &found_key, root);
if (IS_ERR(inode))
break; break;
if (inode->i_state & I_NEW) {
BTRFS_I(inode)->root = root;
/* have to set the location manually */
BTRFS_I(inode)->location.objectid = inode->i_ino;
BTRFS_I(inode)->location.type = BTRFS_INODE_ITEM_KEY;
BTRFS_I(inode)->location.offset = 0;
btrfs_read_locked_inode(inode);
unlock_new_inode(inode);
}
/* /*
* add this inode to the orphan list so btrfs_orphan_del does * add this inode to the orphan list so btrfs_orphan_del does
* the proper thing when we hit it * the proper thing when we hit it
...@@ -2069,7 +2061,7 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf, ...@@ -2069,7 +2061,7 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf,
/* /*
* read an inode from the btree into the in-memory inode * read an inode from the btree into the in-memory inode
*/ */
void btrfs_read_locked_inode(struct inode *inode) static void btrfs_read_locked_inode(struct inode *inode)
{ {
struct btrfs_path *path; struct btrfs_path *path;
struct extent_buffer *leaf; struct extent_buffer *leaf;
...@@ -2599,9 +2591,8 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -2599,9 +2591,8 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
struct btrfs_file_extent_item *fi; struct btrfs_file_extent_item *fi;
u64 extent_start = 0; u64 extent_start = 0;
u64 extent_num_bytes = 0; u64 extent_num_bytes = 0;
u64 extent_offset = 0;
u64 item_end = 0; u64 item_end = 0;
u64 root_gen = 0;
u64 root_owner = 0;
int found_extent; int found_extent;
int del_item; int del_item;
int pending_del_nr = 0; int pending_del_nr = 0;
...@@ -2716,6 +2707,9 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -2716,6 +2707,9 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
extent_num_bytes = extent_num_bytes =
btrfs_file_extent_disk_num_bytes(leaf, btrfs_file_extent_disk_num_bytes(leaf,
fi); fi);
extent_offset = found_key.offset -
btrfs_file_extent_offset(leaf, fi);
/* FIXME blocksize != 4096 */ /* FIXME blocksize != 4096 */
num_dec = btrfs_file_extent_num_bytes(leaf, fi); num_dec = btrfs_file_extent_num_bytes(leaf, fi);
if (extent_start != 0) { if (extent_start != 0) {
...@@ -2723,8 +2717,6 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -2723,8 +2717,6 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
if (root->ref_cows) if (root->ref_cows)
inode_sub_bytes(inode, num_dec); inode_sub_bytes(inode, num_dec);
} }
root_gen = btrfs_header_generation(leaf);
root_owner = btrfs_header_owner(leaf);
} }
} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) { } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
/* /*
...@@ -2768,12 +2760,12 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -2768,12 +2760,12 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
} else { } else {
break; break;
} }
if (found_extent) { if (found_extent && root->ref_cows) {
btrfs_set_path_blocking(path); btrfs_set_path_blocking(path);
ret = btrfs_free_extent(trans, root, extent_start, ret = btrfs_free_extent(trans, root, extent_start,
extent_num_bytes, extent_num_bytes, 0,
leaf->start, root_owner, btrfs_header_owner(leaf),
root_gen, inode->i_ino, 0); inode->i_ino, extent_offset);
BUG_ON(ret); BUG_ON(ret);
} }
next: next:
...@@ -3105,6 +3097,45 @@ static int fixup_tree_root_location(struct btrfs_root *root, ...@@ -3105,6 +3097,45 @@ static int fixup_tree_root_location(struct btrfs_root *root,
return 0; return 0;
} }
static void inode_tree_add(struct inode *inode)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_inode *entry;
struct rb_node **p = &root->inode_tree.rb_node;
struct rb_node *parent = NULL;
spin_lock(&root->inode_lock);
while (*p) {
parent = *p;
entry = rb_entry(parent, struct btrfs_inode, rb_node);
if (inode->i_ino < entry->vfs_inode.i_ino)
p = &(*p)->rb_left;
else if (inode->i_ino > entry->vfs_inode.i_ino)
p = &(*p)->rb_right;
else {
WARN_ON(!(entry->vfs_inode.i_state &
(I_WILL_FREE | I_FREEING | I_CLEAR)));
break;
}
}
rb_link_node(&BTRFS_I(inode)->rb_node, parent, p);
rb_insert_color(&BTRFS_I(inode)->rb_node, &root->inode_tree);
spin_unlock(&root->inode_lock);
}
static void inode_tree_del(struct inode *inode)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
if (!RB_EMPTY_NODE(&BTRFS_I(inode)->rb_node)) {
spin_lock(&root->inode_lock);
rb_erase(&BTRFS_I(inode)->rb_node, &root->inode_tree);
spin_unlock(&root->inode_lock);
RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
}
}
static noinline void init_btrfs_i(struct inode *inode) static noinline void init_btrfs_i(struct inode *inode)
{ {
struct btrfs_inode *bi = BTRFS_I(inode); struct btrfs_inode *bi = BTRFS_I(inode);
...@@ -3130,6 +3161,7 @@ static noinline void init_btrfs_i(struct inode *inode) ...@@ -3130,6 +3161,7 @@ static noinline void init_btrfs_i(struct inode *inode)
inode->i_mapping, GFP_NOFS); inode->i_mapping, GFP_NOFS);
INIT_LIST_HEAD(&BTRFS_I(inode)->delalloc_inodes); INIT_LIST_HEAD(&BTRFS_I(inode)->delalloc_inodes);
INIT_LIST_HEAD(&BTRFS_I(inode)->ordered_operations); INIT_LIST_HEAD(&BTRFS_I(inode)->ordered_operations);
RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
btrfs_ordered_inode_tree_init(&BTRFS_I(inode)->ordered_tree); btrfs_ordered_inode_tree_init(&BTRFS_I(inode)->ordered_tree);
mutex_init(&BTRFS_I(inode)->extent_mutex); mutex_init(&BTRFS_I(inode)->extent_mutex);
mutex_init(&BTRFS_I(inode)->log_mutex); mutex_init(&BTRFS_I(inode)->log_mutex);
...@@ -3152,26 +3184,9 @@ static int btrfs_find_actor(struct inode *inode, void *opaque) ...@@ -3152,26 +3184,9 @@ static int btrfs_find_actor(struct inode *inode, void *opaque)
args->root == BTRFS_I(inode)->root; args->root == BTRFS_I(inode)->root;
} }
struct inode *btrfs_ilookup(struct super_block *s, u64 objectid, static struct inode *btrfs_iget_locked(struct super_block *s,
struct btrfs_root *root, int wait) u64 objectid,
{ struct btrfs_root *root)
struct inode *inode;
struct btrfs_iget_args args;
args.ino = objectid;
args.root = root;
if (wait) {
inode = ilookup5(s, objectid, btrfs_find_actor,
(void *)&args);
} else {
inode = ilookup5_nowait(s, objectid, btrfs_find_actor,
(void *)&args);
}
return inode;
}
struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
struct btrfs_root *root)
{ {
struct inode *inode; struct inode *inode;
struct btrfs_iget_args args; struct btrfs_iget_args args;
...@@ -3188,24 +3203,21 @@ struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid, ...@@ -3188,24 +3203,21 @@ struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
* Returns in *is_new if the inode was read from disk * Returns in *is_new if the inode was read from disk
*/ */
struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
struct btrfs_root *root, int *is_new) struct btrfs_root *root)
{ {
struct inode *inode; struct inode *inode;
inode = btrfs_iget_locked(s, location->objectid, root); inode = btrfs_iget_locked(s, location->objectid, root);
if (!inode) if (!inode)
return ERR_PTR(-EACCES); return ERR_PTR(-ENOMEM);
if (inode->i_state & I_NEW) { if (inode->i_state & I_NEW) {
BTRFS_I(inode)->root = root; BTRFS_I(inode)->root = root;
memcpy(&BTRFS_I(inode)->location, location, sizeof(*location)); memcpy(&BTRFS_I(inode)->location, location, sizeof(*location));
btrfs_read_locked_inode(inode); btrfs_read_locked_inode(inode);
inode_tree_add(inode);
unlock_new_inode(inode); unlock_new_inode(inode);
if (is_new)
*is_new = 1;
} else {
if (is_new)
*is_new = 0;
} }
return inode; return inode;
...@@ -3218,7 +3230,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) ...@@ -3218,7 +3230,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
struct btrfs_root *root = bi->root; struct btrfs_root *root = bi->root;
struct btrfs_root *sub_root = root; struct btrfs_root *sub_root = root;
struct btrfs_key location; struct btrfs_key location;
int ret, new; int ret;
if (dentry->d_name.len > BTRFS_NAME_LEN) if (dentry->d_name.len > BTRFS_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
...@@ -3236,7 +3248,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) ...@@ -3236,7 +3248,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
return ERR_PTR(ret); return ERR_PTR(ret);
if (ret > 0) if (ret > 0)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
inode = btrfs_iget(dir->i_sb, &location, sub_root, &new); inode = btrfs_iget(dir->i_sb, &location, sub_root);
if (IS_ERR(inode)) if (IS_ERR(inode))
return ERR_CAST(inode); return ERR_CAST(inode);
} }
...@@ -3631,6 +3643,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, ...@@ -3631,6 +3643,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY); btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY);
insert_inode_hash(inode); insert_inode_hash(inode);
inode_tree_add(inode);
return inode; return inode;
fail: fail:
if (dir) if (dir)
...@@ -4683,6 +4696,7 @@ void btrfs_destroy_inode(struct inode *inode) ...@@ -4683,6 +4696,7 @@ void btrfs_destroy_inode(struct inode *inode)
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
} }
} }
inode_tree_del(inode);
btrfs_drop_extent_cache(inode, 0, (u64)-1, 0); btrfs_drop_extent_cache(inode, 0, (u64)-1, 0);
kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));
} }
......
...@@ -82,22 +82,25 @@ static noinline int create_subvol(struct btrfs_root *root, ...@@ -82,22 +82,25 @@ static noinline int create_subvol(struct btrfs_root *root,
if (ret) if (ret)
goto fail; goto fail;
leaf = btrfs_alloc_free_block(trans, root, root->leafsize, 0, leaf = btrfs_alloc_free_block(trans, root, root->leafsize,
objectid, trans->transid, 0, 0, 0); 0, objectid, NULL, 0, 0, 0);
if (IS_ERR(leaf)) { if (IS_ERR(leaf)) {
ret = PTR_ERR(leaf); ret = PTR_ERR(leaf);
goto fail; goto fail;
} }
btrfs_set_header_nritems(leaf, 0); memset_extent_buffer(leaf, 0, 0, sizeof(struct btrfs_header));
btrfs_set_header_level(leaf, 0);
btrfs_set_header_bytenr(leaf, leaf->start); btrfs_set_header_bytenr(leaf, leaf->start);
btrfs_set_header_generation(leaf, trans->transid); btrfs_set_header_generation(leaf, trans->transid);
btrfs_set_header_backref_rev(leaf, BTRFS_MIXED_BACKREF_REV);
btrfs_set_header_owner(leaf, objectid); btrfs_set_header_owner(leaf, objectid);
write_extent_buffer(leaf, root->fs_info->fsid, write_extent_buffer(leaf, root->fs_info->fsid,
(unsigned long)btrfs_header_fsid(leaf), (unsigned long)btrfs_header_fsid(leaf),
BTRFS_FSID_SIZE); BTRFS_FSID_SIZE);
write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid,
(unsigned long)btrfs_header_chunk_tree_uuid(leaf),
BTRFS_UUID_SIZE);
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
inode_item = &root_item.inode; inode_item = &root_item.inode;
...@@ -125,7 +128,7 @@ static noinline int create_subvol(struct btrfs_root *root, ...@@ -125,7 +128,7 @@ static noinline int create_subvol(struct btrfs_root *root,
btrfs_set_root_dirid(&root_item, new_dirid); btrfs_set_root_dirid(&root_item, new_dirid);
key.objectid = objectid; key.objectid = objectid;
key.offset = 1; key.offset = 0;
btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key, ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key,
&root_item); &root_item);
...@@ -911,10 +914,10 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, ...@@ -911,10 +914,10 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
if (disko) { if (disko) {
inode_add_bytes(inode, datal); inode_add_bytes(inode, datal);
ret = btrfs_inc_extent_ref(trans, root, ret = btrfs_inc_extent_ref(trans, root,
disko, diskl, leaf->start, disko, diskl, 0,
root->root_key.objectid, root->root_key.objectid,
trans->transid, inode->i_ino,
inode->i_ino); new_key.offset - datao);
BUG_ON(ret); BUG_ON(ret);
} }
} else if (type == BTRFS_FILE_EXTENT_INLINE) { } else if (type == BTRFS_FILE_EXTENT_INLINE) {
......
...@@ -45,22 +45,132 @@ static void print_dev_item(struct extent_buffer *eb, ...@@ -45,22 +45,132 @@ static void print_dev_item(struct extent_buffer *eb,
(unsigned long long)btrfs_device_total_bytes(eb, dev_item), (unsigned long long)btrfs_device_total_bytes(eb, dev_item),
(unsigned long long)btrfs_device_bytes_used(eb, dev_item)); (unsigned long long)btrfs_device_bytes_used(eb, dev_item));
} }
static void print_extent_data_ref(struct extent_buffer *eb,
struct btrfs_extent_data_ref *ref)
{
printk(KERN_INFO "\t\textent data backref root %llu "
"objectid %llu offset %llu count %u\n",
(unsigned long long)btrfs_extent_data_ref_root(eb, ref),
(unsigned long long)btrfs_extent_data_ref_objectid(eb, ref),
(unsigned long long)btrfs_extent_data_ref_offset(eb, ref),
btrfs_extent_data_ref_count(eb, ref));
}
static void print_extent_item(struct extent_buffer *eb, int slot)
{
struct btrfs_extent_item *ei;
struct btrfs_extent_inline_ref *iref;
struct btrfs_extent_data_ref *dref;
struct btrfs_shared_data_ref *sref;
struct btrfs_disk_key key;
unsigned long end;
unsigned long ptr;
int type;
u32 item_size = btrfs_item_size_nr(eb, slot);
u64 flags;
u64 offset;
if (item_size < sizeof(*ei)) {
#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
struct btrfs_extent_item_v0 *ei0;
BUG_ON(item_size != sizeof(*ei0));
ei0 = btrfs_item_ptr(eb, slot, struct btrfs_extent_item_v0);
printk(KERN_INFO "\t\textent refs %u\n",
btrfs_extent_refs_v0(eb, ei0));
return;
#else
BUG();
#endif
}
ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item);
flags = btrfs_extent_flags(eb, ei);
printk(KERN_INFO "\t\textent refs %llu gen %llu flags %llu\n",
(unsigned long long)btrfs_extent_refs(eb, ei),
(unsigned long long)btrfs_extent_generation(eb, ei),
(unsigned long long)flags);
if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
struct btrfs_tree_block_info *info;
info = (struct btrfs_tree_block_info *)(ei + 1);
btrfs_tree_block_key(eb, info, &key);
printk(KERN_INFO "\t\ttree block key (%llu %x %llu) "
"level %d\n",
(unsigned long long)btrfs_disk_key_objectid(&key),
key.type,
(unsigned long long)btrfs_disk_key_offset(&key),
btrfs_tree_block_level(eb, info));
iref = (struct btrfs_extent_inline_ref *)(info + 1);
} else {
iref = (struct btrfs_extent_inline_ref *)(ei + 1);
}
ptr = (unsigned long)iref;
end = (unsigned long)ei + item_size;
while (ptr < end) {
iref = (struct btrfs_extent_inline_ref *)ptr;
type = btrfs_extent_inline_ref_type(eb, iref);
offset = btrfs_extent_inline_ref_offset(eb, iref);
switch (type) {
case BTRFS_TREE_BLOCK_REF_KEY:
printk(KERN_INFO "\t\ttree block backref "
"root %llu\n", (unsigned long long)offset);
break;
case BTRFS_SHARED_BLOCK_REF_KEY:
printk(KERN_INFO "\t\tshared block backref "
"parent %llu\n", (unsigned long long)offset);
break;
case BTRFS_EXTENT_DATA_REF_KEY:
dref = (struct btrfs_extent_data_ref *)(&iref->offset);
print_extent_data_ref(eb, dref);
break;
case BTRFS_SHARED_DATA_REF_KEY:
sref = (struct btrfs_shared_data_ref *)(iref + 1);
printk(KERN_INFO "\t\tshared data backref "
"parent %llu count %u\n",
(unsigned long long)offset,
btrfs_shared_data_ref_count(eb, sref));
break;
default:
BUG();
}
ptr += btrfs_extent_inline_ref_size(type);
}
WARN_ON(ptr > end);
}
#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
static void print_extent_ref_v0(struct extent_buffer *eb, int slot)
{
struct btrfs_extent_ref_v0 *ref0;
ref0 = btrfs_item_ptr(eb, slot, struct btrfs_extent_ref_v0);
printk("\t\textent back ref root %llu gen %llu "
"owner %llu num_refs %lu\n",
(unsigned long long)btrfs_ref_root_v0(eb, ref0),
(unsigned long long)btrfs_ref_generation_v0(eb, ref0),
(unsigned long long)btrfs_ref_objectid_v0(eb, ref0),
(unsigned long)btrfs_ref_count_v0(eb, ref0));
}
#endif
void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
{ {
int i; int i;
u32 type;
u32 nr = btrfs_header_nritems(l); u32 nr = btrfs_header_nritems(l);
struct btrfs_item *item; struct btrfs_item *item;
struct btrfs_extent_item *ei;
struct btrfs_root_item *ri; struct btrfs_root_item *ri;
struct btrfs_dir_item *di; struct btrfs_dir_item *di;
struct btrfs_inode_item *ii; struct btrfs_inode_item *ii;
struct btrfs_block_group_item *bi; struct btrfs_block_group_item *bi;
struct btrfs_file_extent_item *fi; struct btrfs_file_extent_item *fi;
struct btrfs_extent_data_ref *dref;
struct btrfs_shared_data_ref *sref;
struct btrfs_dev_extent *dev_extent;
struct btrfs_key key; struct btrfs_key key;
struct btrfs_key found_key; struct btrfs_key found_key;
struct btrfs_extent_ref *ref;
struct btrfs_dev_extent *dev_extent;
u32 type;
printk(KERN_INFO "leaf %llu total ptrs %d free space %d\n", printk(KERN_INFO "leaf %llu total ptrs %d free space %d\n",
(unsigned long long)btrfs_header_bytenr(l), nr, (unsigned long long)btrfs_header_bytenr(l), nr,
...@@ -100,20 +210,25 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) ...@@ -100,20 +210,25 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
btrfs_disk_root_refs(l, ri)); btrfs_disk_root_refs(l, ri));
break; break;
case BTRFS_EXTENT_ITEM_KEY: case BTRFS_EXTENT_ITEM_KEY:
ei = btrfs_item_ptr(l, i, struct btrfs_extent_item); print_extent_item(l, i);
printk(KERN_INFO "\t\textent data refs %u\n", break;
btrfs_extent_refs(l, ei)); case BTRFS_TREE_BLOCK_REF_KEY:
break; printk(KERN_INFO "\t\ttree block backref\n");
case BTRFS_EXTENT_REF_KEY: break;
ref = btrfs_item_ptr(l, i, struct btrfs_extent_ref); case BTRFS_SHARED_BLOCK_REF_KEY:
printk(KERN_INFO "\t\textent back ref root %llu " printk(KERN_INFO "\t\tshared block backref\n");
"gen %llu owner %llu num_refs %lu\n", break;
(unsigned long long)btrfs_ref_root(l, ref), case BTRFS_EXTENT_DATA_REF_KEY:
(unsigned long long)btrfs_ref_generation(l, ref), dref = btrfs_item_ptr(l, i,
(unsigned long long)btrfs_ref_objectid(l, ref), struct btrfs_extent_data_ref);
(unsigned long)btrfs_ref_num_refs(l, ref)); print_extent_data_ref(l, dref);
break;
case BTRFS_SHARED_DATA_REF_KEY:
sref = btrfs_item_ptr(l, i,
struct btrfs_shared_data_ref);
printk(KERN_INFO "\t\tshared data backref count %u\n",
btrfs_shared_data_ref_count(l, sref));
break; break;
case BTRFS_EXTENT_DATA_KEY: case BTRFS_EXTENT_DATA_KEY:
fi = btrfs_item_ptr(l, i, fi = btrfs_item_ptr(l, i,
struct btrfs_file_extent_item); struct btrfs_file_extent_item);
...@@ -139,6 +254,12 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) ...@@ -139,6 +254,12 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
(unsigned long long) (unsigned long long)
btrfs_file_extent_ram_bytes(l, fi)); btrfs_file_extent_ram_bytes(l, fi));
break; break;
case BTRFS_EXTENT_REF_V0_KEY:
#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
print_extent_ref_v0(l, i);
#else
BUG();
#endif
case BTRFS_BLOCK_GROUP_ITEM_KEY: case BTRFS_BLOCK_GROUP_ITEM_KEY:
bi = btrfs_item_ptr(l, i, bi = btrfs_item_ptr(l, i,
struct btrfs_block_group_item); struct btrfs_block_group_item);
......
This diff is collapsed.
...@@ -111,6 +111,15 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, ...@@ -111,6 +111,15 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
return ret; return ret;
} }
int btrfs_set_root_node(struct btrfs_root_item *item,
struct extent_buffer *node)
{
btrfs_set_root_bytenr(item, node->start);
btrfs_set_root_level(item, btrfs_header_level(node));
btrfs_set_root_generation(item, btrfs_header_generation(node));
return 0;
}
/* /*
* copy the data in 'item' into the btree * copy the data in 'item' into the btree
*/ */
...@@ -164,8 +173,7 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root ...@@ -164,8 +173,7 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
* offset lower than the latest root. They need to be queued for deletion to * offset lower than the latest root. They need to be queued for deletion to
* finish what was happening when we crashed. * finish what was happening when we crashed.
*/ */
int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid, int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid)
struct btrfs_root *latest)
{ {
struct btrfs_root *dead_root; struct btrfs_root *dead_root;
struct btrfs_item *item; struct btrfs_item *item;
...@@ -227,10 +235,7 @@ int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid, ...@@ -227,10 +235,7 @@ int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid,
goto err; goto err;
} }
if (objectid == BTRFS_TREE_RELOC_OBJECTID) ret = btrfs_add_dead_root(dead_root);
ret = btrfs_add_dead_reloc_root(dead_root);
else
ret = btrfs_add_dead_root(dead_root, latest);
if (ret) if (ret)
goto err; goto err;
goto again; goto again;
......
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
#include "export.h" #include "export.h"
#include "compression.h" #include "compression.h"
static struct super_operations btrfs_super_ops; static struct super_operations btrfs_super_ops;
static void btrfs_put_super(struct super_block *sb) static void btrfs_put_super(struct super_block *sb)
...@@ -322,7 +321,7 @@ static int btrfs_fill_super(struct super_block *sb, ...@@ -322,7 +321,7 @@ static int btrfs_fill_super(struct super_block *sb,
struct dentry *root_dentry; struct dentry *root_dentry;
struct btrfs_super_block *disk_super; struct btrfs_super_block *disk_super;
struct btrfs_root *tree_root; struct btrfs_root *tree_root;
struct btrfs_inode *bi; struct btrfs_key key;
int err; int err;
sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_maxbytes = MAX_LFS_FILESIZE;
...@@ -341,23 +340,15 @@ static int btrfs_fill_super(struct super_block *sb, ...@@ -341,23 +340,15 @@ static int btrfs_fill_super(struct super_block *sb,
} }
sb->s_fs_info = tree_root; sb->s_fs_info = tree_root;
disk_super = &tree_root->fs_info->super_copy; disk_super = &tree_root->fs_info->super_copy;
inode = btrfs_iget_locked(sb, BTRFS_FIRST_FREE_OBJECTID,
tree_root->fs_info->fs_root);
bi = BTRFS_I(inode);
bi->location.objectid = inode->i_ino;
bi->location.offset = 0;
bi->root = tree_root->fs_info->fs_root;
btrfs_set_key_type(&bi->location, BTRFS_INODE_ITEM_KEY);
if (!inode) { key.objectid = BTRFS_FIRST_FREE_OBJECTID;
err = -ENOMEM; key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
inode = btrfs_iget(sb, &key, tree_root->fs_info->fs_root);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto fail_close; goto fail_close;
} }
if (inode->i_state & I_NEW) {
btrfs_read_locked_inode(inode);
unlock_new_inode(inode);
}
root_dentry = d_alloc_root(inode); root_dentry = d_alloc_root(inode);
if (!root_dentry) { if (!root_dentry) {
...@@ -584,7 +575,8 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) ...@@ -584,7 +575,8 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
if (btrfs_super_log_root(&root->fs_info->super_copy) != 0) if (btrfs_super_log_root(&root->fs_info->super_copy) != 0)
return -EINVAL; return -EINVAL;
ret = btrfs_cleanup_reloc_trees(root); /* recover relocation */
ret = btrfs_recover_relocation(root);
WARN_ON(ret); WARN_ON(ret);
ret = btrfs_cleanup_fs_roots(root->fs_info); ret = btrfs_cleanup_fs_roots(root->fs_info);
......
This diff is collapsed.
...@@ -62,12 +62,6 @@ struct btrfs_pending_snapshot { ...@@ -62,12 +62,6 @@ struct btrfs_pending_snapshot {
struct list_head list; struct list_head list;
}; };
struct btrfs_dirty_root {
struct list_head list;
struct btrfs_root *root;
struct btrfs_root *latest_root;
};
static inline void btrfs_set_trans_block_group(struct btrfs_trans_handle *trans, static inline void btrfs_set_trans_block_group(struct btrfs_trans_handle *trans,
struct inode *inode) struct inode *inode)
{ {
...@@ -100,7 +94,8 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, ...@@ -100,7 +94,8 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
struct btrfs_root *root); struct btrfs_root *root);
int btrfs_add_dead_root(struct btrfs_root *root, struct btrfs_root *latest); int btrfs_add_dead_root(struct btrfs_root *root);
int btrfs_drop_dead_root(struct btrfs_root *root);
int btrfs_defrag_root(struct btrfs_root *root, int cacheonly); int btrfs_defrag_root(struct btrfs_root *root, int cacheonly);
int btrfs_clean_old_snapshots(struct btrfs_root *root); int btrfs_clean_old_snapshots(struct btrfs_root *root);
int btrfs_commit_transaction(struct btrfs_trans_handle *trans, int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
...@@ -108,7 +103,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -108,7 +103,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans,
struct btrfs_root *root); struct btrfs_root *root);
void btrfs_throttle(struct btrfs_root *root); void btrfs_throttle(struct btrfs_root *root);
int btrfs_record_root_in_trans(struct btrfs_root *root); int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,
struct extent_io_tree *dirty_pages); struct extent_io_tree *dirty_pages);
#endif #endif
...@@ -430,18 +430,16 @@ static noinline int overwrite_item(struct btrfs_trans_handle *trans, ...@@ -430,18 +430,16 @@ static noinline int overwrite_item(struct btrfs_trans_handle *trans,
static noinline struct inode *read_one_inode(struct btrfs_root *root, static noinline struct inode *read_one_inode(struct btrfs_root *root,
u64 objectid) u64 objectid)
{ {
struct btrfs_key key;
struct inode *inode; struct inode *inode;
inode = btrfs_iget_locked(root->fs_info->sb, objectid, root);
if (inode->i_state & I_NEW) {
BTRFS_I(inode)->root = root;
BTRFS_I(inode)->location.objectid = objectid;
BTRFS_I(inode)->location.type = BTRFS_INODE_ITEM_KEY;
BTRFS_I(inode)->location.offset = 0;
btrfs_read_locked_inode(inode);
unlock_new_inode(inode);
} key.objectid = objectid;
if (is_bad_inode(inode)) { key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
inode = btrfs_iget(root->fs_info->sb, &key, root);
if (IS_ERR(inode)) {
inode = NULL;
} else if (is_bad_inode(inode)) {
iput(inode); iput(inode);
inode = NULL; inode = NULL;
} }
...@@ -541,6 +539,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, ...@@ -541,6 +539,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
if (found_type == BTRFS_FILE_EXTENT_REG || if (found_type == BTRFS_FILE_EXTENT_REG ||
found_type == BTRFS_FILE_EXTENT_PREALLOC) { found_type == BTRFS_FILE_EXTENT_PREALLOC) {
u64 offset;
unsigned long dest_offset; unsigned long dest_offset;
struct btrfs_key ins; struct btrfs_key ins;
...@@ -555,6 +554,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, ...@@ -555,6 +554,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
ins.objectid = btrfs_file_extent_disk_bytenr(eb, item); ins.objectid = btrfs_file_extent_disk_bytenr(eb, item);
ins.offset = btrfs_file_extent_disk_num_bytes(eb, item); ins.offset = btrfs_file_extent_disk_num_bytes(eb, item);
ins.type = BTRFS_EXTENT_ITEM_KEY; ins.type = BTRFS_EXTENT_ITEM_KEY;
offset = key->offset - btrfs_file_extent_offset(eb, item);
if (ins.objectid > 0) { if (ins.objectid > 0) {
u64 csum_start; u64 csum_start;
...@@ -569,19 +569,16 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, ...@@ -569,19 +569,16 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
if (ret == 0) { if (ret == 0) {
ret = btrfs_inc_extent_ref(trans, root, ret = btrfs_inc_extent_ref(trans, root,
ins.objectid, ins.offset, ins.objectid, ins.offset,
path->nodes[0]->start, 0, root->root_key.objectid,
root->root_key.objectid, key->objectid, offset);
trans->transid, key->objectid);
} else { } else {
/* /*
* insert the extent pointer in the extent * insert the extent pointer in the extent
* allocation tree * allocation tree
*/ */
ret = btrfs_alloc_logged_extent(trans, root, ret = btrfs_alloc_logged_file_extent(trans,
path->nodes[0]->start, root, root->root_key.objectid,
root->root_key.objectid, key->objectid, offset, &ins);
trans->transid, key->objectid,
&ins);
BUG_ON(ret); BUG_ON(ret);
} }
btrfs_release_path(root, path); btrfs_release_path(root, path);
...@@ -1706,9 +1703,6 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, ...@@ -1706,9 +1703,6 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
btrfs_wait_tree_block_writeback(next); btrfs_wait_tree_block_writeback(next);
btrfs_tree_unlock(next); btrfs_tree_unlock(next);
ret = btrfs_drop_leaf_ref(trans, root, next);
BUG_ON(ret);
WARN_ON(root_owner != WARN_ON(root_owner !=
BTRFS_TREE_LOG_OBJECTID); BTRFS_TREE_LOG_OBJECTID);
ret = btrfs_free_reserved_extent(root, ret = btrfs_free_reserved_extent(root,
...@@ -1753,10 +1747,6 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, ...@@ -1753,10 +1747,6 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
btrfs_wait_tree_block_writeback(next); btrfs_wait_tree_block_writeback(next);
btrfs_tree_unlock(next); btrfs_tree_unlock(next);
if (*level == 0) {
ret = btrfs_drop_leaf_ref(trans, root, next);
BUG_ON(ret);
}
WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID); WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID);
ret = btrfs_free_reserved_extent(root, bytenr, blocksize); ret = btrfs_free_reserved_extent(root, bytenr, blocksize);
BUG_ON(ret); BUG_ON(ret);
...@@ -1811,12 +1801,6 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, ...@@ -1811,12 +1801,6 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
btrfs_wait_tree_block_writeback(next); btrfs_wait_tree_block_writeback(next);
btrfs_tree_unlock(next); btrfs_tree_unlock(next);
if (*level == 0) {
ret = btrfs_drop_leaf_ref(trans, root,
next);
BUG_ON(ret);
}
WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID); WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID);
ret = btrfs_free_reserved_extent(root, ret = btrfs_free_reserved_extent(root,
path->nodes[*level]->start, path->nodes[*level]->start,
...@@ -1884,11 +1868,6 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, ...@@ -1884,11 +1868,6 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
btrfs_wait_tree_block_writeback(next); btrfs_wait_tree_block_writeback(next);
btrfs_tree_unlock(next); btrfs_tree_unlock(next);
if (orig_level == 0) {
ret = btrfs_drop_leaf_ref(trans, log,
next);
BUG_ON(ret);
}
WARN_ON(log->root_key.objectid != WARN_ON(log->root_key.objectid !=
BTRFS_TREE_LOG_OBJECTID); BTRFS_TREE_LOG_OBJECTID);
ret = btrfs_free_reserved_extent(log, next->start, ret = btrfs_free_reserved_extent(log, next->start,
...@@ -2027,9 +2006,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, ...@@ -2027,9 +2006,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
ret = btrfs_write_and_wait_marked_extents(log, &log->dirty_log_pages); ret = btrfs_write_and_wait_marked_extents(log, &log->dirty_log_pages);
BUG_ON(ret); BUG_ON(ret);
btrfs_set_root_bytenr(&log->root_item, log->node->start); btrfs_set_root_node(&log->root_item, log->node);
btrfs_set_root_generation(&log->root_item, trans->transid);
btrfs_set_root_level(&log->root_item, btrfs_header_level(log->node));
root->log_batch = 0; root->log_batch = 0;
root->log_transid++; root->log_transid++;
...@@ -2581,7 +2558,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, ...@@ -2581,7 +2558,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
ins_keys, ins_sizes, nr); ins_keys, ins_sizes, nr);
BUG_ON(ret); BUG_ON(ret);
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++, dst_path->slots[0]++) {
dst_offset = btrfs_item_ptr_offset(dst_path->nodes[0], dst_offset = btrfs_item_ptr_offset(dst_path->nodes[0],
dst_path->slots[0]); dst_path->slots[0]);
...@@ -2617,36 +2594,31 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, ...@@ -2617,36 +2594,31 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
found_type = btrfs_file_extent_type(src, extent); found_type = btrfs_file_extent_type(src, extent);
if (found_type == BTRFS_FILE_EXTENT_REG || if (found_type == BTRFS_FILE_EXTENT_REG ||
found_type == BTRFS_FILE_EXTENT_PREALLOC) { found_type == BTRFS_FILE_EXTENT_PREALLOC) {
u64 ds = btrfs_file_extent_disk_bytenr(src, u64 ds, dl, cs, cl;
extent); ds = btrfs_file_extent_disk_bytenr(src,
u64 dl = btrfs_file_extent_disk_num_bytes(src, extent);
extent); /* ds == 0 is a hole */
u64 cs = btrfs_file_extent_offset(src, extent); if (ds == 0)
u64 cl = btrfs_file_extent_num_bytes(src, continue;
extent);;
dl = btrfs_file_extent_disk_num_bytes(src,
extent);
cs = btrfs_file_extent_offset(src, extent);
cl = btrfs_file_extent_num_bytes(src,
extent);;
if (btrfs_file_extent_compression(src, if (btrfs_file_extent_compression(src,
extent)) { extent)) {
cs = 0; cs = 0;
cl = dl; cl = dl;
} }
/* ds == 0 is a hole */
if (ds != 0) { ret = btrfs_lookup_csums_range(
ret = btrfs_inc_extent_ref(trans, log, log->fs_info->csum_root,
ds, dl, ds + cs, ds + cs + cl - 1,
dst_path->nodes[0]->start, &ordered_sums);
BTRFS_TREE_LOG_OBJECTID, BUG_ON(ret);
trans->transid,
ins_keys[i].objectid);
BUG_ON(ret);
ret = btrfs_lookup_csums_range(
log->fs_info->csum_root,
ds + cs, ds + cs + cl - 1,
&ordered_sums);
BUG_ON(ret);
}
} }
} }
dst_path->slots[0]++;
} }
btrfs_mark_buffer_dirty(dst_path->nodes[0]); btrfs_mark_buffer_dirty(dst_path->nodes[0]);
...@@ -3029,9 +3001,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) ...@@ -3029,9 +3001,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
BUG_ON(!wc.replay_dest); BUG_ON(!wc.replay_dest);
wc.replay_dest->log_root = log; wc.replay_dest->log_root = log;
mutex_lock(&fs_info->trans_mutex); btrfs_record_root_in_trans(trans, wc.replay_dest);
btrfs_record_root_in_trans(wc.replay_dest);
mutex_unlock(&fs_info->trans_mutex);
ret = walk_log_tree(trans, log, &wc); ret = walk_log_tree(trans, log, &wc);
BUG_ON(ret); BUG_ON(ret);
......
...@@ -1671,8 +1671,6 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, ...@@ -1671,8 +1671,6 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
int ret; int ret;
int i; int i;
printk(KERN_INFO "btrfs relocating chunk %llu\n",
(unsigned long long)chunk_offset);
root = root->fs_info->chunk_root; root = root->fs_info->chunk_root;
extent_root = root->fs_info->extent_root; extent_root = root->fs_info->extent_root;
em_tree = &root->fs_info->mapping_tree.map_tree; em_tree = &root->fs_info->mapping_tree.map_tree;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment