From patchwork Sun Aug 7 21:54:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peeters Simon X-Patchwork-Id: 1042812 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p77LsonV020366 for ; Sun, 7 Aug 2011 21:54:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755425Ab1HGVye (ORCPT ); Sun, 7 Aug 2011 17:54:34 -0400 Received: from mail-iy0-f170.google.com ([209.85.210.170]:46593 "EHLO mail-iy0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755370Ab1HGVyc (ORCPT ); Sun, 7 Aug 2011 17:54:32 -0400 Received: by iye16 with SMTP id 16so7732163iye.1 for ; Sun, 07 Aug 2011 14:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=Qm2UzzLFtgHgpCv3GPG48P+LihJWqVj5GmOm8caN030=; b=ppAP1IvNcbd5csrSTEaDKI34wLT4/sC7Y2Pm53+zqAq9z24yjNIl+XOphq3JiUyPRV /8QPtjSB/RfQ2qklEZunvB1RsZqam+UPMMvP+FUUyHUJc7Bn0ntiUuK6BWxqFNQe9CAb El6g+jyimhc3IStWceOqowW/FcC6qUd5f9cQY= MIME-Version: 1.0 Received: by 10.42.156.3 with SMTP id x3mr4963763icw.274.1312754071631; Sun, 07 Aug 2011 14:54:31 -0700 (PDT) Received: by 10.42.167.72 with HTTP; Sun, 7 Aug 2011 14:54:31 -0700 (PDT) Date: Sun, 7 Aug 2011 23:54:31 +0200 Message-ID: Subject: [patch] Move nodesize/leafsize/sectorsize to fs_info From: Peeters Simon To: linux-btrfs@vger.kernel.org Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 07 Aug 2011 21:54:50 +0000 (UTC) moved nodesize, leafsize and sectorsize from btrfs_root to btrfs_fs_info as mentioned in [1] and updated everything accordingly. patch against the "for-linus" tree builds and loads, no further testing done. [1] https://btrfs.wiki.kernel.org/index.php/Cleanup_ideas ps: "Pass fs_info instead of root" is next. diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 8ec5d86..146286c 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -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); diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 011cab3..b5862a8 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -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); diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index a6263bd..ee6c872 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -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; } diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 94ecac3..10158cef 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -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, diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 66bac22..009c0c3 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -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); diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 8491712..4656757 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -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; diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index b910694..b97e657 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -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 + diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 010aec8..96d6ea4 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -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; diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 6377713..c84e752 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -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) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 34195f9..bcc138b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -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) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 2bb0886..dfa3a33 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -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); diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index a1c9404..5742481 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -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); diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index ff1f69a..3f18fdb 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h @@ -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); diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 59bb176..0d81f08 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -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); diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index a8d03d5..23d44a0 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -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; } diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 15634d4..4a07966 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -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); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index babee65..d69bae4 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -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; diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3c5f2fc..03ef6d0 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -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;