Commit d397712b authored by Chris Mason's avatar Chris Mason

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: default avatarChris Mason <chris.mason@oracle.com>
parent 1f3c79a2
...@@ -161,8 +161,7 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) ...@@ -161,8 +161,7 @@ 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)
btrfs_update_cached_acl(inode, p_acl, acl); btrfs_update_cached_acl(inode, p_acl, acl);
...@@ -213,7 +212,7 @@ static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name, ...@@ -213,7 +212,7 @@ static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name,
} }
static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name, static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name,
const void *value, size_t size, int flags) const void *value, size_t size, int flags)
{ {
return btrfs_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); return btrfs_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
} }
......
...@@ -104,7 +104,7 @@ static noinline int run_ordered_completions(struct btrfs_workers *workers, ...@@ -104,7 +104,7 @@ static noinline int run_ordered_completions(struct btrfs_workers *workers,
spin_lock_irqsave(&workers->lock, flags); spin_lock_irqsave(&workers->lock, flags);
while(!list_empty(&workers->order_list)) { while (!list_empty(&workers->order_list)) {
work = list_entry(workers->order_list.next, work = list_entry(workers->order_list.next,
struct btrfs_work, order_list); struct btrfs_work, order_list);
...@@ -143,7 +143,7 @@ static int worker_loop(void *arg) ...@@ -143,7 +143,7 @@ static int worker_loop(void *arg)
struct btrfs_work *work; struct btrfs_work *work;
do { do {
spin_lock_irq(&worker->lock); spin_lock_irq(&worker->lock);
while(!list_empty(&worker->pending)) { while (!list_empty(&worker->pending)) {
cur = worker->pending.next; cur = worker->pending.next;
work = list_entry(cur, struct btrfs_work, list); work = list_entry(cur, struct btrfs_work, list);
list_del(&work->list); list_del(&work->list);
...@@ -188,7 +188,7 @@ int btrfs_stop_workers(struct btrfs_workers *workers) ...@@ -188,7 +188,7 @@ int btrfs_stop_workers(struct btrfs_workers *workers)
struct btrfs_worker_thread *worker; struct btrfs_worker_thread *worker;
list_splice_init(&workers->idle_list, &workers->worker_list); list_splice_init(&workers->idle_list, &workers->worker_list);
while(!list_empty(&workers->worker_list)) { while (!list_empty(&workers->worker_list)) {
cur = workers->worker_list.next; cur = workers->worker_list.next;
worker = list_entry(cur, struct btrfs_worker_thread, worker = list_entry(cur, struct btrfs_worker_thread,
worker_list); worker_list);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#define btrfs_drop_nlink(inode) drop_nlink(inode) #define btrfs_drop_nlink(inode) drop_nlink(inode)
#define btrfs_inc_nlink(inode) inc_nlink(inode) #define btrfs_inc_nlink(inode) inc_nlink(inode)
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 27)
static inline struct dentry *d_obtain_alias(struct inode *inode) static inline struct dentry *d_obtain_alias(struct inode *inode)
{ {
struct dentry *d; struct dentry *d;
...@@ -21,7 +21,7 @@ static inline struct dentry *d_obtain_alias(struct inode *inode) ...@@ -21,7 +21,7 @@ static inline struct dentry *d_obtain_alias(struct inode *inode)
} }
#endif #endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
# define __pagevec_lru_add_file __pagevec_lru_add # define __pagevec_lru_add_file __pagevec_lru_add
# define open_bdev_exclusive open_bdev_excl # define open_bdev_exclusive open_bdev_excl
# define close_bdev_exclusive(bdev, mode) close_bdev_excl(bdev) # define close_bdev_exclusive(bdev, mode) close_bdev_excl(bdev)
......
...@@ -137,7 +137,8 @@ static int check_compressed_csum(struct inode *inode, ...@@ -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);
...@@ -217,7 +218,7 @@ static void end_compressed_bio_read(struct bio *bio, int err) ...@@ -217,7 +218,7 @@ static void end_compressed_bio_read(struct bio *bio, int err)
* we have verified the checksum already, set page * we have verified the checksum already, set page
* checked so the end_io handlers know about it * checked so the end_io handlers know about it
*/ */
while(bio_index < cb->orig_bio->bi_vcnt) { while (bio_index < cb->orig_bio->bi_vcnt) {
SetPageChecked(bvec->bv_page); SetPageChecked(bvec->bv_page);
bvec++; bvec++;
bio_index++; bio_index++;
...@@ -246,7 +247,7 @@ static noinline int end_compressed_writeback(struct inode *inode, u64 start, ...@@ -246,7 +247,7 @@ static noinline int end_compressed_writeback(struct inode *inode, u64 start,
int i; int i;
int ret; int ret;
while(nr_pages > 0) { while (nr_pages > 0) {
ret = find_get_pages_contig(inode->i_mapping, index, ret = find_get_pages_contig(inode->i_mapping, index,
min_t(unsigned long, min_t(unsigned long,
nr_pages, ARRAY_SIZE(pages)), pages); nr_pages, ARRAY_SIZE(pages)), pages);
...@@ -463,7 +464,7 @@ static noinline int add_ra_bio_pages(struct inode *inode, ...@@ -463,7 +464,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
end_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT; end_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT;
pagevec_init(&pvec, 0); pagevec_init(&pvec, 0);
while(last_offset < compressed_end) { while (last_offset < compressed_end) {
page_index = last_offset >> PAGE_CACHE_SHIFT; page_index = last_offset >> PAGE_CACHE_SHIFT;
if (page_index > end_index) if (page_index > end_index)
...@@ -697,9 +698,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -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);
......
This diff is collapsed.
...@@ -126,7 +126,6 @@ struct btrfs_ordered_sum; ...@@ -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
...@@ -283,8 +282,8 @@ struct btrfs_header { ...@@ -283,8 +282,8 @@ struct btrfs_header {
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \ #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \
sizeof(struct btrfs_header)) / \ sizeof(struct btrfs_header)) / \
sizeof(struct btrfs_key_ptr)) sizeof(struct btrfs_key_ptr))
#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize)) #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize))
#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
...@@ -1512,7 +1511,7 @@ static inline struct btrfs_header *btrfs_buffer_header(struct extent_buffer *eb) ...@@ -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) ...@@ -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,20 +1659,20 @@ static inline int btrfs_set_root_name(struct btrfs_root *root, ...@@ -1660,20 +1659,20 @@ 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);
if (!root->name) if (!root->name)
return -ENOMEM; return -ENOMEM;
memcpy(root->name, name, len); memcpy(root->name, name, len);
root->name[len] ='\0'; root->name[len] = '\0';
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,9 +1706,9 @@ int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans, ...@@ -1707,9 +1706,9 @@ 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);
struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
...@@ -1908,8 +1907,9 @@ int btrfs_search_root(struct btrfs_root *root, u64 search_start, ...@@ -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,
......
...@@ -333,7 +333,7 @@ struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, ...@@ -333,7 +333,7 @@ struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
leaf = path->nodes[0]; leaf = path->nodes[0];
dir_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dir_item); dir_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dir_item);
total_len = btrfs_item_size_nr(leaf, path->slots[0]); total_len = btrfs_item_size_nr(leaf, path->slots[0]);
while(cur < total_len) { while (cur < total_len) {
this_len = sizeof(*dir_item) + this_len = sizeof(*dir_item) +
btrfs_dir_name_len(leaf, dir_item) + btrfs_dir_name_len(leaf, dir_item) +
btrfs_dir_data_len(leaf, dir_item); btrfs_dir_data_len(leaf, dir_item);
......
This diff is collapsed.
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
#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_ROOT (sizeof(struct btrfs_fid)/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)
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,
int connectable) int connectable)
......
This diff is collapsed.
This diff is collapsed.
...@@ -89,11 +89,11 @@ EXPORT_SYMBOL(free_extent_map); ...@@ -89,11 +89,11 @@ EXPORT_SYMBOL(free_extent_map);
static struct rb_node *tree_insert(struct rb_root *root, u64 offset, static struct rb_node *tree_insert(struct rb_root *root, u64 offset,
struct rb_node *node) struct rb_node *node)
{ {
struct rb_node ** p = &root->rb_node; struct rb_node **p = &root->rb_node;
struct rb_node * parent = NULL; struct rb_node *parent = NULL;
struct extent_map *entry; struct extent_map *entry;
while(*p) { while (*p) {
parent = *p; parent = *p;
entry = rb_entry(parent, struct extent_map, rb_node); entry = rb_entry(parent, struct extent_map, rb_node);
...@@ -122,13 +122,13 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset, ...@@ -122,13 +122,13 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
struct rb_node **prev_ret, struct rb_node **prev_ret,
struct rb_node **next_ret) struct rb_node **next_ret)
{ {
struct rb_node * n = root->rb_node; struct rb_node *n = root->rb_node;
struct rb_node *prev = NULL; struct rb_node *prev = NULL;
struct rb_node *orig_prev = NULL; struct rb_node *orig_prev = NULL;
struct extent_map *entry; struct extent_map *entry;
struct extent_map *prev_entry = NULL; struct extent_map *prev_entry = NULL;
while(n) { while (n) {
entry = rb_entry(n, struct extent_map, rb_node); entry = rb_entry(n, struct extent_map, rb_node);
prev = n; prev = n;
prev_entry = entry; prev_entry = entry;
...@@ -145,7 +145,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset, ...@@ -145,7 +145,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
if (prev_ret) { if (prev_ret) {
orig_prev = prev; orig_prev = prev;
while(prev && offset >= extent_map_end(prev_entry)) { while (prev && offset >= extent_map_end(prev_entry)) {
prev = rb_next(prev); prev = rb_next(prev);
prev_entry = rb_entry(prev, struct extent_map, rb_node); prev_entry = rb_entry(prev, struct extent_map, rb_node);
} }
...@@ -155,7 +155,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset, ...@@ -155,7 +155,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
if (next_ret) { if (next_ret) {
prev_entry = rb_entry(prev, struct extent_map, rb_node); prev_entry = rb_entry(prev, struct extent_map, rb_node);
while(prev && offset < prev_entry->start) { while (prev && offset < prev_entry->start) {
prev = rb_prev(prev); prev = rb_prev(prev);
prev_entry = rb_entry(prev, struct extent_map, rb_node); prev_entry = rb_entry(prev, struct extent_map, rb_node);
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "transaction.h" #include "transaction.h"
#include "print-tree.h" #include "print-tree.h"
#define MAX_CSUM_ITEMS(r,size) ((((BTRFS_LEAF_DATA_SIZE(r) - \ #define MAX_CSUM_ITEMS(r, size) ((((BTRFS_LEAF_DATA_SIZE(r) - \
sizeof(struct btrfs_item) * 2) / \ sizeof(struct btrfs_item) * 2) / \
size) - 1)) size) - 1))
int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
...@@ -166,7 +166,7 @@ int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode, ...@@ -166,7 +166,7 @@ int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
WARN_ON(bio->bi_vcnt <= 0); WARN_ON(bio->bi_vcnt <= 0);
disk_bytenr = (u64)bio->bi_sector << 9; disk_bytenr = (u64)bio->bi_sector << 9;
while(bio_index < bio->bi_vcnt) { while (bio_index < bio->bi_vcnt) {
offset = page_offset(bvec->bv_page) + bvec->bv_offset; offset = page_offset(bvec->bv_page) + bvec->bv_offset;
ret = btrfs_find_ordered_sum(inode, offset, disk_bytenr, &sum); ret = btrfs_find_ordered_sum(inode, offset, disk_bytenr, &sum);
if (ret == 0) if (ret == 0)
...@@ -192,8 +192,9 @@ int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode, ...@@ -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;
...@@ -373,7 +374,7 @@ int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode, ...@@ -373,7 +374,7 @@ int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
BUG_ON(!ordered); BUG_ON(!ordered);
sums->bytenr = ordered->start; sums->bytenr = ordered->start;
while(bio_index < bio->bi_vcnt) { while (bio_index < bio->bi_vcnt) {
if (!contig) if (!contig)
offset = page_offset(bvec->bv_page) + bvec->bv_offset; offset = page_offset(bvec->bv_page) + bvec->bv_offset;
...@@ -507,7 +508,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, ...@@ -507,7 +508,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path(); path = btrfs_alloc_path();
while(1) { while (1) {
key.objectid = BTRFS_EXTENT_CSUM_OBJECTID; key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
key.offset = end_byte - 1; key.offset = end_byte - 1;
key.type = BTRFS_EXTENT_CSUM_KEY; key.type = BTRFS_EXTENT_CSUM_KEY;
...@@ -715,9 +716,8 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, ...@@ -715,9 +716,8 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
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);
...@@ -732,7 +732,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, ...@@ -732,7 +732,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
u64 next_sector = sector_sum->bytenr; u64 next_sector = sector_sum->bytenr;
struct btrfs_sector_sum *next = sector_sum + 1; struct btrfs_sector_sum *next = sector_sum + 1;
while(tmp < sums->len) { while (tmp < sums->len) {
if (next_sector + root->sectorsize != next->bytenr) if (next_sector + root->sectorsize != next->bytenr)
break; break;
tmp += root->sectorsize; tmp += root->sectorsize;
......
...@@ -44,10 +44,10 @@ ...@@ -44,10 +44,10 @@
/* 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)
{ {
long page_fault = 0; long page_fault = 0;
int i; int i;
...@@ -78,7 +78,7 @@ static int noinline btrfs_copy_from_user(loff_t pos, int num_pages, ...@@ -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) ...@@ -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, ...@@ -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
...@@ -185,7 +182,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, ...@@ -185,7 +182,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
len = (u64)-1; len = (u64)-1;
testend = 0; testend = 0;
} }
while(1) { while (1) {
if (!split) if (!split)
split = alloc_extent_map(GFP_NOFS); split = alloc_extent_map(GFP_NOFS);
if (!split2) if (!split2)
...@@ -295,7 +292,7 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) ...@@ -295,7 +292,7 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode)
path = btrfs_alloc_path(); path = btrfs_alloc_path();
ret = btrfs_lookup_file_extent(NULL, root, path, inode->i_ino, ret = btrfs_lookup_file_extent(NULL, root, path, inode->i_ino,
last_offset, 0); last_offset, 0);
while(1) { while (1) {
nritems = btrfs_header_nritems(path->nodes[0]); nritems = btrfs_header_nritems(path->nodes[0]);
if (path->slots[0] >= nritems) { if (path->slots[0] >= nritems) {
ret = btrfs_next_leaf(root, path); ret = btrfs_next_leaf(root, path);
...@@ -314,8 +311,10 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) ...@@ -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;
} }
...@@ -331,7 +330,7 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) ...@@ -331,7 +330,7 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode)
extent_end = found_key.offset + extent_end = found_key.offset +
btrfs_file_extent_inline_len(leaf, extent); btrfs_file_extent_inline_len(leaf, extent);
extent_end = (extent_end + root->sectorsize - 1) & extent_end = (extent_end + root->sectorsize - 1) &
~((u64)root->sectorsize -1 ); ~((u64)root->sectorsize - 1);
} }
last_offset = extent_end; last_offset = extent_end;
path->slots[0]++; path->slots[0]++;
...@@ -339,8 +338,9 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) ...@@ -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 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) ...@@ -362,7 +362,7 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode)
* 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)
{ {
...@@ -398,7 +398,7 @@ int noinline btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -398,7 +398,7 @@ int noinline btrfs_drop_extents(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
while(1) { while (1) {
recow = 0; recow = 0;
btrfs_release_path(root, path); btrfs_release_path(root, path);
ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino,
...@@ -649,16 +649,15 @@ int noinline btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -649,16 +649,15 @@ int noinline btrfs_drop_extents(struct btrfs_trans_handle *trans,
if (disk_bytenr != 0) { if (disk_bytenr != 0) {
ret = btrfs_update_extent_ref(trans, root, ret = btrfs_update_extent_ref(trans, root,
disk_bytenr, orig_parent, disk_bytenr, orig_parent,
leaf->start, leaf->start,
root->root_key.objectid, root->root_key.objectid,
trans->transid, ins.objectid); trans->transid, ins.objectid);
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) {
...@@ -944,7 +943,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -944,7 +943,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
* 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 @@ static int noinline prepare_pages(struct btrfs_root *root, struct file *file, ...@@ -979,7 +978,8 @@ static int noinline prepare_pages(struct btrfs_root *root, struct file *file,
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) {
...@@ -1085,7 +1085,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf, ...@@ -1085,7 +1085,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
} }
} }
while(count > 0) { while (count > 0) {
size_t offset = pos & (PAGE_CACHE_SIZE - 1); size_t offset = pos & (PAGE_CACHE_SIZE - 1);
size_t write_bytes = min(count, nrptrs * size_t write_bytes = min(count, nrptrs *
(size_t)PAGE_CACHE_SIZE - (size_t)PAGE_CACHE_SIZE -
...@@ -1178,7 +1178,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf, ...@@ -1178,7 +1178,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
return num_written ? num_written : err; return num_written ? num_written : err;
} }
int btrfs_release_file(struct inode * inode, struct file * filp) int btrfs_release_file(struct inode *inode, struct file *filp)
{ {
if (filp->private_data) if (filp->private_data)
btrfs_ioctl_trans_end(filp); btrfs_ioctl_trans_end(filp);
...@@ -1237,9 +1237,8 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync) ...@@ -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
......
...@@ -213,10 +213,13 @@ static int __btrfs_add_free_space(struct btrfs_block_group_cache *block_group, ...@@ -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, ...@@ -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,8 +271,7 @@ static int __btrfs_add_free_space(struct btrfs_block_group_cache *block_group, ...@@ -265,8 +271,7 @@ static int __btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
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, ...@@ -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, ...@@ -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);
......
...@@ -129,7 +129,6 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, ...@@ -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);
......
This diff is collapsed.
...@@ -311,7 +311,7 @@ static noinline int btrfs_mksubvol(struct path *parent, char *name, ...@@ -311,7 +311,7 @@ static noinline int btrfs_mksubvol(struct path *parent, char *name,
* to see if is references the subvolume where we are * to see if is references the subvolume where we are
* placing this new snapshot. * placing this new snapshot.
*/ */
while(1) { while (1) {
if (!test || if (!test ||
dir == snap_src->fs_info->sb->s_root || dir == snap_src->fs_info->sb->s_root ||
test == snap_src->fs_info->sb->s_root || test == snap_src->fs_info->sb->s_root ||
...@@ -319,7 +319,8 @@ static noinline int btrfs_mksubvol(struct path *parent, char *name, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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);
} }
...@@ -985,7 +984,7 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, ...@@ -985,7 +984,7 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
} }
next: next:
btrfs_release_path(root, path); btrfs_release_path(root, path);
key.offset++; key.offset++;
} }
......
...@@ -31,9 +31,10 @@ ...@@ -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;
......
...@@ -39,11 +39,11 @@ static u64 entry_end(struct btrfs_ordered_extent *entry) ...@@ -39,11 +39,11 @@ static u64 entry_end(struct btrfs_ordered_extent *entry)
static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset, static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset,
struct rb_node *node) struct rb_node *node)
{ {
struct rb_node ** p = &root->rb_node; struct rb_node **p = &root->rb_node;
struct rb_node * parent = NULL; struct rb_node *parent = NULL;
struct btrfs_ordered_extent *entry; struct btrfs_ordered_extent *entry;
while(*p) { while (*p) {
parent = *p; parent = *p;
entry = rb_entry(parent, struct btrfs_ordered_extent, rb_node); entry = rb_entry(parent, struct btrfs_ordered_extent, rb_node);
...@@ -67,13 +67,13 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset, ...@@ -67,13 +67,13 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 file_offset,
static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset, static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
struct rb_node **prev_ret) struct rb_node **prev_ret)
{ {
struct rb_node * n = root->rb_node; struct rb_node *n = root->rb_node;
struct rb_node *prev = NULL; struct rb_node *prev = NULL;
struct rb_node *test; struct rb_node *test;
struct btrfs_ordered_extent *entry; struct btrfs_ordered_extent *entry;
struct btrfs_ordered_extent *prev_entry = NULL; struct btrfs_ordered_extent *prev_entry = NULL;
while(n) { while (n) {
entry = rb_entry(n, struct btrfs_ordered_extent, rb_node); entry = rb_entry(n, struct btrfs_ordered_extent, rb_node);
prev = n; prev = n;
prev_entry = entry; prev_entry = entry;
...@@ -88,7 +88,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset, ...@@ -88,7 +88,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
if (!prev_ret) if (!prev_ret)
return NULL; return NULL;
while(prev && file_offset >= entry_end(prev_entry)) { while (prev && file_offset >= entry_end(prev_entry)) {
test = rb_next(prev); test = rb_next(prev);
if (!test) if (!test)
break; break;
...@@ -102,7 +102,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset, ...@@ -102,7 +102,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
if (prev) if (prev)
prev_entry = rb_entry(prev, struct btrfs_ordered_extent, prev_entry = rb_entry(prev, struct btrfs_ordered_extent,
rb_node); rb_node);
while(prev && file_offset < entry_end(prev_entry)) { while (prev && file_offset < entry_end(prev_entry)) {
test = rb_prev(prev); test = rb_prev(prev);
if (!test) if (!test)
break; break;
...@@ -193,10 +193,8 @@ int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, ...@@ -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);
...@@ -282,7 +280,7 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) ...@@ -282,7 +280,7 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
struct btrfs_ordered_sum *sum; struct btrfs_ordered_sum *sum;
if (atomic_dec_and_test(&entry->refs)) { if (atomic_dec_and_test(&entry->refs)) {
while(!list_empty(&entry->list)) { while (!list_empty(&entry->list)) {
cur = entry->list.next; cur = entry->list.next;
sum = list_entry(cur, struct btrfs_ordered_sum, list); sum = list_entry(cur, struct btrfs_ordered_sum, list);
list_del(&sum->list); list_del(&sum->list);
...@@ -432,11 +430,10 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len) ...@@ -432,11 +430,10 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
orig_end >> PAGE_CACHE_SHIFT); orig_end >> PAGE_CACHE_SHIFT);
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;
...@@ -492,7 +489,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode, ...@@ -492,7 +489,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct inode *inode,
* if none is found * if none is found
*/ */
struct btrfs_ordered_extent * struct btrfs_ordered_extent *
btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset) btrfs_lookup_first_ordered_extent(struct inode *inode, u64 file_offset)
{ {
struct btrfs_ordered_inode_tree *tree; struct btrfs_ordered_inode_tree *tree;
struct rb_node *node; struct rb_node *node;
...@@ -553,7 +550,7 @@ int btrfs_ordered_update_i_size(struct inode *inode, ...@@ -553,7 +550,7 @@ int btrfs_ordered_update_i_size(struct inode *inode,
* yet * yet
*/ */
node = &ordered->rb_node; node = &ordered->rb_node;
while(1) { while (1) {
node = rb_prev(node); node = rb_prev(node);
if (!node) if (!node)
break; break;
...@@ -581,9 +578,8 @@ int btrfs_ordered_update_i_size(struct inode *inode, ...@@ -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);
} }
......
...@@ -24,13 +24,14 @@ static void print_chunk(struct extent_buffer *eb, struct btrfs_chunk *chunk) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 "
btrfs_file_extent_inline_len(l, fi)); "size %u\n",
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) ...@@ -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) ...@@ -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,
......
...@@ -74,11 +74,11 @@ void btrfs_free_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref) ...@@ -74,11 +74,11 @@ void btrfs_free_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref)
static struct rb_node *tree_insert(struct rb_root *root, u64 bytenr, static struct rb_node *tree_insert(struct rb_root *root, u64 bytenr,
struct rb_node *node) struct rb_node *node)
{ {
struct rb_node ** p = &root->rb_node; struct rb_node **p = &root->rb_node;
struct rb_node * parent = NULL; struct rb_node *parent = NULL;
struct btrfs_leaf_ref *entry; struct btrfs_leaf_ref *entry;
while(*p) { while (*p) {
parent = *p; parent = *p;
entry = rb_entry(parent, struct btrfs_leaf_ref, rb_node); entry = rb_entry(parent, struct btrfs_leaf_ref, rb_node);
...@@ -98,10 +98,10 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 bytenr, ...@@ -98,10 +98,10 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 bytenr,
static struct rb_node *tree_search(struct rb_root *root, u64 bytenr) static struct rb_node *tree_search(struct rb_root *root, u64 bytenr)
{ {
struct rb_node * n = root->rb_node; struct rb_node *n = root->rb_node;
struct btrfs_leaf_ref *entry; struct btrfs_leaf_ref *entry;
while(n) { while (n) {
entry = rb_entry(n, struct btrfs_leaf_ref, rb_node); entry = rb_entry(n, struct btrfs_leaf_ref, rb_node);
WARN_ON(!entry->in_tree); WARN_ON(!entry->in_tree);
...@@ -127,7 +127,7 @@ int btrfs_remove_leaf_refs(struct btrfs_root *root, u64 max_root_gen, ...@@ -127,7 +127,7 @@ int btrfs_remove_leaf_refs(struct btrfs_root *root, u64 max_root_gen,
return 0; return 0;
spin_lock(&tree->lock); spin_lock(&tree->lock);
while(!list_empty(&tree->list)) { while (!list_empty(&tree->list)) {
ref = list_entry(tree->list.next, struct btrfs_leaf_ref, list); ref = list_entry(tree->list.next, struct btrfs_leaf_ref, list);
BUG_ON(ref->tree != tree); BUG_ON(ref->tree != tree);
if (ref->root_gen > max_root_gen) if (ref->root_gen > max_root_gen)
......
...@@ -132,8 +132,9 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root ...@@ -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 ...@@ -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)
...@@ -188,7 +189,7 @@ int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid, ...@@ -188,7 +189,7 @@ int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid,
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
goto err; goto err;
while(1) { while (1) {
leaf = path->nodes[0]; leaf = path->nodes[0];
nritems = btrfs_header_nritems(leaf); nritems = btrfs_header_nritems(leaf);
slot = path->slots[0]; slot = path->slots[0];
...@@ -258,11 +259,7 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, ...@@ -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);
......
...@@ -66,7 +66,7 @@ u##bits btrfs_##name(struct extent_buffer *eb, \ ...@@ -66,7 +66,7 @@ u##bits btrfs_##name(struct extent_buffer *eb, \
unsigned long map_len; \ unsigned long map_len; \
u##bits res; \ u##bits res; \
err = map_extent_buffer(eb, offset, \ err = map_extent_buffer(eb, offset, \
sizeof(((type *)0)->member), \ sizeof(((type *)0)->member), \
&map_token, &kaddr, \ &map_token, &kaddr, \
&map_start, &map_len, KM_USER1); \ &map_start, &map_len, KM_USER1); \
if (err) { \ if (err) { \
...@@ -103,7 +103,7 @@ void btrfs_set_##name(struct extent_buffer *eb, \ ...@@ -103,7 +103,7 @@ void btrfs_set_##name(struct extent_buffer *eb, \
unsigned long map_start; \ unsigned long map_start; \
unsigned long map_len; \ unsigned long map_len; \
err = map_extent_buffer(eb, offset, \ err = map_extent_buffer(eb, offset, \
sizeof(((type *)0)->member), \ sizeof(((type *)0)->member), \
&map_token, &kaddr, \ &map_token, &kaddr, \
&map_start, &map_len, KM_USER1); \ &map_start, &map_len, KM_USER1); \
if (err) { \ if (err) { \
......
...@@ -55,18 +55,12 @@ ...@@ -55,18 +55,12 @@
static struct super_operations btrfs_super_ops; static struct super_operations btrfs_super_ops;
static void btrfs_put_super (struct super_block * sb) static void btrfs_put_super(struct super_block *sb)
{ {
struct btrfs_root *root = btrfs_sb(sb); struct btrfs_root *root = btrfs_sb(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;
} }
...@@ -299,12 +293,12 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, ...@@ -299,12 +293,12 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
return error; return error;
} }
static int btrfs_fill_super(struct super_block * sb, static int btrfs_fill_super(struct super_block *sb,
struct btrfs_fs_devices *fs_devices, struct btrfs_fs_devices *fs_devices,
void * data, int silent) void *data, int silent)
{ {
struct inode * inode; struct inode *inode;
struct dentry * root_dentry; struct dentry *root_dentry;
struct btrfs_super_block *disk_super; struct btrfs_super_block *disk_super;
struct btrfs_root *tree_root; struct btrfs_root *tree_root;
struct btrfs_inode *bi; struct btrfs_inode *bi;
...@@ -479,8 +473,10 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, ...@@ -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,8 +553,9 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -557,8 +553,9 @@ 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 */
buf->f_fsid.val[0] = be32_to_cpu(fsid[0]) ^ be32_to_cpu(fsid[2]); buf->f_fsid.val[0] = be32_to_cpu(fsid[0]) ^ be32_to_cpu(fsid[2]);
buf->f_fsid.val[1] = be32_to_cpu(fsid[1]) ^ be32_to_cpu(fsid[3]); buf->f_fsid.val[1] = be32_to_cpu(fsid[1]) ^ be32_to_cpu(fsid[3]);
...@@ -658,7 +655,7 @@ static int btrfs_interface_init(void) ...@@ -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)
......
...@@ -67,7 +67,8 @@ struct btrfs_root_attr { ...@@ -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 { ...@@ -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);
......
...@@ -28,9 +28,6 @@ ...@@ -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) ...@@ -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)
{ {
...@@ -144,7 +141,7 @@ static void wait_current_trans(struct btrfs_root *root) ...@@ -144,7 +141,7 @@ static void wait_current_trans(struct btrfs_root *root)
if (cur_trans && cur_trans->blocked) { if (cur_trans && cur_trans->blocked) {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
cur_trans->use_count++; cur_trans->use_count++;
while(1) { while (1) {
prepare_to_wait(&root->fs_info->transaction_wait, &wait, prepare_to_wait(&root->fs_info->transaction_wait, &wait,
TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
if (cur_trans->blocked) { if (cur_trans->blocked) {
...@@ -213,7 +210,7 @@ static noinline int wait_for_commit(struct btrfs_root *root, ...@@ -213,7 +210,7 @@ static noinline int wait_for_commit(struct btrfs_root *root,
{ {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
mutex_lock(&root->fs_info->trans_mutex); mutex_lock(&root->fs_info->trans_mutex);
while(!commit->commit_done) { while (!commit->commit_done) {
prepare_to_wait(&commit->commit_wait, &wait, prepare_to_wait(&commit->commit_wait, &wait,
TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
if (commit->commit_done) if (commit->commit_done)
...@@ -228,8 +225,8 @@ static noinline int wait_for_commit(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)
{ {
...@@ -332,12 +329,12 @@ int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, ...@@ -332,12 +329,12 @@ int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,
u64 end; u64 end;
unsigned long index; unsigned long index;
while(1) { while (1) {
ret = find_first_extent_bit(dirty_pages, start, &start, &end, ret = find_first_extent_bit(dirty_pages, start, &start, &end,
EXTENT_DIRTY); EXTENT_DIRTY);
if (ret) if (ret)
break; break;
while(start <= end) { while (start <= end) {
cond_resched(); cond_resched();
index = start >> PAGE_CACHE_SHIFT; index = start >> PAGE_CACHE_SHIFT;
...@@ -368,14 +365,14 @@ int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, ...@@ -368,14 +365,14 @@ int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,
page_cache_release(page); page_cache_release(page);
} }
} }
while(1) { while (1) {
ret = find_first_extent_bit(dirty_pages, 0, &start, &end, ret = find_first_extent_bit(dirty_pages, 0, &start, &end,
EXTENT_DIRTY); EXTENT_DIRTY);
if (ret) if (ret)
break; break;
clear_extent_dirty(dirty_pages, start, end, GFP_NOFS); clear_extent_dirty(dirty_pages, start, end, GFP_NOFS);
while(start <= end) { while (start <= end) {
index = start >> PAGE_CACHE_SHIFT; index = start >> PAGE_CACHE_SHIFT;
start = (u64)(index + 1) << PAGE_CACHE_SHIFT; start = (u64)(index + 1) << PAGE_CACHE_SHIFT;
page = find_get_page(btree_inode->i_mapping, index); page = find_get_page(btree_inode->i_mapping, index);
...@@ -431,7 +428,7 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans, ...@@ -431,7 +428,7 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
btrfs_write_dirty_block_groups(trans, root); btrfs_write_dirty_block_groups(trans, root);
btrfs_extent_post_op(trans, root); btrfs_extent_post_op(trans, root);
while(1) { while (1) {
old_root_bytenr = btrfs_root_bytenr(&root->root_item); old_root_bytenr = btrfs_root_bytenr(&root->root_item);
if (old_root_bytenr == root->node->start) if (old_root_bytenr == root->node->start)
break; break;
...@@ -472,7 +469,7 @@ int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, ...@@ -472,7 +469,7 @@ int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
btrfs_extent_post_op(trans, fs_info->tree_root); btrfs_extent_post_op(trans, fs_info->tree_root);
while(!list_empty(&fs_info->dirty_cowonly_roots)) { while (!list_empty(&fs_info->dirty_cowonly_roots)) {
next = fs_info->dirty_cowonly_roots.next; next = fs_info->dirty_cowonly_roots.next;
list_del_init(next); list_del_init(next);
root = list_entry(next, struct btrfs_root, dirty_list); root = list_entry(next, struct btrfs_root, dirty_list);
...@@ -521,7 +518,7 @@ static noinline int add_dirty_roots(struct btrfs_trans_handle *trans, ...@@ -521,7 +518,7 @@ static noinline int add_dirty_roots(struct btrfs_trans_handle *trans,
int err = 0; int err = 0;
u32 refs; u32 refs;
while(1) { while (1) {
ret = radix_tree_gang_lookup_tag(radix, (void **)gang, 0, ret = radix_tree_gang_lookup_tag(radix, (void **)gang, 0,
ARRAY_SIZE(gang), ARRAY_SIZE(gang),
BTRFS_ROOT_TRANS_TAG); BTRFS_ROOT_TRANS_TAG);
...@@ -653,7 +650,7 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root, ...@@ -653,7 +650,7 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root,
int ret = 0; int ret = 0;
int err; int err;
while(!list_empty(list)) { while (!list_empty(list)) {
struct btrfs_root *root; struct btrfs_root *root;
dirty = list_entry(list->prev, struct btrfs_dirty_root, list); dirty = list_entry(list->prev, struct btrfs_dirty_root, list);
...@@ -663,13 +660,12 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root, ...@@ -663,13 +660,12 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root,
root = dirty->latest_root; root = dirty->latest_root;
atomic_inc(&root->fs_info->throttles); atomic_inc(&root->fs_info->throttles);
while(1) { while (1) {
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,
...@@ -874,7 +870,7 @@ static noinline int finish_pending_snapshots(struct btrfs_trans_handle *trans, ...@@ -874,7 +870,7 @@ static noinline int finish_pending_snapshots(struct btrfs_trans_handle *trans,
struct list_head *head = &trans->transaction->pending_snapshots; struct list_head *head = &trans->transaction->pending_snapshots;
int ret; int ret;
while(!list_empty(head)) { while (!list_empty(head)) {
pending = list_entry(head->next, pending = list_entry(head->next,
struct btrfs_pending_snapshot, list); struct btrfs_pending_snapshot, list);
ret = finish_pending_snapshot(fs_info, pending); ret = finish_pending_snapshot(fs_info, pending);
...@@ -1076,9 +1072,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *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;
} }
......
...@@ -66,9 +66,9 @@ static inline void btrfs_set_trans_block_group(struct btrfs_trans_handle *trans, ...@@ -66,9 +66,9 @@ 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;
} }
......
...@@ -23,10 +23,11 @@ ...@@ -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, ...@@ -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;
......
...@@ -829,7 +829,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, ...@@ -829,7 +829,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
*/ */
ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
ptr_end = ptr + btrfs_item_size_nr(leaf, path->slots[0]); ptr_end = ptr + btrfs_item_size_nr(leaf, path->slots[0]);
while(ptr < ptr_end) { while (ptr < ptr_end) {
victim_ref = (struct btrfs_inode_ref *)ptr; victim_ref = (struct btrfs_inode_ref *)ptr;
victim_name_len = btrfs_inode_ref_name_len(leaf, victim_name_len = btrfs_inode_ref_name_len(leaf,
victim_ref); victim_ref);
...@@ -938,9 +938,8 @@ static noinline int replay_one_csum(struct btrfs_trans_handle *trans, ...@@ -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;
...@@ -952,7 +951,7 @@ static noinline int replay_one_csum(struct btrfs_trans_handle *trans, ...@@ -952,7 +951,7 @@ static noinline int replay_one_csum(struct btrfs_trans_handle *trans,
sector_sum = sums->sums; sector_sum = sums->sums;
cur_offset = key->offset; cur_offset = key->offset;
ptr = btrfs_item_ptr_offset(eb, slot); ptr = btrfs_item_ptr_offset(eb, slot);
while(item_size > 0) { while (item_size > 0) {
sector_sum->bytenr = cur_offset; sector_sum->bytenr = cur_offset;
read_extent_buffer(eb, &sector_sum->sum, ptr, csum_size); read_extent_buffer(eb, &sector_sum->sum, ptr, csum_size);
sector_sum++; sector_sum++;
...@@ -995,7 +994,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, ...@@ -995,7 +994,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path(); path = btrfs_alloc_path();
while(1) { while (1) {
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
break; break;
...@@ -1012,7 +1011,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, ...@@ -1012,7 +1011,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]);
ptr_end = ptr + btrfs_item_size_nr(path->nodes[0], ptr_end = ptr + btrfs_item_size_nr(path->nodes[0],
path->slots[0]); path->slots[0]);
while(ptr < ptr_end) { while (ptr < ptr_end) {
struct btrfs_inode_ref *ref; struct btrfs_inode_ref *ref;
ref = (struct btrfs_inode_ref *)ptr; ref = (struct btrfs_inode_ref *)ptr;
...@@ -1048,7 +1047,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans, ...@@ -1048,7 +1047,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
key.objectid = BTRFS_TREE_LOG_FIXUP_OBJECTID; key.objectid = BTRFS_TREE_LOG_FIXUP_OBJECTID;
key.type = BTRFS_ORPHAN_ITEM_KEY; key.type = BTRFS_ORPHAN_ITEM_KEY;
key.offset = (u64)-1; key.offset = (u64)-1;
while(1) { while (1) {
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)
break; break;
...@@ -1206,8 +1205,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans, ...@@ -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,
...@@ -1282,7 +1280,7 @@ static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans, ...@@ -1282,7 +1280,7 @@ static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans,
ptr = btrfs_item_ptr_offset(eb, slot); ptr = btrfs_item_ptr_offset(eb, slot);
ptr_end = ptr + item_size; ptr_end = ptr + item_size;
while(ptr < ptr_end) { while (ptr < ptr_end) {
di = (struct btrfs_dir_item *)ptr; di = (struct btrfs_dir_item *)ptr;
name_len = btrfs_dir_name_len(eb, di); name_len = btrfs_dir_name_len(eb, di);
ret = replay_one_name(trans, root, path, eb, di, key); ret = replay_one_name(trans, root, path, eb, di, key);
...@@ -1408,7 +1406,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans, ...@@ -1408,7 +1406,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
item_size = btrfs_item_size_nr(eb, slot); item_size = btrfs_item_size_nr(eb, slot);
ptr = btrfs_item_ptr_offset(eb, slot); ptr = btrfs_item_ptr_offset(eb, slot);
ptr_end = ptr + item_size; ptr_end = ptr + item_size;
while(ptr < ptr_end) { while (ptr < ptr_end) {
di = (struct btrfs_dir_item *)ptr; di = (struct btrfs_dir_item *)ptr;
name_len = btrfs_dir_name_len(eb, di); name_len = btrfs_dir_name_len(eb, di);
name = kmalloc(name_len, GFP_NOFS); name = kmalloc(name_len, GFP_NOFS);
...@@ -1513,14 +1511,14 @@ static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans, ...@@ -1513,14 +1511,14 @@ static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans,
again: again:
range_start = 0; range_start = 0;
range_end = 0; range_end = 0;
while(1) { while (1) {
ret = find_dir_range(log, path, dirid, key_type, ret = find_dir_range(log, path, dirid, key_type,
&range_start, &range_end); &range_start, &range_end);
if (ret != 0) if (ret != 0)
break; break;
dir_key.offset = range_start; dir_key.offset = range_start;
while(1) { while (1) {
int nritems; int nritems;
ret = btrfs_search_slot(NULL, root, &dir_key, path, ret = btrfs_search_slot(NULL, root, &dir_key, path,
0, 0); 0, 0);
...@@ -1676,7 +1674,7 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb, ...@@ -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)
...@@ -1694,7 +1692,7 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans, ...@@ -1694,7 +1692,7 @@ 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);
while(*level > 0) { while (*level > 0) {
WARN_ON(*level < 0); WARN_ON(*level < 0);
WARN_ON(*level >= BTRFS_MAX_LEVEL); WARN_ON(*level >= BTRFS_MAX_LEVEL);
cur = path->nodes[*level]; cur = path->nodes[*level];
...@@ -1753,11 +1751,11 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans, ...@@ -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, ...@@ -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)
...@@ -1801,7 +1799,7 @@ static int noinline walk_up_log_tree(struct btrfs_trans_handle *trans, ...@@ -1801,7 +1799,7 @@ static int noinline walk_up_log_tree(struct btrfs_trans_handle *trans,
int slot; int slot;
int ret; int ret;
for(i = *level; i < BTRFS_MAX_LEVEL - 1 && path->nodes[i]; i++) { for (i = *level; i < BTRFS_MAX_LEVEL - 1 && path->nodes[i]; i++) {
slot = path->slots[i]; slot = path->slots[i];
if (slot < btrfs_header_nritems(path->nodes[i]) - 1) { if (slot < btrfs_header_nritems(path->nodes[i]) - 1) {
struct extent_buffer *node; struct extent_buffer *node;
...@@ -1875,7 +1873,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, ...@@ -1875,7 +1873,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
extent_buffer_get(log->node); extent_buffer_get(log->node);
path->slots[level] = 0; path->slots[level] = 0;
while(1) { while (1) {
wret = walk_down_log_tree(trans, log, path, &level, wc); wret = walk_down_log_tree(trans, log, path, &level, wc);
if (wret > 0) if (wret > 0)
break; break;
...@@ -1941,7 +1939,7 @@ static int wait_log_commit(struct btrfs_root *log) ...@@ -1941,7 +1939,7 @@ static int wait_log_commit(struct btrfs_root *log)
schedule(); schedule();
finish_wait(&log->fs_info->tree_log_wait, &wait); finish_wait(&log->fs_info->tree_log_wait, &wait);
mutex_lock(&log->fs_info->tree_log_mutex); mutex_lock(&log->fs_info->tree_log_mutex);
} while(transid == log->fs_info->tree_log_transid && } while (transid == log->fs_info->tree_log_transid &&
atomic_read(&log->fs_info->tree_log_commit)); atomic_read(&log->fs_info->tree_log_commit));
return 0; return 0;
} }
...@@ -1965,13 +1963,13 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, ...@@ -1965,13 +1963,13 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
} }
atomic_set(&log->fs_info->tree_log_commit, 1); atomic_set(&log->fs_info->tree_log_commit, 1);
while(1) { while (1) {
batch = log->fs_info->tree_log_batch; batch = log->fs_info->tree_log_batch;
mutex_unlock(&log->fs_info->tree_log_mutex); mutex_unlock(&log->fs_info->tree_log_mutex);
schedule_timeout_uninterruptible(1); schedule_timeout_uninterruptible(1);
mutex_lock(&log->fs_info->tree_log_mutex); mutex_lock(&log->fs_info->tree_log_mutex);
while(atomic_read(&log->fs_info->tree_log_writers)) { while (atomic_read(&log->fs_info->tree_log_writers)) {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
prepare_to_wait(&log->fs_info->tree_log_wait, &wait, prepare_to_wait(&log->fs_info->tree_log_wait, &wait,
TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
...@@ -2030,7 +2028,7 @@ int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root) ...@@ -2030,7 +2028,7 @@ int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root)
ret = walk_log_tree(trans, log, &wc); ret = walk_log_tree(trans, log, &wc);
BUG_ON(ret); BUG_ON(ret);
while(1) { while (1) {
ret = find_first_extent_bit(&log->dirty_log_pages, ret = find_first_extent_bit(&log->dirty_log_pages,
0, &start, &end, EXTENT_DIRTY); 0, &start, &end, EXTENT_DIRTY);
if (ret) if (ret)
...@@ -2287,9 +2285,8 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, ...@@ -2287,9 +2285,8 @@ 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;
} }
...@@ -2319,7 +2316,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, ...@@ -2319,7 +2316,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
* we have a block from this transaction, log every item in it * we have a block from this transaction, log every item in it
* from our directory * from our directory
*/ */
while(1) { while (1) {
struct btrfs_key tmp; struct btrfs_key tmp;
src = path->nodes[0]; src = path->nodes[0];
nritems = btrfs_header_nritems(src); nritems = btrfs_header_nritems(src);
...@@ -2396,7 +2393,7 @@ static noinline int log_directory_changes(struct btrfs_trans_handle *trans, ...@@ -2396,7 +2393,7 @@ static noinline int log_directory_changes(struct btrfs_trans_handle *trans,
again: again:
min_key = 0; min_key = 0;
max_key = 0; max_key = 0;
while(1) { while (1) {
ret = log_dir_items(trans, root, inode, path, ret = log_dir_items(trans, root, inode, path,
dst_path, key_type, min_key, dst_path, key_type, min_key,
&max_key); &max_key);
...@@ -2432,7 +2429,7 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans, ...@@ -2432,7 +2429,7 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
key.type = max_key_type; key.type = max_key_type;
key.offset = (u64)-1; key.offset = (u64)-1;
while(1) { while (1) {
ret = btrfs_search_slot(trans, log, &key, path, -1, 1); ret = btrfs_search_slot(trans, log, &key, path, -1, 1);
if (ret != 1) if (ret != 1)
...@@ -2481,7 +2478,7 @@ static noinline int copy_extent_csums(struct btrfs_trans_handle *trans, ...@@ -2481,7 +2478,7 @@ static noinline int copy_extent_csums(struct btrfs_trans_handle *trans,
list_add_tail(&sums->list, list); list_add_tail(&sums->list, list);
path = btrfs_alloc_path(); path = btrfs_alloc_path();
while(disk_bytenr < end) { while (disk_bytenr < end) {
if (!item || disk_bytenr < item_start_offset || if (!item || disk_bytenr < item_start_offset ||
disk_bytenr >= item_last_offset) { disk_bytenr >= item_last_offset) {
struct btrfs_key found_key; struct btrfs_key found_key;
...@@ -2496,7 +2493,8 @@ static noinline int copy_extent_csums(struct btrfs_trans_handle *trans, ...@@ -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);
...@@ -2643,7 +2641,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, ...@@ -2643,7 +2641,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
* we have to do this after the loop above to avoid changing the * we have to do this after the loop above to avoid changing the
* log tree while trying to change the log tree. * log tree while trying to change the log tree.
*/ */
while(!list_empty(&ordered_sums)) { while (!list_empty(&ordered_sums)) {
struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next, struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next,
struct btrfs_ordered_sum, struct btrfs_ordered_sum,
list); list);
...@@ -2736,7 +2734,7 @@ static int __btrfs_log_inode(struct btrfs_trans_handle *trans, ...@@ -2736,7 +2734,7 @@ static int __btrfs_log_inode(struct btrfs_trans_handle *trans,
BUG_ON(ret); BUG_ON(ret);
path->keep_locks = 1; path->keep_locks = 1;
while(1) { while (1) {
ins_nr = 0; ins_nr = 0;
ret = btrfs_search_forward(root, &min_key, &max_key, ret = btrfs_search_forward(root, &min_key, &max_key,
path, 0, trans->transid); path, 0, trans->transid);
...@@ -2848,7 +2846,7 @@ int btrfs_log_dentry(struct btrfs_trans_handle *trans, ...@@ -2848,7 +2846,7 @@ int btrfs_log_dentry(struct btrfs_trans_handle *trans,
start_log_trans(trans, root); start_log_trans(trans, root);
sb = dentry->d_inode->i_sb; sb = dentry->d_inode->i_sb;
while(1) { while (1) {
ret = __btrfs_log_inode(trans, root, dentry->d_inode, ret = __btrfs_log_inode(trans, root, dentry->d_inode,
inode_only); inode_only);
BUG_ON(ret); BUG_ON(ret);
...@@ -2919,7 +2917,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) ...@@ -2919,7 +2917,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
key.offset = (u64)-1; key.offset = (u64)-1;
btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
while(1) { while (1) {
ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0); ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
break; break;
......
...@@ -140,7 +140,7 @@ static noinline struct btrfs_fs_devices *find_fsid(u8 *fsid) ...@@ -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;
...@@ -187,7 +187,7 @@ static int noinline run_scheduled_bios(struct btrfs_device *device) ...@@ -187,7 +187,7 @@ static int noinline run_scheduled_bios(struct btrfs_device *device)
} }
spin_unlock(&device->io_lock); spin_unlock(&device->io_lock);
while(pending) { while (pending) {
cur = pending; cur = pending;
pending = pending->bi_next; pending = pending->bi_next;
cur->bi_next = NULL; cur->bi_next = NULL;
...@@ -458,7 +458,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, ...@@ -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, ...@@ -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 @@ static noinline int find_free_dev_extent(struct btrfs_trans_handle *trans, ...@@ -683,9 +684,8 @@ static noinline int find_free_dev_extent(struct btrfs_trans_handle *trans,
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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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,8 +1404,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) ...@@ -1401,8 +1404,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
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;
struct btrfs_path *path; struct btrfs_path *path;
...@@ -1563,7 +1566,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, ...@@ -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;
...@@ -1748,7 +1751,7 @@ int btrfs_balance(struct btrfs_root *dev_root) ...@@ -1748,7 +1751,7 @@ int btrfs_balance(struct btrfs_root *dev_root)
key.offset = (u64)-1; key.offset = (u64)-1;
key.type = BTRFS_CHUNK_ITEM_KEY; key.type = BTRFS_CHUNK_ITEM_KEY;
while(1) { while (1) {
ret = btrfs_search_slot(NULL, chunk_root, &key, path, 0, 0); ret = btrfs_search_slot(NULL, chunk_root, &key, path, 0, 0);
if (ret < 0) if (ret < 0)
goto error; goto error;
...@@ -1916,7 +1919,7 @@ static int btrfs_add_system_chunk(struct btrfs_trans_handle *trans, ...@@ -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))
...@@ -2041,7 +2044,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, ...@@ -2041,7 +2044,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
min_free += 1024 * 1024; min_free += 1024 * 1024;
INIT_LIST_HEAD(&private_devs); INIT_LIST_HEAD(&private_devs);
while(index < num_stripes) { while (index < num_stripes) {
device = list_entry(cur, struct btrfs_device, dev_alloc_list); device = list_entry(cur, struct btrfs_device, dev_alloc_list);
BUG_ON(!device->writeable); BUG_ON(!device->writeable);
if (device->total_bytes > device->bytes_used) if (device->total_bytes > device->bytes_used)
...@@ -2242,7 +2245,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, ...@@ -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)
{ {
...@@ -2338,7 +2341,7 @@ void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree) ...@@ -2338,7 +2341,7 @@ void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree)
{ {
struct extent_map *em; struct extent_map *em;
while(1) { while (1) {
spin_lock(&tree->map_tree.lock); spin_lock(&tree->map_tree.lock);
em = lookup_extent_mapping(&tree->map_tree, 0, (u64)-1); em = lookup_extent_mapping(&tree->map_tree, 0, (u64)-1);
if (em) if (em)
...@@ -2413,9 +2416,8 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, ...@@ -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 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, ...@@ -2434,7 +2436,9 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
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,9 +2545,8 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, ...@@ -2541,9 +2545,8 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
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 =
...@@ -2717,7 +2720,7 @@ struct async_sched { ...@@ -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, ...@@ -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;
...@@ -2794,7 +2799,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, ...@@ -2794,7 +2799,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
multi->orig_bio = first_bio; multi->orig_bio = first_bio;
atomic_set(&multi->stripes_pending, multi->num_stripes); atomic_set(&multi->stripes_pending, multi->num_stripes);
while(dev_nr < total_devs) { while (dev_nr < total_devs) {
if (total_devs > 1) { if (total_devs > 1) {
if (dev_nr < total_devs - 1) { if (dev_nr < total_devs - 1) {
bio = bio_clone(first_bio, GFP_NOFS); bio = bio_clone(first_bio, GFP_NOFS);
...@@ -3058,7 +3063,8 @@ static int read_one_dev(struct btrfs_root *root, ...@@ -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, ...@@ -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;
} }
...@@ -3174,7 +3174,7 @@ int btrfs_read_chunk_tree(struct btrfs_root *root) ...@@ -3174,7 +3174,7 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
key.type = 0; key.type = 0;
again: again:
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
while(1) { while (1) {
leaf = path->nodes[0]; leaf = path->nodes[0];
slot = path->slots[0]; slot = path->slots[0];
if (slot >= btrfs_header_nritems(leaf)) { if (slot >= btrfs_header_nritems(leaf)) {
......
...@@ -264,7 +264,8 @@ struct xattr_handler *btrfs_xattr_handlers[] = { ...@@ -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);
......
...@@ -152,7 +152,7 @@ static int free_workspace(struct workspace *workspace) ...@@ -152,7 +152,7 @@ static int free_workspace(struct workspace *workspace)
static void free_workspaces(void) static void free_workspaces(void)
{ {
struct workspace *workspace; struct workspace *workspace;
while(!list_empty(&idle_workspace)) { while (!list_empty(&idle_workspace)) {
workspace = list_entry(idle_workspace.next, struct workspace, workspace = list_entry(idle_workspace.next, struct workspace,
list); list);
list_del(&workspace->list); list_del(&workspace->list);
...@@ -397,12 +397,10 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in, ...@@ -397,12 +397,10 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
ret = -1; ret = -1;
goto out; goto out;
} }
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, ...@@ -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
...@@ -448,7 +444,7 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in, ...@@ -448,7 +444,7 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
current_buf_start = buf_start; current_buf_start = buf_start;
/* copy bytes from the working buffer into the pages */ /* copy bytes from the working buffer into the pages */
while(working_bytes > 0) { while (working_bytes > 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);
bytes = min(bytes, working_bytes); bytes = min(bytes, working_bytes);
...@@ -471,6 +467,7 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in, ...@@ -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, ...@@ -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 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in, ...@@ -517,11 +513,10 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
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)
...@@ -579,16 +574,15 @@ int btrfs_zlib_decompress(unsigned char *data_in, ...@@ -579,16 +574,15 @@ int btrfs_zlib_decompress(unsigned char *data_in,
goto out; goto out;
} }
while(bytes_left > 0) { while (bytes_left > 0) {
unsigned long buf_start; unsigned long buf_start;
unsigned long buf_offset; unsigned long buf_offset;
unsigned long bytes; unsigned long bytes;
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, ...@@ -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 @@ int btrfs_zlib_decompress(unsigned char *data_in, ...@@ -622,11 +614,12 @@ int btrfs_zlib_decompress(unsigned char *data_in,
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment