mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	btrfs: use nodesize everywhere, kill leafsize
The nodesize and leafsize were never of different values. Unify the usage and make nodesize the one. Cleanup the redundant checks and helpers. Shaves a few bytes from .text: text data bss dec hex filename 852418 24560 23112 900090 dbbfa btrfs.ko.before 851074 24584 23112 898770 db6d2 btrfs.ko.after Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
		
							parent
							
								
									962a298f35
								
							
						
					
					
						commit
						707e8a0715
					
				
					 15 changed files with 89 additions and 141 deletions
				
			
		| 
						 | 
					@ -482,7 +482,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		BUG_ON(!ref->wanted_disk_byte);
 | 
							BUG_ON(!ref->wanted_disk_byte);
 | 
				
			||||||
		eb = read_tree_block(fs_info->tree_root, ref->wanted_disk_byte,
 | 
							eb = read_tree_block(fs_info->tree_root, ref->wanted_disk_byte,
 | 
				
			||||||
				     fs_info->tree_root->leafsize, 0);
 | 
									     fs_info->tree_root->nodesize, 0);
 | 
				
			||||||
		if (!eb || !extent_buffer_uptodate(eb)) {
 | 
							if (!eb || !extent_buffer_uptodate(eb)) {
 | 
				
			||||||
			free_extent_buffer(eb);
 | 
								free_extent_buffer(eb);
 | 
				
			||||||
			return -EIO;
 | 
								return -EIO;
 | 
				
			||||||
| 
						 | 
					@ -991,8 +991,8 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
 | 
				
			||||||
			    ref->level == 0) {
 | 
								    ref->level == 0) {
 | 
				
			||||||
				u32 bsz;
 | 
									u32 bsz;
 | 
				
			||||||
				struct extent_buffer *eb;
 | 
									struct extent_buffer *eb;
 | 
				
			||||||
				bsz = btrfs_level_size(fs_info->extent_root,
 | 
					
 | 
				
			||||||
							ref->level);
 | 
									bsz = fs_info->extent_root->nodesize;
 | 
				
			||||||
				eb = read_tree_block(fs_info->extent_root,
 | 
									eb = read_tree_block(fs_info->extent_root,
 | 
				
			||||||
							   ref->parent, bsz, 0);
 | 
												   ref->parent, bsz, 0);
 | 
				
			||||||
				if (!eb || !extent_buffer_uptodate(eb)) {
 | 
									if (!eb || !extent_buffer_uptodate(eb)) {
 | 
				
			||||||
| 
						 | 
					@ -1366,7 +1366,7 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	btrfs_item_key_to_cpu(path->nodes[0], found_key, path->slots[0]);
 | 
						btrfs_item_key_to_cpu(path->nodes[0], found_key, path->slots[0]);
 | 
				
			||||||
	if (found_key->type == BTRFS_METADATA_ITEM_KEY)
 | 
						if (found_key->type == BTRFS_METADATA_ITEM_KEY)
 | 
				
			||||||
		size = fs_info->extent_root->leafsize;
 | 
							size = fs_info->extent_root->nodesize;
 | 
				
			||||||
	else if (found_key->type == BTRFS_EXTENT_ITEM_KEY)
 | 
						else if (found_key->type == BTRFS_EXTENT_ITEM_KEY)
 | 
				
			||||||
		size = found_key->offset;
 | 
							size = found_key->offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -820,7 +820,6 @@ static int btrfsic_process_superblock_dev_mirror(
 | 
				
			||||||
	    btrfs_super_magic(super_tmp) != BTRFS_MAGIC ||
 | 
						    btrfs_super_magic(super_tmp) != BTRFS_MAGIC ||
 | 
				
			||||||
	    memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_SIZE) ||
 | 
						    memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_SIZE) ||
 | 
				
			||||||
	    btrfs_super_nodesize(super_tmp) != state->metablock_size ||
 | 
						    btrfs_super_nodesize(super_tmp) != state->metablock_size ||
 | 
				
			||||||
	    btrfs_super_leafsize(super_tmp) != state->metablock_size ||
 | 
					 | 
				
			||||||
	    btrfs_super_sectorsize(super_tmp) != state->datablock_size) {
 | 
						    btrfs_super_sectorsize(super_tmp) != state->datablock_size) {
 | 
				
			||||||
		brelse(bh);
 | 
							brelse(bh);
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
| 
						 | 
					@ -3120,24 +3119,12 @@ int btrfsic_mount(struct btrfs_root *root,
 | 
				
			||||||
	struct list_head *dev_head = &fs_devices->devices;
 | 
						struct list_head *dev_head = &fs_devices->devices;
 | 
				
			||||||
	struct btrfs_device *device;
 | 
						struct btrfs_device *device;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (root->nodesize != root->leafsize) {
 | 
					 | 
				
			||||||
		printk(KERN_INFO
 | 
					 | 
				
			||||||
		       "btrfsic: cannot handle nodesize %d != leafsize %d!\n",
 | 
					 | 
				
			||||||
		       root->nodesize, root->leafsize);
 | 
					 | 
				
			||||||
		return -1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (root->nodesize & ((u64)PAGE_CACHE_SIZE - 1)) {
 | 
						if (root->nodesize & ((u64)PAGE_CACHE_SIZE - 1)) {
 | 
				
			||||||
		printk(KERN_INFO
 | 
							printk(KERN_INFO
 | 
				
			||||||
		       "btrfsic: cannot handle nodesize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n",
 | 
							       "btrfsic: cannot handle nodesize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n",
 | 
				
			||||||
		       root->nodesize, PAGE_CACHE_SIZE);
 | 
							       root->nodesize, PAGE_CACHE_SIZE);
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (root->leafsize & ((u64)PAGE_CACHE_SIZE - 1)) {
 | 
					 | 
				
			||||||
		printk(KERN_INFO
 | 
					 | 
				
			||||||
		       "btrfsic: cannot handle leafsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n",
 | 
					 | 
				
			||||||
		       root->leafsize, PAGE_CACHE_SIZE);
 | 
					 | 
				
			||||||
		return -1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (root->sectorsize & ((u64)PAGE_CACHE_SIZE - 1)) {
 | 
						if (root->sectorsize & ((u64)PAGE_CACHE_SIZE - 1)) {
 | 
				
			||||||
		printk(KERN_INFO
 | 
							printk(KERN_INFO
 | 
				
			||||||
		       "btrfsic: cannot handle sectorsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n",
 | 
							       "btrfsic: cannot handle sectorsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1444,7 +1444,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
 | 
				
			||||||
	if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) {
 | 
						if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) {
 | 
				
			||||||
		btrfs_tree_read_unlock(eb_root);
 | 
							btrfs_tree_read_unlock(eb_root);
 | 
				
			||||||
		free_extent_buffer(eb_root);
 | 
							free_extent_buffer(eb_root);
 | 
				
			||||||
		blocksize = btrfs_level_size(root, old_root->level);
 | 
							blocksize = root->nodesize;
 | 
				
			||||||
		old = read_tree_block(root, logical, blocksize, 0);
 | 
							old = read_tree_block(root, logical, blocksize, 0);
 | 
				
			||||||
		if (WARN_ON(!old || !extent_buffer_uptodate(old))) {
 | 
							if (WARN_ON(!old || !extent_buffer_uptodate(old))) {
 | 
				
			||||||
			free_extent_buffer(old);
 | 
								free_extent_buffer(old);
 | 
				
			||||||
| 
						 | 
					@ -1651,7 +1651,7 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	WARN_ON(trans->transid != root->fs_info->generation);
 | 
						WARN_ON(trans->transid != root->fs_info->generation);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	parent_nritems = btrfs_header_nritems(parent);
 | 
						parent_nritems = btrfs_header_nritems(parent);
 | 
				
			||||||
	blocksize = btrfs_level_size(root, parent_level - 1);
 | 
						blocksize = root->nodesize;
 | 
				
			||||||
	end_slot = parent_nritems;
 | 
						end_slot = parent_nritems;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (parent_nritems == 1)
 | 
						if (parent_nritems == 1)
 | 
				
			||||||
| 
						 | 
					@ -1872,7 +1872,7 @@ static noinline struct extent_buffer *read_node_slot(struct btrfs_root *root,
 | 
				
			||||||
	BUG_ON(level == 0);
 | 
						BUG_ON(level == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	eb = read_tree_block(root, btrfs_node_blockptr(parent, slot),
 | 
						eb = read_tree_block(root, btrfs_node_blockptr(parent, slot),
 | 
				
			||||||
			     btrfs_level_size(root, level - 1),
 | 
								     root->nodesize,
 | 
				
			||||||
			     btrfs_node_ptr_generation(parent, slot));
 | 
								     btrfs_node_ptr_generation(parent, slot));
 | 
				
			||||||
	if (eb && !extent_buffer_uptodate(eb)) {
 | 
						if (eb && !extent_buffer_uptodate(eb)) {
 | 
				
			||||||
		free_extent_buffer(eb);
 | 
							free_extent_buffer(eb);
 | 
				
			||||||
| 
						 | 
					@ -2267,7 +2267,7 @@ static void reada_for_search(struct btrfs_root *root,
 | 
				
			||||||
	node = path->nodes[level];
 | 
						node = path->nodes[level];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	search = btrfs_node_blockptr(node, slot);
 | 
						search = btrfs_node_blockptr(node, slot);
 | 
				
			||||||
	blocksize = btrfs_level_size(root, level - 1);
 | 
						blocksize = root->nodesize;
 | 
				
			||||||
	eb = btrfs_find_tree_block(root, search, blocksize);
 | 
						eb = btrfs_find_tree_block(root, search, blocksize);
 | 
				
			||||||
	if (eb) {
 | 
						if (eb) {
 | 
				
			||||||
		free_extent_buffer(eb);
 | 
							free_extent_buffer(eb);
 | 
				
			||||||
| 
						 | 
					@ -2325,7 +2325,7 @@ static noinline void reada_for_balance(struct btrfs_root *root,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nritems = btrfs_header_nritems(parent);
 | 
						nritems = btrfs_header_nritems(parent);
 | 
				
			||||||
	slot = path->slots[level + 1];
 | 
						slot = path->slots[level + 1];
 | 
				
			||||||
	blocksize = btrfs_level_size(root, level);
 | 
						blocksize = root->nodesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (slot > 0) {
 | 
						if (slot > 0) {
 | 
				
			||||||
		block1 = btrfs_node_blockptr(parent, slot - 1);
 | 
							block1 = btrfs_node_blockptr(parent, slot - 1);
 | 
				
			||||||
| 
						 | 
					@ -2461,7 +2461,7 @@ read_block_for_search(struct btrfs_trans_handle *trans,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	blocknr = btrfs_node_blockptr(b, slot);
 | 
						blocknr = btrfs_node_blockptr(b, slot);
 | 
				
			||||||
	gen = btrfs_node_ptr_generation(b, slot);
 | 
						gen = btrfs_node_ptr_generation(b, slot);
 | 
				
			||||||
	blocksize = btrfs_level_size(root, level - 1);
 | 
						blocksize = root->nodesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tmp = btrfs_find_tree_block(root, blocknr, blocksize);
 | 
						tmp = btrfs_find_tree_block(root, blocknr, blocksize);
 | 
				
			||||||
	if (tmp) {
 | 
						if (tmp) {
 | 
				
			||||||
| 
						 | 
					@ -4282,13 +4282,13 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		btrfs_item_key(l, &disk_key, mid);
 | 
							btrfs_item_key(l, &disk_key, mid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	right = btrfs_alloc_free_block(trans, root, root->leafsize, 0,
 | 
						right = btrfs_alloc_free_block(trans, root, root->nodesize, 0,
 | 
				
			||||||
					root->root_key.objectid,
 | 
										root->root_key.objectid,
 | 
				
			||||||
					&disk_key, 0, l->start, 0);
 | 
										&disk_key, 0, l->start, 0);
 | 
				
			||||||
	if (IS_ERR(right))
 | 
						if (IS_ERR(right))
 | 
				
			||||||
		return PTR_ERR(right);
 | 
							return PTR_ERR(right);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	root_add_used(root, root->leafsize);
 | 
						root_add_used(root, root->nodesize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset_extent_buffer(right, 0, 0, sizeof(struct btrfs_header));
 | 
						memset_extent_buffer(right, 0, 0, sizeof(struct btrfs_header));
 | 
				
			||||||
	btrfs_set_header_bytenr(right, right->start);
 | 
						btrfs_set_header_bytenr(right, right->start);
 | 
				
			||||||
| 
						 | 
					@ -5375,7 +5375,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tmp_buf = kmalloc(left_root->leafsize, GFP_NOFS);
 | 
						tmp_buf = kmalloc(left_root->nodesize, GFP_NOFS);
 | 
				
			||||||
	if (!tmp_buf) {
 | 
						if (!tmp_buf) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -391,7 +391,7 @@ struct btrfs_header {
 | 
				
			||||||
				      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->nodesize))
 | 
				
			||||||
#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
 | 
					#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
 | 
				
			||||||
					sizeof(struct btrfs_item) - \
 | 
										sizeof(struct btrfs_item) - \
 | 
				
			||||||
					sizeof(struct btrfs_file_extent_item))
 | 
										sizeof(struct btrfs_file_extent_item))
 | 
				
			||||||
| 
						 | 
					@ -474,7 +474,7 @@ struct btrfs_super_block {
 | 
				
			||||||
	__le64 num_devices;
 | 
						__le64 num_devices;
 | 
				
			||||||
	__le32 sectorsize;
 | 
						__le32 sectorsize;
 | 
				
			||||||
	__le32 nodesize;
 | 
						__le32 nodesize;
 | 
				
			||||||
	__le32 leafsize;
 | 
						__le32 __unused_leafsize;
 | 
				
			||||||
	__le32 stripesize;
 | 
						__le32 stripesize;
 | 
				
			||||||
	__le32 sys_chunk_array_size;
 | 
						__le32 sys_chunk_array_size;
 | 
				
			||||||
	__le64 chunk_root_generation;
 | 
						__le64 chunk_root_generation;
 | 
				
			||||||
| 
						 | 
					@ -1806,9 +1806,6 @@ struct btrfs_root {
 | 
				
			||||||
	/* node allocations are done in nodesize units */
 | 
						/* node allocations are done in nodesize units */
 | 
				
			||||||
	u32 nodesize;
 | 
						u32 nodesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* leaf allocations are done in leafsize units */
 | 
					 | 
				
			||||||
	u32 leafsize;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	u32 stripesize;
 | 
						u32 stripesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	u32 type;
 | 
						u32 type;
 | 
				
			||||||
| 
						 | 
					@ -2995,8 +2992,6 @@ BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block,
 | 
				
			||||||
			 sectorsize, 32);
 | 
								 sectorsize, 32);
 | 
				
			||||||
BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block,
 | 
					BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block,
 | 
				
			||||||
			 nodesize, 32);
 | 
								 nodesize, 32);
 | 
				
			||||||
BTRFS_SETGET_STACK_FUNCS(super_leafsize, struct btrfs_super_block,
 | 
					 | 
				
			||||||
			 leafsize, 32);
 | 
					 | 
				
			||||||
BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block,
 | 
					BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block,
 | 
				
			||||||
			 stripesize, 32);
 | 
								 stripesize, 32);
 | 
				
			||||||
BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block,
 | 
					BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block,
 | 
				
			||||||
| 
						 | 
					@ -3232,13 +3227,6 @@ static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb)
 | 
				
			||||||
	return sb->s_fs_info;
 | 
						return sb->s_fs_info;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline u32 btrfs_level_size(struct btrfs_root *root, int level)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (level == 0)
 | 
					 | 
				
			||||||
		return root->leafsize;
 | 
					 | 
				
			||||||
	return root->nodesize;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* helper function to cast into the data area of the leaf. */
 | 
					/* helper function to cast into the data area of the leaf. */
 | 
				
			||||||
#define btrfs_item_ptr(leaf, slot, type) \
 | 
					#define btrfs_item_ptr(leaf, slot, type) \
 | 
				
			||||||
	((type *)(btrfs_leaf_data(leaf) + \
 | 
						((type *)(btrfs_leaf_data(leaf) + \
 | 
				
			||||||
| 
						 | 
					@ -3263,7 +3251,7 @@ static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping)
 | 
				
			||||||
static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
 | 
					static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
 | 
				
			||||||
						 unsigned num_items)
 | 
											 unsigned num_items)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
 | 
						return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
 | 
				
			||||||
		2 * num_items;
 | 
							2 * num_items;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3274,8 +3262,7 @@ static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
 | 
				
			||||||
static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_root *root,
 | 
					static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_root *root,
 | 
				
			||||||
						 unsigned num_items)
 | 
											 unsigned num_items)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
 | 
						return root->nodesize * BTRFS_MAX_LEVEL * num_items;
 | 
				
			||||||
		num_items;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
 | 
					int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1200,16 +1200,14 @@ btrfs_free_subvolume_writers(struct btrfs_subvolume_writers *writers)
 | 
				
			||||||
	kfree(writers);
 | 
						kfree(writers);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
 | 
					static void __setup_root(u32 nodesize, u32 sectorsize, u32 stripesize,
 | 
				
			||||||
			 u32 stripesize, struct btrfs_root *root,
 | 
								 struct btrfs_root *root, struct btrfs_fs_info *fs_info,
 | 
				
			||||||
			 struct btrfs_fs_info *fs_info,
 | 
					 | 
				
			||||||
			 u64 objectid)
 | 
								 u64 objectid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	root->node = NULL;
 | 
						root->node = NULL;
 | 
				
			||||||
	root->commit_root = NULL;
 | 
						root->commit_root = NULL;
 | 
				
			||||||
	root->sectorsize = sectorsize;
 | 
						root->sectorsize = sectorsize;
 | 
				
			||||||
	root->nodesize = nodesize;
 | 
						root->nodesize = nodesize;
 | 
				
			||||||
	root->leafsize = leafsize;
 | 
					 | 
				
			||||||
	root->stripesize = stripesize;
 | 
						root->stripesize = stripesize;
 | 
				
			||||||
	root->state = 0;
 | 
						root->state = 0;
 | 
				
			||||||
	root->orphan_cleanup_state = 0;
 | 
						root->orphan_cleanup_state = 0;
 | 
				
			||||||
| 
						 | 
					@ -1295,7 +1293,7 @@ struct btrfs_root *btrfs_alloc_dummy_root(void)
 | 
				
			||||||
	root = btrfs_alloc_root(NULL);
 | 
						root = btrfs_alloc_root(NULL);
 | 
				
			||||||
	if (!root)
 | 
						if (!root)
 | 
				
			||||||
		return ERR_PTR(-ENOMEM);
 | 
							return ERR_PTR(-ENOMEM);
 | 
				
			||||||
	__setup_root(4096, 4096, 4096, 4096, root, NULL, 1);
 | 
						__setup_root(4096, 4096, 4096, root, NULL, 1);
 | 
				
			||||||
	set_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state);
 | 
						set_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state);
 | 
				
			||||||
	root->alloc_bytenr = 0;
 | 
						root->alloc_bytenr = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1318,14 +1316,13 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	if (!root)
 | 
						if (!root)
 | 
				
			||||||
		return ERR_PTR(-ENOMEM);
 | 
							return ERR_PTR(-ENOMEM);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__setup_root(tree_root->nodesize, tree_root->leafsize,
 | 
						__setup_root(tree_root->nodesize, tree_root->sectorsize,
 | 
				
			||||||
		     tree_root->sectorsize, tree_root->stripesize,
 | 
							tree_root->stripesize, root, fs_info, objectid);
 | 
				
			||||||
		     root, fs_info, objectid);
 | 
					 | 
				
			||||||
	root->root_key.objectid = objectid;
 | 
						root->root_key.objectid = objectid;
 | 
				
			||||||
	root->root_key.type = BTRFS_ROOT_ITEM_KEY;
 | 
						root->root_key.type = BTRFS_ROOT_ITEM_KEY;
 | 
				
			||||||
	root->root_key.offset = 0;
 | 
						root->root_key.offset = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	leaf = btrfs_alloc_free_block(trans, root, root->leafsize,
 | 
						leaf = btrfs_alloc_free_block(trans, root, root->nodesize,
 | 
				
			||||||
				      0, objectid, NULL, 0, 0, 0);
 | 
									      0, objectid, NULL, 0, 0, 0);
 | 
				
			||||||
	if (IS_ERR(leaf)) {
 | 
						if (IS_ERR(leaf)) {
 | 
				
			||||||
		ret = PTR_ERR(leaf);
 | 
							ret = PTR_ERR(leaf);
 | 
				
			||||||
| 
						 | 
					@ -1396,9 +1393,9 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	if (!root)
 | 
						if (!root)
 | 
				
			||||||
		return ERR_PTR(-ENOMEM);
 | 
							return ERR_PTR(-ENOMEM);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__setup_root(tree_root->nodesize, tree_root->leafsize,
 | 
						__setup_root(tree_root->nodesize, tree_root->sectorsize,
 | 
				
			||||||
		     tree_root->sectorsize, tree_root->stripesize,
 | 
							     tree_root->stripesize, root, fs_info,
 | 
				
			||||||
		     root, fs_info, BTRFS_TREE_LOG_OBJECTID);
 | 
							     BTRFS_TREE_LOG_OBJECTID);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID;
 | 
						root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID;
 | 
				
			||||||
	root->root_key.type = BTRFS_ROOT_ITEM_KEY;
 | 
						root->root_key.type = BTRFS_ROOT_ITEM_KEY;
 | 
				
			||||||
| 
						 | 
					@ -1413,7 +1410,7 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	 * updated (along with back refs to the log tree).
 | 
						 * updated (along with back refs to the log tree).
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	leaf = btrfs_alloc_free_block(trans, root, root->leafsize, 0,
 | 
						leaf = btrfs_alloc_free_block(trans, root, root->nodesize, 0,
 | 
				
			||||||
				      BTRFS_TREE_LOG_OBJECTID, NULL,
 | 
									      BTRFS_TREE_LOG_OBJECTID, NULL,
 | 
				
			||||||
				      0, 0, 0);
 | 
									      0, 0, 0);
 | 
				
			||||||
	if (IS_ERR(leaf)) {
 | 
						if (IS_ERR(leaf)) {
 | 
				
			||||||
| 
						 | 
					@ -1465,7 +1462,7 @@ int btrfs_add_log_tree(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	btrfs_set_stack_inode_generation(inode_item, 1);
 | 
						btrfs_set_stack_inode_generation(inode_item, 1);
 | 
				
			||||||
	btrfs_set_stack_inode_size(inode_item, 3);
 | 
						btrfs_set_stack_inode_size(inode_item, 3);
 | 
				
			||||||
	btrfs_set_stack_inode_nlink(inode_item, 1);
 | 
						btrfs_set_stack_inode_nlink(inode_item, 1);
 | 
				
			||||||
	btrfs_set_stack_inode_nbytes(inode_item, root->leafsize);
 | 
						btrfs_set_stack_inode_nbytes(inode_item, root->nodesize);
 | 
				
			||||||
	btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);
 | 
						btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	btrfs_set_root_node(&log_root->root_item, log_root->node);
 | 
						btrfs_set_root_node(&log_root->root_item, log_root->node);
 | 
				
			||||||
| 
						 | 
					@ -1498,9 +1495,8 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
 | 
				
			||||||
		goto alloc_fail;
 | 
							goto alloc_fail;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__setup_root(tree_root->nodesize, tree_root->leafsize,
 | 
						__setup_root(tree_root->nodesize, tree_root->sectorsize,
 | 
				
			||||||
		     tree_root->sectorsize, tree_root->stripesize,
 | 
							tree_root->stripesize, root, fs_info, key->objectid);
 | 
				
			||||||
		     root, fs_info, key->objectid);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = btrfs_find_root(tree_root, key, path,
 | 
						ret = btrfs_find_root(tree_root, key, path,
 | 
				
			||||||
			      &root->root_item, &root->root_key);
 | 
								      &root->root_item, &root->root_key);
 | 
				
			||||||
| 
						 | 
					@ -1511,7 +1507,7 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	generation = btrfs_root_generation(&root->root_item);
 | 
						generation = btrfs_root_generation(&root->root_item);
 | 
				
			||||||
	blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item));
 | 
						blocksize = root->nodesize;
 | 
				
			||||||
	root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
 | 
						root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
 | 
				
			||||||
				     blocksize, generation);
 | 
									     blocksize, generation);
 | 
				
			||||||
	if (!root->node) {
 | 
						if (!root->node) {
 | 
				
			||||||
| 
						 | 
					@ -2143,7 +2139,6 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	u32 sectorsize;
 | 
						u32 sectorsize;
 | 
				
			||||||
	u32 nodesize;
 | 
						u32 nodesize;
 | 
				
			||||||
	u32 leafsize;
 | 
					 | 
				
			||||||
	u32 blocksize;
 | 
						u32 blocksize;
 | 
				
			||||||
	u32 stripesize;
 | 
						u32 stripesize;
 | 
				
			||||||
	u64 generation;
 | 
						u64 generation;
 | 
				
			||||||
| 
						 | 
					@ -2389,7 +2384,7 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
		goto fail_alloc;
 | 
							goto fail_alloc;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__setup_root(4096, 4096, 4096, 4096, tree_root,
 | 
						__setup_root(4096, 4096, 4096, tree_root,
 | 
				
			||||||
		     fs_info, BTRFS_ROOT_TREE_OBJECTID);
 | 
							     fs_info, BTRFS_ROOT_TREE_OBJECTID);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	invalidate_bdev(fs_devices->latest_bdev);
 | 
						invalidate_bdev(fs_devices->latest_bdev);
 | 
				
			||||||
| 
						 | 
					@ -2469,19 +2464,22 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
		goto fail_alloc;
 | 
							goto fail_alloc;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (btrfs_super_leafsize(disk_super) !=
 | 
						/*
 | 
				
			||||||
 | 
						 * Leafsize and nodesize were always equal, this is only a sanity check.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (le32_to_cpu(disk_super->__unused_leafsize) !=
 | 
				
			||||||
	    btrfs_super_nodesize(disk_super)) {
 | 
						    btrfs_super_nodesize(disk_super)) {
 | 
				
			||||||
		printk(KERN_ERR "BTRFS: couldn't mount because metadata "
 | 
							printk(KERN_ERR "BTRFS: couldn't mount because metadata "
 | 
				
			||||||
		       "blocksizes don't match.  node %d leaf %d\n",
 | 
							       "blocksizes don't match.  node %d leaf %d\n",
 | 
				
			||||||
		       btrfs_super_nodesize(disk_super),
 | 
							       btrfs_super_nodesize(disk_super),
 | 
				
			||||||
		       btrfs_super_leafsize(disk_super));
 | 
							       le32_to_cpu(disk_super->__unused_leafsize));
 | 
				
			||||||
		err = -EINVAL;
 | 
							err = -EINVAL;
 | 
				
			||||||
		goto fail_alloc;
 | 
							goto fail_alloc;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (btrfs_super_leafsize(disk_super) > BTRFS_MAX_METADATA_BLOCKSIZE) {
 | 
						if (btrfs_super_nodesize(disk_super) > BTRFS_MAX_METADATA_BLOCKSIZE) {
 | 
				
			||||||
		printk(KERN_ERR "BTRFS: couldn't mount because metadata "
 | 
							printk(KERN_ERR "BTRFS: couldn't mount because metadata "
 | 
				
			||||||
		       "blocksize (%d) was too large\n",
 | 
							       "blocksize (%d) was too large\n",
 | 
				
			||||||
		       btrfs_super_leafsize(disk_super));
 | 
							       btrfs_super_nodesize(disk_super));
 | 
				
			||||||
		err = -EINVAL;
 | 
							err = -EINVAL;
 | 
				
			||||||
		goto fail_alloc;
 | 
							goto fail_alloc;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -2498,17 +2496,16 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
	 * flag our filesystem as having big metadata blocks if
 | 
						 * flag our filesystem as having big metadata blocks if
 | 
				
			||||||
	 * they are bigger than the page size
 | 
						 * they are bigger than the page size
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (btrfs_super_leafsize(disk_super) > PAGE_CACHE_SIZE) {
 | 
						if (btrfs_super_nodesize(disk_super) > PAGE_CACHE_SIZE) {
 | 
				
			||||||
		if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA))
 | 
							if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA))
 | 
				
			||||||
			printk(KERN_INFO "BTRFS: flagging fs with big metadata feature\n");
 | 
								printk(KERN_INFO "BTRFS: flagging fs with big metadata feature\n");
 | 
				
			||||||
		features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA;
 | 
							features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nodesize = btrfs_super_nodesize(disk_super);
 | 
						nodesize = btrfs_super_nodesize(disk_super);
 | 
				
			||||||
	leafsize = btrfs_super_leafsize(disk_super);
 | 
					 | 
				
			||||||
	sectorsize = btrfs_super_sectorsize(disk_super);
 | 
						sectorsize = btrfs_super_sectorsize(disk_super);
 | 
				
			||||||
	stripesize = btrfs_super_stripesize(disk_super);
 | 
						stripesize = btrfs_super_stripesize(disk_super);
 | 
				
			||||||
	fs_info->dirty_metadata_batch = leafsize * (1 + ilog2(nr_cpu_ids));
 | 
						fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids));
 | 
				
			||||||
	fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids));
 | 
						fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
| 
						 | 
					@ -2516,7 +2513,7 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
	 * extent buffers for the same range.  It leads to corruptions
 | 
						 * extent buffers for the same range.  It leads to corruptions
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if ((features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS) &&
 | 
						if ((features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS) &&
 | 
				
			||||||
	    (sectorsize != leafsize)) {
 | 
						    (sectorsize != nodesize)) {
 | 
				
			||||||
		printk(KERN_WARNING "BTRFS: unequal leaf/node/sector sizes "
 | 
							printk(KERN_WARNING "BTRFS: unequal leaf/node/sector sizes "
 | 
				
			||||||
				"are not allowed for mixed block groups on %s\n",
 | 
									"are not allowed for mixed block groups on %s\n",
 | 
				
			||||||
				sb->s_id);
 | 
									sb->s_id);
 | 
				
			||||||
| 
						 | 
					@ -2615,7 +2612,6 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
				    4 * 1024 * 1024 / PAGE_CACHE_SIZE);
 | 
									    4 * 1024 * 1024 / PAGE_CACHE_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tree_root->nodesize = nodesize;
 | 
						tree_root->nodesize = nodesize;
 | 
				
			||||||
	tree_root->leafsize = leafsize;
 | 
					 | 
				
			||||||
	tree_root->sectorsize = sectorsize;
 | 
						tree_root->sectorsize = sectorsize;
 | 
				
			||||||
	tree_root->stripesize = stripesize;
 | 
						tree_root->stripesize = stripesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2642,12 +2638,11 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
		goto fail_sb_buffer;
 | 
							goto fail_sb_buffer;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	blocksize = btrfs_level_size(tree_root,
 | 
						blocksize = tree_root->nodesize;
 | 
				
			||||||
				     btrfs_super_chunk_root_level(disk_super));
 | 
					 | 
				
			||||||
	generation = btrfs_super_chunk_root_generation(disk_super);
 | 
						generation = btrfs_super_chunk_root_generation(disk_super);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__setup_root(nodesize, leafsize, sectorsize, stripesize,
 | 
						__setup_root(nodesize, sectorsize, stripesize, chunk_root,
 | 
				
			||||||
		     chunk_root, fs_info, BTRFS_CHUNK_TREE_OBJECTID);
 | 
							     fs_info, BTRFS_CHUNK_TREE_OBJECTID);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	chunk_root->node = read_tree_block(chunk_root,
 | 
						chunk_root->node = read_tree_block(chunk_root,
 | 
				
			||||||
					   btrfs_super_chunk_root(disk_super),
 | 
										   btrfs_super_chunk_root(disk_super),
 | 
				
			||||||
| 
						 | 
					@ -2684,8 +2679,7 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
retry_root_backup:
 | 
					retry_root_backup:
 | 
				
			||||||
	blocksize = btrfs_level_size(tree_root,
 | 
						blocksize = tree_root->nodesize;
 | 
				
			||||||
				     btrfs_super_root_level(disk_super));
 | 
					 | 
				
			||||||
	generation = btrfs_super_generation(disk_super);
 | 
						generation = btrfs_super_generation(disk_super);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tree_root->node = read_tree_block(tree_root,
 | 
						tree_root->node = read_tree_block(tree_root,
 | 
				
			||||||
| 
						 | 
					@ -2859,9 +2853,7 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
			err = -EIO;
 | 
								err = -EIO;
 | 
				
			||||||
			goto fail_qgroup;
 | 
								goto fail_qgroup;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		blocksize =
 | 
							blocksize = tree_root->nodesize;
 | 
				
			||||||
		     btrfs_level_size(tree_root,
 | 
					 | 
				
			||||||
				      btrfs_super_log_root_level(disk_super));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		log_tree_root = btrfs_alloc_root(fs_info);
 | 
							log_tree_root = btrfs_alloc_root(fs_info);
 | 
				
			||||||
		if (!log_tree_root) {
 | 
							if (!log_tree_root) {
 | 
				
			||||||
| 
						 | 
					@ -2869,7 +2861,7 @@ int open_ctree(struct super_block *sb,
 | 
				
			||||||
			goto fail_qgroup;
 | 
								goto fail_qgroup;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		__setup_root(nodesize, leafsize, sectorsize, stripesize,
 | 
							__setup_root(nodesize, sectorsize, stripesize,
 | 
				
			||||||
			     log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID);
 | 
								     log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		log_tree_root->node = read_tree_block(tree_root, bytenr,
 | 
							log_tree_root->node = read_tree_block(tree_root, bytenr,
 | 
				
			||||||
| 
						 | 
					@ -4008,8 +4000,8 @@ static int btrfs_destroy_marked_extents(struct btrfs_root *root,
 | 
				
			||||||
		clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS);
 | 
							clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS);
 | 
				
			||||||
		while (start <= end) {
 | 
							while (start <= end) {
 | 
				
			||||||
			eb = btrfs_find_tree_block(root, start,
 | 
								eb = btrfs_find_tree_block(root, start,
 | 
				
			||||||
						   root->leafsize);
 | 
											   root->nodesize);
 | 
				
			||||||
			start += root->leafsize;
 | 
								start += root->nodesize;
 | 
				
			||||||
			if (!eb)
 | 
								if (!eb)
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			wait_on_extent_buffer_writeback(eb);
 | 
								wait_on_extent_buffer_writeback(eb);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -491,7 +491,7 @@ static noinline void caching_thread(struct btrfs_work *work)
 | 
				
			||||||
							  key.objectid);
 | 
												  key.objectid);
 | 
				
			||||||
			if (key.type == BTRFS_METADATA_ITEM_KEY)
 | 
								if (key.type == BTRFS_METADATA_ITEM_KEY)
 | 
				
			||||||
				last = key.objectid +
 | 
									last = key.objectid +
 | 
				
			||||||
					fs_info->tree_root->leafsize;
 | 
										fs_info->tree_root->nodesize;
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
				last = key.objectid + key.offset;
 | 
									last = key.objectid + key.offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -765,7 +765,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	 * different
 | 
						 * different
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (metadata && !btrfs_fs_incompat(root->fs_info, SKINNY_METADATA)) {
 | 
						if (metadata && !btrfs_fs_incompat(root->fs_info, SKINNY_METADATA)) {
 | 
				
			||||||
		offset = root->leafsize;
 | 
							offset = root->nodesize;
 | 
				
			||||||
		metadata = 0;
 | 
							metadata = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -799,13 +799,13 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 | 
				
			||||||
					      path->slots[0]);
 | 
										      path->slots[0]);
 | 
				
			||||||
			if (key.objectid == bytenr &&
 | 
								if (key.objectid == bytenr &&
 | 
				
			||||||
			    key.type == BTRFS_EXTENT_ITEM_KEY &&
 | 
								    key.type == BTRFS_EXTENT_ITEM_KEY &&
 | 
				
			||||||
			    key.offset == root->leafsize)
 | 
								    key.offset == root->nodesize)
 | 
				
			||||||
				ret = 0;
 | 
									ret = 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (ret) {
 | 
							if (ret) {
 | 
				
			||||||
			key.objectid = bytenr;
 | 
								key.objectid = bytenr;
 | 
				
			||||||
			key.type = BTRFS_EXTENT_ITEM_KEY;
 | 
								key.type = BTRFS_EXTENT_ITEM_KEY;
 | 
				
			||||||
			key.offset = root->leafsize;
 | 
								key.offset = root->nodesize;
 | 
				
			||||||
			btrfs_release_path(path);
 | 
								btrfs_release_path(path);
 | 
				
			||||||
			goto again;
 | 
								goto again;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -2651,7 +2651,7 @@ int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	num_bytes = btrfs_calc_trans_metadata_size(root, 1);
 | 
						num_bytes = btrfs_calc_trans_metadata_size(root, 1);
 | 
				
			||||||
	num_heads = heads_to_leaves(root, num_heads);
 | 
						num_heads = heads_to_leaves(root, num_heads);
 | 
				
			||||||
	if (num_heads > 1)
 | 
						if (num_heads > 1)
 | 
				
			||||||
		num_bytes += (num_heads - 1) * root->leafsize;
 | 
							num_bytes += (num_heads - 1) * root->nodesize;
 | 
				
			||||||
	num_bytes <<= 1;
 | 
						num_bytes <<= 1;
 | 
				
			||||||
	global_rsv = &root->fs_info->global_block_rsv;
 | 
						global_rsv = &root->fs_info->global_block_rsv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3117,7 +3117,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
 | 
				
			||||||
				goto fail;
 | 
									goto fail;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			bytenr = btrfs_node_blockptr(buf, i);
 | 
								bytenr = btrfs_node_blockptr(buf, i);
 | 
				
			||||||
			num_bytes = btrfs_level_size(root, level - 1);
 | 
								num_bytes = root->nodesize;
 | 
				
			||||||
			ret = process_func(trans, root, bytenr, num_bytes,
 | 
								ret = process_func(trans, root, bytenr, num_bytes,
 | 
				
			||||||
					   parent, ref_root, level - 1, 0,
 | 
										   parent, ref_root, level - 1, 0,
 | 
				
			||||||
					   1);
 | 
										   1);
 | 
				
			||||||
| 
						 | 
					@ -4839,7 +4839,7 @@ static u64 calc_global_metadata_size(struct btrfs_fs_info *fs_info)
 | 
				
			||||||
	if (num_bytes * 3 > meta_used)
 | 
						if (num_bytes * 3 > meta_used)
 | 
				
			||||||
		num_bytes = div64_u64(meta_used, 3);
 | 
							num_bytes = div64_u64(meta_used, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10);
 | 
						return ALIGN(num_bytes, fs_info->extent_root->nodesize << 10);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
 | 
					static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
 | 
				
			||||||
| 
						 | 
					@ -4988,7 +4988,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (root->fs_info->quota_enabled) {
 | 
						if (root->fs_info->quota_enabled) {
 | 
				
			||||||
		/* One for parent inode, two for dir entries */
 | 
							/* One for parent inode, two for dir entries */
 | 
				
			||||||
		num_bytes = 3 * root->leafsize;
 | 
							num_bytes = 3 * root->nodesize;
 | 
				
			||||||
		ret = btrfs_qgroup_reserve(root, num_bytes);
 | 
							ret = btrfs_qgroup_reserve(root, num_bytes);
 | 
				
			||||||
		if (ret)
 | 
							if (ret)
 | 
				
			||||||
			return ret;
 | 
								return ret;
 | 
				
			||||||
| 
						 | 
					@ -5176,7 +5176,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (root->fs_info->quota_enabled) {
 | 
						if (root->fs_info->quota_enabled) {
 | 
				
			||||||
		ret = btrfs_qgroup_reserve(root, num_bytes +
 | 
							ret = btrfs_qgroup_reserve(root, num_bytes +
 | 
				
			||||||
					   nr_extents * root->leafsize);
 | 
										   nr_extents * root->nodesize);
 | 
				
			||||||
		if (ret)
 | 
							if (ret)
 | 
				
			||||||
			goto out_fail;
 | 
								goto out_fail;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -5185,7 +5185,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
 | 
				
			||||||
	if (unlikely(ret)) {
 | 
						if (unlikely(ret)) {
 | 
				
			||||||
		if (root->fs_info->quota_enabled)
 | 
							if (root->fs_info->quota_enabled)
 | 
				
			||||||
			btrfs_qgroup_free(root, num_bytes +
 | 
								btrfs_qgroup_free(root, num_bytes +
 | 
				
			||||||
						nr_extents * root->leafsize);
 | 
											nr_extents * root->nodesize);
 | 
				
			||||||
		goto out_fail;
 | 
							goto out_fail;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5301,7 +5301,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes)
 | 
				
			||||||
				      btrfs_ino(inode), to_free, 0);
 | 
									      btrfs_ino(inode), to_free, 0);
 | 
				
			||||||
	if (root->fs_info->quota_enabled) {
 | 
						if (root->fs_info->quota_enabled) {
 | 
				
			||||||
		btrfs_qgroup_free(root, num_bytes +
 | 
							btrfs_qgroup_free(root, num_bytes +
 | 
				
			||||||
					dropped * root->leafsize);
 | 
										dropped * root->nodesize);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	btrfs_block_rsv_release(root, &root->fs_info->delalloc_block_rsv,
 | 
						btrfs_block_rsv_release(root, &root->fs_info->delalloc_block_rsv,
 | 
				
			||||||
| 
						 | 
					@ -7077,7 +7077,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	path = btrfs_alloc_path();
 | 
						path = btrfs_alloc_path();
 | 
				
			||||||
	if (!path) {
 | 
						if (!path) {
 | 
				
			||||||
		btrfs_free_and_pin_reserved_extent(root, ins->objectid,
 | 
							btrfs_free_and_pin_reserved_extent(root, ins->objectid,
 | 
				
			||||||
						   root->leafsize);
 | 
											   root->nodesize);
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7086,7 +7086,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 | 
				
			||||||
				      ins, size);
 | 
									      ins, size);
 | 
				
			||||||
	if (ret) {
 | 
						if (ret) {
 | 
				
			||||||
		btrfs_free_and_pin_reserved_extent(root, ins->objectid,
 | 
							btrfs_free_and_pin_reserved_extent(root, ins->objectid,
 | 
				
			||||||
						   root->leafsize);
 | 
											   root->nodesize);
 | 
				
			||||||
		btrfs_free_path(path);
 | 
							btrfs_free_path(path);
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -7101,7 +7101,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (skinny_metadata) {
 | 
						if (skinny_metadata) {
 | 
				
			||||||
		iref = (struct btrfs_extent_inline_ref *)(extent_item + 1);
 | 
							iref = (struct btrfs_extent_inline_ref *)(extent_item + 1);
 | 
				
			||||||
		num_bytes = root->leafsize;
 | 
							num_bytes = root->nodesize;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		block_info = (struct btrfs_tree_block_info *)(extent_item + 1);
 | 
							block_info = (struct btrfs_tree_block_info *)(extent_item + 1);
 | 
				
			||||||
		btrfs_set_tree_block_key(leaf, block_info, key);
 | 
							btrfs_set_tree_block_key(leaf, block_info, key);
 | 
				
			||||||
| 
						 | 
					@ -7131,14 +7131,14 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 | 
				
			||||||
			return ret;
 | 
								return ret;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = update_block_group(root, ins->objectid, root->leafsize, 1);
 | 
						ret = update_block_group(root, ins->objectid, root->nodesize, 1);
 | 
				
			||||||
	if (ret) { /* -ENOENT, logic error */
 | 
						if (ret) { /* -ENOENT, logic error */
 | 
				
			||||||
		btrfs_err(fs_info, "update block group failed for %llu %llu",
 | 
							btrfs_err(fs_info, "update block group failed for %llu %llu",
 | 
				
			||||||
			ins->objectid, ins->offset);
 | 
								ins->objectid, ins->offset);
 | 
				
			||||||
		BUG();
 | 
							BUG();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	trace_btrfs_reserved_extent_alloc(root, ins->objectid, root->leafsize);
 | 
						trace_btrfs_reserved_extent_alloc(root, ins->objectid, root->nodesize);
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7417,7 +7417,7 @@ static noinline void reada_walk_down(struct btrfs_trans_handle *trans,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	eb = path->nodes[wc->level];
 | 
						eb = path->nodes[wc->level];
 | 
				
			||||||
	nritems = btrfs_header_nritems(eb);
 | 
						nritems = btrfs_header_nritems(eb);
 | 
				
			||||||
	blocksize = btrfs_level_size(root, wc->level - 1);
 | 
						blocksize = root->nodesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (slot = path->slots[wc->level]; slot < nritems; slot++) {
 | 
						for (slot = path->slots[wc->level]; slot < nritems; slot++) {
 | 
				
			||||||
		if (nread >= wc->reada_count)
 | 
							if (nread >= wc->reada_count)
 | 
				
			||||||
| 
						 | 
					@ -7806,7 +7806,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bytenr = btrfs_node_blockptr(path->nodes[level], path->slots[level]);
 | 
						bytenr = btrfs_node_blockptr(path->nodes[level], path->slots[level]);
 | 
				
			||||||
	blocksize = btrfs_level_size(root, level - 1);
 | 
						blocksize = root->nodesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	next = btrfs_find_tree_block(root, bytenr, blocksize);
 | 
						next = btrfs_find_tree_block(root, bytenr, blocksize);
 | 
				
			||||||
	if (!next) {
 | 
						if (!next) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1653,7 +1653,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
 | 
				
			||||||
		cond_resched();
 | 
							cond_resched();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		balance_dirty_pages_ratelimited(inode->i_mapping);
 | 
							balance_dirty_pages_ratelimited(inode->i_mapping);
 | 
				
			||||||
		if (dirty_pages < (root->leafsize >> PAGE_CACHE_SHIFT) + 1)
 | 
							if (dirty_pages < (root->nodesize >> PAGE_CACHE_SHIFT) + 1)
 | 
				
			||||||
			btrfs_btree_balance_dirty(root);
 | 
								btrfs_btree_balance_dirty(root);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		pos += copied;
 | 
							pos += copied;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -477,7 +477,7 @@ static noinline int create_subvol(struct inode *dir,
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		goto fail;
 | 
							goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	leaf = btrfs_alloc_free_block(trans, root, root->leafsize,
 | 
						leaf = btrfs_alloc_free_block(trans, root, root->nodesize,
 | 
				
			||||||
				      0, objectid, NULL, 0, 0, 0);
 | 
									      0, objectid, NULL, 0, 0, 0);
 | 
				
			||||||
	if (IS_ERR(leaf)) {
 | 
						if (IS_ERR(leaf)) {
 | 
				
			||||||
		ret = PTR_ERR(leaf);
 | 
							ret = PTR_ERR(leaf);
 | 
				
			||||||
| 
						 | 
					@ -503,7 +503,7 @@ static noinline int create_subvol(struct inode *dir,
 | 
				
			||||||
	btrfs_set_stack_inode_generation(inode_item, 1);
 | 
						btrfs_set_stack_inode_generation(inode_item, 1);
 | 
				
			||||||
	btrfs_set_stack_inode_size(inode_item, 3);
 | 
						btrfs_set_stack_inode_size(inode_item, 3);
 | 
				
			||||||
	btrfs_set_stack_inode_nlink(inode_item, 1);
 | 
						btrfs_set_stack_inode_nlink(inode_item, 1);
 | 
				
			||||||
	btrfs_set_stack_inode_nbytes(inode_item, root->leafsize);
 | 
						btrfs_set_stack_inode_nbytes(inode_item, root->nodesize);
 | 
				
			||||||
	btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);
 | 
						btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	btrfs_set_root_flags(&root_item, 0);
 | 
						btrfs_set_root_flags(&root_item, 0);
 | 
				
			||||||
| 
						 | 
					@ -3199,7 +3199,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
 | 
				
			||||||
	u64 last_dest_end = destoff;
 | 
						u64 last_dest_end = destoff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = -ENOMEM;
 | 
						ret = -ENOMEM;
 | 
				
			||||||
	buf = vmalloc(btrfs_level_size(root, 0));
 | 
						buf = vmalloc(root->nodesize);
 | 
				
			||||||
	if (!buf)
 | 
						if (!buf)
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -336,7 +336,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
 | 
				
			||||||
	for (i = 0; i < nr; i++) {
 | 
						for (i = 0; i < nr; i++) {
 | 
				
			||||||
		struct extent_buffer *next = read_tree_block(root,
 | 
							struct extent_buffer *next = read_tree_block(root,
 | 
				
			||||||
					btrfs_node_blockptr(c, i),
 | 
										btrfs_node_blockptr(c, i),
 | 
				
			||||||
					btrfs_level_size(root, level - 1),
 | 
										root->nodesize,
 | 
				
			||||||
					btrfs_node_ptr_generation(c, i));
 | 
										btrfs_node_ptr_generation(c, i));
 | 
				
			||||||
		if (btrfs_is_leaf(next) &&
 | 
							if (btrfs_is_leaf(next) &&
 | 
				
			||||||
		   level != 1)
 | 
							   level != 1)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2237,7 +2237,6 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
 | 
				
			||||||
	if (srcid) {
 | 
						if (srcid) {
 | 
				
			||||||
		struct btrfs_root *srcroot;
 | 
							struct btrfs_root *srcroot;
 | 
				
			||||||
		struct btrfs_key srckey;
 | 
							struct btrfs_key srckey;
 | 
				
			||||||
		int srcroot_level;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		srckey.objectid = srcid;
 | 
							srckey.objectid = srcid;
 | 
				
			||||||
		srckey.type = BTRFS_ROOT_ITEM_KEY;
 | 
							srckey.type = BTRFS_ROOT_ITEM_KEY;
 | 
				
			||||||
| 
						 | 
					@ -2249,8 +2248,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		rcu_read_lock();
 | 
							rcu_read_lock();
 | 
				
			||||||
		srcroot_level = btrfs_header_level(srcroot->node);
 | 
							level_size = srcroot->nodesize;
 | 
				
			||||||
		level_size = btrfs_level_size(srcroot, srcroot_level);
 | 
					 | 
				
			||||||
		rcu_read_unlock();
 | 
							rcu_read_unlock();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2566,7 +2564,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
 | 
				
			||||||
		    found.type != BTRFS_METADATA_ITEM_KEY)
 | 
							    found.type != BTRFS_METADATA_ITEM_KEY)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		if (found.type == BTRFS_METADATA_ITEM_KEY)
 | 
							if (found.type == BTRFS_METADATA_ITEM_KEY)
 | 
				
			||||||
			num_bytes = fs_info->extent_root->leafsize;
 | 
								num_bytes = fs_info->extent_root->nodesize;
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			num_bytes = found.offset;
 | 
								num_bytes = found.offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -347,7 +347,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
 | 
				
			||||||
	if (!re)
 | 
						if (!re)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	blocksize = btrfs_level_size(root, level);
 | 
						blocksize = root->nodesize;
 | 
				
			||||||
	re->logical = logical;
 | 
						re->logical = logical;
 | 
				
			||||||
	re->blocksize = blocksize;
 | 
						re->blocksize = blocksize;
 | 
				
			||||||
	re->top = *top;
 | 
						re->top = *top;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1787,7 +1787,7 @@ int replace_path(struct btrfs_trans_handle *trans,
 | 
				
			||||||
			btrfs_node_key_to_cpu(parent, next_key, slot + 1);
 | 
								btrfs_node_key_to_cpu(parent, next_key, slot + 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		old_bytenr = btrfs_node_blockptr(parent, slot);
 | 
							old_bytenr = btrfs_node_blockptr(parent, slot);
 | 
				
			||||||
		blocksize = btrfs_level_size(dest, level - 1);
 | 
							blocksize = dest->nodesize;
 | 
				
			||||||
		old_ptr_gen = btrfs_node_ptr_generation(parent, slot);
 | 
							old_ptr_gen = btrfs_node_ptr_generation(parent, slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (level <= max_level) {
 | 
							if (level <= max_level) {
 | 
				
			||||||
| 
						 | 
					@ -1970,7 +1970,7 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bytenr = btrfs_node_blockptr(eb, path->slots[i]);
 | 
							bytenr = btrfs_node_blockptr(eb, path->slots[i]);
 | 
				
			||||||
		blocksize = btrfs_level_size(root, i - 1);
 | 
							blocksize = root->nodesize;
 | 
				
			||||||
		eb = read_tree_block(root, bytenr, blocksize, ptr_gen);
 | 
							eb = read_tree_block(root, bytenr, blocksize, ptr_gen);
 | 
				
			||||||
		if (!eb || !extent_buffer_uptodate(eb)) {
 | 
							if (!eb || !extent_buffer_uptodate(eb)) {
 | 
				
			||||||
			free_extent_buffer(eb);
 | 
								free_extent_buffer(eb);
 | 
				
			||||||
| 
						 | 
					@ -2544,8 +2544,7 @@ u64 calcu_metadata_size(struct reloc_control *rc,
 | 
				
			||||||
			if (next->processed && (reserve || next != node))
 | 
								if (next->processed && (reserve || next != node))
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			num_bytes += btrfs_level_size(rc->extent_root,
 | 
								num_bytes += rc->extent_root->nodesize;
 | 
				
			||||||
						      next->level);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (list_empty(&next->upper))
 | 
								if (list_empty(&next->upper))
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
| 
						 | 
					@ -2679,7 +2678,7 @@ static int do_relocation(struct btrfs_trans_handle *trans,
 | 
				
			||||||
				goto next;
 | 
									goto next;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		blocksize = btrfs_level_size(root, node->level);
 | 
							blocksize = root->nodesize;
 | 
				
			||||||
		generation = btrfs_node_ptr_generation(upper->eb, slot);
 | 
							generation = btrfs_node_ptr_generation(upper->eb, slot);
 | 
				
			||||||
		eb = read_tree_block(root, bytenr, blocksize, generation);
 | 
							eb = read_tree_block(root, bytenr, blocksize, generation);
 | 
				
			||||||
		if (!eb || !extent_buffer_uptodate(eb)) {
 | 
							if (!eb || !extent_buffer_uptodate(eb)) {
 | 
				
			||||||
| 
						 | 
					@ -2789,7 +2788,7 @@ static void __mark_block_processed(struct reloc_control *rc,
 | 
				
			||||||
	u32 blocksize;
 | 
						u32 blocksize;
 | 
				
			||||||
	if (node->level == 0 ||
 | 
						if (node->level == 0 ||
 | 
				
			||||||
	    in_block_group(node->bytenr, rc->block_group)) {
 | 
						    in_block_group(node->bytenr, rc->block_group)) {
 | 
				
			||||||
		blocksize = btrfs_level_size(rc->extent_root, node->level);
 | 
							blocksize = rc->extent_root->nodesize;
 | 
				
			||||||
		mark_block_processed(rc, node->bytenr, blocksize);
 | 
							mark_block_processed(rc, node->bytenr, blocksize);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	node->processed = 1;
 | 
						node->processed = 1;
 | 
				
			||||||
| 
						 | 
					@ -2865,7 +2864,7 @@ static int reada_tree_block(struct reloc_control *rc,
 | 
				
			||||||
	if (block->key.type == BTRFS_METADATA_ITEM_KEY)
 | 
						if (block->key.type == BTRFS_METADATA_ITEM_KEY)
 | 
				
			||||||
		readahead_tree_block(rc->extent_root, block->bytenr,
 | 
							readahead_tree_block(rc->extent_root, block->bytenr,
 | 
				
			||||||
				     block->key.objectid,
 | 
									     block->key.objectid,
 | 
				
			||||||
				     rc->extent_root->leafsize);
 | 
									     rc->extent_root->nodesize);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		readahead_tree_block(rc->extent_root, block->bytenr,
 | 
							readahead_tree_block(rc->extent_root, block->bytenr,
 | 
				
			||||||
				     block->key.objectid, block->key.offset);
 | 
									     block->key.objectid, block->key.offset);
 | 
				
			||||||
| 
						 | 
					@ -3313,7 +3312,7 @@ static int add_tree_block(struct reloc_control *rc,
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	block->bytenr = extent_key->objectid;
 | 
						block->bytenr = extent_key->objectid;
 | 
				
			||||||
	block->key.objectid = rc->extent_root->leafsize;
 | 
						block->key.objectid = rc->extent_root->nodesize;
 | 
				
			||||||
	block->key.offset = generation;
 | 
						block->key.offset = generation;
 | 
				
			||||||
	block->level = level;
 | 
						block->level = level;
 | 
				
			||||||
	block->key_ready = 0;
 | 
						block->key_ready = 0;
 | 
				
			||||||
| 
						 | 
					@ -3640,7 +3639,7 @@ int add_data_references(struct reloc_control *rc,
 | 
				
			||||||
	struct btrfs_extent_inline_ref *iref;
 | 
						struct btrfs_extent_inline_ref *iref;
 | 
				
			||||||
	unsigned long ptr;
 | 
						unsigned long ptr;
 | 
				
			||||||
	unsigned long end;
 | 
						unsigned long end;
 | 
				
			||||||
	u32 blocksize = btrfs_level_size(rc->extent_root, 0);
 | 
						u32 blocksize = rc->extent_root->nodesize;
 | 
				
			||||||
	int ret = 0;
 | 
						int ret = 0;
 | 
				
			||||||
	int err = 0;
 | 
						int err = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3783,7 +3782,7 @@ int find_next_extent(struct btrfs_trans_handle *trans,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (key.type == BTRFS_METADATA_ITEM_KEY &&
 | 
							if (key.type == BTRFS_METADATA_ITEM_KEY &&
 | 
				
			||||||
		    key.objectid + rc->extent_root->leafsize <=
 | 
							    key.objectid + rc->extent_root->nodesize <=
 | 
				
			||||||
		    rc->search_start) {
 | 
							    rc->search_start) {
 | 
				
			||||||
			path->slots[0]++;
 | 
								path->slots[0]++;
 | 
				
			||||||
			goto next;
 | 
								goto next;
 | 
				
			||||||
| 
						 | 
					@ -3801,7 +3800,7 @@ int find_next_extent(struct btrfs_trans_handle *trans,
 | 
				
			||||||
				rc->search_start = key.objectid + key.offset;
 | 
									rc->search_start = key.objectid + key.offset;
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
				rc->search_start = key.objectid +
 | 
									rc->search_start = key.objectid +
 | 
				
			||||||
					rc->extent_root->leafsize;
 | 
										rc->extent_root->nodesize;
 | 
				
			||||||
			memcpy(extent_key, &key, sizeof(key));
 | 
								memcpy(extent_key, &key, sizeof(key));
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -137,7 +137,6 @@ struct scrub_ctx {
 | 
				
			||||||
	int			pages_per_rd_bio;
 | 
						int			pages_per_rd_bio;
 | 
				
			||||||
	u32			sectorsize;
 | 
						u32			sectorsize;
 | 
				
			||||||
	u32			nodesize;
 | 
						u32			nodesize;
 | 
				
			||||||
	u32			leafsize;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int			is_dev_replace;
 | 
						int			is_dev_replace;
 | 
				
			||||||
	struct scrub_wr_ctx	wr_ctx;
 | 
						struct scrub_wr_ctx	wr_ctx;
 | 
				
			||||||
| 
						 | 
					@ -438,7 +437,6 @@ struct scrub_ctx *scrub_setup_ctx(struct btrfs_device *dev, int is_dev_replace)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	sctx->first_free = 0;
 | 
						sctx->first_free = 0;
 | 
				
			||||||
	sctx->nodesize = dev->dev_root->nodesize;
 | 
						sctx->nodesize = dev->dev_root->nodesize;
 | 
				
			||||||
	sctx->leafsize = dev->dev_root->leafsize;
 | 
					 | 
				
			||||||
	sctx->sectorsize = dev->dev_root->sectorsize;
 | 
						sctx->sectorsize = dev->dev_root->sectorsize;
 | 
				
			||||||
	atomic_set(&sctx->bios_in_flight, 0);
 | 
						atomic_set(&sctx->bios_in_flight, 0);
 | 
				
			||||||
	atomic_set(&sctx->workers_pending, 0);
 | 
						atomic_set(&sctx->workers_pending, 0);
 | 
				
			||||||
| 
						 | 
					@ -1758,7 +1756,6 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock)
 | 
				
			||||||
		   BTRFS_UUID_SIZE))
 | 
							   BTRFS_UUID_SIZE))
 | 
				
			||||||
		++fail;
 | 
							++fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	WARN_ON(sctx->nodesize != sctx->leafsize);
 | 
					 | 
				
			||||||
	len = sctx->nodesize - BTRFS_CSUM_SIZE;
 | 
						len = sctx->nodesize - BTRFS_CSUM_SIZE;
 | 
				
			||||||
	mapped_size = PAGE_SIZE - BTRFS_CSUM_SIZE;
 | 
						mapped_size = PAGE_SIZE - BTRFS_CSUM_SIZE;
 | 
				
			||||||
	p = ((u8 *)mapped_buffer) + BTRFS_CSUM_SIZE;
 | 
						p = ((u8 *)mapped_buffer) + BTRFS_CSUM_SIZE;
 | 
				
			||||||
| 
						 | 
					@ -2196,7 +2193,6 @@ static int scrub_extent(struct scrub_ctx *sctx, u64 logical, u64 len,
 | 
				
			||||||
		sctx->stat.data_bytes_scrubbed += len;
 | 
							sctx->stat.data_bytes_scrubbed += len;
 | 
				
			||||||
		spin_unlock(&sctx->stat_lock);
 | 
							spin_unlock(&sctx->stat_lock);
 | 
				
			||||||
	} else if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
 | 
						} else if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
 | 
				
			||||||
		WARN_ON(sctx->nodesize != sctx->leafsize);
 | 
					 | 
				
			||||||
		blocksize = sctx->nodesize;
 | 
							blocksize = sctx->nodesize;
 | 
				
			||||||
		spin_lock(&sctx->stat_lock);
 | 
							spin_lock(&sctx->stat_lock);
 | 
				
			||||||
		sctx->stat.tree_extents_scrubbed++;
 | 
							sctx->stat.tree_extents_scrubbed++;
 | 
				
			||||||
| 
						 | 
					@ -2487,7 +2483,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
 | 
				
			||||||
			btrfs_item_key_to_cpu(l, &key, slot);
 | 
								btrfs_item_key_to_cpu(l, &key, slot);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (key.type == BTRFS_METADATA_ITEM_KEY)
 | 
								if (key.type == BTRFS_METADATA_ITEM_KEY)
 | 
				
			||||||
				bytes = root->leafsize;
 | 
									bytes = root->nodesize;
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
				bytes = key.offset;
 | 
									bytes = key.offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2910,17 +2906,6 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
 | 
				
			||||||
	if (btrfs_fs_closing(fs_info))
 | 
						if (btrfs_fs_closing(fs_info))
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	 * check some assumptions
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	if (fs_info->chunk_root->nodesize != fs_info->chunk_root->leafsize) {
 | 
					 | 
				
			||||||
		btrfs_err(fs_info,
 | 
					 | 
				
			||||||
			   "scrub: size assumption nodesize == leafsize (%d == %d) fails",
 | 
					 | 
				
			||||||
		       fs_info->chunk_root->nodesize,
 | 
					 | 
				
			||||||
		       fs_info->chunk_root->leafsize);
 | 
					 | 
				
			||||||
		return -EINVAL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (fs_info->chunk_root->nodesize > BTRFS_STRIPE_LEN) {
 | 
						if (fs_info->chunk_root->nodesize > BTRFS_STRIPE_LEN) {
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * in this case scrub is unable to calculate the checksum
 | 
							 * in this case scrub is unable to calculate the checksum
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -408,7 +408,7 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,
 | 
				
			||||||
	if (num_items > 0 && root != root->fs_info->chunk_root) {
 | 
						if (num_items > 0 && root != root->fs_info->chunk_root) {
 | 
				
			||||||
		if (root->fs_info->quota_enabled &&
 | 
							if (root->fs_info->quota_enabled &&
 | 
				
			||||||
		    is_fstree(root->root_key.objectid)) {
 | 
							    is_fstree(root->root_key.objectid)) {
 | 
				
			||||||
			qgroup_reserved = num_items * root->leafsize;
 | 
								qgroup_reserved = num_items * root->nodesize;
 | 
				
			||||||
			ret = btrfs_qgroup_reserve(root, qgroup_reserved);
 | 
								ret = btrfs_qgroup_reserve(root, qgroup_reserved);
 | 
				
			||||||
			if (ret)
 | 
								if (ret)
 | 
				
			||||||
				return ERR_PTR(ret);
 | 
									return ERR_PTR(ret);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2157,7 +2157,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
 | 
							bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
 | 
				
			||||||
		ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]);
 | 
							ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]);
 | 
				
			||||||
		blocksize = btrfs_level_size(root, *level - 1);
 | 
							blocksize = root->nodesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		parent = path->nodes[*level];
 | 
							parent = path->nodes[*level];
 | 
				
			||||||
		root_owner = btrfs_header_owner(parent);
 | 
							root_owner = btrfs_header_owner(parent);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue