Btrfs: Fix checkpatch.pl warnings

There were many, most are fixed now.  struct-funcs.c generates some warnings
but these are bogus.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Chris Mason 2009-01-05 21:25:51 -05:00
commit d397712bcc
33 changed files with 770 additions and 898 deletions

View file

@ -161,7 +161,6 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
ret = __btrfs_setxattr(inode, name, value, size, 0); ret = __btrfs_setxattr(inode, name, value, size, 0);
out: out:
if (value)
kfree(value); kfree(value);
if (!ret) if (!ret)

View file

@ -137,7 +137,8 @@ static int check_compressed_csum(struct inode *inode,
kunmap_atomic(kaddr, KM_USER0); kunmap_atomic(kaddr, KM_USER0);
if (csum != *cb_sum) { if (csum != *cb_sum) {
printk("btrfs csum failed ino %lu extent %llu csum %u " printk(KERN_INFO "btrfs csum failed ino %lu "
"extent %llu csum %u "
"wanted %u mirror %d\n", inode->i_ino, "wanted %u mirror %d\n", inode->i_ino,
(unsigned long long)disk_start, (unsigned long long)disk_start,
csum, *cb_sum, cb->mirror_num); csum, *cb_sum, cb->mirror_num);
@ -697,9 +698,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0); ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0);
BUG_ON(ret); BUG_ON(ret);
if (!btrfs_test_flag(inode, NODATASUM)) { if (!btrfs_test_flag(inode, NODATASUM))
btrfs_lookup_bio_sums(root, inode, comp_bio, sums); btrfs_lookup_bio_sums(root, inode, comp_bio, sums);
}
ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0); ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0);
BUG_ON(ret); BUG_ON(ret);

View file

@ -67,7 +67,7 @@ void btrfs_free_path(struct btrfs_path *p)
* *
* It is safe to call this on paths that no locks or extent buffers held. * It is safe to call this on paths that no locks or extent buffers held.
*/ */
void noinline btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p) noinline void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p)
{ {
int i; int i;
@ -202,22 +202,22 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
} }
/* /*
* does the dirty work in cow of a single block. The parent block * does the dirty work in cow of a single block. The parent block (if
* (if supplied) is updated to point to the new cow copy. The new * supplied) is updated to point to the new cow copy. The new buffer is marked
* buffer is marked dirty and returned locked. If you modify the block * dirty and returned locked. If you modify the block it needs to be marked
* it needs to be marked dirty again. * dirty again.
* *
* search_start -- an allocation hint for the new block * search_start -- an allocation hint for the new block
* *
* empty_size -- a hint that you plan on doing more cow. This is the size in bytes * empty_size -- a hint that you plan on doing more cow. This is the size in
* the allocator should try to find free next to the block it returns. This is * bytes the allocator should try to find free next to the block it returns.
* just a hint and may be ignored by the allocator. * This is just a hint and may be ignored by the allocator.
* *
* prealloc_dest -- if you have already reserved a destination for the cow, * prealloc_dest -- if you have already reserved a destination for the cow,
* this uses that block instead of allocating a new one. btrfs_alloc_reserved_extent * this uses that block instead of allocating a new one.
* is used to finish the allocation. * btrfs_alloc_reserved_extent is used to finish the allocation.
*/ */
static int noinline __btrfs_cow_block(struct btrfs_trans_handle *trans, static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct extent_buffer *buf, struct extent_buffer *buf,
struct extent_buffer *parent, int parent_slot, struct extent_buffer *parent, int parent_slot,
@ -366,7 +366,7 @@ static int noinline __btrfs_cow_block(struct btrfs_trans_handle *trans,
* This version of it has extra checks so that a block isn't cow'd more than * This version of it has extra checks so that a block isn't cow'd more than
* once per transaction, as long as it hasn't been written yet * once per transaction, as long as it hasn't been written yet
*/ */
int noinline btrfs_cow_block(struct btrfs_trans_handle *trans, noinline int btrfs_cow_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct extent_buffer *buf, struct btrfs_root *root, struct extent_buffer *buf,
struct extent_buffer *parent, int parent_slot, struct extent_buffer *parent, int parent_slot,
struct extent_buffer **cow_ret, u64 prealloc_dest) struct extent_buffer **cow_ret, u64 prealloc_dest)
@ -375,13 +375,16 @@ int noinline btrfs_cow_block(struct btrfs_trans_handle *trans,
int ret; int ret;
if (trans->transaction != root->fs_info->running_transaction) { if (trans->transaction != root->fs_info->running_transaction) {
printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid, printk(KERN_CRIT "trans %llu running %llu\n",
(unsigned long long)trans->transid,
(unsigned long long)
root->fs_info->running_transaction->transid); root->fs_info->running_transaction->transid);
WARN_ON(1); WARN_ON(1);
} }
if (trans->transid != root->fs_info->generation) { if (trans->transid != root->fs_info->generation) {
printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid, printk(KERN_CRIT "trans %llu running %llu\n",
root->fs_info->generation); (unsigned long long)trans->transid,
(unsigned long long)root->fs_info->generation);
WARN_ON(1); WARN_ON(1);
} }
@ -489,16 +492,10 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
if (cache_only && parent_level != 1) if (cache_only && parent_level != 1)
return 0; return 0;
if (trans->transaction != root->fs_info->running_transaction) { if (trans->transaction != root->fs_info->running_transaction)
printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid,
root->fs_info->running_transaction->transid);
WARN_ON(1); WARN_ON(1);
} if (trans->transid != root->fs_info->generation)
if (trans->transid != root->fs_info->generation) {
printk(KERN_CRIT "trans %Lu running %Lu\n", trans->transid,
root->fs_info->generation);
WARN_ON(1); WARN_ON(1);
}
parent_nritems = btrfs_header_nritems(parent); parent_nritems = btrfs_header_nritems(parent);
blocksize = btrfs_level_size(root, parent_level - 1); blocksize = btrfs_level_size(root, parent_level - 1);
@ -681,51 +678,18 @@ static int check_leaf(struct btrfs_root *root, struct btrfs_path *path,
BUG_ON(btrfs_node_blockptr(parent, parent_slot) != BUG_ON(btrfs_node_blockptr(parent, parent_slot) !=
btrfs_header_bytenr(leaf)); btrfs_header_bytenr(leaf));
} }
#if 0
for (i = 0; nritems > 1 && i < nritems - 2; i++) {
btrfs_item_key_to_cpu(leaf, &cpukey, i + 1);
btrfs_item_key(leaf, &leaf_key, i);
if (comp_keys(&leaf_key, &cpukey) >= 0) {
btrfs_print_leaf(root, leaf);
printk("slot %d offset bad key\n", i);
BUG_ON(1);
}
if (btrfs_item_offset_nr(leaf, i) !=
btrfs_item_end_nr(leaf, i + 1)) {
btrfs_print_leaf(root, leaf);
printk("slot %d offset bad\n", i);
BUG_ON(1);
}
if (i == 0) {
if (btrfs_item_offset_nr(leaf, i) +
btrfs_item_size_nr(leaf, i) !=
BTRFS_LEAF_DATA_SIZE(root)) {
btrfs_print_leaf(root, leaf);
printk("slot %d first offset bad\n", i);
BUG_ON(1);
}
}
}
if (nritems > 0) {
if (btrfs_item_size_nr(leaf, nritems - 1) > 4096) {
btrfs_print_leaf(root, leaf);
printk("slot %d bad size \n", nritems - 1);
BUG_ON(1);
}
}
#endif
if (slot != 0 && slot < nritems - 1) { if (slot != 0 && slot < nritems - 1) {
btrfs_item_key(leaf, &leaf_key, slot); btrfs_item_key(leaf, &leaf_key, slot);
btrfs_item_key_to_cpu(leaf, &cpukey, slot - 1); btrfs_item_key_to_cpu(leaf, &cpukey, slot - 1);
if (comp_keys(&leaf_key, &cpukey) <= 0) { if (comp_keys(&leaf_key, &cpukey) <= 0) {
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("slot %d offset bad key\n", slot); printk(KERN_CRIT "slot %d offset bad key\n", slot);
BUG_ON(1); BUG_ON(1);
} }
if (btrfs_item_offset_nr(leaf, slot - 1) != if (btrfs_item_offset_nr(leaf, slot - 1) !=
btrfs_item_end_nr(leaf, slot)) { btrfs_item_end_nr(leaf, slot)) {
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("slot %d offset bad\n", slot); printk(KERN_CRIT "slot %d offset bad\n", slot);
BUG_ON(1); BUG_ON(1);
} }
} }
@ -736,7 +700,7 @@ static int check_leaf(struct btrfs_root *root, struct btrfs_path *path,
if (btrfs_item_offset_nr(leaf, slot) != if (btrfs_item_offset_nr(leaf, slot) !=
btrfs_item_end_nr(leaf, slot + 1)) { btrfs_item_end_nr(leaf, slot + 1)) {
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("slot %d offset bad\n", slot); printk(KERN_CRIT "slot %d offset bad\n", slot);
BUG_ON(1); BUG_ON(1);
} }
} }
@ -745,30 +709,10 @@ static int check_leaf(struct btrfs_root *root, struct btrfs_path *path,
return 0; return 0;
} }
static int noinline check_block(struct btrfs_root *root, static noinline int check_block(struct btrfs_root *root,
struct btrfs_path *path, int level) struct btrfs_path *path, int level)
{ {
u64 found_start;
return 0; return 0;
if (btrfs_header_level(path->nodes[level]) != level)
printk("warning: bad level %Lu wanted %d found %d\n",
path->nodes[level]->start, level,
btrfs_header_level(path->nodes[level]));
found_start = btrfs_header_bytenr(path->nodes[level]);
if (found_start != path->nodes[level]->start) {
printk("warning: bad bytentr %Lu found %Lu\n",
path->nodes[level]->start, found_start);
}
#if 0
struct extent_buffer *buf = path->nodes[level];
if (memcmp_extent_buffer(buf, root->fs_info->fsid,
(unsigned long)btrfs_header_fsid(buf),
BTRFS_FSID_SIZE)) {
printk("warning bad block %Lu\n", buf->start);
return 1;
}
#endif
if (level == 0) if (level == 0)
return check_leaf(root, path, level); return check_leaf(root, path, level);
return check_node(root, path, level); return check_node(root, path, level);
@ -1130,7 +1074,7 @@ enospc:
* when they are completely full. This is also done top down, so we * when they are completely full. This is also done top down, so we
* have to be pessimistic. * have to be pessimistic.
*/ */
static int noinline push_nodes_for_insert(struct btrfs_trans_handle *trans, static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, int level) struct btrfs_path *path, int level)
{ {
@ -1322,6 +1266,7 @@ static noinline void reada_for_search(struct btrfs_root *root,
nscan++; nscan++;
if (path->reada < 2 && (nread > (64 * 1024) || nscan > 32)) if (path->reada < 2 && (nread > (64 * 1024) || nscan > 32))
break; break;
if (nread > (256 * 1024) || nscan > 128) if (nread > (256 * 1024) || nscan > 128)
break; break;
@ -1333,17 +1278,17 @@ static noinline void reada_for_search(struct btrfs_root *root,
} }
/* /*
* when we walk down the tree, it is usually safe to unlock the higher layers in * when we walk down the tree, it is usually safe to unlock the higher layers
* the tree. The exceptions are when our path goes through slot 0, because operations * in the tree. The exceptions are when our path goes through slot 0, because
* on the tree might require changing key pointers higher up in the tree. * operations on the tree might require changing key pointers higher up in the
* tree.
* *
* callers might also have set path->keep_locks, which tells this code to * callers might also have set path->keep_locks, which tells this code to keep
* keep the lock if the path points to the last slot in the block. This is * the lock if the path points to the last slot in the block. This is part of
* part of walking through the tree, and selecting the next slot in the higher * walking through the tree, and selecting the next slot in the higher block.
* block.
* *
* lowest_unlock sets the lowest level in the tree we're allowed to unlock. * lowest_unlock sets the lowest level in the tree we're allowed to unlock. so
* so if lowest_unlock is 1, level 0 won't be unlocked * if lowest_unlock is 1, level 0 won't be unlocked
*/ */
static noinline void unlock_up(struct btrfs_path *path, int level, static noinline void unlock_up(struct btrfs_path *path, int level,
int lowest_unlock) int lowest_unlock)
@ -1832,9 +1777,8 @@ static int push_node_left(struct btrfs_trans_handle *trans,
if (!empty && src_nritems <= 8) if (!empty && src_nritems <= 8)
return 1; return 1;
if (push_items <= 0) { if (push_items <= 0)
return 1; return 1;
}
if (empty) { if (empty) {
push_items = min(src_nritems, push_items); push_items = min(src_nritems, push_items);
@ -1899,19 +1843,16 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
src_nritems = btrfs_header_nritems(src); src_nritems = btrfs_header_nritems(src);
dst_nritems = btrfs_header_nritems(dst); dst_nritems = btrfs_header_nritems(dst);
push_items = BTRFS_NODEPTRS_PER_BLOCK(root) - dst_nritems; push_items = BTRFS_NODEPTRS_PER_BLOCK(root) - dst_nritems;
if (push_items <= 0) { if (push_items <= 0)
return 1; return 1;
}
if (src_nritems < 4) { if (src_nritems < 4)
return 1; return 1;
}
max_push = src_nritems / 2 + 1; max_push = src_nritems / 2 + 1;
/* don't try to empty the node */ /* don't try to empty the node */
if (max_push >= src_nritems) { if (max_push >= src_nritems)
return 1; return 1;
}
if (max_push < push_items) if (max_push < push_items)
push_items = max_push; push_items = max_push;
@ -1945,7 +1886,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
* *
* returns zero on success or < 0 on failure. * returns zero on success or < 0 on failure.
*/ */
static int noinline insert_new_root(struct btrfs_trans_handle *trans, static noinline int insert_new_root(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, int level) struct btrfs_path *path, int level)
{ {
@ -2176,14 +2117,15 @@ static int leaf_space_used(struct extent_buffer *l, int start, int nr)
* the start of the leaf data. IOW, how much room * the start of the leaf data. IOW, how much room
* the leaf has left for both items and data * the leaf has left for both items and data
*/ */
int noinline btrfs_leaf_free_space(struct btrfs_root *root, noinline int btrfs_leaf_free_space(struct btrfs_root *root,
struct extent_buffer *leaf) struct extent_buffer *leaf)
{ {
int nritems = btrfs_header_nritems(leaf); int nritems = btrfs_header_nritems(leaf);
int ret; int ret;
ret = BTRFS_LEAF_DATA_SIZE(root) - leaf_space_used(leaf, 0, nritems); ret = BTRFS_LEAF_DATA_SIZE(root) - leaf_space_used(leaf, 0, nritems);
if (ret < 0) { if (ret < 0) {
printk("leaf free space ret %d, leaf data size %lu, used %d nritems %d\n", printk(KERN_CRIT "leaf free space ret %d, leaf data size %lu, "
"used %d nritems %d\n",
ret, (unsigned long) BTRFS_LEAF_DATA_SIZE(root), ret, (unsigned long) BTRFS_LEAF_DATA_SIZE(root),
leaf_space_used(leaf, 0, nritems), nritems); leaf_space_used(leaf, 0, nritems), nritems);
} }
@ -2219,9 +2161,9 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
int ret; int ret;
slot = path->slots[1]; slot = path->slots[1];
if (!path->nodes[1]) { if (!path->nodes[1])
return 1; return 1;
}
upper = path->nodes[1]; upper = path->nodes[1];
if (slot >= btrfs_header_nritems(upper) - 1) if (slot >= btrfs_header_nritems(upper) - 1)
return 1; return 1;
@ -2418,9 +2360,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
return 1; return 1;
right_nritems = btrfs_header_nritems(right); right_nritems = btrfs_header_nritems(right);
if (right_nritems == 0) { if (right_nritems == 0)
return 1; return 1;
}
WARN_ON(!btrfs_tree_locked(path->nodes[1])); WARN_ON(!btrfs_tree_locked(path->nodes[1]));
@ -2537,7 +2478,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
/* fixup right node */ /* fixup right node */
if (push_items > right_nritems) { if (push_items > right_nritems) {
printk("push items %d nr %u\n", push_items, right_nritems); printk(KERN_CRIT "push items %d nr %u\n", push_items,
right_nritems);
WARN_ON(1); WARN_ON(1);
} }
@ -2640,9 +2582,8 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
/* first try to make some room by pushing left and right */ /* first try to make some room by pushing left and right */
if (data_size && ins_key->type != BTRFS_DIR_ITEM_KEY) { if (data_size && ins_key->type != BTRFS_DIR_ITEM_KEY) {
wret = push_leaf_right(trans, root, path, data_size, 0); wret = push_leaf_right(trans, root, path, data_size, 0);
if (wret < 0) { if (wret < 0)
return wret; return wret;
}
if (wret) { if (wret) {
wret = push_leaf_left(trans, root, path, data_size, 0); wret = push_leaf_left(trans, root, path, data_size, 0);
if (wret < 0) if (wret < 0)
@ -3096,7 +3037,8 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
BUG_ON(slot < 0); BUG_ON(slot < 0);
if (slot >= nritems) { if (slot >= nritems) {
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("slot %d too large, nritems %d\n", slot, nritems); printk(KERN_CRIT "slot %d too large, nritems %d\n",
slot, nritems);
BUG_ON(1); BUG_ON(1);
} }
@ -3218,7 +3160,7 @@ int btrfs_insert_some_items(struct btrfs_trans_handle *trans,
if (old_data < data_end) { if (old_data < data_end) {
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("slot %d old_data %d data_end %d\n", printk(KERN_CRIT "slot %d old_data %d data_end %d\n",
slot, old_data, data_end); slot, old_data, data_end);
BUG_ON(1); BUG_ON(1);
} }
@ -3317,9 +3259,8 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
unsigned int data_end; unsigned int data_end;
struct btrfs_disk_key disk_key; struct btrfs_disk_key disk_key;
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++)
total_data += data_size[i]; total_data += data_size[i];
}
total_size = total_data + (nr * sizeof(struct btrfs_item)); total_size = total_data + (nr * sizeof(struct btrfs_item));
ret = btrfs_search_slot(trans, root, cpu_key, path, total_size, 1); ret = btrfs_search_slot(trans, root, cpu_key, path, total_size, 1);
@ -3336,7 +3277,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
if (btrfs_leaf_free_space(root, leaf) < total_size) { if (btrfs_leaf_free_space(root, leaf) < total_size) {
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("not enough freespace need %u have %d\n", printk(KERN_CRIT "not enough freespace need %u have %d\n",
total_size, btrfs_leaf_free_space(root, leaf)); total_size, btrfs_leaf_free_space(root, leaf));
BUG(); BUG();
} }
@ -3349,7 +3290,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
if (old_data < data_end) { if (old_data < data_end) {
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("slot %d old_data %d data_end %d\n", printk(KERN_CRIT "slot %d old_data %d data_end %d\n",
slot, old_data, data_end); slot, old_data, data_end);
BUG_ON(1); BUG_ON(1);
} }
@ -3614,7 +3555,8 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
if (btrfs_header_nritems(leaf) == 0) { if (btrfs_header_nritems(leaf) == 0) {
path->slots[1] = slot; path->slots[1] = slot;
ret = btrfs_del_leaf(trans, root, path, leaf->start); ret = btrfs_del_leaf(trans, root, path,
leaf->start);
BUG_ON(ret); BUG_ON(ret);
free_extent_buffer(leaf); free_extent_buffer(leaf);
} else { } else {
@ -3839,9 +3781,8 @@ int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path,
next: next:
if (slot >= btrfs_header_nritems(c)) { if (slot >= btrfs_header_nritems(c)) {
level++; level++;
if (level == BTRFS_MAX_LEVEL) { if (level == BTRFS_MAX_LEVEL)
return 1; return 1;
}
continue; continue;
} }
if (level == 0) if (level == 0)
@ -3889,9 +3830,8 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
int ret; int ret;
nritems = btrfs_header_nritems(path->nodes[0]); nritems = btrfs_header_nritems(path->nodes[0]);
if (nritems == 0) { if (nritems == 0)
return 1; return 1;
}
btrfs_item_key_to_cpu(path->nodes[0], &key, nritems - 1); btrfs_item_key_to_cpu(path->nodes[0], &key, nritems - 1);
@ -3923,9 +3863,8 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
c = path->nodes[level]; c = path->nodes[level];
if (slot >= btrfs_header_nritems(c)) { if (slot >= btrfs_header_nritems(c)) {
level++; level++;
if (level == BTRFS_MAX_LEVEL) { if (level == BTRFS_MAX_LEVEL)
return 1; return 1;
}
continue; continue;
} }

View file

@ -126,7 +126,6 @@ struct btrfs_ordered_sum;
static int btrfs_csum_sizes[] = { 4, 0 }; static int btrfs_csum_sizes[] = { 4, 0 };
/* four bytes for CRC32 */ /* four bytes for CRC32 */
//#define BTRFS_CRC32_SIZE 4
#define BTRFS_EMPTY_DIR_SIZE 0 #define BTRFS_EMPTY_DIR_SIZE 0
#define BTRFS_FT_UNKNOWN 0 #define BTRFS_FT_UNKNOWN 0
@ -1512,7 +1511,7 @@ static inline struct btrfs_header *btrfs_buffer_header(struct extent_buffer *eb)
static inline int btrfs_is_leaf(struct extent_buffer *eb) static inline int btrfs_is_leaf(struct extent_buffer *eb)
{ {
return (btrfs_header_level(eb) == 0); return btrfs_header_level(eb) == 0;
} }
/* struct btrfs_root_item */ /* struct btrfs_root_item */
@ -1597,8 +1596,8 @@ static inline unsigned long btrfs_leaf_data(struct extent_buffer *l)
/* struct btrfs_file_extent_item */ /* struct btrfs_file_extent_item */
BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8); BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8);
static inline unsigned long btrfs_file_extent_inline_start(struct static inline unsigned long
btrfs_file_extent_item *e) btrfs_file_extent_inline_start(struct btrfs_file_extent_item *e)
{ {
unsigned long offset = (unsigned long)e; unsigned long offset = (unsigned long)e;
offset += offsetof(struct btrfs_file_extent_item, disk_bytenr); offset += offsetof(struct btrfs_file_extent_item, disk_bytenr);
@ -1660,7 +1659,6 @@ static inline int btrfs_set_root_name(struct btrfs_root *root,
const char *name, int len) const char *name, int len)
{ {
/* if we already have a name just free it */ /* if we already have a name just free it */
if (root->name)
kfree(root->name); kfree(root->name);
root->name = kmalloc(len+1, GFP_KERNEL); root->name = kmalloc(len+1, GFP_KERNEL);
@ -1673,7 +1671,8 @@ static inline int btrfs_set_root_name(struct btrfs_root *root,
return 0; return 0;
} }
static inline u32 btrfs_level_size(struct btrfs_root *root, int level) { static inline u32 btrfs_level_size(struct btrfs_root *root, int level)
{
if (level == 0) if (level == 0)
return root->leafsize; return root->leafsize;
return root->nodesize; return root->nodesize;
@ -1707,8 +1706,8 @@ int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans,
int btrfs_extent_post_op(struct btrfs_trans_handle *trans, int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
struct btrfs_root *root); struct btrfs_root *root);
int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy); int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy);
struct btrfs_block_group_cache *btrfs_lookup_block_group(struct struct btrfs_block_group_cache *btrfs_lookup_block_group(
btrfs_fs_info *info, struct btrfs_fs_info *info,
u64 bytenr); u64 bytenr);
u64 btrfs_find_block_group(struct btrfs_root *root, u64 btrfs_find_block_group(struct btrfs_root *root,
u64 search_start, u64 search_hint, int owner); u64 search_start, u64 search_hint, int owner);
@ -1908,8 +1907,9 @@ int btrfs_search_root(struct btrfs_root *root, u64 search_start,
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_root); struct btrfs_root *latest_root);
/* dir-item.c */ /* dir-item.c */
int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root int btrfs_insert_dir_item(struct btrfs_trans_handle *trans,
*root, const char *name, int name_len, u64 dir, struct btrfs_root *root, const char *name,
int name_len, u64 dir,
struct btrfs_key *location, u8 type, u64 index); struct btrfs_key *location, u8 type, u64 index);
struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,

View file

@ -23,7 +23,7 @@
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/radix-tree.h> #include <linux/radix-tree.h>
#include <linux/writeback.h> #include <linux/writeback.h>
#include <linux/buffer_head.h> // for block_sync_page #include <linux/buffer_head.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/freezer.h> #include <linux/freezer.h>
@ -40,19 +40,6 @@
#include "ref-cache.h" #include "ref-cache.h"
#include "tree-log.h" #include "tree-log.h"
#if 0
static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf)
{
if (extent_buffer_blocknr(buf) != btrfs_header_blocknr(buf)) {
printk(KERN_CRIT "buf blocknr(buf) is %llu, header is %llu\n",
(unsigned long long)extent_buffer_blocknr(buf),
(unsigned long long)btrfs_header_blocknr(buf));
return 1;
}
return 0;
}
#endif
static struct extent_io_ops btree_extent_io_ops; static struct extent_io_ops btree_extent_io_ops;
static void end_workqueue_fn(struct btrfs_work *work); static void end_workqueue_fn(struct btrfs_work *work);
@ -128,23 +115,13 @@ static struct extent_map *btree_get_extent(struct inode *inode,
u64 failed_start = em->start; u64 failed_start = em->start;
u64 failed_len = em->len; u64 failed_len = em->len;
printk("failed to insert %Lu %Lu -> %Lu into tree\n",
em->start, em->len, em->block_start);
free_extent_map(em); free_extent_map(em);
em = lookup_extent_mapping(em_tree, start, len); em = lookup_extent_mapping(em_tree, start, len);
if (em) { if (em) {
printk("after failing, found %Lu %Lu %Lu\n",
em->start, em->len, em->block_start);
ret = 0; ret = 0;
} else { } else {
em = lookup_extent_mapping(em_tree, failed_start, em = lookup_extent_mapping(em_tree, failed_start,
failed_len); failed_len);
if (em) {
printk("double failure lookup gives us "
"%Lu %Lu -> %Lu\n", em->start,
em->len, em->block_start);
free_extent_map(em);
}
ret = -EIO; ret = -EIO;
} }
} else if (ret) { } else if (ret) {
@ -195,11 +172,8 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
err = map_private_extent_buffer(buf, offset, 32, err = map_private_extent_buffer(buf, offset, 32,
&map_token, &kaddr, &map_token, &kaddr,
&map_start, &map_len, KM_USER0); &map_start, &map_len, KM_USER0);
if (err) { if (err)
printk("failed to map extent buffer! %lu\n",
offset);
return 1; return 1;
}
cur_len = min(len, map_len - (offset - map_start)); cur_len = min(len, map_len - (offset - map_start));
crc = btrfs_csum_data(root, kaddr + offset - map_start, crc = btrfs_csum_data(root, kaddr + offset - map_start,
crc, cur_len); crc, cur_len);
@ -218,15 +192,14 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
btrfs_csum_final(crc, result); btrfs_csum_final(crc, result);
if (verify) { if (verify) {
/* FIXME, this is not good */
if (memcmp_extent_buffer(buf, result, 0, csum_size)) { if (memcmp_extent_buffer(buf, result, 0, csum_size)) {
u32 val; u32 val;
u32 found = 0; u32 found = 0;
memcpy(&found, result, csum_size); memcpy(&found, result, csum_size);
read_extent_buffer(buf, &val, 0, csum_size); read_extent_buffer(buf, &val, 0, csum_size);
printk("btrfs: %s checksum verify failed on %llu " printk(KERN_INFO "btrfs: %s checksum verify failed "
"wanted %X found %X level %d\n", "on %llu wanted %X found %X level %d\n",
root->fs_info->sb->s_id, root->fs_info->sb->s_id,
buf->start, val, found, btrfs_header_level(buf)); buf->start, val, found, btrfs_header_level(buf));
if (result != (char *)&inline_result) if (result != (char *)&inline_result)
@ -293,7 +266,7 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
if (!ret && if (!ret &&
!verify_parent_transid(io_tree, eb, parent_transid)) !verify_parent_transid(io_tree, eb, parent_transid))
return ret; return ret;
printk("read extent buffer pages failed with ret %d mirror no %d\n", ret, mirror_num);
num_copies = btrfs_num_copies(&root->fs_info->mapping_tree, num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
eb->start, eb->len); eb->start, eb->len);
if (num_copies == 1) if (num_copies == 1)
@ -307,9 +280,10 @@ printk("read extent buffer pages failed with ret %d mirror no %d\n", ret, mirror
} }
/* /*
* checksum a dirty tree block before IO. This has extra checks to make * checksum a dirty tree block before IO. This has extra checks to make sure
* sure we only fill in the checksum field in the first page of a multi-page block * we only fill in the checksum field in the first page of a multi-page block
*/ */
static int csum_dirty_buffer(struct btrfs_root *root, struct page *page) static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
{ {
struct extent_io_tree *tree; struct extent_io_tree *tree;
@ -327,28 +301,22 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
if (!page->private) if (!page->private)
goto out; goto out;
len = page->private >> 2; len = page->private >> 2;
if (len == 0) { WARN_ON(len == 0);
WARN_ON(1);
}
eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS); eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS);
ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE, ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE,
btrfs_header_generation(eb)); btrfs_header_generation(eb));
BUG_ON(ret); BUG_ON(ret);
found_start = btrfs_header_bytenr(eb); found_start = btrfs_header_bytenr(eb);
if (found_start != start) { if (found_start != start) {
printk("warning: eb start incorrect %Lu buffer %Lu len %lu\n",
start, found_start, len);
WARN_ON(1); WARN_ON(1);
goto err; goto err;
} }
if (eb->first_page != page) { if (eb->first_page != page) {
printk("bad first page %lu %lu\n", eb->first_page->index,
page->index);
WARN_ON(1); WARN_ON(1);
goto err; goto err;
} }
if (!PageUptodate(page)) { if (!PageUptodate(page)) {
printk("csum not up to date page %lu\n", page->index);
WARN_ON(1); WARN_ON(1);
goto err; goto err;
} }
@ -396,29 +364,30 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
goto out; goto out;
if (!page->private) if (!page->private)
goto out; goto out;
len = page->private >> 2; len = page->private >> 2;
if (len == 0) { WARN_ON(len == 0);
WARN_ON(1);
}
eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS); eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS);
found_start = btrfs_header_bytenr(eb); found_start = btrfs_header_bytenr(eb);
if (found_start != start) { if (found_start != start) {
printk("bad tree block start %llu %llu\n", printk(KERN_INFO "btrfs bad tree block start %llu %llu\n",
(unsigned long long)found_start, (unsigned long long)found_start,
(unsigned long long)eb->start); (unsigned long long)eb->start);
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
if (eb->first_page != page) { if (eb->first_page != page) {
printk("bad first page %lu %lu\n", eb->first_page->index, printk(KERN_INFO "btrfs bad first page %lu %lu\n",
page->index); eb->first_page->index, page->index);
WARN_ON(1); WARN_ON(1);
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
if (check_tree_block_fsid(root, eb)) { if (check_tree_block_fsid(root, eb)) {
printk("bad fsid on block %Lu\n", eb->start); printk(KERN_INFO "btrfs bad fsid on block %llu\n",
(unsigned long long)eb->start);
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
@ -680,10 +649,9 @@ static int btree_writepages(struct address_space *mapping,
num_dirty = count_range_bits(tree, &start, (u64)-1, num_dirty = count_range_bits(tree, &start, (u64)-1,
thresh, EXTENT_DIRTY); thresh, EXTENT_DIRTY);
if (num_dirty < thresh) { if (num_dirty < thresh)
return 0; return 0;
} }
}
return extent_writepages(tree, mapping, btree_get_extent, wbc); return extent_writepages(tree, mapping, btree_get_extent, wbc);
} }
@ -707,9 +675,8 @@ static int btree_releasepage(struct page *page, gfp_t gfp_flags)
map = &BTRFS_I(page->mapping->host)->extent_tree; map = &BTRFS_I(page->mapping->host)->extent_tree;
ret = try_release_extent_state(map, tree, page, gfp_flags); ret = try_release_extent_state(map, tree, page, gfp_flags);
if (!ret) { if (!ret)
return 0; return 0;
}
ret = try_release_extent_buffer(tree, page); ret = try_release_extent_buffer(tree, page);
if (ret == 1) { if (ret == 1) {
@ -728,8 +695,8 @@ static void btree_invalidatepage(struct page *page, unsigned long offset)
extent_invalidatepage(tree, page, offset); extent_invalidatepage(tree, page, offset);
btree_releasepage(page, GFP_NOFS); btree_releasepage(page, GFP_NOFS);
if (PagePrivate(page)) { if (PagePrivate(page)) {
printk("warning page private not zero on page %Lu\n", printk(KERN_WARNING "btrfs warning page private not zero "
page_offset(page)); "on page %llu\n", (unsigned long long)page_offset(page));
ClearPagePrivate(page); ClearPagePrivate(page);
set_page_private(page, 0); set_page_private(page, 0);
page_cache_release(page); page_cache_release(page);
@ -832,11 +799,10 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid);
if (ret == 0) { if (ret == 0)
buf->flags |= EXTENT_UPTODATE; buf->flags |= EXTENT_UPTODATE;
} else { else
WARN_ON(1); WARN_ON(1);
}
return buf; return buf;
} }
@ -1165,24 +1131,6 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
root->in_sysfs = 1; root->in_sysfs = 1;
return root; return root;
} }
#if 0
static int add_hasher(struct btrfs_fs_info *info, char *type) {
struct btrfs_hasher *hasher;
hasher = kmalloc(sizeof(*hasher), GFP_NOFS);
if (!hasher)
return -ENOMEM;
hasher->hash_tfm = crypto_alloc_hash(type, 0, CRYPTO_ALG_ASYNC);
if (!hasher->hash_tfm) {
kfree(hasher);
return -EINVAL;
}
spin_lock(&info->hash_lock);
list_add(&hasher->list, &info->hashers);
spin_unlock(&info->hash_lock);
return 0;
}
#endif
static int btrfs_congested_fn(void *congested_data, int bdi_bits) static int btrfs_congested_fn(void *congested_data, int bdi_bits)
{ {
@ -1226,11 +1174,10 @@ static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
continue; continue;
bdi = blk_get_backing_dev_info(device->bdev); bdi = blk_get_backing_dev_info(device->bdev);
if (bdi->unplug_io_fn) { if (bdi->unplug_io_fn)
bdi->unplug_io_fn(bdi, page); bdi->unplug_io_fn(bdi, page);
} }
} }
}
static void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) static void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
{ {
@ -1420,7 +1367,8 @@ static int transaction_kthread(void *arg)
mutex_lock(&root->fs_info->transaction_kthread_mutex); mutex_lock(&root->fs_info->transaction_kthread_mutex);
if (root->fs_info->total_ref_cache_size > 20 * 1024 * 1024) { if (root->fs_info->total_ref_cache_size > 20 * 1024 * 1024) {
printk("btrfs: total reference cache size %Lu\n", printk(KERN_INFO "btrfs: total reference cache "
"size %llu\n",
root->fs_info->total_ref_cache_size); root->fs_info->total_ref_cache_size);
} }
@ -1592,14 +1540,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
atomic_set(&fs_info->tree_log_writers, 0); atomic_set(&fs_info->tree_log_writers, 0);
fs_info->tree_log_transid = 0; fs_info->tree_log_transid = 0;
#if 0
ret = add_hasher(fs_info, "crc32c");
if (ret) {
printk("btrfs: failed hash setup, modprobe cryptomgr?\n");
err = -ENOMEM;
goto fail_iput;
}
#endif
__setup_root(4096, 4096, 4096, 4096, tree_root, __setup_root(4096, 4096, 4096, 4096, tree_root,
fs_info, BTRFS_ROOT_TREE_OBJECTID); fs_info, BTRFS_ROOT_TREE_OBJECTID);
@ -1720,7 +1660,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC, if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC,
sizeof(disk_super->magic))) { sizeof(disk_super->magic))) {
printk("btrfs: valid FS not found on %s\n", sb->s_id); printk(KERN_INFO "btrfs: valid FS not found on %s\n", sb->s_id);
goto fail_sb_buffer; goto fail_sb_buffer;
} }
@ -1728,8 +1668,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
ret = btrfs_read_sys_array(tree_root); ret = btrfs_read_sys_array(tree_root);
mutex_unlock(&fs_info->chunk_mutex); mutex_unlock(&fs_info->chunk_mutex);
if (ret) { if (ret) {
printk("btrfs: failed to read the system array on %s\n", printk(KERN_WARNING "btrfs: failed to read the system "
sb->s_id); "array on %s\n", sb->s_id);
goto fail_sys_array; goto fail_sys_array;
} }
@ -1753,7 +1693,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
ret = btrfs_read_chunk_tree(chunk_root); ret = btrfs_read_chunk_tree(chunk_root);
mutex_unlock(&fs_info->chunk_mutex); mutex_unlock(&fs_info->chunk_mutex);
if (ret) { if (ret) {
printk("btrfs: failed to read chunk tree on %s\n", sb->s_id); printk(KERN_WARNING "btrfs: failed to read chunk tree on %s\n",
sb->s_id);
goto fail_chunk_root; goto fail_chunk_root;
} }
@ -1812,7 +1753,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
u64 bytenr = btrfs_super_log_root(disk_super); u64 bytenr = btrfs_super_log_root(disk_super);
if (fs_devices->rw_devices == 0) { if (fs_devices->rw_devices == 0) {
printk("Btrfs log replay required on RO media\n"); printk(KERN_WARNING "Btrfs log replay required "
"on RO media\n");
err = -EIO; err = -EIO;
goto fail_trans_kthread; goto fail_trans_kthread;
} }
@ -2097,7 +2039,8 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
total_errors++; total_errors++;
} }
if (total_errors > max_errors) { if (total_errors > max_errors) {
printk("btrfs: %d errors while writing supers\n", total_errors); printk(KERN_ERR "btrfs: %d errors while writing supers\n",
total_errors);
BUG(); BUG();
} }
@ -2114,7 +2057,8 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
total_errors++; total_errors++;
} }
if (total_errors > max_errors) { if (total_errors > max_errors) {
printk("btrfs: %d errors while writing supers\n", total_errors); printk(KERN_ERR "btrfs: %d errors while writing supers\n",
total_errors);
BUG(); BUG();
} }
return 0; return 0;
@ -2137,15 +2081,10 @@ int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
down_write(&root->anon_super.s_umount); down_write(&root->anon_super.s_umount);
kill_anon_super(&root->anon_super); kill_anon_super(&root->anon_super);
} }
#if 0
if (root->in_sysfs)
btrfs_sysfs_del_root(root);
#endif
if (root->node) if (root->node)
free_extent_buffer(root->node); free_extent_buffer(root->node);
if (root->commit_root) if (root->commit_root)
free_extent_buffer(root->commit_root); free_extent_buffer(root->commit_root);
if (root->name)
kfree(root->name); kfree(root->name);
kfree(root); kfree(root);
return 0; return 0;
@ -2228,18 +2167,17 @@ int close_ctree(struct btrfs_root *root)
if (!(fs_info->sb->s_flags & MS_RDONLY)) { if (!(fs_info->sb->s_flags & MS_RDONLY)) {
ret = btrfs_commit_super(root); ret = btrfs_commit_super(root);
if (ret) { if (ret)
printk("btrfs: commit super returns %d\n", ret); printk(KERN_ERR "btrfs: commit super ret %d\n", ret);
}
} }
if (fs_info->delalloc_bytes) { if (fs_info->delalloc_bytes) {
printk("btrfs: at unmount delalloc count %Lu\n", printk(KERN_INFO "btrfs: at unmount delalloc count %llu\n",
fs_info->delalloc_bytes); fs_info->delalloc_bytes);
} }
if (fs_info->total_ref_cache_size) { if (fs_info->total_ref_cache_size) {
printk("btrfs: at umount reference cache size %Lu\n", printk(KERN_INFO "btrfs: at umount reference cache size %llu\n",
fs_info->total_ref_cache_size); (unsigned long long)fs_info->total_ref_cache_size);
} }
if (fs_info->extent_root->node) if (fs_info->extent_root->node)
@ -2248,13 +2186,13 @@ int close_ctree(struct btrfs_root *root)
if (fs_info->tree_root->node) if (fs_info->tree_root->node)
free_extent_buffer(fs_info->tree_root->node); free_extent_buffer(fs_info->tree_root->node);
if (root->fs_info->chunk_root->node); if (root->fs_info->chunk_root->node)
free_extent_buffer(root->fs_info->chunk_root->node); free_extent_buffer(root->fs_info->chunk_root->node);
if (root->fs_info->dev_root->node); if (root->fs_info->dev_root->node)
free_extent_buffer(root->fs_info->dev_root->node); free_extent_buffer(root->fs_info->dev_root->node);
if (root->fs_info->csum_root->node); if (root->fs_info->csum_root->node)
free_extent_buffer(root->fs_info->csum_root->node); free_extent_buffer(root->fs_info->csum_root->node);
btrfs_free_block_groups(root->fs_info); btrfs_free_block_groups(root->fs_info);
@ -2324,9 +2262,11 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
WARN_ON(!btrfs_tree_locked(buf)); WARN_ON(!btrfs_tree_locked(buf));
if (transid != root->fs_info->generation) { if (transid != root->fs_info->generation) {
printk(KERN_CRIT "transid mismatch buffer %llu, found %Lu running %Lu\n", printk(KERN_CRIT "btrfs transid mismatch buffer %llu, "
"found %llu running %llu\n",
(unsigned long long)buf->start, (unsigned long long)buf->start,
transid, root->fs_info->generation); (unsigned long long)transid,
(unsigned long long)root->fs_info->generation);
WARN_ON(1); WARN_ON(1);
} }
set_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, buf); set_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, buf);
@ -2361,9 +2301,8 @@ int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid)
struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
int ret; int ret;
ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid);
if (ret == 0) { if (ret == 0)
buf->flags |= EXTENT_UPTODATE; buf->flags |= EXTENT_UPTODATE;
}
return ret; return ret;
} }

View file

@ -7,8 +7,10 @@
#include "export.h" #include "export.h"
#include "compat.h" #include "compat.h"
#define BTRFS_FID_SIZE_NON_CONNECTABLE (offsetof(struct btrfs_fid, parent_objectid)/4) #define BTRFS_FID_SIZE_NON_CONNECTABLE (offsetof(struct btrfs_fid, \
#define BTRFS_FID_SIZE_CONNECTABLE (offsetof(struct btrfs_fid, parent_root_objectid)/4) parent_objectid) / 4)
#define BTRFS_FID_SIZE_CONNECTABLE (offsetof(struct btrfs_fid, \
parent_root_objectid) / 4)
#define BTRFS_FID_SIZE_CONNECTABLE_ROOT (sizeof(struct btrfs_fid) / 4) #define BTRFS_FID_SIZE_CONNECTABLE_ROOT (sizeof(struct btrfs_fid) / 4)
static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len, static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len,

View file

@ -49,10 +49,10 @@ struct pending_extent_op {
int del; int del;
}; };
static int finish_current_insert(struct btrfs_trans_handle *trans, struct static int finish_current_insert(struct btrfs_trans_handle *trans,
btrfs_root *extent_root, int all); struct btrfs_root *extent_root, int all);
static int del_pending_extents(struct btrfs_trans_handle *trans, struct static int del_pending_extents(struct btrfs_trans_handle *trans,
btrfs_root *extent_root, int all); struct btrfs_root *extent_root, int all);
static int pin_down_bytes(struct btrfs_trans_handle *trans, static int pin_down_bytes(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
u64 bytenr, u64 num_bytes, int is_data); u64 bytenr, u64 num_bytes, int is_data);
@ -292,9 +292,8 @@ err:
/* /*
* return the block group that starts at or after bytenr * return the block group that starts at or after bytenr
*/ */
static struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct static struct btrfs_block_group_cache *
btrfs_fs_info *info, btrfs_lookup_first_block_group(struct btrfs_fs_info *info, u64 bytenr)
u64 bytenr)
{ {
struct btrfs_block_group_cache *cache; struct btrfs_block_group_cache *cache;
@ -306,8 +305,8 @@ static struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct
/* /*
* return the block group that contains teh given bytenr * return the block group that contains teh given bytenr
*/ */
struct btrfs_block_group_cache *btrfs_lookup_block_group(struct struct btrfs_block_group_cache *btrfs_lookup_block_group(
btrfs_fs_info *info, struct btrfs_fs_info *info,
u64 bytenr) u64 bytenr)
{ {
struct btrfs_block_group_cache *cache; struct btrfs_block_group_cache *cache;
@ -492,7 +491,7 @@ int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len)
* to the key objectid. * to the key objectid.
*/ */
static int noinline lookup_extent_backref(struct btrfs_trans_handle *trans, static noinline int lookup_extent_backref(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, struct btrfs_path *path,
u64 bytenr, u64 parent, u64 bytenr, u64 parent,
@ -537,7 +536,7 @@ out:
* updates all the backrefs that are pending on update_list for the * updates all the backrefs that are pending on update_list for the
* extent_root * extent_root
*/ */
static int noinline update_backrefs(struct btrfs_trans_handle *trans, static noinline int update_backrefs(struct btrfs_trans_handle *trans,
struct btrfs_root *extent_root, struct btrfs_root *extent_root,
struct btrfs_path *path, struct btrfs_path *path,
struct list_head *update_list) struct list_head *update_list)
@ -573,9 +572,11 @@ loop:
btrfs_ref_generation(leaf, ref) != op->orig_generation || btrfs_ref_generation(leaf, ref) != op->orig_generation ||
(ref_objectid != op->level && (ref_objectid != op->level &&
ref_objectid != BTRFS_MULTIPLE_OBJECTIDS)) { ref_objectid != BTRFS_MULTIPLE_OBJECTIDS)) {
printk(KERN_ERR "couldn't find %Lu, parent %Lu, root %Lu, " printk(KERN_ERR "btrfs couldn't find %llu, parent %llu, "
"owner %u\n", op->bytenr, op->orig_parent, "root %llu, owner %u\n",
ref_root, op->level); (unsigned long long)op->bytenr,
(unsigned long long)op->orig_parent,
(unsigned long long)ref_root, op->level);
btrfs_print_leaf(extent_root, leaf); btrfs_print_leaf(extent_root, leaf);
BUG(); BUG();
} }
@ -620,7 +621,7 @@ out:
return 0; return 0;
} }
static int noinline insert_extents(struct btrfs_trans_handle *trans, static noinline int insert_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *extent_root, struct btrfs_root *extent_root,
struct btrfs_path *path, struct btrfs_path *path,
struct list_head *insert_list, int nr) struct list_head *insert_list, int nr)
@ -781,7 +782,7 @@ static int noinline insert_extents(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
static int noinline insert_extent_backref(struct btrfs_trans_handle *trans, static noinline int insert_extent_backref(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, struct btrfs_path *path,
u64 bytenr, u64 parent, u64 bytenr, u64 parent,
@ -840,7 +841,7 @@ out:
return ret; return ret;
} }
static int noinline remove_extent_backref(struct btrfs_trans_handle *trans, static noinline int remove_extent_backref(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path) struct btrfs_path *path)
{ {
@ -908,7 +909,7 @@ static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
#endif #endif
} }
static int noinline free_extents(struct btrfs_trans_handle *trans, static noinline int free_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *extent_root, struct btrfs_root *extent_root,
struct list_head *del_list) struct list_head *del_list)
{ {
@ -937,10 +938,11 @@ search:
extent_root->root_key.objectid, extent_root->root_key.objectid,
op->orig_generation, op->level, 1); op->orig_generation, op->level, 1);
if (ret) { if (ret) {
printk("Unable to find backref byte nr %Lu root %Lu gen %Lu " printk(KERN_ERR "btrfs unable to find backref byte nr %llu "
"owner %u\n", op->bytenr, "root %llu gen %llu owner %u\n",
extent_root->root_key.objectid, op->orig_generation, (unsigned long long)op->bytenr,
op->level); (unsigned long long)extent_root->root_key.objectid,
(unsigned long long)op->orig_generation, op->level);
btrfs_print_leaf(extent_root, path->nodes[0]); btrfs_print_leaf(extent_root, path->nodes[0]);
WARN_ON(1); WARN_ON(1);
goto out; goto out;
@ -1282,7 +1284,9 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
btrfs_item_key_to_cpu(l, &key, path->slots[0]); btrfs_item_key_to_cpu(l, &key, path->slots[0]);
if (key.objectid != bytenr) { if (key.objectid != bytenr) {
btrfs_print_leaf(root->fs_info->extent_root, path->nodes[0]); btrfs_print_leaf(root->fs_info->extent_root, path->nodes[0]);
printk("wanted %Lu found %Lu\n", bytenr, key.objectid); printk(KERN_ERR "btrfs wanted %llu found %llu\n",
(unsigned long long)bytenr,
(unsigned long long)key.objectid);
BUG(); BUG();
} }
BUG_ON(key.type != BTRFS_EXTENT_ITEM_KEY); BUG_ON(key.type != BTRFS_EXTENT_ITEM_KEY);
@ -1353,7 +1357,8 @@ int btrfs_lookup_extent_ref(struct btrfs_trans_handle *trans,
goto out; goto out;
if (ret != 0) { if (ret != 0) {
btrfs_print_leaf(root, path->nodes[0]); btrfs_print_leaf(root, path->nodes[0]);
printk("failed to find block number %Lu\n", bytenr); printk(KERN_INFO "btrfs failed to find block number %llu\n",
(unsigned long long)bytenr);
BUG(); BUG();
} }
l = path->nodes[0]; l = path->nodes[0];
@ -1921,10 +1926,8 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
ret = btrfs_alloc_chunk(trans, extent_root, flags); ret = btrfs_alloc_chunk(trans, extent_root, flags);
if (ret) { if (ret)
printk("space info full %Lu\n", flags);
space_info->full = 1; space_info->full = 1;
}
out: out:
mutex_unlock(&extent_root->fs_info->chunk_mutex); mutex_unlock(&extent_root->fs_info->chunk_mutex);
return ret; return ret;
@ -2422,8 +2425,8 @@ static int __free_extent(struct btrfs_trans_handle *trans,
&key, path, -1, 1); &key, path, -1, 1);
if (ret) { if (ret) {
printk(KERN_ERR "umm, got %d back from search" printk(KERN_ERR "umm, got %d back from search"
", was looking for %Lu\n", ret, ", was looking for %llu\n", ret,
bytenr); (unsigned long long)bytenr);
btrfs_print_leaf(extent_root, path->nodes[0]); btrfs_print_leaf(extent_root, path->nodes[0]);
} }
BUG_ON(ret); BUG_ON(ret);
@ -2432,9 +2435,12 @@ static int __free_extent(struct btrfs_trans_handle *trans,
} else { } else {
btrfs_print_leaf(extent_root, path->nodes[0]); btrfs_print_leaf(extent_root, path->nodes[0]);
WARN_ON(1); WARN_ON(1);
printk("Unable to find ref byte nr %Lu root %Lu " printk(KERN_ERR "btrfs unable to find ref byte nr %llu "
"gen %Lu owner %Lu\n", bytenr, "root %llu gen %llu owner %llu\n",
root_objectid, ref_generation, owner_objectid); (unsigned long long)bytenr,
(unsigned long long)root_objectid,
(unsigned long long)ref_generation,
(unsigned long long)owner_objectid);
} }
leaf = path->nodes[0]; leaf = path->nodes[0];
@ -2517,8 +2523,8 @@ static int __free_extent(struct btrfs_trans_handle *trans,
* find all the blocks marked as pending in the radix tree and remove * find all the blocks marked as pending in the radix tree and remove
* them from the extent map * them from the extent map
*/ */
static int del_pending_extents(struct btrfs_trans_handle *trans, struct static int del_pending_extents(struct btrfs_trans_handle *trans,
btrfs_root *extent_root, int all) struct btrfs_root *extent_root, int all)
{ {
int ret; int ret;
int err = 0; int err = 0;
@ -2753,7 +2759,7 @@ static u64 stripe_align(struct btrfs_root *root, u64 val)
* ins->offset == number of blocks * ins->offset == number of blocks
* Any available blocks before search_start are skipped. * Any available blocks before search_start are skipped.
*/ */
static int noinline find_free_extent(struct btrfs_trans_handle *trans, static noinline int find_free_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *orig_root, struct btrfs_root *orig_root,
u64 num_bytes, u64 empty_size, u64 num_bytes, u64 empty_size,
u64 search_start, u64 search_end, u64 search_start, u64 search_end,
@ -2995,8 +3001,10 @@ loop_check:
*last_ptr = ins->objectid + ins->offset; *last_ptr = ins->objectid + ins->offset;
ret = 0; ret = 0;
} else if (!ret) { } else if (!ret) {
printk(KERN_ERR "we were searching for %Lu bytes, num_bytes %Lu," printk(KERN_ERR "btrfs searching for %llu bytes, "
" loop %d, allowed_alloc %d\n", total_needed, num_bytes, "num_bytes %llu, loop %d, allowed_alloc %d\n",
(unsigned long long)total_needed,
(unsigned long long)num_bytes,
loop, allowed_chunk_alloc); loop, allowed_chunk_alloc);
ret = -ENOSPC; ret = -ENOSPC;
} }
@ -3012,19 +3020,22 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes)
struct btrfs_block_group_cache *cache; struct btrfs_block_group_cache *cache;
struct list_head *l; struct list_head *l;
printk(KERN_INFO "space_info has %Lu free, is %sfull\n", printk(KERN_INFO "space_info has %llu free, is %sfull\n",
info->total_bytes - info->bytes_used - info->bytes_pinned - (unsigned long long)(info->total_bytes - info->bytes_used -
info->bytes_reserved, (info->full) ? "" : "not "); info->bytes_pinned - info->bytes_reserved),
(info->full) ? "" : "not ");
down_read(&info->groups_sem); down_read(&info->groups_sem);
list_for_each(l, &info->block_groups) { list_for_each(l, &info->block_groups) {
cache = list_entry(l, struct btrfs_block_group_cache, list); cache = list_entry(l, struct btrfs_block_group_cache, list);
spin_lock(&cache->lock); spin_lock(&cache->lock);
printk(KERN_INFO "block group %Lu has %Lu bytes, %Lu used " printk(KERN_INFO "block group %llu has %llu bytes, %llu used "
"%Lu pinned %Lu reserved\n", "%llu pinned %llu reserved\n",
cache->key.objectid, cache->key.offset, (unsigned long long)cache->key.objectid,
btrfs_block_group_used(&cache->item), (unsigned long long)cache->key.offset,
cache->pinned, cache->reserved); (unsigned long long)btrfs_block_group_used(&cache->item),
(unsigned long long)cache->pinned,
(unsigned long long)cache->reserved);
btrfs_dump_free_space(cache, bytes); btrfs_dump_free_space(cache, bytes);
spin_unlock(&cache->lock); spin_unlock(&cache->lock);
} }
@ -3092,8 +3103,9 @@ again:
struct btrfs_space_info *sinfo; struct btrfs_space_info *sinfo;
sinfo = __find_space_info(root->fs_info, data); sinfo = __find_space_info(root->fs_info, data);
printk("allocation failed flags %Lu, wanted %Lu\n", printk(KERN_ERR "btrfs allocation failed flags %llu, "
data, num_bytes); "wanted %llu\n", (unsigned long long)data,
(unsigned long long)num_bytes);
dump_space_info(sinfo, num_bytes); dump_space_info(sinfo, num_bytes);
BUG(); BUG();
} }
@ -3108,7 +3120,8 @@ int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len)
cache = btrfs_lookup_block_group(root->fs_info, start); cache = btrfs_lookup_block_group(root->fs_info, start);
if (!cache) { if (!cache) {
printk(KERN_ERR "Unable to find block group for %Lu\n", start); printk(KERN_ERR "Unable to find block group for %llu\n",
(unsigned long long)start);
return -ENOSPC; return -ENOSPC;
} }
@ -3235,10 +3248,12 @@ static int __btrfs_alloc_reserved_extent(struct btrfs_trans_handle *trans,
} }
update_block: update_block:
ret = update_block_group(trans, root, ins->objectid, ins->offset, 1, 0); ret = update_block_group(trans, root, ins->objectid,
ins->offset, 1, 0);
if (ret) { if (ret) {
printk("update block group failed for %Lu %Lu\n", printk(KERN_ERR "btrfs update block group failed for %llu "
ins->objectid, ins->offset); "%llu\n", (unsigned long long)ins->objectid,
(unsigned long long)ins->offset);
BUG(); BUG();
} }
out: out:
@ -3420,7 +3435,7 @@ int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
return 0; return 0;
} }
static int noinline cache_drop_leaf_ref(struct btrfs_trans_handle *trans, static noinline int cache_drop_leaf_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_leaf_ref *ref) struct btrfs_leaf_ref *ref)
{ {
@ -3445,15 +3460,15 @@ static int noinline cache_drop_leaf_ref(struct btrfs_trans_handle *trans,
return 0; return 0;
} }
static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start, u64 len, static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start,
u32 *refs) u64 len, u32 *refs)
{ {
int ret; int ret;
ret = btrfs_lookup_extent_ref(NULL, root, start, len, refs); ret = btrfs_lookup_extent_ref(NULL, root, start, len, refs);
BUG_ON(ret); BUG_ON(ret);
#if 0 // some debugging code in case we see problems here #if 0 /* some debugging code in case we see problems here */
/* if the refs count is one, it won't get increased again. But /* if the refs count is one, it won't get increased again. But
* if the ref count is > 1, someone may be decreasing it at * if the ref count is > 1, someone may be decreasing it at
* the same time we are. * the same time we are.
@ -3474,8 +3489,8 @@ static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start, u64 len
free_extent_buffer(eb); free_extent_buffer(eb);
} }
if (*refs == 1) { if (*refs == 1) {
printk("block %llu went down to one during drop_snap\n", printk(KERN_ERR "btrfs block %llu went down to one "
(unsigned long long)start); "during drop_snap\n", (unsigned long long)start);
} }
} }
@ -3489,7 +3504,7 @@ static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start, u64 len
* helper function for drop_snapshot, this walks down the tree dropping ref * helper function for drop_snapshot, this walks down the tree dropping ref
* counts as it goes. * counts as it goes.
*/ */
static int noinline walk_down_tree(struct btrfs_trans_handle *trans, static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, int *level) struct btrfs_path *path, int *level)
{ {
@ -3576,10 +3591,6 @@ static int noinline walk_down_tree(struct btrfs_trans_handle *trans,
*level = 0; *level = 0;
break; break;
} }
if (printk_ratelimit()) {
printk("leaf ref miss for bytenr %llu\n",
(unsigned long long)bytenr);
}
} }
next = btrfs_find_tree_block(root, bytenr, blocksize); next = btrfs_find_tree_block(root, bytenr, blocksize);
if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) { if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
@ -3641,7 +3652,7 @@ out:
* walk_down_tree. The main difference is that it checks reference * walk_down_tree. The main difference is that it checks reference
* counts while tree blocks are locked. * counts while tree blocks are locked.
*/ */
static int noinline walk_down_subtree(struct btrfs_trans_handle *trans, static noinline int walk_down_subtree(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, int *level) struct btrfs_path *path, int *level)
{ {
@ -3730,7 +3741,7 @@ out:
* to find the first node higher up where we haven't yet gone through * to find the first node higher up where we haven't yet gone through
* all the slots * all the slots
*/ */
static int noinline walk_up_tree(struct btrfs_trans_handle *trans, static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, struct btrfs_path *path,
int *level, int max_level) int *level, int max_level)
@ -3920,7 +3931,7 @@ static unsigned long calc_ra(unsigned long start, unsigned long last,
return min(last, start + nr - 1); return min(last, start + nr - 1);
} }
static int noinline relocate_inode_pages(struct inode *inode, u64 start, static noinline int relocate_inode_pages(struct inode *inode, u64 start,
u64 len) u64 len)
{ {
u64 page_start; u64 page_start;
@ -4011,7 +4022,7 @@ out_unlock:
return ret; return ret;
} }
static int noinline relocate_data_extent(struct inode *reloc_inode, static noinline int relocate_data_extent(struct inode *reloc_inode,
struct btrfs_key *extent_key, struct btrfs_key *extent_key,
u64 offset) u64 offset)
{ {
@ -4087,7 +4098,7 @@ static int is_cowonly_root(u64 root_objectid)
return 0; return 0;
} }
static int noinline __next_ref_path(struct btrfs_trans_handle *trans, static noinline int __next_ref_path(struct btrfs_trans_handle *trans,
struct btrfs_root *extent_root, struct btrfs_root *extent_root,
struct btrfs_ref_path *ref_path, struct btrfs_ref_path *ref_path,
int first_time) int first_time)
@ -4119,11 +4130,10 @@ walk_down:
if (level < ref_path->lowest_level) if (level < ref_path->lowest_level)
break; break;
if (level >= 0) { if (level >= 0)
bytenr = ref_path->nodes[level]; bytenr = ref_path->nodes[level];
} else { else
bytenr = ref_path->extent_start; bytenr = ref_path->extent_start;
}
BUG_ON(bytenr == 0); BUG_ON(bytenr == 0);
parent = ref_path->nodes[level + 1]; parent = ref_path->nodes[level + 1];
@ -4170,11 +4180,12 @@ walk_up:
level = ref_path->current_level; level = ref_path->current_level;
while (level < BTRFS_MAX_LEVEL - 1) { while (level < BTRFS_MAX_LEVEL - 1) {
u64 ref_objectid; u64 ref_objectid;
if (level >= 0) {
if (level >= 0)
bytenr = ref_path->nodes[level]; bytenr = ref_path->nodes[level];
} else { else
bytenr = ref_path->extent_start; bytenr = ref_path->extent_start;
}
BUG_ON(bytenr == 0); BUG_ON(bytenr == 0);
key.objectid = bytenr; key.objectid = bytenr;
@ -4299,7 +4310,7 @@ static int btrfs_next_ref_path(struct btrfs_trans_handle *trans,
return __next_ref_path(trans, extent_root, ref_path, 0); return __next_ref_path(trans, extent_root, ref_path, 0);
} }
static int noinline get_new_locations(struct inode *reloc_inode, static noinline int get_new_locations(struct inode *reloc_inode,
struct btrfs_key *extent_key, struct btrfs_key *extent_key,
u64 offset, int no_fragment, u64 offset, int no_fragment,
struct disk_extent **extents, struct disk_extent **extents,
@ -4420,7 +4431,7 @@ out:
return ret; return ret;
} }
static int noinline replace_one_extent(struct btrfs_trans_handle *trans, static noinline int replace_one_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, struct btrfs_path *path,
struct btrfs_key *extent_key, struct btrfs_key *extent_key,
@ -4778,7 +4789,7 @@ int btrfs_reloc_tree_cache_ref(struct btrfs_trans_handle *trans,
return 0; return 0;
} }
static int noinline invalidate_extent_cache(struct btrfs_root *root, static noinline int invalidate_extent_cache(struct btrfs_root *root,
struct extent_buffer *leaf, struct extent_buffer *leaf,
struct btrfs_block_group_cache *group, struct btrfs_block_group_cache *group,
struct btrfs_root *target_root) struct btrfs_root *target_root)
@ -4826,7 +4837,7 @@ static int noinline invalidate_extent_cache(struct btrfs_root *root,
return 0; return 0;
} }
static int noinline replace_extents_in_leaf(struct btrfs_trans_handle *trans, static noinline int replace_extents_in_leaf(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct extent_buffer *leaf, struct extent_buffer *leaf,
struct btrfs_block_group_cache *group, struct btrfs_block_group_cache *group,
@ -5035,7 +5046,7 @@ int btrfs_cleanup_reloc_trees(struct btrfs_root *root)
return 0; return 0;
} }
static int noinline init_reloc_tree(struct btrfs_trans_handle *trans, static noinline int init_reloc_tree(struct btrfs_trans_handle *trans,
struct btrfs_root *root) struct btrfs_root *root)
{ {
struct btrfs_root *reloc_root; struct btrfs_root *reloc_root;
@ -5102,7 +5113,7 @@ static int noinline init_reloc_tree(struct btrfs_trans_handle *trans,
* tree blocks are shared between reloc trees, so they are also shared * tree blocks are shared between reloc trees, so they are also shared
* between subvols. * between subvols.
*/ */
static int noinline relocate_one_path(struct btrfs_trans_handle *trans, static noinline int relocate_one_path(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, struct btrfs_path *path,
struct btrfs_key *first_key, struct btrfs_key *first_key,
@ -5199,7 +5210,7 @@ static int noinline relocate_one_path(struct btrfs_trans_handle *trans,
return 0; return 0;
} }
static int noinline relocate_tree_block(struct btrfs_trans_handle *trans, static noinline int relocate_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, struct btrfs_path *path,
struct btrfs_key *first_key, struct btrfs_key *first_key,
@ -5217,7 +5228,7 @@ static int noinline relocate_tree_block(struct btrfs_trans_handle *trans,
return 0; return 0;
} }
static int noinline del_extent_zero(struct btrfs_trans_handle *trans, static noinline int del_extent_zero(struct btrfs_trans_handle *trans,
struct btrfs_root *extent_root, struct btrfs_root *extent_root,
struct btrfs_path *path, struct btrfs_path *path,
struct btrfs_key *extent_key) struct btrfs_key *extent_key)
@ -5233,7 +5244,7 @@ out:
return ret; return ret;
} }
static struct btrfs_root noinline *read_ref_root(struct btrfs_fs_info *fs_info, static noinline struct btrfs_root *read_ref_root(struct btrfs_fs_info *fs_info,
struct btrfs_ref_path *ref_path) struct btrfs_ref_path *ref_path)
{ {
struct btrfs_key root_key; struct btrfs_key root_key;
@ -5248,7 +5259,7 @@ static struct btrfs_root noinline *read_ref_root(struct btrfs_fs_info *fs_info,
return btrfs_read_fs_root_no_name(fs_info, &root_key); return btrfs_read_fs_root_no_name(fs_info, &root_key);
} }
static int noinline relocate_one_extent(struct btrfs_root *extent_root, static noinline int relocate_one_extent(struct btrfs_root *extent_root,
struct btrfs_path *path, struct btrfs_path *path,
struct btrfs_key *extent_key, struct btrfs_key *extent_key,
struct btrfs_block_group_cache *group, struct btrfs_block_group_cache *group,
@ -5497,7 +5508,7 @@ out:
return ret; return ret;
} }
static struct inode noinline *create_reloc_inode(struct btrfs_fs_info *fs_info, static noinline struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *group) struct btrfs_block_group_cache *group)
{ {
struct inode *inode = NULL; struct inode *inode = NULL;
@ -5617,7 +5628,7 @@ int btrfs_relocate_block_group(struct btrfs_root *root, u64 group_start)
block_group = btrfs_lookup_block_group(info, group_start); block_group = btrfs_lookup_block_group(info, group_start);
BUG_ON(!block_group); BUG_ON(!block_group);
printk("btrfs relocating block group %llu flags %llu\n", printk(KERN_INFO "btrfs relocating block group %llu flags %llu\n",
(unsigned long long)block_group->key.objectid, (unsigned long long)block_group->key.objectid,
(unsigned long long)block_group->flags); (unsigned long long)block_group->flags);
@ -5712,7 +5723,7 @@ next:
} }
if (total_found > 0) { if (total_found > 0) {
printk("btrfs found %llu extents in pass %d\n", printk(KERN_INFO "btrfs found %llu extents in pass %d\n",
(unsigned long long)total_found, pass); (unsigned long long)total_found, pass);
pass++; pass++;
if (total_found == skipped && pass > 2) { if (total_found == skipped && pass > 2) {

View file

@ -32,7 +32,7 @@ static LIST_HEAD(states);
#define LEAK_DEBUG 0 #define LEAK_DEBUG 0
#ifdef LEAK_DEBUG #ifdef LEAK_DEBUG
static spinlock_t leak_lock = SPIN_LOCK_UNLOCKED; static DEFINE_SPINLOCK(leak_lock);
#endif #endif
#define BUFFER_LRU_MAX 64 #define BUFFER_LRU_MAX 64
@ -81,7 +81,11 @@ void extent_io_exit(void)
while (!list_empty(&states)) { while (!list_empty(&states)) {
state = list_entry(states.next, struct extent_state, leak_list); state = list_entry(states.next, struct extent_state, leak_list);
printk("state leak: start %Lu end %Lu state %lu in tree %p refs %d\n", state->start, state->end, state->state, state->tree, atomic_read(&state->refs)); printk(KERN_ERR "btrfs state leak: start %llu end %llu "
"state %lu in tree %p refs %d\n",
(unsigned long long)state->start,
(unsigned long long)state->end,
state->state, state->tree, atomic_read(&state->refs));
list_del(&state->leak_list); list_del(&state->leak_list);
kmem_cache_free(extent_state_cache, state); kmem_cache_free(extent_state_cache, state);
@ -89,7 +93,9 @@ void extent_io_exit(void)
while (!list_empty(&buffers)) { while (!list_empty(&buffers)) {
eb = list_entry(buffers.next, struct extent_buffer, leak_list); eb = list_entry(buffers.next, struct extent_buffer, leak_list);
printk("buffer leak start %Lu len %lu refs %d\n", eb->start, eb->len, atomic_read(&eb->refs)); printk(KERN_ERR "btrfs buffer leak start %llu len %lu "
"refs %d\n", (unsigned long long)eb->start,
eb->len, atomic_read(&eb->refs));
list_del(&eb->leak_list); list_del(&eb->leak_list);
kmem_cache_free(extent_buffer_cache, eb); kmem_cache_free(extent_buffer_cache, eb);
} }
@ -200,10 +206,9 @@ static struct rb_node *__etree_search(struct extent_io_tree *tree, u64 offset,
n = n->rb_left; n = n->rb_left;
else if (offset > entry->end) else if (offset > entry->end)
n = n->rb_right; n = n->rb_right;
else { else
return n; return n;
} }
}
if (prev_ret) { if (prev_ret) {
orig_prev = prev; orig_prev = prev;
@ -233,9 +238,8 @@ static inline struct rb_node *tree_search(struct extent_io_tree *tree,
struct rb_node *ret; struct rb_node *ret;
ret = __etree_search(tree, offset, &prev, NULL); ret = __etree_search(tree, offset, &prev, NULL);
if (!ret) { if (!ret)
return prev; return prev;
}
return ret; return ret;
} }
@ -363,7 +367,9 @@ static int insert_state(struct extent_io_tree *tree,
struct rb_node *node; struct rb_node *node;
if (end < start) { if (end < start) {
printk("end < start %Lu %Lu\n", end, start); printk(KERN_ERR "btrfs end < start %llu %llu\n",
(unsigned long long)end,
(unsigned long long)start);
WARN_ON(1); WARN_ON(1);
} }
if (bits & EXTENT_DIRTY) if (bits & EXTENT_DIRTY)
@ -376,7 +382,10 @@ static int insert_state(struct extent_io_tree *tree,
if (node) { if (node) {
struct extent_state *found; struct extent_state *found;
found = rb_entry(node, struct extent_state, rb_node); found = rb_entry(node, struct extent_state, rb_node);
printk("found node %Lu %Lu on insert of %Lu %Lu\n", found->start, found->end, start, end); printk(KERN_ERR "btrfs found node %llu %llu on insert of "
"%llu %llu\n", (unsigned long long)found->start,
(unsigned long long)found->end,
(unsigned long long)start, (unsigned long long)end);
free_extent_state(state); free_extent_state(state);
return -EEXIST; return -EEXIST;
} }
@ -412,7 +421,6 @@ static int split_state(struct extent_io_tree *tree, struct extent_state *orig,
if (node) { if (node) {
struct extent_state *found; struct extent_state *found;
found = rb_entry(node, struct extent_state, rb_node); found = rb_entry(node, struct extent_state, rb_node);
printk("found node %Lu %Lu on insert of %Lu %Lu\n", found->start, found->end, prealloc->start, prealloc->end);
free_extent_state(prealloc); free_extent_state(prealloc);
return -EEXIST; return -EEXIST;
} }
@ -661,8 +669,9 @@ static void set_state_bits(struct extent_io_tree *tree,
* [start, end] is inclusive * [start, end] is inclusive
* This takes the tree lock. * This takes the tree lock.
*/ */
static int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, static int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
int exclusive, u64 *failed_start, gfp_t mask) int bits, int exclusive, u64 *failed_start,
gfp_t mask)
{ {
struct extent_state *state; struct extent_state *state;
struct extent_state *prealloc = NULL; struct extent_state *prealloc = NULL;
@ -891,8 +900,8 @@ int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
} }
EXPORT_SYMBOL(set_extent_uptodate); EXPORT_SYMBOL(set_extent_uptodate);
static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
gfp_t mask) u64 end, gfp_t mask)
{ {
return clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0, mask); return clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0, mask);
} }
@ -904,8 +913,8 @@ static int set_extent_writeback(struct extent_io_tree *tree, u64 start, u64 end,
0, NULL, mask); 0, NULL, mask);
} }
static int clear_extent_writeback(struct extent_io_tree *tree, u64 start, u64 end, static int clear_extent_writeback(struct extent_io_tree *tree, u64 start,
gfp_t mask) u64 end, gfp_t mask)
{ {
return clear_extent_bit(tree, start, end, EXTENT_WRITEBACK, 1, 0, mask); return clear_extent_bit(tree, start, end, EXTENT_WRITEBACK, 1, 0, mask);
} }
@ -1025,9 +1034,8 @@ int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
* our range starts. * our range starts.
*/ */
node = tree_search(tree, start); node = tree_search(tree, start);
if (!node) { if (!node)
goto out; goto out;
}
while (1) { while (1) {
state = rb_entry(node, struct extent_state, rb_node); state = rb_entry(node, struct extent_state, rb_node);
@ -1062,15 +1070,14 @@ struct extent_state *find_first_extent_bit_state(struct extent_io_tree *tree,
* our range starts. * our range starts.
*/ */
node = tree_search(tree, start); node = tree_search(tree, start);
if (!node) { if (!node)
goto out; goto out;
}
while (1) { while (1) {
state = rb_entry(node, struct extent_state, rb_node); state = rb_entry(node, struct extent_state, rb_node);
if (state->end >= start && (state->state & bits)) { if (state->end >= start && (state->state & bits))
return state; return state;
}
node = rb_next(node); node = rb_next(node);
if (!node) if (!node)
break; break;
@ -1263,17 +1270,16 @@ again:
* pages in order, so we can't process delalloc bytes before * pages in order, so we can't process delalloc bytes before
* locked_page * locked_page
*/ */
if (delalloc_start < *start) { if (delalloc_start < *start)
delalloc_start = *start; delalloc_start = *start;
}
/* /*
* make sure to limit the number of pages we try to lock down * make sure to limit the number of pages we try to lock down
* if we're looping. * if we're looping.
*/ */
if (delalloc_end + 1 - delalloc_start > max_bytes && loops) { if (delalloc_end + 1 - delalloc_start > max_bytes && loops)
delalloc_end = delalloc_start + PAGE_CACHE_SIZE - 1; delalloc_end = delalloc_start + PAGE_CACHE_SIZE - 1;
}
/* step two, lock all the pages after the page that has start */ /* step two, lock all the pages after the page that has start */
ret = lock_delalloc_pages(inode, locked_page, ret = lock_delalloc_pages(inode, locked_page,
delalloc_start, delalloc_end); delalloc_start, delalloc_end);
@ -1384,7 +1390,6 @@ u64 count_range_bits(struct extent_io_tree *tree,
int found = 0; int found = 0;
if (search_end <= cur_start) { if (search_end <= cur_start) {
printk("search_end %Lu start %Lu\n", search_end, cur_start);
WARN_ON(1); WARN_ON(1);
return 0; return 0;
} }
@ -1399,9 +1404,8 @@ u64 count_range_bits(struct extent_io_tree *tree,
* our range starts. * our range starts.
*/ */
node = tree_search(tree, cur_start); node = tree_search(tree, cur_start);
if (!node) { if (!node)
goto out; goto out;
}
while (1) { while (1) {
state = rb_entry(node, struct extent_state, rb_node); state = rb_entry(node, struct extent_state, rb_node);
@ -1927,19 +1931,15 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
nr = bio_get_nr_vecs(bdev); nr = bio_get_nr_vecs(bdev);
bio = extent_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH); bio = extent_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH);
if (!bio) {
printk("failed to allocate bio nr %d\n", nr);
}
bio_add_page(bio, page, page_size, offset); bio_add_page(bio, page, page_size, offset);
bio->bi_end_io = end_io_func; bio->bi_end_io = end_io_func;
bio->bi_private = tree; bio->bi_private = tree;
if (bio_ret) { if (bio_ret)
*bio_ret = bio; *bio_ret = bio;
} else { else
ret = submit_one_bio(rw, bio, mirror_num, bio_flags); ret = submit_one_bio(rw, bio, mirror_num, bio_flags);
}
return ret; return ret;
} }
@ -2028,13 +2028,7 @@ static int __extent_read_full_page(struct extent_io_tree *tree,
break; break;
} }
extent_offset = cur - em->start; extent_offset = cur - em->start;
if (extent_map_end(em) <= cur) {
printk("bad mapping em [%Lu %Lu] cur %Lu\n", em->start, extent_map_end(em), cur);
}
BUG_ON(extent_map_end(em) <= cur); BUG_ON(extent_map_end(em) <= cur);
if (end < cur) {
printk("2bad mapping end %Lu cur %Lu\n", end, cur);
}
BUG_ON(end < cur); BUG_ON(end < cur);
if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags))
@ -2242,9 +2236,8 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
nr_written++; nr_written++;
end = page_end; end = page_end;
if (test_range_bit(tree, start, page_end, EXTENT_DELALLOC, 0)) { if (test_range_bit(tree, start, page_end, EXTENT_DELALLOC, 0))
printk("found delalloc bits after lock_extent\n"); printk(KERN_ERR "btrfs delalloc bits after lock_extent\n");
}
if (last_byte <= start) { if (last_byte <= start) {
clear_extent_dirty(tree, start, page_end, GFP_NOFS); clear_extent_dirty(tree, start, page_end, GFP_NOFS);
@ -2344,9 +2337,9 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
set_range_writeback(tree, cur, cur + iosize - 1); set_range_writeback(tree, cur, cur + iosize - 1);
if (!PageWriteback(page)) { if (!PageWriteback(page)) {
printk("warning page %lu not writeback, " printk(KERN_ERR "btrfs warning page %lu not "
"cur %llu end %llu\n", page->index, "writeback, cur %llu end %llu\n",
(unsigned long long)cur, page->index, (unsigned long long)cur,
(unsigned long long)end); (unsigned long long)end);
} }
@ -2430,8 +2423,8 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
retry: retry:
while (!done && (index <= end) && while (!done && (index <= end) &&
(nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
PAGECACHE_TAG_DIRTY, PAGECACHE_TAG_DIRTY, min(end - index,
min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) { (pgoff_t)PAGEVEC_SIZE-1) + 1))) {
unsigned i; unsigned i;
scanned = 1; scanned = 1;
@ -2536,9 +2529,8 @@ int extent_write_full_page(struct extent_io_tree *tree, struct page *page,
extent_write_cache_pages(tree, mapping, &wbc_writepages, extent_write_cache_pages(tree, mapping, &wbc_writepages,
__extent_writepage, &epd, flush_write_bio); __extent_writepage, &epd, flush_write_bio);
if (epd.bio) { if (epd.bio)
submit_one_bio(WRITE, epd.bio, 0, 0); submit_one_bio(WRITE, epd.bio, 0, 0);
}
return ret; return ret;
} }
EXPORT_SYMBOL(extent_write_full_page); EXPORT_SYMBOL(extent_write_full_page);
@ -2606,9 +2598,8 @@ int extent_writepages(struct extent_io_tree *tree,
ret = extent_write_cache_pages(tree, mapping, wbc, ret = extent_write_cache_pages(tree, mapping, wbc,
__extent_writepage, &epd, __extent_writepage, &epd,
flush_write_bio); flush_write_bio);
if (epd.bio) { if (epd.bio)
submit_one_bio(WRITE, epd.bio, 0, 0); submit_one_bio(WRITE, epd.bio, 0, 0);
}
return ret; return ret;
} }
EXPORT_SYMBOL(extent_writepages); EXPORT_SYMBOL(extent_writepages);
@ -2730,9 +2721,9 @@ int extent_prepare_write(struct extent_io_tree *tree,
while (block_start <= block_end) { while (block_start <= block_end) {
em = get_extent(inode, page, page_offset, block_start, em = get_extent(inode, page, page_offset, block_start,
block_end - block_start + 1, 1); block_end - block_start + 1, 1);
if (IS_ERR(em) || !em) { if (IS_ERR(em) || !em)
goto err; goto err;
}
cur_end = min(block_end, extent_map_end(em) - 1); cur_end = min(block_end, extent_map_end(em) - 1);
block_off_start = block_start & (PAGE_CACHE_SIZE - 1); block_off_start = block_start & (PAGE_CACHE_SIZE - 1);
block_off_end = block_off_start + blocksize; block_off_end = block_off_start + blocksize;
@ -3321,16 +3312,12 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
lock_page(page); lock_page(page);
} }
locked_pages++; locked_pages++;
if (!PageUptodate(page)) { if (!PageUptodate(page))
all_uptodate = 0; all_uptodate = 0;
} }
}
if (all_uptodate) { if (all_uptodate) {
if (start_i == 0) if (start_i == 0)
eb->flags |= EXTENT_UPTODATE; eb->flags |= EXTENT_UPTODATE;
if (ret) {
printk("all up to date but ret is %d\n", ret);
}
goto unlock_exit; goto unlock_exit;
} }
@ -3345,10 +3332,8 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
err = __extent_read_full_page(tree, page, err = __extent_read_full_page(tree, page,
get_extent, &bio, get_extent, &bio,
mirror_num, &bio_flags); mirror_num, &bio_flags);
if (err) { if (err)
ret = err; ret = err;
printk("err %d from __extent_read_full_page\n", ret);
}
} else { } else {
unlock_page(page); unlock_page(page);
} }
@ -3357,19 +3342,16 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
if (bio) if (bio)
submit_one_bio(READ, bio, mirror_num, bio_flags); submit_one_bio(READ, bio, mirror_num, bio_flags);
if (ret || !wait) { if (ret || !wait)
if (ret)
printk("ret %d wait %d returning\n", ret, wait);
return ret; return ret;
}
for (i = start_i; i < num_pages; i++) { for (i = start_i; i < num_pages; i++) {
page = extent_buffer_page(eb, i); page = extent_buffer_page(eb, i);
wait_on_page_locked(page); wait_on_page_locked(page);
if (!PageUptodate(page)) { if (!PageUptodate(page))
printk("page not uptodate after wait_on_page_locked\n");
ret = -EIO; ret = -EIO;
} }
}
if (!ret) if (!ret)
eb->flags |= EXTENT_UPTODATE; eb->flags |= EXTENT_UPTODATE;
return ret; return ret;
@ -3442,8 +3424,11 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start,
offset = 0; offset = 0;
*map_start = ((u64)i << PAGE_CACHE_SHIFT) - start_offset; *map_start = ((u64)i << PAGE_CACHE_SHIFT) - start_offset;
} }
if (start + min_len > eb->len) { if (start + min_len > eb->len) {
printk("bad mapping eb start %Lu len %lu, wanted %lu %lu\n", eb->start, eb->len, start, min_len); printk(KERN_ERR "btrfs bad mapping eb start %llu len %lu, "
"wanted %lu %lu\n", (unsigned long long)eb->start,
eb->len, start, min_len);
WARN_ON(1); WARN_ON(1);
} }
@ -3674,13 +3659,13 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
unsigned long src_i; unsigned long src_i;
if (src_offset + len > dst->len) { if (src_offset + len > dst->len) {
printk("memmove bogus src_offset %lu move len %lu len %lu\n", printk(KERN_ERR "btrfs memmove bogus src_offset %lu move "
src_offset, len, dst->len); "len %lu dst len %lu\n", src_offset, len, dst->len);
BUG_ON(1); BUG_ON(1);
} }
if (dst_offset + len > dst->len) { if (dst_offset + len > dst->len) {
printk("memmove bogus dst_offset %lu move len %lu len %lu\n", printk(KERN_ERR "btrfs memmove bogus dst_offset %lu move "
dst_offset, len, dst->len); "len %lu dst len %lu\n", dst_offset, len, dst->len);
BUG_ON(1); BUG_ON(1);
} }
@ -3722,13 +3707,13 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
unsigned long src_i; unsigned long src_i;
if (src_offset + len > dst->len) { if (src_offset + len > dst->len) {
printk("memmove bogus src_offset %lu move len %lu len %lu\n", printk(KERN_ERR "btrfs memmove bogus src_offset %lu move "
src_offset, len, dst->len); "len %lu len %lu\n", src_offset, len, dst->len);
BUG_ON(1); BUG_ON(1);
} }
if (dst_offset + len > dst->len) { if (dst_offset + len > dst->len) {
printk("memmove bogus dst_offset %lu move len %lu len %lu\n", printk(KERN_ERR "btrfs memmove bogus dst_offset %lu move "
dst_offset, len, dst->len); "len %lu len %lu\n", dst_offset, len, dst->len);
BUG_ON(1); BUG_ON(1);
} }
if (dst_offset < src_offset) { if (dst_offset < src_offset) {

View file

@ -192,8 +192,9 @@ int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
offset + bvec->bv_len - 1, offset + bvec->bv_len - 1,
EXTENT_NODATASUM, GFP_NOFS); EXTENT_NODATASUM, GFP_NOFS);
} else { } else {
printk("no csum found for inode %lu " printk(KERN_INFO "btrfs no csum found "
"start %llu\n", inode->i_ino, "for inode %lu start %llu\n",
inode->i_ino,
(unsigned long long)offset); (unsigned long long)offset);
} }
item = NULL; item = NULL;
@ -715,9 +716,8 @@ again:
goto csum; goto csum;
diff = diff - btrfs_item_size_nr(leaf, path->slots[0]); diff = diff - btrfs_item_size_nr(leaf, path->slots[0]);
if (diff != csum_size) { if (diff != csum_size)
goto insert; goto insert;
}
ret = btrfs_extend_item(trans, root, path, diff); ret = btrfs_extend_item(trans, root, path, diff);
BUG_ON(ret); BUG_ON(ret);

View file

@ -44,7 +44,7 @@
/* simple helper to fault in pages and copy. This should go away /* simple helper to fault in pages and copy. This should go away
* and be replaced with calls into generic code. * and be replaced with calls into generic code.
*/ */
static int noinline btrfs_copy_from_user(loff_t pos, int num_pages, static noinline int btrfs_copy_from_user(loff_t pos, int num_pages,
int write_bytes, int write_bytes,
struct page **prepared_pages, struct page **prepared_pages,
const char __user *buf) const char __user *buf)
@ -78,7 +78,7 @@ static int noinline btrfs_copy_from_user(loff_t pos, int num_pages,
/* /*
* unlocks pages after btrfs_file_write is done with them * unlocks pages after btrfs_file_write is done with them
*/ */
static void noinline btrfs_drop_pages(struct page **pages, size_t num_pages) static noinline void btrfs_drop_pages(struct page **pages, size_t num_pages)
{ {
size_t i; size_t i;
for (i = 0; i < num_pages; i++) { for (i = 0; i < num_pages; i++) {
@ -103,7 +103,7 @@ static void noinline btrfs_drop_pages(struct page **pages, size_t num_pages)
* this also makes the decision about creating an inline extent vs * this also makes the decision about creating an inline extent vs
* doing real data extents, marking pages dirty and delalloc as required. * doing real data extents, marking pages dirty and delalloc as required.
*/ */
static int noinline dirty_and_release_pages(struct btrfs_trans_handle *trans, static noinline int dirty_and_release_pages(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct file *file, struct file *file,
struct page **pages, struct page **pages,
@ -137,9 +137,6 @@ static int noinline dirty_and_release_pages(struct btrfs_trans_handle *trans,
btrfs_set_trans_block_group(trans, inode); btrfs_set_trans_block_group(trans, inode);
hint_byte = 0; hint_byte = 0;
if ((end_of_last_block & 4095) == 0) {
printk("strange end of last %Lu %zu %Lu\n", start_pos, write_bytes, end_of_last_block);
}
set_extent_uptodate(io_tree, start_pos, end_of_last_block, GFP_NOFS); set_extent_uptodate(io_tree, start_pos, end_of_last_block, GFP_NOFS);
/* check for reserved extents on each page, we don't want /* check for reserved extents on each page, we don't want
@ -314,8 +311,10 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode)
if (found_key.offset < last_offset) { if (found_key.offset < last_offset) {
WARN_ON(1); WARN_ON(1);
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("inode %lu found offset %Lu expected %Lu\n", printk(KERN_ERR "inode %lu found offset %llu "
inode->i_ino, found_key.offset, last_offset); "expected %llu\n", inode->i_ino,
(unsigned long long)found_key.offset,
(unsigned long long)last_offset);
err = 1; err = 1;
goto out; goto out;
} }
@ -339,8 +338,9 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode)
if (0 && last_offset < inode->i_size) { if (0 && last_offset < inode->i_size) {
WARN_ON(1); WARN_ON(1);
btrfs_print_leaf(root, leaf); btrfs_print_leaf(root, leaf);
printk("inode %lu found offset %Lu size %Lu\n", inode->i_ino, printk(KERN_ERR "inode %lu found offset %llu size %llu\n",
last_offset, inode->i_size); inode->i_ino, (unsigned long long)last_offset,
(unsigned long long)inode->i_size);
err = 1; err = 1;
} }
@ -362,7 +362,7 @@ out:
* inline_limit is used to tell this code which offsets in the file to keep * inline_limit is used to tell this code which offsets in the file to keep
* if they contain inline extents. * if they contain inline extents.
*/ */
int noinline btrfs_drop_extents(struct btrfs_trans_handle *trans, noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode, struct btrfs_root *root, struct inode *inode,
u64 start, u64 end, u64 inline_limit, u64 *hint_byte) u64 start, u64 end, u64 inline_limit, u64 *hint_byte)
{ {
@ -656,10 +656,9 @@ next_slot:
BUG_ON(ret); BUG_ON(ret);
} }
btrfs_release_path(root, path); btrfs_release_path(root, path);
if (disk_bytenr != 0) { if (disk_bytenr != 0)
inode_add_bytes(inode, extent_end - end); inode_add_bytes(inode, extent_end - end);
} }
}
if (found_extent && !keep) { if (found_extent && !keep) {
u64 old_disk_bytenr = le64_to_cpu(old.disk_bytenr); u64 old_disk_bytenr = le64_to_cpu(old.disk_bytenr);
@ -944,7 +943,7 @@ done:
* waits for data=ordered extents to finish before allowing the pages to be * waits for data=ordered extents to finish before allowing the pages to be
* modified. * modified.
*/ */
static int noinline prepare_pages(struct btrfs_root *root, struct file *file, static noinline int prepare_pages(struct btrfs_root *root, struct file *file,
struct page **pages, size_t num_pages, struct page **pages, size_t num_pages,
loff_t pos, unsigned long first_index, loff_t pos, unsigned long first_index,
unsigned long last_index, size_t write_bytes) unsigned long last_index, size_t write_bytes)
@ -979,7 +978,8 @@ again:
struct btrfs_ordered_extent *ordered; struct btrfs_ordered_extent *ordered;
lock_extent(&BTRFS_I(inode)->io_tree, lock_extent(&BTRFS_I(inode)->io_tree,
start_pos, last_pos - 1, GFP_NOFS); start_pos, last_pos - 1, GFP_NOFS);
ordered = btrfs_lookup_first_ordered_extent(inode, last_pos -1); ordered = btrfs_lookup_first_ordered_extent(inode,
last_pos - 1);
if (ordered && if (ordered &&
ordered->file_offset + ordered->len > start_pos && ordered->file_offset + ordered->len > start_pos &&
ordered->file_offset < last_pos) { ordered->file_offset < last_pos) {
@ -1237,9 +1237,8 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
} }
ret = btrfs_log_dentry_safe(trans, root, file->f_dentry); ret = btrfs_log_dentry_safe(trans, root, file->f_dentry);
if (ret < 0) { if (ret < 0)
goto out; goto out;
}
/* we've logged all the items and now have a consistent /* we've logged all the items and now have a consistent
* version of the file in the log. It is possible that * version of the file in the log. It is possible that

View file

@ -213,10 +213,13 @@ static int __btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
info->offset = offset; info->offset = offset;
info->bytes += bytes; info->bytes += bytes;
} else if (right_info && right_info->offset != offset+bytes) { } else if (right_info && right_info->offset != offset+bytes) {
printk(KERN_ERR "adding space in the middle of an existing " printk(KERN_ERR "btrfs adding space in the middle of an "
"free space area. existing: offset=%Lu, bytes=%Lu. " "existing free space area. existing: "
"new: offset=%Lu, bytes=%Lu\n", right_info->offset, "offset=%llu, bytes=%llu. new: offset=%llu, "
right_info->bytes, offset, bytes); "bytes=%llu\n", (unsigned long long)right_info->offset,
(unsigned long long)right_info->bytes,
(unsigned long long)offset,
(unsigned long long)bytes);
BUG(); BUG();
} }
@ -225,11 +228,14 @@ static int __btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
if (unlikely((left_info->offset + left_info->bytes) != if (unlikely((left_info->offset + left_info->bytes) !=
offset)) { offset)) {
printk(KERN_ERR "free space to the left of new free " printk(KERN_ERR "btrfs free space to the left "
"space isn't quite right. existing: offset=%Lu," "of new free space isn't "
" bytes=%Lu. new: offset=%Lu, bytes=%Lu\n", "quite right. existing: offset=%llu, "
left_info->offset, left_info->bytes, offset, "bytes=%llu. new: offset=%llu, bytes=%llu\n",
bytes); (unsigned long long)left_info->offset,
(unsigned long long)left_info->bytes,
(unsigned long long)offset,
(unsigned long long)bytes);
BUG(); BUG();
} }
@ -265,7 +271,6 @@ out:
BUG(); BUG();
} }
if (alloc_info)
kfree(alloc_info); kfree(alloc_info);
return ret; return ret;
@ -283,9 +288,11 @@ __btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
if (info && info->offset == offset) { if (info && info->offset == offset) {
if (info->bytes < bytes) { if (info->bytes < bytes) {
printk(KERN_ERR "Found free space at %Lu, size %Lu," printk(KERN_ERR "Found free space at %llu, size %llu,"
"trying to use %Lu\n", "trying to use %llu\n",
info->offset, info->bytes, bytes); (unsigned long long)info->offset,
(unsigned long long)info->bytes,
(unsigned long long)bytes);
WARN_ON(1); WARN_ON(1);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
@ -401,8 +408,6 @@ void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,
info = rb_entry(n, struct btrfs_free_space, offset_index); info = rb_entry(n, struct btrfs_free_space, offset_index);
if (info->bytes >= bytes) if (info->bytes >= bytes)
count++; count++;
//printk(KERN_INFO "offset=%Lu, bytes=%Lu\n", info->offset,
// info->bytes);
} }
printk(KERN_INFO "%d blocks of free space at or bigger than bytes is" printk(KERN_INFO "%d blocks of free space at or bigger than bytes is"
"\n", count); "\n", count);

View file

@ -129,7 +129,6 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
last_ino = key.objectid + 1; last_ino = key.objectid + 1;
path->slots[0]++; path->slots[0]++;
} }
// FIXME -ENOSPC
BUG_ON(1); BUG_ON(1);
found: found:
btrfs_release_path(root, path); btrfs_release_path(root, path);

View file

@ -124,7 +124,7 @@ int btrfs_check_free_space(struct btrfs_root *root, u64 num_required,
* the btree. The caller should have done a btrfs_drop_extents so that * the btree. The caller should have done a btrfs_drop_extents so that
* no overlapping inline items exist in the btree * no overlapping inline items exist in the btree
*/ */
static int noinline insert_inline_extent(struct btrfs_trans_handle *trans, static noinline int insert_inline_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode, struct btrfs_root *root, struct inode *inode,
u64 start, size_t size, size_t compressed_size, u64 start, size_t size, size_t compressed_size,
struct page **compressed_pages) struct page **compressed_pages)
@ -148,7 +148,8 @@ static int noinline insert_inline_extent(struct btrfs_trans_handle *trans,
cur_size = compressed_size; cur_size = compressed_size;
} }
path = btrfs_alloc_path(); if (!path) path = btrfs_alloc_path();
if (!path)
return -ENOMEM; return -ENOMEM;
btrfs_set_trans_block_group(trans, inode); btrfs_set_trans_block_group(trans, inode);
@ -165,7 +166,6 @@ static int noinline insert_inline_extent(struct btrfs_trans_handle *trans,
BUG_ON(ret); BUG_ON(ret);
if (ret) { if (ret) {
err = ret; err = ret;
printk("got bad ret %d\n", ret);
goto fail; goto fail;
} }
leaf = path->nodes[0]; leaf = path->nodes[0];
@ -519,7 +519,6 @@ free_pages_out:
WARN_ON(pages[i]->mapping); WARN_ON(pages[i]->mapping);
page_cache_release(pages[i]); page_cache_release(pages[i]);
} }
if (pages)
kfree(pages); kfree(pages);
goto out; goto out;
@ -562,8 +561,8 @@ static noinline int submit_compressed_extents(struct inode *inode,
unsigned long nr_written = 0; unsigned long nr_written = 0;
lock_extent(io_tree, async_extent->start, lock_extent(io_tree, async_extent->start,
async_extent->start + async_extent->ram_size - 1, async_extent->start +
GFP_NOFS); async_extent->ram_size - 1, GFP_NOFS);
/* allocate blocks */ /* allocate blocks */
cow_file_range(inode, async_cow->locked_page, cow_file_range(inode, async_cow->locked_page,
@ -740,9 +739,8 @@ static noinline int cow_file_range(struct inode *inode,
ret = btrfs_reserve_extent(trans, root, cur_alloc_size, ret = btrfs_reserve_extent(trans, root, cur_alloc_size,
root->sectorsize, 0, alloc_hint, root->sectorsize, 0, alloc_hint,
(u64)-1, &ins, 1); (u64)-1, &ins, 1);
if (ret) { BUG_ON(ret);
BUG();
}
em = alloc_extent_map(GFP_NOFS); em = alloc_extent_map(GFP_NOFS);
em->start = start; em->start = start;
em->orig_start = em->start; em->orig_start = em->start;
@ -779,11 +777,9 @@ static noinline int cow_file_range(struct inode *inode,
BUG_ON(ret); BUG_ON(ret);
} }
if (disk_num_bytes < cur_alloc_size) { if (disk_num_bytes < cur_alloc_size)
printk("num_bytes %Lu cur_alloc %Lu\n", disk_num_bytes,
cur_alloc_size);
break; break;
}
/* we're not doing compressed IO, don't unlock the first /* we're not doing compressed IO, don't unlock the first
* page (which the caller expects to stay locked), don't * page (which the caller expects to stay locked), don't
* clear any dirty bits and don't set any writeback bits * clear any dirty bits and don't set any writeback bits
@ -842,10 +838,9 @@ static noinline void async_cow_submit(struct btrfs_work *work)
waitqueue_active(&root->fs_info->async_submit_wait)) waitqueue_active(&root->fs_info->async_submit_wait))
wake_up(&root->fs_info->async_submit_wait); wake_up(&root->fs_info->async_submit_wait);
if (async_cow->inode) { if (async_cow->inode)
submit_compressed_extents(async_cow->inode, async_cow); submit_compressed_extents(async_cow->inode, async_cow);
} }
}
static noinline void async_cow_free(struct btrfs_work *work) static noinline void async_cow_free(struct btrfs_work *work)
{ {
@ -918,7 +913,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
return 0; return 0;
} }
static int noinline csum_exist_in_range(struct btrfs_root *root, static noinline int csum_exist_in_range(struct btrfs_root *root,
u64 bytenr, u64 num_bytes) u64 bytenr, u64 num_bytes)
{ {
int ret; int ret;
@ -1200,8 +1195,11 @@ static int btrfs_clear_bit_hook(struct inode *inode, u64 start, u64 end,
spin_lock(&root->fs_info->delalloc_lock); spin_lock(&root->fs_info->delalloc_lock);
if (end - start + 1 > root->fs_info->delalloc_bytes) { if (end - start + 1 > root->fs_info->delalloc_bytes) {
printk("warning: delalloc account %Lu %Lu\n", printk(KERN_INFO "btrfs warning: delalloc account "
end - start + 1, root->fs_info->delalloc_bytes); "%llu %llu\n",
(unsigned long long)end - start + 1,
(unsigned long long)
root->fs_info->delalloc_bytes);
root->fs_info->delalloc_bytes = 0; root->fs_info->delalloc_bytes = 0;
BTRFS_I(inode)->delalloc_bytes = 0; BTRFS_I(inode)->delalloc_bytes = 0;
} else { } else {
@ -1241,9 +1239,8 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
ret = btrfs_map_block(map_tree, READ, logical, ret = btrfs_map_block(map_tree, READ, logical,
&map_length, NULL, 0); &map_length, NULL, 0);
if (map_length < length + size) { if (map_length < length + size)
return 1; return 1;
}
return 0; return 0;
} }
@ -1255,8 +1252,9 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
* At IO completion time the cums attached on the ordered extent record * At IO completion time the cums attached on the ordered extent record
* are inserted into the btree * are inserted into the btree
*/ */
static int __btrfs_submit_bio_start(struct inode *inode, int rw, struct bio *bio, static int __btrfs_submit_bio_start(struct inode *inode, int rw,
int mirror_num, unsigned long bio_flags) struct bio *bio, int mirror_num,
unsigned long bio_flags)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
int ret = 0; int ret = 0;
@ -1341,9 +1339,8 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end) int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end)
{ {
if ((end & (PAGE_CACHE_SIZE - 1)) == 0) { if ((end & (PAGE_CACHE_SIZE - 1)) == 0)
WARN_ON(1); WARN_ON(1);
}
return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end, return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end,
GFP_NOFS); GFP_NOFS);
} }
@ -1755,14 +1752,14 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
} }
local_irq_save(flags); local_irq_save(flags);
kaddr = kmap_atomic(page, KM_IRQ0); kaddr = kmap_atomic(page, KM_IRQ0);
if (ret) { if (ret)
goto zeroit; goto zeroit;
}
csum = btrfs_csum_data(root, kaddr + offset, csum, end - start + 1); csum = btrfs_csum_data(root, kaddr + offset, csum, end - start + 1);
btrfs_csum_final(csum, (char *)&csum); btrfs_csum_final(csum, (char *)&csum);
if (csum != private) { if (csum != private)
goto zeroit; goto zeroit;
}
kunmap_atomic(kaddr, KM_IRQ0); kunmap_atomic(kaddr, KM_IRQ0);
local_irq_restore(flags); local_irq_restore(flags);
good: good:
@ -1773,9 +1770,10 @@ good:
return 0; return 0;
zeroit: zeroit:
printk("btrfs csum failed ino %lu off %llu csum %u private %Lu\n", printk(KERN_INFO "btrfs csum failed ino %lu off %llu csum %u "
page->mapping->host->i_ino, (unsigned long long)start, csum, "private %llu\n", page->mapping->host->i_ino,
private); (unsigned long long)start, csum,
(unsigned long long)private);
memset(kaddr + offset, 1, end - start + 1); memset(kaddr + offset, 1, end - start + 1);
flush_dcache_page(page); flush_dcache_page(page);
kunmap_atomic(kaddr, KM_IRQ0); kunmap_atomic(kaddr, KM_IRQ0);
@ -2097,9 +2095,8 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
/* /*
* copy everything in the in-memory inode into the btree. * copy everything in the in-memory inode into the btree.
*/ */
int noinline btrfs_update_inode(struct btrfs_trans_handle *trans, noinline int btrfs_update_inode(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root, struct inode *inode)
struct inode *inode)
{ {
struct btrfs_inode_item *inode_item; struct btrfs_inode_item *inode_item;
struct btrfs_path *path; struct btrfs_path *path;
@ -2174,7 +2171,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
inode->i_ino, inode->i_ino,
dir->i_ino, &index); dir->i_ino, &index);
if (ret) { if (ret) {
printk("failed to delete reference to %.*s, " printk(KERN_INFO "btrfs failed to delete reference to %.*s, "
"inode %lu parent %lu\n", name_len, name, "inode %lu parent %lu\n", name_len, name,
inode->i_ino, dir->i_ino); inode->i_ino, dir->i_ino);
goto err; goto err;
@ -2280,9 +2277,8 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
/* now the directory is empty */ /* now the directory is empty */
err = btrfs_unlink_inode(trans, root, dir, dentry->d_inode, err = btrfs_unlink_inode(trans, root, dir, dentry->d_inode,
dentry->d_name.name, dentry->d_name.len); dentry->d_name.name, dentry->d_name.len);
if (!err) { if (!err)
btrfs_i_size_write(inode, 0); btrfs_i_size_write(inode, 0);
}
fail_trans: fail_trans:
nr = trans->blocks_used; nr = trans->blocks_used;
@ -2516,9 +2512,9 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
search_again: search_again:
ret = btrfs_search_slot(trans, root, &key, path, -1, 1); ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
if (ret < 0) { if (ret < 0)
goto error; goto error;
}
if (ret > 0) { if (ret > 0) {
/* there are no items in the tree for us to truncate, we're /* there are no items in the tree for us to truncate, we're
* done * done
@ -2562,19 +2558,18 @@ search_again:
item_end--; item_end--;
} }
if (item_end < new_size) { if (item_end < new_size) {
if (found_type == BTRFS_DIR_ITEM_KEY) { if (found_type == BTRFS_DIR_ITEM_KEY)
found_type = BTRFS_INODE_ITEM_KEY; found_type = BTRFS_INODE_ITEM_KEY;
} else if (found_type == BTRFS_EXTENT_ITEM_KEY) { else if (found_type == BTRFS_EXTENT_ITEM_KEY)
found_type = BTRFS_EXTENT_DATA_KEY; found_type = BTRFS_EXTENT_DATA_KEY;
} else if (found_type == BTRFS_EXTENT_DATA_KEY) { else if (found_type == BTRFS_EXTENT_DATA_KEY)
found_type = BTRFS_XATTR_ITEM_KEY; found_type = BTRFS_XATTR_ITEM_KEY;
} else if (found_type == BTRFS_XATTR_ITEM_KEY) { else if (found_type == BTRFS_XATTR_ITEM_KEY)
found_type = BTRFS_INODE_REF_KEY; found_type = BTRFS_INODE_REF_KEY;
} else if (found_type) { else if (found_type)
found_type--; found_type--;
} else { else
break; break;
}
btrfs_set_key_type(&key, found_type); btrfs_set_key_type(&key, found_type);
goto next; goto next;
} }
@ -2656,7 +2651,7 @@ delete:
pending_del_nr++; pending_del_nr++;
pending_del_slot = path->slots[0]; pending_del_slot = path->slots[0];
} else { } else {
printk("bad pending slot %d pending_del_nr %d pending_del_slot %d\n", path->slots[0], pending_del_nr, pending_del_slot); BUG();
} }
} else { } else {
break; break;
@ -2938,9 +2933,10 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
namelen, 0); namelen, 0);
if (IS_ERR(di)) if (IS_ERR(di))
ret = PTR_ERR(di); ret = PTR_ERR(di);
if (!di || IS_ERR(di)) {
if (!di || IS_ERR(di))
goto out_err; goto out_err;
}
btrfs_dir_item_key_to_cpu(path->nodes[0], di, location); btrfs_dir_item_key_to_cpu(path->nodes[0], di, location);
out: out:
btrfs_free_path(path); btrfs_free_path(path);
@ -3020,8 +3016,8 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p)
static int btrfs_find_actor(struct inode *inode, void *opaque) static int btrfs_find_actor(struct inode *inode, void *opaque)
{ {
struct btrfs_iget_args *args = opaque; struct btrfs_iget_args *args = opaque;
return (args->ino == inode->i_ino && return args->ino == inode->i_ino &&
args->root == BTRFS_I(inode)->root); args->root == BTRFS_I(inode)->root;
} }
struct inode *btrfs_ilookup(struct super_block *s, u64 objectid, struct inode *btrfs_ilookup(struct super_block *s, u64 objectid,
@ -3385,10 +3381,9 @@ int btrfs_set_inode_index(struct inode *dir, u64 *index)
if (BTRFS_I(dir)->index_cnt == (u64)-1) { if (BTRFS_I(dir)->index_cnt == (u64)-1) {
ret = btrfs_set_inode_index_count(dir); ret = btrfs_set_inode_index_count(dir);
if (ret) { if (ret)
return ret; return ret;
} }
}
*index = BTRFS_I(dir)->index_cnt; *index = BTRFS_I(dir)->index_cnt;
BTRFS_I(dir)->index_cnt++; BTRFS_I(dir)->index_cnt++;
@ -3879,12 +3874,13 @@ static noinline int uncompress_inline(struct btrfs_path *path,
/* /*
* a bit scary, this does extent mapping from logical file offset to the disk. * a bit scary, this does extent mapping from logical file offset to the disk.
* the ugly parts come from merging extents from the disk with the * the ugly parts come from merging extents from the disk with the in-ram
* in-ram representation. This gets more complex because of the data=ordered code, * representation. This gets more complex because of the data=ordered code,
* where the in-ram extents might be locked pending data=ordered completion. * where the in-ram extents might be locked pending data=ordered completion.
* *
* This also copies inline extents directly into the page. * This also copies inline extents directly into the page.
*/ */
struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page, struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
size_t pg_offset, u64 start, u64 len, size_t pg_offset, u64 start, u64 len,
int create) int create)
@ -4081,7 +4077,7 @@ again:
extent_map_end(em) - 1, GFP_NOFS); extent_map_end(em) - 1, GFP_NOFS);
goto insert; goto insert;
} else { } else {
printk("unkknown found_type %d\n", found_type); printk(KERN_ERR "btrfs unknown found_type %d\n", found_type);
WARN_ON(1); WARN_ON(1);
} }
not_found: not_found:
@ -4093,7 +4089,11 @@ not_found_em:
insert: insert:
btrfs_release_path(root, path); btrfs_release_path(root, path);
if (em->start > start || extent_map_end(em) <= start) { if (em->start > start || extent_map_end(em) <= start) {
printk("bad extent! em: [%Lu %Lu] passed [%Lu %Lu]\n", em->start, em->len, start, len); printk(KERN_ERR "Btrfs: bad extent! em: [%llu %llu] passed "
"[%llu %llu]\n", (unsigned long long)em->start,
(unsigned long long)em->len,
(unsigned long long)start,
(unsigned long long)len);
err = -EIO; err = -EIO;
goto out; goto out;
} }
@ -4130,8 +4130,6 @@ insert:
} }
} else { } else {
err = -EIO; err = -EIO;
printk("failing to insert %Lu %Lu\n",
start, len);
free_extent_map(em); free_extent_map(em);
em = NULL; em = NULL;
} }
@ -4147,10 +4145,9 @@ out:
btrfs_free_path(path); btrfs_free_path(path);
if (trans) { if (trans) {
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans, root);
if (!err) { if (!err)
err = ret; err = ret;
} }
}
if (err) { if (err) {
free_extent_map(em); free_extent_map(em);
WARN_ON(1); WARN_ON(1);
@ -4487,8 +4484,10 @@ void btrfs_destroy_inode(struct inode *inode)
if (!ordered) if (!ordered)
break; break;
else { else {
printk("found ordered extent %Lu %Lu\n", printk(KERN_ERR "btrfs found ordered "
ordered->file_offset, ordered->len); "extent %llu %llu on inode cleanup\n",
(unsigned long long)ordered->file_offset,
(unsigned long long)ordered->len);
btrfs_remove_ordered_extent(inode, ordered); btrfs_remove_ordered_extent(inode, ordered);
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);

View file

@ -319,7 +319,8 @@ static noinline int btrfs_mksubvol(struct path *parent, char *name,
break; break;
} }
if (S_ISLNK(test->d_inode->i_mode)) { if (S_ISLNK(test->d_inode->i_mode)) {
printk("Symlink in snapshot path, failed\n"); printk(KERN_INFO "Btrfs symlink in snapshot "
"path, failed\n");
error = -EMLINK; error = -EMLINK;
btrfs_free_path(path); btrfs_free_path(path);
goto out_drop_write; goto out_drop_write;
@ -329,7 +330,8 @@ static noinline int btrfs_mksubvol(struct path *parent, char *name,
ret = btrfs_find_root_ref(snap_src->fs_info->tree_root, ret = btrfs_find_root_ref(snap_src->fs_info->tree_root,
path, test_oid, parent_oid); path, test_oid, parent_oid);
if (ret == 0) { if (ret == 0) {
printk("Snapshot creation failed, looping\n"); printk(KERN_INFO "Btrfs snapshot creation "
"failed, looping\n");
error = -EMLINK; error = -EMLINK;
btrfs_free_path(path); btrfs_free_path(path);
goto out_drop_write; goto out_drop_write;
@ -617,7 +619,8 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
src_inode = src_file->f_path.dentry->d_inode; src_inode = src_file->f_path.dentry->d_inode;
if (src_inode->i_sb != file->f_path.dentry->d_inode->i_sb) { if (src_inode->i_sb != file->f_path.dentry->d_inode->i_sb) {
printk("btrfs: Snapshot src from another FS\n"); printk(KERN_INFO "btrfs: Snapshot src from "
"another FS\n");
ret = -EINVAL; ret = -EINVAL;
fput(src_file); fput(src_file);
goto out; goto out;
@ -810,9 +813,6 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
((off + len) & (bs-1))) ((off + len) & (bs-1)))
goto out_unlock; goto out_unlock;
printk("final src extent is %llu~%llu\n", off, len);
printk("final dst extent is %llu~%llu\n", destoff, len);
/* do any pending delalloc/csum calc on src, one way or /* do any pending delalloc/csum calc on src, one way or
another, and lock file content */ another, and lock file content */
while (1) { while (1) {
@ -883,10 +883,13 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
comp = btrfs_file_extent_compression(leaf, extent); comp = btrfs_file_extent_compression(leaf, extent);
type = btrfs_file_extent_type(leaf, extent); type = btrfs_file_extent_type(leaf, extent);
if (type == BTRFS_FILE_EXTENT_REG) { if (type == BTRFS_FILE_EXTENT_REG) {
disko = btrfs_file_extent_disk_bytenr(leaf, extent); disko = btrfs_file_extent_disk_bytenr(leaf,
diskl = btrfs_file_extent_disk_num_bytes(leaf, extent); extent);
diskl = btrfs_file_extent_disk_num_bytes(leaf,
extent);
datao = btrfs_file_extent_offset(leaf, extent); datao = btrfs_file_extent_offset(leaf, extent);
datal = btrfs_file_extent_num_bytes(leaf, extent); datal = btrfs_file_extent_num_bytes(leaf,
extent);
} else if (type == BTRFS_FILE_EXTENT_INLINE) { } else if (type == BTRFS_FILE_EXTENT_INLINE) {
/* take upper bound, may be compressed */ /* take upper bound, may be compressed */
datal = btrfs_file_extent_ram_bytes(leaf, datal = btrfs_file_extent_ram_bytes(leaf,
@ -916,8 +919,6 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
extent = btrfs_item_ptr(leaf, slot, extent = btrfs_item_ptr(leaf, slot,
struct btrfs_file_extent_item); struct btrfs_file_extent_item);
printk(" orig disk %llu~%llu data %llu~%llu\n",
disko, diskl, datao, datal);
if (off > key.offset) { if (off > key.offset) {
datao += off - key.offset; datao += off - key.offset;
@ -929,8 +930,6 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
/* disko == 0 means it's a hole */ /* disko == 0 means it's a hole */
if (!disko) if (!disko)
datao = 0; datao = 0;
printk(" final disk %llu~%llu data %llu~%llu\n",
disko, diskl, datao, datal);
btrfs_set_file_extent_offset(leaf, extent, btrfs_set_file_extent_offset(leaf, extent,
datao); datao);
@ -952,12 +951,11 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
skip = off - key.offset; skip = off - key.offset;
new_key.offset += skip; new_key.offset += skip;
} }
if (key.offset + datal > off+len) if (key.offset + datal > off+len)
trim = key.offset + datal - (off+len); trim = key.offset + datal - (off+len);
printk("len %lld skip %lld trim %lld\n",
datal, skip, trim);
if (comp && (skip || trim)) { if (comp && (skip || trim)) {
printk("btrfs clone_range can't split compressed inline extents yet\n");
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
@ -969,7 +967,8 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
goto out; goto out;
if (skip) { if (skip) {
u32 start = btrfs_file_extent_calc_inline_size(0); u32 start =
btrfs_file_extent_calc_inline_size(0);
memmove(buf+start, buf+start+skip, memmove(buf+start, buf+start+skip,
datal); datal);
} }

View file

@ -31,9 +31,10 @@
* difference in almost every workload, but spinning for the right amount of * difference in almost every workload, but spinning for the right amount of
* time needs some help. * time needs some help.
* *
* In general, we want to spin as long as the lock holder is doing btree searches, * In general, we want to spin as long as the lock holder is doing btree
* and we should give up if they are in more expensive code. * searches, and we should give up if they are in more expensive code.
*/ */
int btrfs_tree_lock(struct extent_buffer *eb) int btrfs_tree_lock(struct extent_buffer *eb)
{ {
int i; int i;

View file

@ -193,10 +193,8 @@ int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
node = tree_insert(&tree->tree, file_offset, node = tree_insert(&tree->tree, file_offset,
&entry->rb_node); &entry->rb_node);
if (node) { BUG_ON(node);
printk("warning dup entry from add_ordered_extent\n");
BUG();
}
set_extent_ordered(&BTRFS_I(inode)->io_tree, file_offset, set_extent_ordered(&BTRFS_I(inode)->io_tree, file_offset,
entry_end(entry) - 1, GFP_NOFS); entry_end(entry) - 1, GFP_NOFS);
@ -434,9 +432,8 @@ again:
end = orig_end; end = orig_end;
while (1) { while (1) {
ordered = btrfs_lookup_first_ordered_extent(inode, end); ordered = btrfs_lookup_first_ordered_extent(inode, end);
if (!ordered) { if (!ordered)
break; break;
}
if (ordered->file_offset > orig_end) { if (ordered->file_offset > orig_end) {
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
break; break;
@ -581,9 +578,8 @@ int btrfs_ordered_update_i_size(struct inode *inode,
* between our ordered extent and the next one. * between our ordered extent and the next one.
*/ */
test = rb_entry(node, struct btrfs_ordered_extent, rb_node); test = rb_entry(node, struct btrfs_ordered_extent, rb_node);
if (test->file_offset > entry_end(ordered)) { if (test->file_offset > entry_end(ordered))
i_size_test = test->file_offset; i_size_test = test->file_offset;
}
} else { } else {
i_size_test = i_size_read(inode); i_size_test = i_size_read(inode);
} }

View file

@ -24,13 +24,14 @@ static void print_chunk(struct extent_buffer *eb, struct btrfs_chunk *chunk)
{ {
int num_stripes = btrfs_chunk_num_stripes(eb, chunk); int num_stripes = btrfs_chunk_num_stripes(eb, chunk);
int i; int i;
printk("\t\tchunk length %llu owner %llu type %llu num_stripes %d\n", printk(KERN_INFO "\t\tchunk length %llu owner %llu type %llu "
"num_stripes %d\n",
(unsigned long long)btrfs_chunk_length(eb, chunk), (unsigned long long)btrfs_chunk_length(eb, chunk),
(unsigned long long)btrfs_chunk_owner(eb, chunk), (unsigned long long)btrfs_chunk_owner(eb, chunk),
(unsigned long long)btrfs_chunk_type(eb, chunk), (unsigned long long)btrfs_chunk_type(eb, chunk),
num_stripes); num_stripes);
for (i = 0 ; i < num_stripes ; i++) { for (i = 0 ; i < num_stripes ; i++) {
printk("\t\t\tstripe %d devid %llu offset %llu\n", i, printk(KERN_INFO "\t\t\tstripe %d devid %llu offset %llu\n", i,
(unsigned long long)btrfs_stripe_devid_nr(eb, chunk, i), (unsigned long long)btrfs_stripe_devid_nr(eb, chunk, i),
(unsigned long long)btrfs_stripe_offset_nr(eb, chunk, i)); (unsigned long long)btrfs_stripe_offset_nr(eb, chunk, i));
} }
@ -38,8 +39,8 @@ static void print_chunk(struct extent_buffer *eb, struct btrfs_chunk *chunk)
static void print_dev_item(struct extent_buffer *eb, static void print_dev_item(struct extent_buffer *eb,
struct btrfs_dev_item *dev_item) struct btrfs_dev_item *dev_item)
{ {
printk("\t\tdev item devid %llu " printk(KERN_INFO "\t\tdev item devid %llu "
"total_bytes %llu bytes used %Lu\n", "total_bytes %llu bytes used %llu\n",
(unsigned long long)btrfs_device_id(eb, dev_item), (unsigned long long)btrfs_device_id(eb, dev_item),
(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));
@ -61,14 +62,15 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
struct btrfs_dev_extent *dev_extent; struct btrfs_dev_extent *dev_extent;
u32 type; u32 type;
printk("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,
btrfs_leaf_free_space(root, l)); btrfs_leaf_free_space(root, l));
for (i = 0 ; i < nr ; i++) { for (i = 0 ; i < nr ; i++) {
item = btrfs_item_nr(l, i); item = btrfs_item_nr(l, i);
btrfs_item_key_to_cpu(l, &key, i); btrfs_item_key_to_cpu(l, &key, i);
type = btrfs_key_type(&key); type = btrfs_key_type(&key);
printk("\titem %d key (%llu %x %llu) itemoff %d itemsize %d\n", printk(KERN_INFO "\titem %d key (%llu %x %llu) itemoff %d "
"itemsize %d\n",
i, i,
(unsigned long long)key.objectid, type, (unsigned long long)key.objectid, type,
(unsigned long long)key.offset, (unsigned long long)key.offset,
@ -76,33 +78,36 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
switch (type) { switch (type) {
case BTRFS_INODE_ITEM_KEY: case BTRFS_INODE_ITEM_KEY:
ii = btrfs_item_ptr(l, i, struct btrfs_inode_item); ii = btrfs_item_ptr(l, i, struct btrfs_inode_item);
printk("\t\tinode generation %llu size %llu mode %o\n", printk(KERN_INFO "\t\tinode generation %llu size %llu "
(unsigned long long)btrfs_inode_generation(l, ii), "mode %o\n",
(unsigned long long)
btrfs_inode_generation(l, ii),
(unsigned long long)btrfs_inode_size(l, ii), (unsigned long long)btrfs_inode_size(l, ii),
btrfs_inode_mode(l, ii)); btrfs_inode_mode(l, ii));
break; break;
case BTRFS_DIR_ITEM_KEY: case BTRFS_DIR_ITEM_KEY:
di = btrfs_item_ptr(l, i, struct btrfs_dir_item); di = btrfs_item_ptr(l, i, struct btrfs_dir_item);
btrfs_dir_item_key_to_cpu(l, di, &found_key); btrfs_dir_item_key_to_cpu(l, di, &found_key);
printk("\t\tdir oid %llu type %u\n", printk(KERN_INFO "\t\tdir oid %llu type %u\n",
(unsigned long long)found_key.objectid, (unsigned long long)found_key.objectid,
btrfs_dir_type(l, di)); btrfs_dir_type(l, di));
break; break;
case BTRFS_ROOT_ITEM_KEY: case BTRFS_ROOT_ITEM_KEY:
ri = btrfs_item_ptr(l, i, struct btrfs_root_item); ri = btrfs_item_ptr(l, i, struct btrfs_root_item);
printk("\t\troot data bytenr %llu refs %u\n", printk(KERN_INFO "\t\troot data bytenr %llu refs %u\n",
(unsigned long long)btrfs_disk_root_bytenr(l, ri), (unsigned long long)
btrfs_disk_root_bytenr(l, ri),
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); ei = btrfs_item_ptr(l, i, struct btrfs_extent_item);
printk("\t\textent data refs %u\n", printk(KERN_INFO "\t\textent data refs %u\n",
btrfs_extent_refs(l, ei)); btrfs_extent_refs(l, ei));
break; break;
case BTRFS_EXTENT_REF_KEY: case BTRFS_EXTENT_REF_KEY:
ref = btrfs_item_ptr(l, i, struct btrfs_extent_ref); ref = btrfs_item_ptr(l, i, struct btrfs_extent_ref);
printk("\t\textent back ref root %llu gen %llu " printk(KERN_INFO "\t\textent back ref root %llu "
"owner %llu num_refs %lu\n", "gen %llu owner %llu num_refs %lu\n",
(unsigned long long)btrfs_ref_root(l, ref), (unsigned long long)btrfs_ref_root(l, ref),
(unsigned long long)btrfs_ref_generation(l, ref), (unsigned long long)btrfs_ref_generation(l, ref),
(unsigned long long)btrfs_ref_objectid(l, ref), (unsigned long long)btrfs_ref_objectid(l, ref),
@ -114,26 +119,36 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
struct btrfs_file_extent_item); struct btrfs_file_extent_item);
if (btrfs_file_extent_type(l, fi) == if (btrfs_file_extent_type(l, fi) ==
BTRFS_FILE_EXTENT_INLINE) { BTRFS_FILE_EXTENT_INLINE) {
printk("\t\tinline extent data size %u\n", printk(KERN_INFO "\t\tinline extent data "
"size %u\n",
btrfs_file_extent_inline_len(l, fi)); btrfs_file_extent_inline_len(l, fi));
break; break;
} }
printk("\t\textent data disk bytenr %llu nr %llu\n", printk(KERN_INFO "\t\textent data disk bytenr %llu "
(unsigned long long)btrfs_file_extent_disk_bytenr(l, fi), "nr %llu\n",
(unsigned long long)btrfs_file_extent_disk_num_bytes(l, fi)); (unsigned long long)
printk("\t\textent data offset %llu nr %llu ram %llu\n", btrfs_file_extent_disk_bytenr(l, fi),
(unsigned long long)btrfs_file_extent_offset(l, fi), (unsigned long long)
(unsigned long long)btrfs_file_extent_num_bytes(l, fi), btrfs_file_extent_disk_num_bytes(l, fi));
(unsigned long long)btrfs_file_extent_ram_bytes(l, fi)); printk(KERN_INFO "\t\textent data offset %llu "
"nr %llu ram %llu\n",
(unsigned long long)
btrfs_file_extent_offset(l, fi),
(unsigned long long)
btrfs_file_extent_num_bytes(l, fi),
(unsigned long long)
btrfs_file_extent_ram_bytes(l, fi));
break; break;
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);
printk("\t\tblock group used %llu\n", printk(KERN_INFO "\t\tblock group used %llu\n",
(unsigned long long)btrfs_disk_block_group_used(l, bi)); (unsigned long long)
btrfs_disk_block_group_used(l, bi));
break; break;
case BTRFS_CHUNK_ITEM_KEY: case BTRFS_CHUNK_ITEM_KEY:
print_chunk(l, btrfs_item_ptr(l, i, struct btrfs_chunk)); print_chunk(l, btrfs_item_ptr(l, i,
struct btrfs_chunk));
break; break;
case BTRFS_DEV_ITEM_KEY: case BTRFS_DEV_ITEM_KEY:
print_dev_item(l, btrfs_item_ptr(l, i, print_dev_item(l, btrfs_item_ptr(l, i,
@ -142,7 +157,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
case BTRFS_DEV_EXTENT_KEY: case BTRFS_DEV_EXTENT_KEY:
dev_extent = btrfs_item_ptr(l, i, dev_extent = btrfs_item_ptr(l, i,
struct btrfs_dev_extent); struct btrfs_dev_extent);
printk("\t\tdev extent chunk_tree %llu\n" printk(KERN_INFO "\t\tdev extent chunk_tree %llu\n"
"\t\tchunk objectid %llu chunk offset %llu " "\t\tchunk objectid %llu chunk offset %llu "
"length %llu\n", "length %llu\n",
(unsigned long long) (unsigned long long)
@ -171,13 +186,13 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
btrfs_print_leaf(root, c); btrfs_print_leaf(root, c);
return; return;
} }
printk("node %llu level %d total ptrs %d free spc %u\n", printk(KERN_INFO "node %llu level %d total ptrs %d free spc %u\n",
(unsigned long long)btrfs_header_bytenr(c), (unsigned long long)btrfs_header_bytenr(c),
btrfs_header_level(c), nr, btrfs_header_level(c), nr,
(u32)BTRFS_NODEPTRS_PER_BLOCK(root) - nr); (u32)BTRFS_NODEPTRS_PER_BLOCK(root) - nr);
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
btrfs_node_key_to_cpu(c, &key, i); btrfs_node_key_to_cpu(c, &key, i);
printk("\tkey %d (%llu %u %llu) block %llu\n", printk(KERN_INFO "\tkey %d (%llu %u %llu) block %llu\n",
i, i,
(unsigned long long)key.objectid, (unsigned long long)key.objectid,
key.type, key.type,

View file

@ -132,8 +132,9 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
if (ret != 0) { if (ret != 0) {
btrfs_print_leaf(root, path->nodes[0]); btrfs_print_leaf(root, path->nodes[0]);
printk("unable to update root key %Lu %u %Lu\n", printk(KERN_CRIT "unable to update root key %llu %u %llu\n",
key->objectid, key->type, key->offset); (unsigned long long)key->objectid, key->type,
(unsigned long long)key->offset);
BUG_ON(1); BUG_ON(1);
} }
@ -159,9 +160,9 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
/* /*
* at mount time we want to find all the old transaction snapshots that were in * at mount time we want to find all the old transaction snapshots that were in
* the process of being deleted if we crashed. This is any root item with an offset * the process of being deleted if we crashed. This is any root item with an
* lower than the latest root. They need to be queued for deletion to finish * offset lower than the latest root. They need to be queued for deletion to
* 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 *latest)
@ -258,11 +259,7 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
ret = btrfs_search_slot(trans, root, key, path, -1, 1); ret = btrfs_search_slot(trans, root, key, path, -1, 1);
if (ret < 0) if (ret < 0)
goto out; goto out;
if (ret) {
btrfs_print_leaf(root, path->nodes[0]);
printk("failed to del %Lu %u %Lu\n", key->objectid, key->type, key->offset);
}
BUG_ON(ret != 0); BUG_ON(ret != 0);
leaf = path->nodes[0]; leaf = path->nodes[0];
ri = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_item); ri = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_item);

View file

@ -61,12 +61,6 @@ static void btrfs_put_super (struct super_block * sb)
int ret; int ret;
ret = close_ctree(root); ret = close_ctree(root);
if (ret) {
printk("close ctree returns %d\n", ret);
}
#if 0
btrfs_sysfs_del_super(root->fs_info);
#endif
sb->s_fs_info = NULL; sb->s_fs_info = NULL;
} }
@ -479,8 +473,10 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
root = dget(s->s_root); root = dget(s->s_root);
else { else {
mutex_lock(&s->s_root->d_inode->i_mutex); mutex_lock(&s->s_root->d_inode->i_mutex);
root = lookup_one_len(subvol_name, s->s_root, strlen(subvol_name)); root = lookup_one_len(subvol_name, s->s_root,
strlen(subvol_name));
mutex_unlock(&s->s_root->d_inode->i_mutex); mutex_unlock(&s->s_root->d_inode->i_mutex);
if (IS_ERR(root)) { if (IS_ERR(root)) {
up_write(&s->s_umount); up_write(&s->s_umount);
deactivate_super(s); deactivate_super(s);
@ -557,6 +553,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_bavail = buf->f_bfree; buf->f_bavail = buf->f_bfree;
buf->f_bsize = dentry->d_sb->s_blocksize; buf->f_bsize = dentry->d_sb->s_blocksize;
buf->f_type = BTRFS_SUPER_MAGIC; buf->f_type = BTRFS_SUPER_MAGIC;
/* We treat it as constant endianness (it doesn't matter _which_) /* We treat it as constant endianness (it doesn't matter _which_)
because we want the fsid to come out the same whether mounted because we want the fsid to come out the same whether mounted
on a big-endian or little-endian host */ on a big-endian or little-endian host */
@ -658,7 +655,7 @@ static int btrfs_interface_init(void)
static void btrfs_interface_exit(void) static void btrfs_interface_exit(void)
{ {
if (misc_deregister(&btrfs_misc) < 0) if (misc_deregister(&btrfs_misc) < 0)
printk("misc_deregister failed for control device"); printk(KERN_INFO "misc_deregister failed for control device");
} }
static int __init init_btrfs_fs(void) static int __init init_btrfs_fs(void)

View file

@ -67,7 +67,8 @@ struct btrfs_root_attr {
}; };
#define ROOT_ATTR(name, mode, show, store) \ #define ROOT_ATTR(name, mode, show, store) \
static struct btrfs_root_attr btrfs_root_attr_##name = __ATTR(name, mode, show, store) static struct btrfs_root_attr btrfs_root_attr_##name = __ATTR(name, mode, \
show, store)
ROOT_ATTR(blocks_used, 0444, root_blocks_used_show, NULL); ROOT_ATTR(blocks_used, 0444, root_blocks_used_show, NULL);
ROOT_ATTR(block_limit, 0644, root_block_limit_show, NULL); ROOT_ATTR(block_limit, 0644, root_block_limit_show, NULL);
@ -86,7 +87,8 @@ struct btrfs_super_attr {
}; };
#define SUPER_ATTR(name, mode, show, store) \ #define SUPER_ATTR(name, mode, show, store) \
static struct btrfs_super_attr btrfs_super_attr_##name = __ATTR(name, mode, show, store) static struct btrfs_super_attr btrfs_super_attr_##name = __ATTR(name, mode, \
show, store)
SUPER_ATTR(blocks_used, 0444, super_blocks_used_show, NULL); SUPER_ATTR(blocks_used, 0444, super_blocks_used_show, NULL);
SUPER_ATTR(total_blocks, 0444, super_total_blocks_show, NULL); SUPER_ATTR(total_blocks, 0444, super_total_blocks_show, NULL);

View file

@ -28,9 +28,6 @@
#include "ref-cache.h" #include "ref-cache.h"
#include "tree-log.h" #include "tree-log.h"
extern struct kmem_cache *btrfs_trans_handle_cachep;
extern struct kmem_cache *btrfs_transaction_cachep;
#define BTRFS_ROOT_TRANS_TAG 0 #define BTRFS_ROOT_TRANS_TAG 0
static noinline void put_transaction(struct btrfs_transaction *transaction) static noinline void put_transaction(struct btrfs_transaction *transaction)
@ -85,10 +82,10 @@ static noinline int join_transaction(struct btrfs_root *root)
} }
/* /*
* this does all the record keeping required to make sure that a * this does all the record keeping required to make sure that a reference
* reference counted root is properly recorded in a given transaction. * counted root is properly recorded in a given transaction. This is required
* This is required to make sure the old root from before we joined the transaction * to make sure the old root from before we joined the transaction is deleted
* is deleted when the transaction commits * when the transaction commits
*/ */
noinline int btrfs_record_root_in_trans(struct btrfs_root *root) noinline int btrfs_record_root_in_trans(struct btrfs_root *root)
{ {
@ -228,8 +225,8 @@ static noinline int wait_for_commit(struct btrfs_root *root,
} }
/* /*
* rate limit against the drop_snapshot code. This helps to slow down new operations * rate limit against the drop_snapshot code. This helps to slow down new
* if the drop_snapshot code isn't able to keep up. * operations if the drop_snapshot code isn't able to keep up.
*/ */
static void throttle_on_drops(struct btrfs_root *root) static void throttle_on_drops(struct btrfs_root *root)
{ {
@ -667,9 +664,8 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root,
trans = btrfs_start_transaction(tree_root, 1); trans = btrfs_start_transaction(tree_root, 1);
mutex_lock(&root->fs_info->drop_mutex); mutex_lock(&root->fs_info->drop_mutex);
ret = btrfs_drop_snapshot(trans, dirty->root); ret = btrfs_drop_snapshot(trans, dirty->root);
if (ret != -EAGAIN) { if (ret != -EAGAIN)
break; break;
}
mutex_unlock(&root->fs_info->drop_mutex); mutex_unlock(&root->fs_info->drop_mutex);
err = btrfs_update_root(trans, err = btrfs_update_root(trans,
@ -1076,9 +1072,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
kmem_cache_free(btrfs_trans_handle_cachep, trans); kmem_cache_free(btrfs_trans_handle_cachep, trans);
if (root->fs_info->closing) { if (root->fs_info->closing)
drop_dirty_roots(root->fs_info->tree_root, &dirty_fs_roots); drop_dirty_roots(root->fs_info->tree_root, &dirty_fs_roots);
}
return ret; return ret;
} }

View file

@ -66,8 +66,8 @@ static inline void btrfs_set_trans_block_group(struct btrfs_trans_handle *trans,
trans->block_group = BTRFS_I(inode)->block_group; trans->block_group = BTRFS_I(inode)->block_group;
} }
static inline void btrfs_update_inode_block_group(struct static inline void btrfs_update_inode_block_group(
btrfs_trans_handle *trans, struct btrfs_trans_handle *trans,
struct inode *inode) struct inode *inode)
{ {
BTRFS_I(inode)->block_group = trans->block_group; BTRFS_I(inode)->block_group = trans->block_group;

View file

@ -23,10 +23,11 @@
#include "transaction.h" #include "transaction.h"
#include "locking.h" #include "locking.h"
/* defrag all the leaves in a given btree. If cache_only == 1, don't read things /* defrag all the leaves in a given btree. If cache_only == 1, don't read
* from disk, otherwise read all the leaves and try to get key order to * things from disk, otherwise read all the leaves and try to get key order to
* better reflect disk order * better reflect disk order
*/ */
int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
struct btrfs_root *root, int cache_only) struct btrfs_root *root, int cache_only)
{ {
@ -65,9 +66,9 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
level = btrfs_header_level(root->node); level = btrfs_header_level(root->node);
orig_level = level; orig_level = level;
if (level == 0) { if (level == 0)
goto out; goto out;
}
if (root->defrag_progress.objectid == 0) { if (root->defrag_progress.objectid == 0) {
struct extent_buffer *root_node; struct extent_buffer *root_node;
u32 nritems; u32 nritems;

View file

@ -938,9 +938,8 @@ static noinline int replay_one_csum(struct btrfs_trans_handle *trans,
file_bytes = (item_size / csum_size) * root->sectorsize; file_bytes = (item_size / csum_size) * root->sectorsize;
sums = kzalloc(btrfs_ordered_sum_size(root, file_bytes), GFP_NOFS); sums = kzalloc(btrfs_ordered_sum_size(root, file_bytes), GFP_NOFS);
if (!sums) { if (!sums)
return -ENOMEM; return -ENOMEM;
}
INIT_LIST_HEAD(&sums->list); INIT_LIST_HEAD(&sums->list);
sums->len = file_bytes; sums->len = file_bytes;
@ -1206,8 +1205,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
if (key->type == BTRFS_DIR_ITEM_KEY) { if (key->type == BTRFS_DIR_ITEM_KEY) {
dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid, dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,
name, name_len, 1); name, name_len, 1);
} } else if (key->type == BTRFS_DIR_INDEX_KEY) {
else if (key->type == BTRFS_DIR_INDEX_KEY) {
dst_di = btrfs_lookup_dir_index_item(trans, root, path, dst_di = btrfs_lookup_dir_index_item(trans, root, path,
key->objectid, key->objectid,
key->offset, name, key->offset, name,
@ -1676,7 +1674,7 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb,
return 0; return 0;
} }
static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans, static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, int *level, struct btrfs_path *path, int *level,
struct walk_control *wc) struct walk_control *wc)
@ -1753,11 +1751,11 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans,
WARN_ON(*level < 0); WARN_ON(*level < 0);
WARN_ON(*level >= BTRFS_MAX_LEVEL); WARN_ON(*level >= BTRFS_MAX_LEVEL);
if (path->nodes[*level] == root->node) { if (path->nodes[*level] == root->node)
parent = path->nodes[*level]; parent = path->nodes[*level];
} else { else
parent = path->nodes[*level + 1]; parent = path->nodes[*level + 1];
}
bytenr = path->nodes[*level]->start; bytenr = path->nodes[*level]->start;
blocksize = btrfs_level_size(root, *level); blocksize = btrfs_level_size(root, *level);
@ -1790,7 +1788,7 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans,
return 0; return 0;
} }
static int noinline walk_up_log_tree(struct btrfs_trans_handle *trans, static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_path *path, int *level, struct btrfs_path *path, int *level,
struct walk_control *wc) struct walk_control *wc)
@ -2287,10 +2285,9 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
struct btrfs_key tmp; struct btrfs_key tmp;
btrfs_item_key_to_cpu(path->nodes[0], &tmp, btrfs_item_key_to_cpu(path->nodes[0], &tmp,
path->slots[0]); path->slots[0]);
if (key_type == tmp.type) { if (key_type == tmp.type)
first_offset = max(min_offset, tmp.offset) + 1; first_offset = max(min_offset, tmp.offset) + 1;
} }
}
goto done; goto done;
} }
@ -2496,7 +2493,8 @@ static noinline int copy_extent_csums(struct btrfs_trans_handle *trans,
if (ret == -ENOENT || ret == -EFBIG) if (ret == -ENOENT || ret == -EFBIG)
ret = 0; ret = 0;
sum = 0; sum = 0;
printk("log no csum found for byte %llu\n", printk(KERN_INFO "log no csum found for "
"byte %llu\n",
(unsigned long long)disk_bytenr); (unsigned long long)disk_bytenr);
item = NULL; item = NULL;
btrfs_release_path(root, path); btrfs_release_path(root, path);

View file

@ -140,7 +140,7 @@ static noinline struct btrfs_fs_devices *find_fsid(u8 *fsid)
* the list if the block device is congested. This way, multiple devices * the list if the block device is congested. This way, multiple devices
* can make progress from a single worker thread. * can make progress from a single worker thread.
*/ */
static int noinline run_scheduled_bios(struct btrfs_device *device) static noinline int run_scheduled_bios(struct btrfs_device *device)
{ {
struct bio *pending; struct bio *pending;
struct backing_dev_info *bdi; struct backing_dev_info *bdi;
@ -458,7 +458,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
bdev = open_bdev_exclusive(device->name, flags, holder); bdev = open_bdev_exclusive(device->name, flags, holder);
if (IS_ERR(bdev)) { if (IS_ERR(bdev)) {
printk("open %s failed\n", device->name); printk(KERN_INFO "open %s failed\n", device->name);
goto error; goto error;
} }
set_blocksize(bdev, 4096); set_blocksize(bdev, 4096);
@ -570,14 +570,15 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
devid = le64_to_cpu(disk_super->dev_item.devid); devid = le64_to_cpu(disk_super->dev_item.devid);
transid = btrfs_super_generation(disk_super); transid = btrfs_super_generation(disk_super);
if (disk_super->label[0]) if (disk_super->label[0])
printk("device label %s ", disk_super->label); printk(KERN_INFO "device label %s ", disk_super->label);
else { else {
/* FIXME, make a readl uuid parser */ /* FIXME, make a readl uuid parser */
printk("device fsid %llx-%llx ", printk(KERN_INFO "device fsid %llx-%llx ",
*(unsigned long long *)disk_super->fsid, *(unsigned long long *)disk_super->fsid,
*(unsigned long long *)(disk_super->fsid + 8)); *(unsigned long long *)(disk_super->fsid + 8));
} }
printk("devid %Lu transid %Lu %s\n", devid, transid, path); printk(KERN_INFO "devid %llu transid %llu %s\n",
(unsigned long long)devid, (unsigned long long)transid, path);
ret = device_list_add(path, disk_super, devid, fs_devices_ret); ret = device_list_add(path, disk_super, devid, fs_devices_ret);
brelse(bh); brelse(bh);
@ -683,9 +684,8 @@ no_more_items:
goto check_pending; goto check_pending;
} }
} }
if (btrfs_key_type(&key) != BTRFS_DEV_EXTENT_KEY) { if (btrfs_key_type(&key) != BTRFS_DEV_EXTENT_KEY)
goto next; goto next;
}
start_found = 1; start_found = 1;
dev_extent = btrfs_item_ptr(l, slot, struct btrfs_dev_extent); dev_extent = btrfs_item_ptr(l, slot, struct btrfs_dev_extent);
@ -1001,14 +1001,16 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) &&
root->fs_info->fs_devices->rw_devices <= 4) { root->fs_info->fs_devices->rw_devices <= 4) {
printk("btrfs: unable to go below four devices on raid10\n"); printk(KERN_ERR "btrfs: unable to go below four devices "
"on raid10\n");
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) &&
root->fs_info->fs_devices->rw_devices <= 2) { root->fs_info->fs_devices->rw_devices <= 2) {
printk("btrfs: unable to go below two devices on raid1\n"); printk(KERN_ERR "btrfs: unable to go below two "
"devices on raid1\n");
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
@ -1031,7 +1033,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
bh = NULL; bh = NULL;
disk_super = NULL; disk_super = NULL;
if (!device) { if (!device) {
printk("btrfs: no missing devices found to remove\n"); printk(KERN_ERR "btrfs: no missing devices found to "
"remove\n");
goto out; goto out;
} }
} else { } else {
@ -1060,7 +1063,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
} }
if (device->writeable && root->fs_info->fs_devices->rw_devices == 1) { if (device->writeable && root->fs_info->fs_devices->rw_devices == 1) {
printk("btrfs: unable to remove the only writeable device\n"); printk(KERN_ERR "btrfs: unable to remove the only writeable "
"device\n");
ret = -EINVAL; ret = -EINVAL;
goto error_brelse; goto error_brelse;
} }
@ -1286,9 +1290,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
return -EINVAL; return -EINVAL;
bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder); bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder);
if (!bdev) { if (!bdev)
return -EIO; return -EIO;
}
if (root->fs_info->fs_devices->seeding) { if (root->fs_info->fs_devices->seeding) {
seeding_dev = 1; seeding_dev = 1;
@ -1401,7 +1404,7 @@ error:
goto out; goto out;
} }
static int noinline btrfs_update_device(struct btrfs_trans_handle *trans, static noinline int btrfs_update_device(struct btrfs_trans_handle *trans,
struct btrfs_device *device) struct btrfs_device *device)
{ {
int ret; int ret;
@ -1563,7 +1566,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
int ret; int ret;
int i; int i;
printk("btrfs relocating chunk %llu\n", printk(KERN_INFO "btrfs relocating chunk %llu\n",
(unsigned long long)chunk_offset); (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;
@ -1916,7 +1919,7 @@ static int btrfs_add_system_chunk(struct btrfs_trans_handle *trans,
return 0; return 0;
} }
static u64 noinline chunk_bytes_by_type(u64 type, u64 calc_size, static noinline u64 chunk_bytes_by_type(u64 type, u64 calc_size,
int num_stripes, int sub_stripes) int num_stripes, int sub_stripes)
{ {
if (type & (BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_DUP)) if (type & (BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_DUP))
@ -2242,7 +2245,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
return 0; return 0;
} }
static int noinline init_first_rw_device(struct btrfs_trans_handle *trans, static noinline int init_first_rw_device(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct btrfs_device *device) struct btrfs_device *device)
{ {
@ -2413,9 +2416,8 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
int max_errors = 0; int max_errors = 0;
struct btrfs_multi_bio *multi = NULL; struct btrfs_multi_bio *multi = NULL;
if (multi_ret && !(rw & (1 << BIO_RW))) { if (multi_ret && !(rw & (1 << BIO_RW)))
stripes_allocated = 1; stripes_allocated = 1;
}
again: again:
if (multi_ret) { if (multi_ret) {
multi = kzalloc(btrfs_multi_bio_size(stripes_allocated), multi = kzalloc(btrfs_multi_bio_size(stripes_allocated),
@ -2434,7 +2436,9 @@ again:
return 0; return 0;
if (!em) { if (!em) {
printk("unable to find logical %Lu len %Lu\n", logical, *length); printk(KERN_CRIT "unable to find logical %llu len %llu\n",
(unsigned long long)logical,
(unsigned long long)*length);
BUG(); BUG();
} }
@ -2541,10 +2545,9 @@ again:
device = map->stripes[stripe_index].dev; device = map->stripes[stripe_index].dev;
if (device->bdev) { if (device->bdev) {
bdi = blk_get_backing_dev_info(device->bdev); bdi = blk_get_backing_dev_info(device->bdev);
if (bdi->unplug_io_fn) { if (bdi->unplug_io_fn)
bdi->unplug_io_fn(bdi, unplug_page); bdi->unplug_io_fn(bdi, unplug_page);
} }
}
} else { } else {
multi->stripes[i].physical = multi->stripes[i].physical =
map->stripes[stripe_index].physical + map->stripes[stripe_index].physical +
@ -2717,7 +2720,7 @@ struct async_sched {
* This will add one bio to the pending list for a device and make sure * This will add one bio to the pending list for a device and make sure
* the work struct is scheduled. * the work struct is scheduled.
*/ */
static int noinline schedule_bio(struct btrfs_root *root, static noinline int schedule_bio(struct btrfs_root *root,
struct btrfs_device *device, struct btrfs_device *device,
int rw, struct bio *bio) int rw, struct bio *bio)
{ {
@ -2785,8 +2788,10 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
total_devs = multi->num_stripes; total_devs = multi->num_stripes;
if (map_length < length) { if (map_length < length) {
printk("mapping failed logical %Lu bio len %Lu " printk(KERN_CRIT "mapping failed logical %llu bio len %llu "
"len %Lu\n", logical, length, map_length); "len %llu\n", (unsigned long long)logical,
(unsigned long long)length,
(unsigned long long)map_length);
BUG(); BUG();
} }
multi->end_io = first_bio->bi_end_io; multi->end_io = first_bio->bi_end_io;
@ -3058,7 +3063,8 @@ static int read_one_dev(struct btrfs_root *root,
return -EIO; return -EIO;
if (!device) { if (!device) {
printk("warning devid %Lu missing\n", devid); printk(KERN_WARNING "warning devid %llu missing\n",
(unsigned long long)devid);
device = add_missing_dev(root, devid, dev_uuid); device = add_missing_dev(root, devid, dev_uuid);
if (!device) if (!device)
return -ENOMEM; return -ENOMEM;
@ -3078,12 +3084,6 @@ static int read_one_dev(struct btrfs_root *root,
if (device->writeable) if (device->writeable)
device->fs_devices->total_rw_bytes += device->total_bytes; device->fs_devices->total_rw_bytes += device->total_bytes;
ret = 0; ret = 0;
#if 0
ret = btrfs_open_device(device);
if (ret) {
kfree(device);
}
#endif
return ret; return ret;
} }

View file

@ -264,7 +264,8 @@ struct xattr_handler *btrfs_xattr_handlers[] = {
*/ */
static bool btrfs_is_valid_xattr(const char *name) static bool btrfs_is_valid_xattr(const char *name)
{ {
return !strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) || return !strncmp(name, XATTR_SECURITY_PREFIX,
XATTR_SECURITY_PREFIX_LEN) ||
!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN) || !strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN) ||
!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) || !strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) ||
!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); !strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);

View file

@ -399,10 +399,8 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
} }
while (workspace->inf_strm.total_in < srclen) { while (workspace->inf_strm.total_in < srclen) {
ret = zlib_inflate(&workspace->inf_strm, Z_NO_FLUSH); ret = zlib_inflate(&workspace->inf_strm, Z_NO_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) { if (ret != Z_OK && ret != Z_STREAM_END)
break; break;
}
/* /*
* buf start is the byte offset we're of the start of * buf start is the byte offset we're of the start of
* our workspace buffer * our workspace buffer
@ -424,16 +422,14 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
/* we didn't make progress in this inflate /* we didn't make progress in this inflate
* call, we're done * call, we're done
*/ */
if (ret != Z_STREAM_END) { if (ret != Z_STREAM_END)
ret = -1; ret = -1;
}
break; break;
} }
/* we haven't yet hit data corresponding to this page */ /* we haven't yet hit data corresponding to this page */
if (total_out <= start_byte) { if (total_out <= start_byte)
goto next; goto next;
}
/* /*
* the start of the data we care about is offset into * the start of the data we care about is offset into
@ -471,6 +467,7 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
ret = 0; ret = 0;
goto done; goto done;
} }
page_out = bvec[page_out_index].bv_page; page_out = bvec[page_out_index].bv_page;
pg_offset = 0; pg_offset = 0;
page_bytes_left = PAGE_CACHE_SIZE; page_bytes_left = PAGE_CACHE_SIZE;
@ -480,9 +477,8 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
* make sure our new page is covered by this * make sure our new page is covered by this
* working buffer * working buffer
*/ */
if (total_out <= start_byte) { if (total_out <= start_byte)
goto next; goto next;
}
/* the next page in the biovec might not /* the next page in the biovec might not
* be adjacent to the last page, but it * be adjacent to the last page, but it
@ -517,11 +513,10 @@ next:
PAGE_CACHE_SIZE); PAGE_CACHE_SIZE);
} }
} }
if (ret != Z_STREAM_END) { if (ret != Z_STREAM_END)
ret = -1; ret = -1;
} else { else
ret = 0; ret = 0;
}
done: done:
zlib_inflateEnd(&workspace->inf_strm); zlib_inflateEnd(&workspace->inf_strm);
if (data_in) if (data_in)
@ -586,9 +581,8 @@ int btrfs_zlib_decompress(unsigned char *data_in,
unsigned long pg_offset = 0; unsigned long pg_offset = 0;
ret = zlib_inflate(&workspace->inf_strm, Z_NO_FLUSH); ret = zlib_inflate(&workspace->inf_strm, Z_NO_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) { if (ret != Z_OK && ret != Z_STREAM_END)
break; break;
}
buf_start = total_out; buf_start = total_out;
total_out = workspace->inf_strm.total_out; total_out = workspace->inf_strm.total_out;
@ -598,15 +592,13 @@ int btrfs_zlib_decompress(unsigned char *data_in,
break; break;
} }
if (total_out <= start_byte) { if (total_out <= start_byte)
goto next; goto next;
}
if (total_out > start_byte && buf_start < start_byte) { if (total_out > start_byte && buf_start < start_byte)
buf_offset = start_byte - buf_start; buf_offset = start_byte - buf_start;
} else { else
buf_offset = 0; buf_offset = 0;
}
bytes = min(PAGE_CACHE_SIZE - pg_offset, bytes = min(PAGE_CACHE_SIZE - pg_offset,
PAGE_CACHE_SIZE - buf_offset); PAGE_CACHE_SIZE - buf_offset);
@ -622,11 +614,12 @@ next:
workspace->inf_strm.next_out = workspace->buf; workspace->inf_strm.next_out = workspace->buf;
workspace->inf_strm.avail_out = PAGE_CACHE_SIZE; workspace->inf_strm.avail_out = PAGE_CACHE_SIZE;
} }
if (ret != Z_STREAM_END && bytes_left != 0) {
if (ret != Z_STREAM_END && bytes_left != 0)
ret = -1; ret = -1;
} else { else
ret = 0; ret = 0;
}
zlib_inflateEnd(&workspace->inf_strm); zlib_inflateEnd(&workspace->inf_strm);
out: out:
free_workspace(workspace); free_workspace(workspace);