@@ -87,7 +87,7 @@ static inline int compressed_bio_size(struct btrfs_root *root,
{
u16 csum_size = btrfs_super_csum_size(&root->fs_info->super_copy);
return sizeof(struct compressed_bio) +
- ((disk_size + root->sectorsize - 1) / root->sectorsize) *
+ ((disk_size + root->fs_info->sectorsize - 1) / root->fs_info->sectorsize) *
csum_size;
}
@@ -674,8 +674,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
comp_bio, sums);
BUG_ON(ret);
}
- sums += (comp_bio->bi_size + root->sectorsize - 1) /
- root->sectorsize;
+ sums += (comp_bio->bi_size + root->fs_info->sectorsize - 1) /
+ root->fs_info->sectorsize;
ret = btrfs_map_bio(root, READ, comp_bio,
mirror_num, 0);
@@ -2070,13 +2070,13 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans,
else
btrfs_node_key(lower, &lower_key, 0);
- c = btrfs_alloc_free_block(trans, root, root->nodesize, 0,
+ c = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize, 0,
root->root_key.objectid, &lower_key,
level, root->node->start, 0);
if (IS_ERR(c))
return PTR_ERR(c);
- root_add_used(root, root->nodesize);
+ root_add_used(root, root->fs_info->nodesize);
memset_extent_buffer(c, 0, 0, sizeof(struct btrfs_header));
btrfs_set_header_nritems(c, 1);
@@ -2197,13 +2197,13 @@ static noinline int split_node(struct btrfs_trans_handle *trans,
mid = (c_nritems + 1) / 2;
btrfs_node_key(c, &disk_key, mid);
- split = btrfs_alloc_free_block(trans, root, root->nodesize, 0,
+ split = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize, 0,
root->root_key.objectid,
&disk_key, level, c->start, 0);
if (IS_ERR(split))
return PTR_ERR(split);
- root_add_used(root, root->nodesize);
+ root_add_used(root, root->fs_info->nodesize);
memset_extent_buffer(split, 0, 0, sizeof(struct btrfs_header));
btrfs_set_header_level(split, btrfs_header_level(c));
@@ -2951,13 +2951,13 @@ again:
else
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->fs_info->leafsize, 0,
root->root_key.objectid,
&disk_key, 0, l->start, 0);
if (IS_ERR(right))
return PTR_ERR(right);
- root_add_used(root, root->leafsize);
+ root_add_used(root, root->fs_info->leafsize);
memset_extent_buffer(right, 0, 0, sizeof(struct btrfs_header));
btrfs_set_header_bytenr(right, right->start);
@@ -339,11 +339,11 @@ struct btrfs_header {
u8 level;
} __attribute__ ((__packed__));
-#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \
+#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->fs_info->nodesize - \
sizeof(struct btrfs_header)) / \
sizeof(struct btrfs_key_ptr))
#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->fs_info->leafsize))
#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
sizeof(struct btrfs_item) - \
sizeof(struct btrfs_file_extent_item))
@@ -1115,6 +1115,15 @@ struct btrfs_fs_info {
int scrub_workers_refcnt;
struct btrfs_workers scrub_workers;
+ /* node allocations are done in nodesize units */
+ u32 nodesize;
+
+ /* leaf allocations are done in leafsize units */
+ u32 leafsize;
+
+ /* data allocations are done in sectorsize units */
+ u32 sectorsize;
+
/* filesystem state */
u64 fs_state;
@@ -1168,15 +1177,6 @@ struct btrfs_root {
u64 objectid;
u64 last_trans;
- /* data allocations are done in sectorsize units */
- u32 sectorsize;
-
- /* node allocations are done in nodesize units */
- u32 nodesize;
-
- /* leaf allocations are done in leafsize units */
- u32 leafsize;
-
u32 stripesize;
u32 type;
@@ -2107,8 +2107,8 @@ static inline struct btrfs_root *btrfs_sb(struct super_block *sb)
static inline u32 btrfs_level_size(struct btrfs_root *root, int level)
{
if (level == 0)
- return root->leafsize;
- return root->nodesize;
+ return root->fs_info->leafsize;
+ return root->fs_info->nodesize;
}
/* helper function to cast into the data area of the leaf. */
@@ -2135,7 +2135,7 @@ static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info)
static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
unsigned num_items)
{
- return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
+ return (root->fs_info->leafsize + root->fs_info->nodesize * (BTRFS_MAX_LEVEL - 1)) *
3 * num_items;
}
@@ -1056,16 +1056,12 @@ int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
return 0;
}
-static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
- u32 stripesize, struct btrfs_root *root,
+static int __setup_root(u32 stripesize, struct btrfs_root *root,
struct btrfs_fs_info *fs_info,
u64 objectid)
{
root->node = NULL;
root->commit_root = NULL;
- root->sectorsize = sectorsize;
- root->nodesize = nodesize;
- root->leafsize = leafsize;
root->stripesize = stripesize;
root->ref_cows = 0;
root->track_dirty = 0;
@@ -1129,9 +1125,7 @@ static int find_and_setup_root(struct btrfs_root *tree_root,
u32 blocksize;
u64 generation;
- __setup_root(tree_root->nodesize, tree_root->leafsize,
- tree_root->sectorsize, tree_root->stripesize,
- root, fs_info, objectid);
+ __setup_root(tree_root->stripesize, root, fs_info, objectid);
ret = btrfs_find_last_root(tree_root, objectid,
&root->root_item, &root->root_key);
if (ret > 0)
@@ -1161,9 +1155,8 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
if (!root)
return ERR_PTR(-ENOMEM);
- __setup_root(tree_root->nodesize, tree_root->leafsize,
- tree_root->sectorsize, tree_root->stripesize,
- root, fs_info, BTRFS_TREE_LOG_OBJECTID);
+ __setup_root(tree_root->stripesize, root, fs_info,
+ BTRFS_TREE_LOG_OBJECTID);
root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID;
root->root_key.type = BTRFS_ROOT_ITEM_KEY;
@@ -1176,7 +1169,7 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
*/
root->ref_cows = 0;
- leaf = btrfs_alloc_free_block(trans, root, root->leafsize, 0,
+ leaf = btrfs_alloc_free_block(trans, root, root->fs_info->leafsize, 0,
BTRFS_TREE_LOG_OBJECTID, NULL, 0, 0, 0);
if (IS_ERR(leaf)) {
kfree(root);
@@ -1228,7 +1221,7 @@ int btrfs_add_log_tree(struct btrfs_trans_handle *trans,
inode_item->generation = cpu_to_le64(1);
inode_item->size = cpu_to_le64(3);
inode_item->nlink = cpu_to_le32(1);
- inode_item->nbytes = cpu_to_le64(root->leafsize);
+ inode_item->nbytes = cpu_to_le64(root->fs_info->leafsize);
inode_item->mode = cpu_to_le32(S_IFDIR | 0755);
btrfs_set_root_node(&log_root->root_item, log_root->node);
@@ -1264,9 +1257,7 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root,
goto out;
}
- __setup_root(tree_root->nodesize, tree_root->leafsize,
- tree_root->sectorsize, tree_root->stripesize,
- root, fs_info, location->objectid);
+ __setup_root(tree_root->stripesize, root, fs_info, location->objectid);
path = btrfs_alloc_path();
if (!path) {
@@ -1762,8 +1753,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
init_waitqueue_head(&fs_info->transaction_blocked_wait);
init_waitqueue_head(&fs_info->async_submit_wait);
- __setup_root(4096, 4096, 4096, 4096, tree_root,
- fs_info, BTRFS_ROOT_TREE_OBJECTID);
+ __setup_root(4096, tree_root, fs_info, BTRFS_ROOT_TREE_OBJECTID);
bh = btrfs_read_dev_super(fs_devices->latest_bdev);
if (!bh) {
@@ -1907,9 +1897,10 @@ struct btrfs_root *open_ctree(struct super_block *sb,
leafsize = btrfs_super_leafsize(disk_super);
sectorsize = btrfs_super_sectorsize(disk_super);
stripesize = btrfs_super_stripesize(disk_super);
- tree_root->nodesize = nodesize;
- tree_root->leafsize = leafsize;
- tree_root->sectorsize = sectorsize;
+
+ fs_info->nodesize = nodesize;
+ fs_info->leafsize = leafsize;
+ fs_info->sectorsize = sectorsize;
tree_root->stripesize = stripesize;
sb->s_blocksize = sectorsize;
@@ -1934,8 +1925,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
btrfs_super_chunk_root_level(disk_super));
generation = btrfs_super_chunk_root_generation(disk_super);
- __setup_root(nodesize, leafsize, sectorsize, stripesize,
- chunk_root, fs_info, BTRFS_CHUNK_TREE_OBJECTID);
+ __setup_root(stripesize, chunk_root, fs_info, BTRFS_CHUNK_TREE_OBJECTID);
chunk_root->node = read_tree_block(chunk_root,
btrfs_super_chunk_root(disk_super),
@@ -2058,8 +2048,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
goto fail_trans_kthread;
}
- __setup_root(nodesize, leafsize, sectorsize, stripesize,
- log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID);
+ __setup_root(stripesize, log_tree_root, fs_info,
+ BTRFS_TREE_LOG_OBJECTID);
log_tree_root->node = read_tree_block(tree_root, bytenr,
blocksize,
@@ -3033,7 +3033,7 @@ int btrfs_check_data_free_space(struct inode *inode, u64 bytes)
int ret = 0, committed = 0, alloc_chunk = 1;
/* make sure bytes are sectorsize aligned */
- bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1);
+ bytes = (bytes + root->fs_info->sectorsize - 1) & ~((u64)root->fs_info->sectorsize - 1);
if (root == root->fs_info->tree_root ||
BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) {
@@ -3131,7 +3131,7 @@ void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes)
struct btrfs_space_info *data_sinfo;
/* make sure bytes are sectorsize aligned */
- bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1);
+ bytes = (bytes + root->fs_info->sectorsize - 1) & ~((u64)root->fs_info->sectorsize - 1);
data_sinfo = BTRFS_I(inode)->space_info;
spin_lock(&data_sinfo->lock);
@@ -3796,7 +3796,7 @@ static u64 calc_global_metadata_size(struct btrfs_fs_info *fs_info)
if (num_bytes * 3 > meta_used)
num_bytes = div64_u64(meta_used, 3);
- return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10);
+ return ALIGN(num_bytes, fs_info->leafsize << 10);
}
static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
@@ -3996,7 +3996,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
if (btrfs_transaction_in_commit(root->fs_info))
schedule_timeout(1);
- num_bytes = ALIGN(num_bytes, root->sectorsize);
+ num_bytes = ALIGN(num_bytes, root->fs_info->sectorsize);
spin_lock(&BTRFS_I(inode)->lock);
BTRFS_I(inode)->outstanding_extents++;
@@ -4035,7 +4035,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes)
u64 to_free = 0;
unsigned dropped;
- num_bytes = ALIGN(num_bytes, root->sectorsize);
+ num_bytes = ALIGN(num_bytes, root->fs_info->sectorsize);
dropped = drop_outstanding_extent(inode);
to_free = calc_csum_metadata_size(inode, num_bytes);
@@ -4882,7 +4882,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
u64 ideal_cache_percent = 0;
u64 ideal_cache_offset = 0;
- WARN_ON(num_bytes < root->sectorsize);
+ WARN_ON(num_bytes < root->fs_info->sectorsize);
btrfs_set_key_type(ins, BTRFS_EXTENT_ITEM_KEY);
ins->objectid = 0;
ins->offset = 0;
@@ -5375,14 +5375,14 @@ again:
num_bytes + 2 * 1024 * 1024, data,
CHUNK_ALLOC_NO_FORCE);
- WARN_ON(num_bytes < root->sectorsize);
+ WARN_ON(num_bytes < root->fs_info->sectorsize);
ret = find_free_extent(trans, root, num_bytes, empty_size,
search_start, search_end, hint_byte,
ins, data);
if (ret == -ENOSPC && num_bytes > min_alloc_size) {
num_bytes = num_bytes >> 1;
- num_bytes = num_bytes & ~(root->sectorsize - 1);
+ num_bytes = num_bytes & ~(root->fs_info->sectorsize - 1);
num_bytes = max(num_bytes, min_alloc_size);
do_chunk_alloc(trans, root->fs_info->extent_root,
num_bytes, data, CHUNK_ALLOC_FORCE);
@@ -7008,7 +7008,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
key.objectid = found_key.objectid + found_key.offset;
btrfs_release_path(path);
cache->flags = btrfs_block_group_flags(&cache->item);
- cache->sectorsize = root->sectorsize;
+ cache->sectorsize = root->fs_info->sectorsize;
btrfs_init_free_space_ctl(cache);
@@ -7108,7 +7108,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
cache->key.objectid = chunk_offset;
cache->key.offset = size;
cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
- cache->sectorsize = root->sectorsize;
+ cache->sectorsize = root->fs_info->sectorsize;
cache->fs_info = root->fs_info;
atomic_set(&cache->count, 1);
@@ -2729,7 +2729,7 @@ static struct extent_map *get_extent_skip_holes(struct inode *inode,
u64 last,
get_extent_t *get_extent)
{
- u64 sectorsize = BTRFS_I(inode)->root->sectorsize;
+ u64 sectorsize = BTRFS_I(inode)->root->fs_info->sectorsize;
struct extent_map *em;
u64 len;
@@ -32,7 +32,7 @@
#define MAX_ORDERED_SUM_BYTES(r) ((PAGE_SIZE - \
sizeof(struct btrfs_ordered_sum)) / \
sizeof(struct btrfs_sector_sum) * \
- (r)->sectorsize - (r)->sectorsize)
+ (r)->fs_info->sectorsize - (r)->fs_info->sectorsize)
int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
@@ -234,7 +234,7 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
path->slots[0]);
item_last_offset = item_start_offset +
(item_size / csum_size) *
- root->sectorsize;
+ root->fs_info->sectorsize;
item = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_csum_item);
}
@@ -243,7 +243,7 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
* a single leaf so it will also fit inside a u32
*/
diff = disk_bytenr - item_start_offset;
- diff = diff / root->sectorsize;
+ diff = diff / root->fs_info->sectorsize;
diff = diff * csum_size;
read_extent_buffer(path->nodes[0], &sum,
@@ -344,7 +344,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
start = key.offset;
size = btrfs_item_size_nr(leaf, path->slots[0]);
- csum_end = key.offset + (size / csum_size) * root->sectorsize;
+ csum_end = key.offset + (size / csum_size) * root->fs_info->sectorsize;
if (csum_end <= start) {
path->slots[0]++;
continue;
@@ -375,8 +375,8 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
offset, csum_size);
sector_sum->bytenr = start;
- size -= root->sectorsize;
- start += root->sectorsize;
+ size -= root->fs_info->sectorsize;
+ start += root->fs_info->sectorsize;
offset += csum_size;
sector_sum++;
}
@@ -783,14 +783,14 @@ insert:
btrfs_release_path(path);
csum_offset = 0;
if (found_next) {
- u64 tmp = total_bytes + root->sectorsize;
+ u64 tmp = total_bytes + root->fs_info->sectorsize;
u64 next_sector = sector_sum->bytenr;
struct btrfs_sector_sum *next = sector_sum + 1;
while (tmp < sums->len) {
- if (next_sector + root->sectorsize != next->bytenr)
+ if (next_sector + root->fs_info->sectorsize != next->bytenr)
break;
- tmp += root->sectorsize;
+ tmp += root->fs_info->sectorsize;
next_sector = next->bytenr;
next++;
}
@@ -826,7 +826,7 @@ next_sector:
write_extent_buffer(leaf, §or_sum->sum, (unsigned long)item, csum_size);
- total_bytes += root->sectorsize;
+ total_bytes += root->fs_info->sectorsize;
sector_sum++;
if (total_bytes < sums->len) {
item = (struct btrfs_csum_item *)((char *)item +
@@ -396,9 +396,9 @@ int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode,
u64 end_pos = pos + write_bytes;
loff_t isize = i_size_read(inode);
- start_pos = pos & ~((u64)root->sectorsize - 1);
+ start_pos = pos & ~((u64)root->fs_info->sectorsize - 1);
num_bytes = (write_bytes + pos - start_pos +
- root->sectorsize - 1) & ~((u64)root->sectorsize - 1);
+ root->fs_info->sectorsize - 1) & ~((u64)root->fs_info->sectorsize - 1);
end_of_last_block = start_pos + num_bytes - 1;
err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block,
@@ -745,7 +745,7 @@ next_slot:
inode_sub_bytes(inode,
extent_end - key.offset);
extent_end = ALIGN(extent_end,
- root->sectorsize);
+ root->fs_info->sectorsize);
} else if (disk_bytenr > 0) {
ret = btrfs_free_extent(trans, root,
disk_bytenr, num_bytes, 0,
@@ -1070,7 +1070,7 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file,
u64 start_pos;
u64 last_pos;
- start_pos = pos & ~((u64)root->sectorsize - 1);
+ start_pos = pos & ~((u64)root->fs_info->sectorsize - 1);
last_pos = ((u64)index + num_pages) << PAGE_CACHE_SHIFT;
if (start_pos > inode->i_size) {
@@ -1264,7 +1264,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
balance_dirty_pages_ratelimited_nr(inode->i_mapping,
dirty_pages);
- if (dirty_pages < (root->leafsize >> PAGE_CACHE_SHIFT) + 1)
+ if (dirty_pages < (root->fs_info->leafsize >> PAGE_CACHE_SHIFT) + 1)
btrfs_btree_balance_dirty(root, 1);
btrfs_throttle(root);
@@ -1563,7 +1563,7 @@ static long btrfs_fallocate(struct file *file, int mode,
u64 alloc_end;
u64 alloc_hint = 0;
u64 locked_end;
- u64 mask = BTRFS_I(inode)->root->sectorsize - 1;
+ u64 mask = BTRFS_I(inode)->root->fs_info->sectorsize - 1;
struct extent_map *em;
int ret;
@@ -567,7 +567,7 @@ int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
filemap_write_and_wait(inode->i_mapping);
btrfs_wait_ordered_range(inode, inode->i_size &
- ~(root->sectorsize - 1), (u64)-1);
+ ~(root->fs_info->sectorsize - 1), (u64)-1);
pages = kzalloc(sizeof(struct page *) * num_pages, GFP_NOFS);
if (!pages)
@@ -226,8 +226,8 @@ static noinline int cow_file_range_inline(struct btrfs_trans_handle *trans,
u64 isize = i_size_read(inode);
u64 actual_end = min(end + 1, isize);
u64 inline_len = actual_end - start;
- u64 aligned_end = (end + root->sectorsize - 1) &
- ~((u64)root->sectorsize - 1);
+ u64 aligned_end = (end + root->fs_info->sectorsize - 1) &
+ ~((u64)root->fs_info->sectorsize - 1);
u64 hint_byte;
u64 data_len = inline_len;
int ret;
@@ -239,7 +239,7 @@ static noinline int cow_file_range_inline(struct btrfs_trans_handle *trans,
actual_end >= PAGE_CACHE_SIZE ||
data_len >= BTRFS_MAX_INLINE_DATA_SIZE(root) ||
(!compressed_size &&
- (actual_end & (root->sectorsize - 1)) == 0) ||
+ (actual_end & (root->fs_info->sectorsize - 1)) == 0) ||
end + 1 < isize ||
data_len > root->fs_info->max_inline) {
return 1;
@@ -326,7 +326,7 @@ static noinline int compress_file_range(struct inode *inode,
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_trans_handle *trans;
u64 num_bytes;
- u64 blocksize = root->sectorsize;
+ u64 blocksize = root->fs_info->sectorsize;
u64 actual_end;
u64 isize = i_size_read(inode);
int ret = 0;
@@ -776,7 +776,7 @@ static noinline int cow_file_range(struct inode *inode,
unsigned long ram_size;
u64 disk_num_bytes;
u64 cur_alloc_size;
- u64 blocksize = root->sectorsize;
+ u64 blocksize = root->fs_info->sectorsize;
struct btrfs_key ins;
struct extent_map *em;
struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
@@ -830,7 +830,7 @@ static noinline int cow_file_range(struct inode *inode,
cur_alloc_size = disk_num_bytes;
ret = btrfs_reserve_extent(trans, root, cur_alloc_size,
- root->sectorsize, 0, alloc_hint,
+ root->fs_info->sectorsize, 0, alloc_hint,
(u64)-1, &ins, 1);
BUG_ON(ret);
@@ -1158,7 +1158,7 @@ next_slot:
} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
extent_end = found_key.offset +
btrfs_file_extent_inline_len(leaf, fi);
- extent_end = ALIGN(extent_end, root->sectorsize);
+ extent_end = ALIGN(extent_end, root->fs_info->sectorsize);
} else {
BUG_ON(1);
}
@@ -3137,7 +3137,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
u64 extent_num_bytes = 0;
u64 extent_offset = 0;
u64 item_end = 0;
- u64 mask = root->sectorsize - 1;
+ u64 mask = root->fs_info->sectorsize - 1;
u32 found_type = (u8)-1;
int found_extent;
int del_item;
@@ -3242,9 +3242,9 @@ search_again:
u64 orig_num_bytes =
btrfs_file_extent_num_bytes(leaf, fi);
extent_num_bytes = new_size -
- found_key.offset + root->sectorsize - 1;
+ found_key.offset + root->fs_info->sectorsize - 1;
extent_num_bytes = extent_num_bytes &
- ~((u64)root->sectorsize - 1);
+ ~((u64)root->fs_info->sectorsize - 1);
btrfs_set_file_extent_num_bytes(leaf, fi,
extent_num_bytes);
num_dec = (orig_num_bytes -
@@ -3364,7 +3364,7 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from)
struct btrfs_ordered_extent *ordered;
struct extent_state *cached_state = NULL;
char *kaddr;
- u32 blocksize = root->sectorsize;
+ u32 blocksize = root->fs_info->sectorsize;
pgoff_t index = from >> PAGE_CACHE_SHIFT;
unsigned offset = from & (PAGE_CACHE_SIZE-1);
struct page *page;
@@ -3465,7 +3465,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
struct extent_map *em = NULL;
struct extent_state *cached_state = NULL;
- u64 mask = root->sectorsize - 1;
+ u64 mask = root->fs_info->sectorsize - 1;
u64 hole_start = (oldsize + mask) & ~mask;
u64 block_end = (size + mask) & ~mask;
u64 last_byte;
@@ -5014,8 +5014,8 @@ again:
} else if (found_type == BTRFS_FILE_EXTENT_INLINE) {
size_t size;
size = btrfs_file_extent_inline_len(leaf, item);
- extent_end = (extent_start + size + root->sectorsize - 1) &
- ~((u64)root->sectorsize - 1);
+ extent_end = (extent_start + size + root->fs_info->sectorsize - 1) &
+ ~((u64)root->fs_info->sectorsize - 1);
}
if (start >= extent_end) {
@@ -5085,8 +5085,8 @@ again:
copy_size = min_t(u64, PAGE_CACHE_SIZE - pg_offset,
size - extent_offset);
em->start = extent_start + extent_offset;
- em->len = (copy_size + root->sectorsize - 1) &
- ~((u64)root->sectorsize - 1);
+ em->len = (copy_size + root->fs_info->sectorsize - 1) &
+ ~((u64)root->fs_info->sectorsize - 1);
em->orig_start = EXTENT_MAP_INLINE;
if (compress_type) {
set_bit(EXTENT_FLAG_COMPRESSED, &em->flags);
@@ -5181,7 +5181,7 @@ insert:
if (existing) {
err = merge_extent_mapping(em_tree, existing,
em, start,
- root->sectorsize);
+ root->fs_info->sectorsize);
free_extent_map(existing);
if (err) {
free_extent_map(em);
@@ -5375,7 +5375,7 @@ static struct extent_map *btrfs_new_extent_direct(struct inode *inode,
trans->block_rsv = &root->fs_info->delalloc_block_rsv;
alloc_hint = get_extent_allocation_hint(inode, start, len);
- ret = btrfs_reserve_extent(trans, root, len, root->sectorsize, 0,
+ ret = btrfs_reserve_extent(trans, root, len, root->fs_info->sectorsize, 0,
alloc_hint, (u64)-1, &ins, 1);
if (ret) {
em = ERR_PTR(ret);
@@ -5564,7 +5564,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
free_extent_map(em);
/* DIO will do one hole at a time, so just unlock a sector */
unlock_extent(&BTRFS_I(inode)->io_tree, start,
- start + root->sectorsize - 1, GFP_NOFS);
+ start + root->fs_info->sectorsize - 1, GFP_NOFS);
return 0;
}
@@ -6109,7 +6109,7 @@ static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *io
int i;
size_t size;
unsigned long addr;
- unsigned blocksize_mask = root->sectorsize - 1;
+ unsigned blocksize_mask = root->fs_info->sectorsize - 1;
ssize_t retval = -EINVAL;
loff_t end = offset;
@@ -6495,7 +6495,7 @@ static int btrfs_truncate(struct inode *inode)
int err = 0;
struct btrfs_trans_handle *trans;
unsigned long nr;
- u64 mask = root->sectorsize - 1;
+ u64 mask = root->fs_info->sectorsize - 1;
ret = btrfs_truncate_page(inode->i_mapping, inode->i_size);
if (ret)
@@ -351,7 +351,7 @@ static noinline int create_subvol(struct btrfs_root *root,
return PTR_ERR(trans);
}
- leaf = btrfs_alloc_free_block(trans, root, root->leafsize,
+ leaf = btrfs_alloc_free_block(trans, root, root->fs_info->leafsize,
0, objectid, NULL, 0, 0, 0);
if (IS_ERR(leaf)) {
ret = PTR_ERR(leaf);
@@ -377,7 +377,7 @@ static noinline int create_subvol(struct btrfs_root *root,
inode_item->generation = cpu_to_le64(1);
inode_item->size = cpu_to_le64(3);
inode_item->nlink = cpu_to_le32(1);
- inode_item->nbytes = cpu_to_le64(root->leafsize);
+ inode_item->nbytes = cpu_to_le64(root->fs_info->leafsize);
inode_item->mode = cpu_to_le32(S_IFDIR | 0755);
root_item.flags = 0;
@@ -1236,8 +1236,8 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
goto out_unlock;
}
- do_div(new_size, root->sectorsize);
- new_size *= root->sectorsize;
+ do_div(new_size, root->fs_info->sectorsize);
+ new_size *= root->fs_info->sectorsize;
printk(KERN_INFO "new size for %s is %llu\n",
device->name, (unsigned long long)new_size);
@@ -780,7 +780,7 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
if (ordered)
offset = entry_end(ordered);
else
- offset = ALIGN(offset, BTRFS_I(inode)->root->sectorsize);
+ offset = ALIGN(offset, BTRFS_I(inode)->root->fs_info->sectorsize);
spin_lock(&tree->lock);
disk_i_size = BTRFS_I(inode)->disk_i_size;
@@ -908,7 +908,7 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree;
unsigned long num_sectors;
unsigned long i;
- u32 sectorsize = BTRFS_I(inode)->root->sectorsize;
+ u32 sectorsize = BTRFS_I(inode)->root->fs_info->sectorsize;
int ret = 1;
ordered = btrfs_lookup_ordered_extent(inode, offset);
@@ -123,8 +123,8 @@ struct btrfs_ordered_extent {
static inline int btrfs_ordered_sum_size(struct btrfs_root *root,
unsigned long bytes)
{
- unsigned long num_sectors = (bytes + root->sectorsize - 1) /
- root->sectorsize;
+ unsigned long num_sectors = (bytes + root->fs_info->sectorsize - 1) /
+ root->fs_info->sectorsize;
num_sectors++;
return sizeof(struct btrfs_ordered_sum) +
num_sectors * sizeof(struct btrfs_sector_sum);
@@ -1571,8 +1571,8 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
end = key.offset +
btrfs_file_extent_num_bytes(leaf, fi);
WARN_ON(!IS_ALIGNED(key.offset,
- root->sectorsize));
- WARN_ON(!IS_ALIGNED(end, root->sectorsize));
+ root->fs_info->sectorsize));
+ WARN_ON(!IS_ALIGNED(end, root->fs_info->sectorsize));
end--;
ret = try_lock_extent(&BTRFS_I(inode)->io_tree,
key.offset, end,
@@ -1929,7 +1929,7 @@ static int invalidate_extent_cache(struct btrfs_root *root,
start = 0;
else {
start = min_key->offset;
- WARN_ON(!IS_ALIGNED(start, root->sectorsize));
+ WARN_ON(!IS_ALIGNED(start, root->fs_info->sectorsize));
}
} else {
start = 0;
@@ -1944,7 +1944,7 @@ static int invalidate_extent_cache(struct btrfs_root *root,
if (max_key->offset == 0)
continue;
end = max_key->offset;
- WARN_ON(!IS_ALIGNED(end, root->sectorsize));
+ WARN_ON(!IS_ALIGNED(end, root->fs_info->sectorsize));
end--;
}
} else {
@@ -2033,7 +2033,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
btrfs_unlock_up_safe(path, 0);
}
- min_reserved = root->nodesize * (BTRFS_MAX_LEVEL - 1) * 2;
+ min_reserved = root->fs_info->nodesize * (BTRFS_MAX_LEVEL - 1) * 2;
memset(&next_key, 0, sizeof(next_key));
while (1) {
@@ -2145,7 +2145,7 @@ int prepare_to_merge(struct reloc_control *rc, int err)
int ret;
mutex_lock(&root->fs_info->reloc_mutex);
- rc->merging_rsv_size += root->nodesize * (BTRFS_MAX_LEVEL - 1) * 2;
+ rc->merging_rsv_size += root->fs_info->nodesize * (BTRFS_MAX_LEVEL - 1) * 2;
rc->merging_rsv_size += rc->nodes_relocated * 2;
mutex_unlock(&root->fs_info->reloc_mutex);
@@ -3646,7 +3646,7 @@ int prepare_to_relocate(struct reloc_control *rc)
* is no reservation in transaction handle.
*/
ret = btrfs_block_rsv_add(NULL, rc->extent_root, rc->block_rsv,
- rc->extent_root->nodesize * 256);
+ rc->extent_root->fs_info->nodesize * 256);
if (ret)
return ret;
@@ -4277,7 +4277,7 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
while (offset < sums->len) {
sector_sum->bytenr += ordered->start - disk_bytenr;
sector_sum++;
- offset += root->sectorsize;
+ offset += root->fs_info->sectorsize;
}
btrfs_add_ordered_sum(inode, ordered, sums);
@@ -666,7 +666,7 @@ static int scrub_find_csum(struct scrub_dev *sdev, u64 logical, u64 len,
int ret = 0;
unsigned long i;
unsigned long num_sectors;
- u32 sectorsize = sdev->dev->dev_root->sectorsize;
+ u32 sectorsize = sdev->dev->dev_root->fs_info->sectorsize;
while (!list_empty(&sdev->csum_list)) {
sum = list_first_entry(&sdev->csum_list,
@@ -1198,9 +1198,9 @@ int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end,
/*
* check some assumptions
*/
- if (root->sectorsize != PAGE_SIZE ||
- root->sectorsize != root->leafsize ||
- root->sectorsize != root->nodesize) {
+ if (root->fs_info->sectorsize != PAGE_SIZE ||
+ root->fs_info->sectorsize != root->fs_info->leafsize ||
+ root->fs_info->sectorsize != root->fs_info->nodesize) {
printk(KERN_ERR "btrfs_scrub: size assumptions fail\n");
return -EINVAL;
}
@@ -320,7 +320,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
if (info->max_inline) {
info->max_inline = max_t(u64,
info->max_inline,
- root->sectorsize);
+ root->fs_info->sectorsize);
}
printk(KERN_INFO "btrfs: max_inline at %llu\n",
(unsigned long long)info->max_inline);
@@ -483,7 +483,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
struct btrfs_key *key)
{
int found_type;
- u64 mask = root->sectorsize - 1;
+ u64 mask = root->fs_info->sectorsize - 1;
u64 extent_end;
u64 alloc_hint;
u64 start = key->offset;
@@ -1634,9 +1634,9 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
generate_random_uuid(device->uuid);
spin_lock_init(&device->io_lock);
device->generation = trans->transid;
- device->io_width = root->sectorsize;
- device->io_align = root->sectorsize;
- device->sector_size = root->sectorsize;
+ device->io_width = root->fs_info->sectorsize;
+ device->io_align = root->fs_info->sectorsize;
+ device->sector_size = root->fs_info->sectorsize;
device->total_bytes = i_size_read(bdev->bd_inode);
device->disk_total_bytes = device->total_bytes;
device->dev_root = root->fs_info->dev_root;
@@ -2500,7 +2500,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
j * stripe_size;
}
}
- map->sector_size = extent_root->sectorsize;
+ map->sector_size = extent_root->fs_info->sectorsize;
map->stripe_len = BTRFS_STRIPE_LEN;
map->io_align = BTRFS_STRIPE_LEN;
map->io_width = BTRFS_STRIPE_LEN;
@@ -2609,7 +2609,7 @@ static int __finish_chunk_alloc(struct btrfs_trans_handle *trans,
btrfs_set_stack_chunk_num_stripes(chunk, map->num_stripes);
btrfs_set_stack_chunk_io_align(chunk, map->stripe_len);
btrfs_set_stack_chunk_io_width(chunk, map->stripe_len);
- btrfs_set_stack_chunk_sector_size(chunk, extent_root->sectorsize);
+ btrfs_set_stack_chunk_sector_size(chunk, extent_root->fs_info->sectorsize);
btrfs_set_stack_chunk_sub_stripes(chunk, map->sub_stripes);
key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;