Cleanups, 3.16 or later
Hi Chris,
this is a set of whole-directory changes that have low impact on stability (xfstests passed), but touch almost all files aiming for simpler code.
I did not catch the merge window train, so I'm leaving it to your consideration if you add it to the upcomming pull request(s).
I'm sending this as a pull request combined with patches to mailinglist.
Top commit cbe260e207c57843c1dcd550f9adbab7507945c6
based on 8408c716d7a4ddd5954ce33f53a7d3cd2876cf65 (current for-linus)
Available in the git repository at:
git://repo.or.cz/linux-2.6/btrfs-unstable.git cleanups-for-3.16
Thanks.
David Sterba (8):
btrfs: remove obsolete comment in btrfs_clean_one_deleted_snapshot
btrfs: clenaup: don't call btrfs_release_path before free_path
btrfs: cleanup ino cache members of btrfs_root
btrfs: make close_ctree return void
btrfs: kill the key type accessor helpers
btrfs: use nodesize everywhere, kill leafsize
btrfs: clean away stripe_align helper
btrfs: use DIV_ROUND_UP instead of open-coded variants
fs/btrfs/backref.c | 12 +++--- fs/btrfs/check-integrity.c | 16 +-------- fs/btrfs/compression.c | 10 ++--- fs/btrfs/ctree.c | 18 +++++----- fs/btrfs/ctree.h | 31 +++++----------- fs/btrfs/delayed-inode.c | 8 ++-- fs/btrfs/dir-item.c | 12 +++--- fs/btrfs/disk-io.c | 84 +++++++++++++++++++------------------------ fs/btrfs/disk-io.h | 2 +- fs/btrfs/export.c | 4 +- fs/btrfs/extent-tree.c | 53 +++++++++++---------------- fs/btrfs/extent_io.c | 2 +- fs/btrfs/file-item.c | 12 +++--- fs/btrfs/file.c | 25 ++++++------- fs/btrfs/free-space-cache.c | 17 ++++----- fs/btrfs/inode-item.c | 12 +++--- fs/btrfs/inode-map.c | 68 +++++++++++++++++----------------- fs/btrfs/inode.c | 28 +++++++------- fs/btrfs/ioctl.c | 23 ++++++------ fs/btrfs/lzo.c | 3 +- fs/btrfs/orphan.c | 4 +- fs/btrfs/print-tree.c | 4 +- fs/btrfs/qgroup.c | 6 +-- fs/btrfs/raid56.c | 8 ++-- fs/btrfs/reada.c | 2 +- fs/btrfs/relocation.c | 22 +++++------ fs/btrfs/scrub.c | 19 +--------- fs/btrfs/super.c | 8 +---- fs/btrfs/transaction.c | 7 +--- fs/btrfs/tree-log.c | 8 ++-- fs/btrfs/volumes.c | 4 +- fs/btrfs/xattr.c | 4 +- fs/btrfs/zlib.c | 3 +- 33 files changed, 228 insertions(+), 311 deletions(-)
Signature · 1 line
1.7.9
PATCH 1/8 btrfs: remove obsolete comment in btrfs_clean_one_deleted_snapshot
The comment applied when there was a BUG_ON.
--- fs/btrfs/transaction.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
fs/btrfs/transaction.c +1 -4
@@ -2012,9 +2012,6 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root) ret =btrfs_drop_snapshot (root,NULL ,0 ,0 ); else ret =btrfs_drop_snapshot (root,NULL ,1 ,0 ); -/* -* If we encounter a transaction abort during snapshot cleaning, we -* don't want to crash here -*/ +return (ret <0 ) ?0 :1 ; }
Signature · 1 line
1.7.9
PATCH 2/8 btrfs: clenaup: don't call btrfs_release_path before free_path
In reply to David Sterba--- fs/btrfs/relocation.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
fs/btrfs/relocation.c +0 -1
@@ -4096,7 +4096,6 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans,btrfs_set_inode_flags (leaf, item,BTRFS_INODE_NOCOMPRESS |BTRFS_INODE_PREALLOC );btrfs_mark_buffer_dirty (leaf); -btrfs_release_path (path); out:btrfs_free_path (path);return ret;
Signature · 1 line
1.7.9
PATCH 3/8 btrfs: cleanup ino cache members of btrfs_root
In reply to David SterbaThe naming is confusing, generic yet used for a specific cache. Add a prefix 'ino_' or rename appropriately.
--- fs/btrfs/ctree.h | 10 +++--- fs/btrfs/disk-io.c | 6 ++-- fs/btrfs/free-space-cache.c | 14 ++++---- fs/btrfs/inode-map.c | 68 +++++++++++++++++++++--------------------- fs/btrfs/ioctl.c | 6 ++-- 5 files changed, 52 insertions(+), 52 deletions(-)
fs/btrfs/ctree.h +5 -5
@@ -1776,12 +1776,12 @@ struct btrfs_root {/* free ino cache stuff */ struct btrfs_free_space_ctl *free_ino_ctl; -enum btrfs_caching_type cached; -spinlock_t cache_lock; -wait_queue_head_t cache_wait; +enum btrfs_caching_type ino_cache_state; +spinlock_t ino_cache_lock; +wait_queue_head_t ino_cache_wait;struct btrfs_free_space_ctl *free_ino_pinned; -u64 cache_progress; -struct inode *cache_inode; +u64 ino_cache_progress; +struct inode *ino_cache_inode;struct mutex log_mutex;wait_queue_head_t log_writer_wait;
fs/btrfs/disk-io.c +3 -3
@@ -1569,8 +1569,8 @@ int btrfs_init_fs_root(struct btrfs_root *root) root->subv_writers = writers;btrfs_init_free_ino_ctl (root); -spin_lock_init (&root->cache_lock); -init_waitqueue_head (&root->cache_wait); +spin_lock_init (&root->ino_cache_lock); +init_waitqueue_head (&root->ino_cache_wait); ret =get_anon_bdev (&root->anon_dev);if (ret)
@@ -3525,7 +3525,7 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,static void free_fs_root (struct btrfs_root *root) { -iput (root->cache_inode); +iput (root->ino_cache_inode);WARN_ON (!RB_EMPTY_ROOT (&root->inode_tree));btrfs_free_block_rsv (root, root->orphan_block_rsv); root->orphan_block_rsv =NULL ;
fs/btrfs/free-space-cache.c +7 -7
@@ -3033,10 +3033,10 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root, {struct inode *inode =NULL ; -spin_lock (&root->cache_lock); -if (root->cache_inode) - inode =igrab (root->cache_inode); -spin_unlock (&root->cache_lock); +spin_lock (&root->ino_cache_lock); +if (root->ino_cache_inode) + inode =igrab (root->ino_cache_inode); +spin_unlock (&root->ino_cache_lock);if (inode)return inode;
@@ -3044,10 +3044,10 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root,if (IS_ERR (inode))return inode; -spin_lock (&root->cache_lock); +spin_lock (&root->ino_cache_lock);if (!btrfs_fs_closing (root->fs_info)) - root->cache_inode =igrab (inode); -spin_unlock (&root->cache_lock); + root->ino_cache_inode =igrab (inode); +spin_unlock (&root->ino_cache_lock);return inode; }
fs/btrfs/inode-map.c +34 -34
143 lines not on this page · raw message
fs/btrfs/ioctl.c +3 -3
@@ -2551,9 +2551,9 @@ out_unlock:ASSERT (dest->send_in_progress ==0 );/* the last ref */ -if (dest->cache_inode) { -iput (dest->cache_inode); - dest->cache_inode =NULL ; +if (dest->ino_cache_inode) { +iput (dest->ino_cache_inode); + dest->ino_cache_inode =NULL ; } } out_dput:
Signature · 1 line
1.7.9
PATCH 4/8 btrfs: make close_ctree return void
In reply to David SterbaThere's no user of the return value and we can get rid of the comment in put_super.
--- fs/btrfs/disk-io.c | 4 +--- fs/btrfs/disk-io.h | 2 +- fs/btrfs/super.c | 8 +------- 3 files changed, 3 insertions(+), 11 deletions(-)
fs/btrfs/disk-io.c +1 -3
@@ -3616,7 +3616,7 @@ int btrfs_commit_super(struct btrfs_root *root)return btrfs_commit_transaction (trans, root); } -int close_ctree (struct btrfs_root *root) +void close_ctree (struct btrfs_root *root) {struct btrfs_fs_info *fs_info = root->fs_info;int ret;
@@ -3704,8 +3704,6 @@ int close_ctree(struct btrfs_root *root)btrfs_free_block_rsv (root, root->orphan_block_rsv); root->orphan_block_rsv =NULL ; - -return 0 ; } int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
fs/btrfs/disk-io.h +1 -1
@@ -56,7 +56,7 @@ void clean_tree_block(struct btrfs_trans_handle *trans,int open_ctree (struct super_block *sb,struct btrfs_fs_devices *fs_devices,char *options); -int close_ctree (struct btrfs_root *root); +void close_ctree (struct btrfs_root *root);int write_ctree_super (struct btrfs_trans_handle *trans,struct btrfs_root *root,int max_mirrors);struct buffer_head *btrfs_read_dev_super (struct block_device *bdev);
fs/btrfs/super.c +1 -7
@@ -307,13 +307,7 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,static void btrfs_put_super (struct super_block *sb) { - (void )close_ctree (btrfs_sb (sb)->tree_root); -/* FIXME: need to fix VFS to return error? */ -/* AV: return it _where_? ->put_super() can be triggered by any number -* of async events, up to and including delivery of SIGKILL to the -* last process that kept it busy. Or segfault in the aforementioned -* process... Whom would you report that to? -*/ +close_ctree (btrfs_sb (sb)->tree_root); }enum {
Signature · 1 line
1.7.9
PATCH 5/8 btrfs: kill the key type accessor helpers
In reply to David Sterbabtrfs_set_key_type and btrfs_key_type are used inconsistently along with open coded variants. Other members of btrfs_key are accessed directly without any helpers anyway.
--- fs/btrfs/backref.c | 4 ++-- fs/btrfs/delayed-inode.c | 8 ++++---- fs/btrfs/dir-item.c | 12 ++++++------ fs/btrfs/export.c | 4 ++-- fs/btrfs/extent-tree.c | 6 +++--- fs/btrfs/extent_io.c | 2 +- fs/btrfs/file-item.c | 12 ++++++------ fs/btrfs/file.c | 4 ++-- fs/btrfs/inode-item.c | 12 ++++++------ fs/btrfs/inode.c | 28 ++++++++++++++-------------- fs/btrfs/ioctl.c | 6 +++--- fs/btrfs/orphan.c | 4 ++-- fs/btrfs/print-tree.c | 2 +- fs/btrfs/scrub.c | 2 +- fs/btrfs/tree-log.c | 6 +++--- fs/btrfs/volumes.c | 4 ++-- fs/btrfs/xattr.c | 4 ++-- 17 files changed, 60 insertions(+), 60 deletions(-)
fs/btrfs/backref.c +2 -2
@@ -1191,7 +1191,7 @@ int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,unsigned long ptr; key.objectid = inode_objectid; -btrfs_set_key_type (&key,BTRFS_INODE_EXTREF_KEY ); + key.type =BTRFS_INODE_EXTREF_KEY ; key.offset = start_off; ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );
@@ -1231,7 +1231,7 @@ int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid, ret = -ENOENT ;if (found_key.objectid != inode_objectid)break ; -if (btrfs_key_type (&found_key) !=BTRFS_INODE_EXTREF_KEY ) +if (found_key.type !=BTRFS_INODE_EXTREF_KEY )break ; ret =0 ;
fs/btrfs/delayed-inode.c +4 -4
@@ -1042,7 +1042,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,int ret; key.objectid = node->inode_id; -btrfs_set_key_type (&key,BTRFS_INODE_ITEM_KEY ); + key.type =BTRFS_INODE_ITEM_KEY ; key.offset =0 ;if (test_bit (BTRFS_DELAYED_NODE_DEL_IREF , &node->flags))
@@ -1099,7 +1099,7 @@ err_out: search:btrfs_release_path (path); -btrfs_set_key_type (&key,BTRFS_INODE_EXTREF_KEY ); + key.type =BTRFS_INODE_EXTREF_KEY ; key.offset =-1 ; ret =btrfs_search_slot (trans, root, &key, path,-1 ,1 );if (ret <0 )
@@ -1473,7 +1473,7 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, } delayed_item->key.objectid =btrfs_ino (dir); -btrfs_set_key_type (&delayed_item->key,BTRFS_DIR_INDEX_KEY ); + delayed_item->key.type =BTRFS_DIR_INDEX_KEY ; delayed_item->key.offset = index; dir_item = (struct btrfs_dir_item *)delayed_item->data;
@@ -1542,7 +1542,7 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,return PTR_ERR (node); item_key.objectid =btrfs_ino (dir); -btrfs_set_key_type (&item_key,BTRFS_DIR_INDEX_KEY ); + item_key.type =BTRFS_DIR_INDEX_KEY ; item_key.offset = index; ret =btrfs_delete_delayed_insertion_item (root, node, &item_key);
fs/btrfs/dir-item.c +6 -6
@@ -86,7 +86,7 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,BUG_ON (name_len + data_len >BTRFS_MAX_XATTR_SIZE (root)); key.objectid = objectid; -btrfs_set_key_type (&key,BTRFS_XATTR_ITEM_KEY ); + key.type =BTRFS_XATTR_ITEM_KEY ; key.offset =btrfs_name_hash (name, name_len); data_size =sizeof (*dir_item) + name_len + data_len;
@@ -137,7 +137,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_rootu32 data_size; key.objectid =btrfs_ino (dir); -btrfs_set_key_type (&key,BTRFS_DIR_ITEM_KEY ); + key.type =BTRFS_DIR_ITEM_KEY ; key.offset =btrfs_name_hash (name, name_len); path =btrfs_alloc_path ();
@@ -204,7 +204,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,int cow = mod !=0 ; key.objectid = dir; -btrfs_set_key_type (&key,BTRFS_DIR_ITEM_KEY ); + key.type =BTRFS_DIR_ITEM_KEY ; key.offset =btrfs_name_hash (name, name_len);
@@ -234,7 +234,7 @@ int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,return -ENOMEM ; key.objectid = dir; -btrfs_set_key_type (&key,BTRFS_DIR_ITEM_KEY ); + key.type =BTRFS_DIR_ITEM_KEY ; key.offset =btrfs_name_hash (name, name_len); ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );
@@ -297,7 +297,7 @@ btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,int cow = mod !=0 ; key.objectid = dir; -btrfs_set_key_type (&key,BTRFS_DIR_INDEX_KEY ); + key.type =BTRFS_DIR_INDEX_KEY ; key.offset = objectid; ret =btrfs_search_slot (trans, root, &key, path, ins_len, cow);
@@ -367,7 +367,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,int cow = mod !=0 ; key.objectid = dir; -btrfs_set_key_type (&key,BTRFS_XATTR_ITEM_KEY ); + key.type =BTRFS_XATTR_ITEM_KEY ; key.offset =btrfs_name_hash (name, name_len); ret =btrfs_search_slot (trans, root, &key, path, ins_len, cow);if (ret <0 )
fs/btrfs/export.c +2 -2
@@ -70,7 +70,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,return ERR_PTR (-ESTALE ); key.objectid = root_objectid; -btrfs_set_key_type (&key,BTRFS_ROOT_ITEM_KEY ); + key.type =BTRFS_ROOT_ITEM_KEY ; key.offset = (u64)-1 ; index =srcu_read_lock (&fs_info->subvol_srcu);
@@ -82,7 +82,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid, } key.objectid = objectid; -btrfs_set_key_type (&key,BTRFS_INODE_ITEM_KEY ); + key.type =BTRFS_INODE_ITEM_KEY ; key.offset =0 ; inode =btrfs_iget (sb, &key, root,NULL );
fs/btrfs/extent-tree.c +3 -3
@@ -3096,7 +3096,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,for (i =0 ; i < nritems; i++) {if (level ==0 ) {btrfs_item_key_to_cpu (buf, &key, i); -if (btrfs_key_type (&key) !=BTRFS_EXTENT_DATA_KEY ) +if (key.type !=BTRFS_EXTENT_DATA_KEY )continue ; fi =btrfs_item_ptr (buf, i, struct btrfs_file_extent_item);
@@ -6472,7 +6472,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,bool have_caching_bg = false;WARN_ON (num_bytes < root->sectorsize); -btrfs_set_key_type (ins,BTRFS_EXTENT_ITEM_KEY ); + ins->type =BTRFS_EXTENT_ITEM_KEY ; ins->objectid =0 ; ins->offset =0 ;
@@ -8764,7 +8764,7 @@ int btrfs_read_block_groups(struct btrfs_root *root) root = info->extent_root; key.objectid =0 ; key.offset =0 ; -btrfs_set_key_type (&key,BTRFS_BLOCK_GROUP_ITEM_KEY ); + key.type =BTRFS_BLOCK_GROUP_ITEM_KEY ; path =btrfs_alloc_path ();if (!path)return -ENOMEM ;
fs/btrfs/extent_io.c +1 -1
@@ -4229,7 +4229,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,WARN_ON (!ret); path->slots[0 ]--;btrfs_item_key_to_cpu (path->nodes[0 ], &found_key, path->slots[0 ]); - found_type =btrfs_key_type (&found_key); + found_type = found_key.type;/* No extents, but there might be delalloc bits */ if (found_key.objectid != btrfs_ino(inode) ||
fs/btrfs/file-item.c +6 -6
@@ -55,7 +55,7 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,return -ENOMEM ; file_key.objectid = objectid; file_key.offset = pos; -btrfs_set_key_type (&file_key,BTRFS_EXTENT_DATA_KEY ); + file_key.type =BTRFS_EXTENT_DATA_KEY ; path->leave_spinning =1 ; ret = btrfs_insert_empty_item(trans, root, path, &file_key,
@@ -100,7 +100,7 @@ btrfs_lookup_csum(struct btrfs_trans_handle *trans, file_key.objectid =BTRFS_EXTENT_CSUM_OBJECTID ; file_key.offset = bytenr; -btrfs_set_key_type (&file_key,BTRFS_EXTENT_CSUM_KEY ); + file_key.type =BTRFS_EXTENT_CSUM_KEY ; ret =btrfs_search_slot (trans, root, &file_key, path,0 , cow);if (ret <0 ) goto fail;
@@ -111,7 +111,7 @@ btrfs_lookup_csum(struct btrfs_trans_handle *trans, goto fail; path->slots[0 ]--;btrfs_item_key_to_cpu (leaf, &found_key, path->slots[0 ]); -if (btrfs_key_type (&found_key) !=BTRFS_EXTENT_CSUM_KEY ) +if (found_key.type !=BTRFS_EXTENT_CSUM_KEY ) goto fail; csum_offset = (bytenr - found_key.offset) >>
@@ -148,7 +148,7 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans, file_key.objectid = objectid; file_key.offset = offset; -btrfs_set_key_type (&file_key,BTRFS_EXTENT_DATA_KEY ); + file_key.type =BTRFS_EXTENT_DATA_KEY ; ret =btrfs_search_slot (trans, root, &file_key, path, ins_len, cow);return ret; }
@@ -720,7 +720,7 @@ again: bytenr = sums->bytenr + total_bytes; file_key.objectid =BTRFS_EXTENT_CSUM_OBJECTID ; file_key.offset = bytenr; -btrfs_set_key_type (&file_key,BTRFS_EXTENT_CSUM_KEY ); + file_key.type =BTRFS_EXTENT_CSUM_KEY ; item =btrfs_lookup_csum (trans, root, path, bytenr,1 );if (!IS_ERR (item)) {
@@ -790,7 +790,7 @@ again: csum_offset = (bytenr - found_key.offset) >> root->fs_info->sb->s_blocksize_bits; -if (btrfs_key_type (&found_key) !=BTRFS_EXTENT_CSUM_KEY || +if (found_key.type !=BTRFS_EXTENT_CSUM_KEY || found_key.objectid !=BTRFS_EXTENT_CSUM_OBJECTID || csum_offset >=MAX_CSUM_ITEMS (root, csum_size)) { goto insert;
fs/btrfs/file.c +2 -2
@@ -299,7 +299,7 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,/* get the inode */ key.objectid = defrag->root; -btrfs_set_key_type (&key,BTRFS_ROOT_ITEM_KEY ); + key.type =BTRFS_ROOT_ITEM_KEY ; key.offset = (u64)-1 ; index =srcu_read_lock (&fs_info->subvol_srcu);
@@ -311,7 +311,7 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, } key.objectid = defrag->ino; -btrfs_set_key_type (&key,BTRFS_INODE_ITEM_KEY ); + key.type =BTRFS_INODE_ITEM_KEY ; key.offset =0 ; inode =btrfs_iget (fs_info->sb, &key, inode_root,NULL );if (IS_ERR (inode)) {
fs/btrfs/inode-item.c +6 -6
@@ -135,7 +135,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,u32 item_size; key.objectid = inode_objectid; -btrfs_set_key_type (&key,BTRFS_INODE_EXTREF_KEY ); + key.type =BTRFS_INODE_EXTREF_KEY ; key.offset =btrfs_extref_hash (ref_objectid, name, name_len); path =btrfs_alloc_path ();
@@ -209,7 +209,7 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans, key.objectid = inode_objectid; key.offset = ref_objectid; -btrfs_set_key_type (&key,BTRFS_INODE_REF_KEY ); + key.type =BTRFS_INODE_REF_KEY ; path =btrfs_alloc_path ();if (!path)
@@ -337,7 +337,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, key.objectid = inode_objectid; key.offset = ref_objectid; -btrfs_set_key_type (&key,BTRFS_INODE_REF_KEY ); + key.type =BTRFS_INODE_REF_KEY ; path =btrfs_alloc_path ();if (!path)
@@ -400,7 +400,7 @@ int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,struct btrfs_key key;int ret; key.objectid = objectid; -btrfs_set_key_type (&key,BTRFS_INODE_ITEM_KEY ); + key.type =BTRFS_INODE_ITEM_KEY ; key.offset =0 ; ret = btrfs_insert_empty_item(trans, root, path, &key,
@@ -420,13 +420,13 @@ int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_rootstruct btrfs_key found_key; ret =btrfs_search_slot (trans, root, location, path, ins_len, cow); -if (ret >0 &&btrfs_key_type (location) ==BTRFS_ROOT_ITEM_KEY && +if (ret >0 && location->type ==BTRFS_ROOT_ITEM_KEY && location->offset == (u64)-1 && path->slots[0 ] !=0 ) { slot = path->slots[0 ] -1 ; leaf = path->nodes[0 ];btrfs_item_key_to_cpu (leaf, &found_key, slot);if (found_key.objectid == location->objectid && -btrfs_key_type (&found_key) ==btrfs_key_type (location)) { + found_key.type == location->type) { path->slots[0 ]--;return 0 ; }
fs/btrfs/inode.c +14 -14
@@ -153,7 +153,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, key.objectid =btrfs_ino (inode); key.offset = start; -btrfs_set_key_type (&key,BTRFS_EXTENT_DATA_KEY ); + key.type =BTRFS_EXTENT_DATA_KEY ; datasize =btrfs_file_extent_calc_inline_size (cur_size); path->leave_spinning =1 ;
@@ -3133,7 +3133,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) path->reada =-1 ; key.objectid =BTRFS_ORPHAN_OBJECTID ; -btrfs_set_key_type (&key,BTRFS_ORPHAN_ITEM_KEY ); + key.type =BTRFS_ORPHAN_ITEM_KEY ; key.offset = (u64)-1 ;while (1 ) {
@@ -3160,7 +3160,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)/* make sure the item matches what we want */ if (found_key.objectid !=BTRFS_ORPHAN_OBJECTID )break ; -if (btrfs_key_type (&found_key) !=BTRFS_ORPHAN_ITEM_KEY ) +if (found_key.type !=BTRFS_ORPHAN_ITEM_KEY )break ;/* release the path since we're done with it */
@@ -4059,7 +4059,7 @@ search_again: fi =NULL ; leaf = path->nodes[0 ];btrfs_item_key_to_cpu (leaf, &found_key, path->slots[0 ]); - found_type =btrfs_key_type (&found_key); + found_type = found_key.type;if (found_key.objectid != ino)break ;
@@ -5262,7 +5262,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)btrfs_get_delayed_items (inode, &ins_list, &del_list); } -btrfs_set_key_type (&key, key_type); + key.type = key_type; key.offset = ctx->pos; key.objectid =btrfs_ino (inode);
@@ -5287,7 +5287,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)if (found_key.objectid != key.objectid)break ; -if (btrfs_key_type (&found_key) != key_type) +if (found_key.type != key_type)break ;if (found_key.offset < ctx->pos) goto next;
@@ -5499,7 +5499,7 @@ static int btrfs_set_inode_index_count(struct inode *inode)int ret; key.objectid =btrfs_ino (inode); -btrfs_set_key_type (&key,BTRFS_DIR_INDEX_KEY ); + key.type =BTRFS_DIR_INDEX_KEY ; key.offset = (u64)-1 ; path =btrfs_alloc_path ();
@@ -5531,7 +5531,7 @@ static int btrfs_set_inode_index_count(struct inode *inode)btrfs_item_key_to_cpu (leaf, &found_key, path->slots[0 ]);if (found_key.objectid !=btrfs_ino (inode) || -btrfs_key_type (&found_key) !=BTRFS_DIR_INDEX_KEY ) { + found_key.type !=BTRFS_DIR_INDEX_KEY ) {BTRFS_I (inode)->index_cnt =2 ; goto out; }
@@ -5631,7 +5631,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,set_bit (BTRFS_INODE_NEEDS_FULL_SYNC , &BTRFS_I (inode)->runtime_flags); key[0 ].objectid = objectid; -btrfs_set_key_type (&key[0 ],BTRFS_INODE_ITEM_KEY ); + key[0 ].type =BTRFS_INODE_ITEM_KEY ; key[0 ].offset =0 ; sizes[0 ] =sizeof (struct btrfs_inode_item );
@@ -5644,7 +5644,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,* add more hard links than can fit in the ref item. */ key[1 ].objectid = objectid; -btrfs_set_key_type (&key[1 ],BTRFS_INODE_REF_KEY ); + key[1 ].type =BTRFS_INODE_REF_KEY ; key[1 ].offset = ref_objectid; sizes[1 ] = name_len +sizeof (*ref);
@@ -5679,7 +5679,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, location = &BTRFS_I (inode)->location; location->objectid = objectid; location->offset =0 ; -btrfs_set_key_type (location,BTRFS_INODE_ITEM_KEY ); + location->type =BTRFS_INODE_ITEM_KEY ;btrfs_inherit_iflags (inode, dir);
@@ -5739,7 +5739,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,memcpy (&key, &BTRFS_I (inode)->root->root_key,sizeof (key)); }else { key.objectid = ino; -btrfs_set_key_type (&key,BTRFS_INODE_ITEM_KEY ); + key.type =BTRFS_INODE_ITEM_KEY ; key.offset =0 ; }
@@ -6220,7 +6220,7 @@ again: struct btrfs_file_extent_item);/* are we inside the extent that was found? */ btrfs_item_key_to_cpu (leaf, &found_key, path->slots[0 ]); - found_type =btrfs_key_type (&found_key); + found_type = found_key.type;if (found_key.objectid != objectid || found_type !=BTRFS_EXTENT_DATA_KEY ) {/*
@@ -8763,7 +8763,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, } key.objectid =btrfs_ino (inode); key.offset =0 ; -btrfs_set_key_type (&key,BTRFS_EXTENT_DATA_KEY ); + key.type =BTRFS_EXTENT_DATA_KEY ; datasize =btrfs_file_extent_calc_inline_size (name_len); err =btrfs_insert_empty_item (trans, root, path, &key, datasize);
fs/btrfs/ioctl.c +3 -3
@@ -532,7 +532,7 @@ static noinline int create_subvol(struct inode *dir, key.objectid = objectid; key.offset =0 ; -btrfs_set_key_type (&key,BTRFS_ROOT_ITEM_KEY ); + key.type =BTRFS_ROOT_ITEM_KEY ; ret =btrfs_insert_root (trans, root->fs_info->tree_root, &key, &root_item);if (ret)
@@ -3273,11 +3273,11 @@ process_slot: slot = path->slots[0 ];btrfs_item_key_to_cpu (leaf, &key, slot); -if (btrfs_key_type (&key) >BTRFS_EXTENT_DATA_KEY || +if (key.type >BTRFS_EXTENT_DATA_KEY || key.objectid !=btrfs_ino (src))break ; -if (btrfs_key_type (&key) ==BTRFS_EXTENT_DATA_KEY ) { +if (key.type ==BTRFS_EXTENT_DATA_KEY ) {struct btrfs_file_extent_item *extent;int type;u32 size;
fs/btrfs/orphan.c +2 -2
@@ -27,7 +27,7 @@ int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,int ret =0 ; key.objectid =BTRFS_ORPHAN_OBJECTID ; -btrfs_set_key_type (&key,BTRFS_ORPHAN_ITEM_KEY ); + key.type =BTRFS_ORPHAN_ITEM_KEY ; key.offset = offset; path =btrfs_alloc_path ();
@@ -48,7 +48,7 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,int ret =0 ; key.objectid =BTRFS_ORPHAN_OBJECTID ; -btrfs_set_key_type (&key,BTRFS_ORPHAN_ITEM_KEY ); + key.type =BTRFS_ORPHAN_ITEM_KEY ; key.offset = offset; path =btrfs_alloc_path ();
fs/btrfs/print-tree.c +1 -1
@@ -195,7 +195,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)for (i =0 ; i < nr ; i++) { item =btrfs_item_nr (i);btrfs_item_key_to_cpu (l, &key, i); - type =btrfs_key_type (&key); + type = key.type; printk(KERN_INFO "\titem %d key (%llu %u %llu) itemoff %d " "itemsize %d\n", i, key.objectid, type, key.offset,
fs/btrfs/scrub.c +1 -1
@@ -2713,7 +2713,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,if (found_key.objectid != scrub_dev->devid)break ; -if (btrfs_key_type (&found_key) !=BTRFS_DEV_EXTENT_KEY ) +if (found_key.type !=BTRFS_DEV_EXTENT_KEY )break ;if (found_key.offset >= end)
fs/btrfs/tree-log.c +3 -3
@@ -1496,7 +1496,7 @@ static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,return -EIO ; key.objectid =BTRFS_TREE_LOG_FIXUP_OBJECTID ; -btrfs_set_key_type (&key,BTRFS_ORPHAN_ITEM_KEY ); + key.type =BTRFS_ORPHAN_ITEM_KEY ; key.offset = objectid; ret =btrfs_insert_empty_item (trans, root, path, &key,0 );
@@ -3363,7 +3363,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,* or deletes of this inode don't have to relog the inode * again */ -if (btrfs_key_type (ins_keys + i) ==BTRFS_EXTENT_DATA_KEY && +if (ins_keys[i].type ==BTRFS_EXTENT_DATA_KEY && !skip_csum) {int found_type; extent = btrfs_item_ptr(src, start_slot + i,
@@ -4316,7 +4316,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) again: key.objectid =BTRFS_TREE_LOG_OBJECTID ; key.offset = (u64)-1 ; -btrfs_set_key_type (&key,BTRFS_ROOT_ITEM_KEY ); + key.type =BTRFS_ROOT_ITEM_KEY ;while (1 ) { ret =btrfs_search_slot (NULL , log_root_tree, &key, path,0 ,0 );
fs/btrfs/volumes.c +2 -2
@@ -1004,7 +1004,7 @@ int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,if (key.objectid > device->devid)break ; -if (btrfs_key_type (&key) !=BTRFS_DEV_EXTENT_KEY ) +if (key.type !=BTRFS_DEV_EXTENT_KEY ) goto next; dev_extent = btrfs_item_ptr(l, slot, struct btrfs_dev_extent);
@@ -1156,7 +1156,7 @@ again:if (key.objectid > device->devid)break ; -if (btrfs_key_type (&key) !=BTRFS_DEV_EXTENT_KEY ) +if (key.type !=BTRFS_DEV_EXTENT_KEY ) goto next;if (key.offset > search_start) {
fs/btrfs/xattr.c +2 -2
@@ -237,7 +237,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)* first xattr that we find and walk forward */ key.objectid =btrfs_ino (inode); -btrfs_set_key_type (&key,BTRFS_XATTR_ITEM_KEY ); + key.type =BTRFS_XATTR_ITEM_KEY ; key.offset =0 ; path =btrfs_alloc_path ();
@@ -273,7 +273,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)/* check to make sure this item is what we want */ if (found_key.objectid != key.objectid)break ; -if (btrfs_key_type (&found_key) !=BTRFS_XATTR_ITEM_KEY ) +if (found_key.type !=BTRFS_XATTR_ITEM_KEY )break ; di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item);
Signature · 1 line
1.7.9
PATCH 6/8 btrfs: use nodesize everywhere, kill leafsize
In reply to David SterbaThe 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
--- fs/btrfs/backref.c | 8 ++-- fs/btrfs/check-integrity.c | 13 -------- fs/btrfs/ctree.c | 18 +++++----- fs/btrfs/ctree.h | 21 ++---------- fs/btrfs/disk-io.c | 74 +++++++++++++++++++------------------------ fs/btrfs/extent-tree.c | 36 +++++++++++----------- fs/btrfs/file.c | 2 +- fs/btrfs/ioctl.c | 6 ++-- fs/btrfs/print-tree.c | 2 +- fs/btrfs/qgroup.c | 6 +-- fs/btrfs/reada.c | 2 +- fs/btrfs/relocation.c | 21 ++++++------ fs/btrfs/scrub.c | 17 +--------- fs/btrfs/transaction.c | 2 +- fs/btrfs/tree-log.c | 2 +- 15 files changed, 89 insertions(+), 141 deletions(-)
fs/btrfs/backref.c +4 -4
@@ -483,7 +483,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,continue ;BUG_ON (!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)) {free_extent_buffer (eb);return -EIO ;
@@ -992,8 +992,8 @@ again: ref->level == 0) {u32 bsz;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, ref->parent, bsz,0 );if (!eb || !extent_buffer_uptodate (eb)) {
@@ -1364,7 +1364,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 ]);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 ) size = found_key->offset;
fs/btrfs/check-integrity.c +0 -13
@@ -820,7 +820,6 @@ static int btrfsic_process_superblock_dev_mirror( btrfs_super_magic(super_tmp) != BTRFS_MAGIC || memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_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) {brelse (bh);return 0 ;
@@ -3120,24 +3119,12 @@ int btrfsic_mount(struct btrfs_root *root,struct list_head *dev_head = &fs_devices->devices;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 )) {printk (KERN_INFO "btrfsic: cannot handle nodesize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n" , root->nodesize,PAGE_CACHE_SIZE );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 )) { printk(KERN_INFO "btrfsic: cannot handle sectorsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n",
fs/btrfs/ctree.c +9 -9
@@ -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 ) {btrfs_tree_read_unlock (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 );if (WARN_ON (!old || !extent_buffer_uptodate (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); parent_nritems =btrfs_header_nritems (parent); - blocksize =btrfs_level_size (root, parent_level -1 ); + blocksize = root->nodesize; end_slot = parent_nritems;if (parent_nritems ==1 )
@@ -1872,7 +1872,7 @@ static noinline struct extent_buffer *read_node_slot(struct btrfs_root *root,BUG_ON (level ==0 ); eb =read_tree_block (root,btrfs_node_blockptr (parent, slot), -btrfs_level_size (root, level -1 ), + root->nodesize,btrfs_node_ptr_generation (parent, slot));if (eb && !extent_buffer_uptodate (eb)) {free_extent_buffer (eb);
@@ -2267,7 +2267,7 @@ static void reada_for_search(struct btrfs_root *root, node = path->nodes[level]; search =btrfs_node_blockptr (node, slot); - blocksize =btrfs_level_size (root, level -1 ); + blocksize = root->nodesize; eb =btrfs_find_tree_block (root, search, blocksize);if (eb) {free_extent_buffer (eb);
@@ -2325,7 +2325,7 @@ static noinline void reada_for_balance(struct btrfs_root *root, nritems =btrfs_header_nritems (parent); slot = path->slots[level +1 ]; - blocksize =btrfs_level_size (root, level); + blocksize = root->nodesize;if (slot >0 ) { 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); 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);if (tmp) {
@@ -4282,13 +4282,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->nodesize,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->nodesize);memset_extent_buffer (right,0 ,0 ,sizeof (struct btrfs_header ));btrfs_set_header_bytenr (right, right->start);
@@ -5375,7 +5375,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root, goto out; } - tmp_buf =kmalloc (left_root->leafsize,GFP_NOFS ); + tmp_buf =kmalloc (left_root->nodesize,GFP_NOFS );if (!tmp_buf) { ret = -ENOMEM ; goto out;
fs/btrfs/ctree.h +4 -17
@@ -391,7 +391,7 @@ struct btrfs_header { 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->nodesize))#define BTRFS_MAX_INLINE_DATA_SIZE (r) (BTRFS_LEAF_DATA_SIZE(r) - \ sizeof(struct btrfs_item) - \ sizeof(struct btrfs_file_extent_item))
@@ -474,7 +474,7 @@ struct btrfs_super_block {__le64 num_devices;__le32 sectorsize;__le32 nodesize; -__le32 leafsize; +__le32 __unused_leafsize;__le32 stripesize;__le32 sys_chunk_array_size;__le64 chunk_root_generation;
@@ -1806,9 +1806,6 @@ struct btrfs_root {/* node allocations are done in nodesize units */ u32 nodesize; -/* leaf allocations are done in leafsize units */ -u32 leafsize; -u32 stripesize;u32 type;
@@ -2995,8 +2992,6 @@ BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block, sectorsize, 32); BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block, nodesize,32 ); -BTRFS_SETGET_STACK_FUNCS(super_leafsize, struct btrfs_super_block, - leafsize,32 ); BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block, stripesize,32 ); 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; } -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. */ #define btrfs_item_ptr (leaf, slot, type) \ ((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,unsigned num_items) { -return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL -1 )) * +return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL -1 )) *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,unsigned num_items) { -return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL -1 )) * - num_items; +return root->nodesize *BTRFS_MAX_LEVEL * num_items; } int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
fs/btrfs/disk-io.c +33 -41
217 lines not on this page · raw message
fs/btrfs/extent-tree.c +18 -18
@@ -491,7 +491,7 @@ next: key.objectid);if (key.type ==BTRFS_METADATA_ITEM_KEY ) last = key.objectid + - fs_info->tree_root->leafsize; + fs_info->tree_root->nodesize;else last = key.objectid + key.offset;
@@ -764,7 +764,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,* different */ if (metadata && !btrfs_fs_incompat (root->fs_info,SKINNY_METADATA )) { - offset = root->leafsize; + offset = root->nodesize; metadata =0 ; }
@@ -798,13 +798,13 @@ again: path->slots[0]);if (key.objectid == bytenr && key.type ==BTRFS_EXTENT_ITEM_KEY && - key.offset == root->leafsize) + key.offset == root->nodesize) ret =0 ; }if (ret) { key.objectid = bytenr; key.type =BTRFS_EXTENT_ITEM_KEY ; - key.offset = root->leafsize; + key.offset = root->nodesize;btrfs_release_path (path); goto again; }
@@ -2650,7 +2650,7 @@ int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans, num_bytes =btrfs_calc_trans_metadata_size (root,1 ); num_heads =heads_to_leaves (root, num_heads);if (num_heads >1 ) - num_bytes += (num_heads -1 ) * root->leafsize; + num_bytes += (num_heads -1 ) * root->nodesize; num_bytes <<=1 ; global_rsv = &root->fs_info->global_block_rsv;
@@ -3116,7 +3116,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, goto fail; }else { 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, parent, ref_root, level -1 ,0 , no_quota);
@@ -4844,7 +4844,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->extent_root->nodesize <<10 ); }static void update_global_block_rsv (struct btrfs_fs_info *fs_info)
@@ -4993,7 +4993,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,if (root->fs_info->quota_enabled) {/* 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);if (ret)return ret;
@@ -5181,7 +5181,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)if (root->fs_info->quota_enabled) { ret =btrfs_qgroup_reserve (root, num_bytes + - nr_extents * root->leafsize); + nr_extents * root->nodesize);if (ret) goto out_fail; }
@@ -5190,7 +5190,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)if (unlikely (ret)) {if (root->fs_info->quota_enabled)btrfs_qgroup_free (root, num_bytes + - nr_extents * root->leafsize); + nr_extents * root->nodesize); goto out_fail; }
@@ -5306,7 +5306,7 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes) btrfs_ino(inode), to_free, 0);if (root->fs_info->quota_enabled) {btrfs_qgroup_free (root, num_bytes + - dropped * root->leafsize); + dropped * root->nodesize); } btrfs_block_rsv_release(root, &root->fs_info->delalloc_block_rsv,
@@ -7085,7 +7085,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, path =btrfs_alloc_path ();if (!path) {btrfs_free_and_pin_reserved_extent (root, ins->objectid, - root->leafsize); + root->nodesize);return -ENOMEM ; }
@@ -7094,7 +7094,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, ins, size);if (ret) {btrfs_free_and_pin_reserved_extent (root, ins->objectid, - root->leafsize); + root->nodesize);btrfs_free_path (path);return ret; }
@@ -7109,7 +7109,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,if (skinny_metadata) { iref = (struct btrfs_extent_inline_ref *)(extent_item +1 ); - num_bytes = root->leafsize; + num_bytes = root->nodesize; }else { block_info = (struct btrfs_tree_block_info *)(extent_item +1 );btrfs_set_tree_block_key (leaf, block_info, key);
@@ -7139,14 +7139,14 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,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 */ btrfs_err (fs_info,"update block group failed for %llu %llu" , ins->objectid, ins->offset);BUG (); } -trace_btrfs_reserved_extent_alloc (root, ins->objectid, root->leafsize); +trace_btrfs_reserved_extent_alloc (root, ins->objectid, root->nodesize);return ret; }
@@ -7425,7 +7425,7 @@ static noinline void reada_walk_down(struct btrfs_trans_handle *trans, eb = path->nodes[wc->level]; 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++) {if (nread >= wc->reada_count)
@@ -7599,7 +7599,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, } 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);if (!next) {
fs/btrfs/file.c +1 -1
@@ -1652,7 +1652,7 @@ again:cond_resched ();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); pos += copied;
fs/btrfs/ioctl.c +3 -3
@@ -474,7 +474,7 @@ static noinline int create_subvol(struct inode *dir,if (ret) 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 );if (IS_ERR (leaf)) { ret =PTR_ERR (leaf);
@@ -500,7 +500,7 @@ static noinline int create_subvol(struct inode *dir,btrfs_set_stack_inode_generation (inode_item,1 );btrfs_set_stack_inode_size (inode_item,3 );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_root_flags (&root_item,0 );
@@ -3220,7 +3220,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,u64 last_dest_end = destoff; ret = -ENOMEM ; - buf =vmalloc (btrfs_level_size (root,0 )); + buf =vmalloc (root->nodesize);if (!buf)return ret;
fs/btrfs/print-tree.c +1 -1
@@ -335,7 +335,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)for (i =0 ; i < nr; i++) {struct extent_buffer *next =read_tree_block (root,btrfs_node_blockptr (c, i), -btrfs_level_size (root, level -1 ), + root->nodesize,btrfs_node_ptr_generation (c, i));if (btrfs_is_leaf (next) && level !=1 )
fs/btrfs/qgroup.c +2 -4
@@ -2068,7 +2068,6 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,if (srcid) {struct btrfs_root *srcroot;struct btrfs_key srckey; -int srcroot_level; srckey.objectid = srcid; srckey.type =BTRFS_ROOT_ITEM_KEY ;
@@ -2080,8 +2079,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, }rcu_read_lock (); - srcroot_level =btrfs_header_level (srcroot->node); - level_size =btrfs_level_size (srcroot, srcroot_level); + level_size = srcroot->nodesize;rcu_read_unlock (); }
@@ -2397,7 +2395,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path, found.type != BTRFS_METADATA_ITEM_KEY)continue ;if (found.type ==BTRFS_METADATA_ITEM_KEY ) - num_bytes = fs_info->extent_root->leafsize; + num_bytes = fs_info->extent_root->nodesize;else num_bytes = found.offset;
fs/btrfs/reada.c +1 -1
@@ -347,7 +347,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,if (!re)return NULL ; - blocksize =btrfs_level_size (root, level); + blocksize = root->nodesize; re->logical = logical; re->blocksize = blocksize; re->top = *top;
fs/btrfs/relocation.c +10 -11
@@ -1787,7 +1787,7 @@ again:btrfs_node_key_to_cpu (parent, next_key, slot +1 ); 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);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]); - blocksize =btrfs_level_size (root, i -1 ); + blocksize = root->nodesize; eb =read_tree_block (root, bytenr, blocksize, ptr_gen);if (!eb || !extent_buffer_uptodate (eb)) {free_extent_buffer (eb);
@@ -2544,8 +2544,7 @@ u64 calcu_metadata_size(struct reloc_control *rc,if (next->processed && (reserve || next != node))break ; - num_bytes +=btrfs_level_size (rc->extent_root, - next->level); + num_bytes += rc->extent_root->nodesize;if (list_empty (&next->upper))break ;
@@ -2679,7 +2678,7 @@ static int do_relocation(struct btrfs_trans_handle *trans, goto next; } - blocksize =btrfs_level_size (root, node->level); + blocksize = root->nodesize; generation =btrfs_node_ptr_generation (upper->eb, slot); eb =read_tree_block (root, bytenr, blocksize, generation);if (!eb || !extent_buffer_uptodate (eb)) {
@@ -2789,7 +2788,7 @@ static void __mark_block_processed(struct reloc_control *rc,u32 blocksize;if (node->level ==0 ||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); } node->processed =1 ;
@@ -2865,7 +2864,7 @@ static int reada_tree_block(struct reloc_control *rc,if (block->key.type ==BTRFS_METADATA_ITEM_KEY )readahead_tree_block (rc->extent_root, block->bytenr, block->key.objectid, - rc->extent_root->leafsize); + rc->extent_root->nodesize);else readahead_tree_block (rc->extent_root, block->bytenr, block->key.objectid, block->key.offset);
@@ -3313,7 +3312,7 @@ static int add_tree_block(struct reloc_control *rc,return -ENOMEM ; block->bytenr = extent_key->objectid; - block->key.objectid = rc->extent_root->leafsize; + block->key.objectid = rc->extent_root->nodesize; block->key.offset = generation; block->level = level; block->key_ready =0 ;
@@ -3640,7 +3639,7 @@ int add_data_references(struct reloc_control *rc,struct btrfs_extent_inline_ref *iref;unsigned long ptr;unsigned long end; -u32 blocksize =btrfs_level_size (rc->extent_root,0 ); +u32 blocksize = rc->extent_root->nodesize;int ret =0 ;int err =0 ;
@@ -3783,7 +3782,7 @@ next: }if (key.type ==BTRFS_METADATA_ITEM_KEY && - key.objectid + rc->extent_root->leafsize <= + key.objectid + rc->extent_root->nodesize <= rc->search_start) { path->slots[0 ]++; goto next;
@@ -3801,7 +3800,7 @@ next: rc->search_start = key.objectid + key.offset; else rc->search_start = key.objectid + - rc->extent_root->leafsize; + rc->extent_root->nodesize;memcpy (extent_key, &key,sizeof (key));return 0 ; }
fs/btrfs/scrub.c +1 -16
@@ -137,7 +137,6 @@ struct scrub_ctx {int pages_per_rd_bio;u32 sectorsize;u32 nodesize; -u32 leafsize;int is_dev_replace;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->nodesize = dev->dev_root->nodesize; - sctx->leafsize = dev->dev_root->leafsize; sctx->sectorsize = dev->dev_root->sectorsize;atomic_set (&sctx->bios_in_flight,0 );atomic_set (&sctx->workers_pending,0 );
@@ -1757,7 +1755,6 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock) BTRFS_UUID_SIZE)) ++fail; -WARN_ON (sctx->nodesize != sctx->leafsize); len = sctx->nodesize -BTRFS_CSUM_SIZE ; mapped_size =PAGE_SIZE -BTRFS_CSUM_SIZE ; p = ((u8 *)mapped_buffer) +BTRFS_CSUM_SIZE ;
@@ -2195,7 +2192,6 @@ static int scrub_extent(struct scrub_ctx *sctx, u64 logical, u64 len, sctx->stat.data_bytes_scrubbed += len;spin_unlock (&sctx->stat_lock); }else if (flags &BTRFS_EXTENT_FLAG_TREE_BLOCK ) { -WARN_ON (sctx->nodesize != sctx->leafsize); blocksize = sctx->nodesize;spin_lock (&sctx->stat_lock); sctx->stat.tree_extents_scrubbed++;
@@ -2486,7 +2482,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,btrfs_item_key_to_cpu (l, &key, slot);if (key.type ==BTRFS_METADATA_ITEM_KEY ) - bytes = root->leafsize; + bytes = root->nodesize;else bytes = key.offset;
@@ -2908,17 +2904,6 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,if (btrfs_fs_closing (fs_info))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 ) {/* * in this case scrub is unable to calculate the checksum
fs/btrfs/transaction.c +1 -1
@@ -407,7 +407,7 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,if (num_items >0 && root != root->fs_info->chunk_root) {if (root->fs_info->quota_enabled &&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);if (ret)return ERR_PTR (ret);
fs/btrfs/tree-log.c +1 -1
@@ -2155,7 +2155,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, bytenr =btrfs_node_blockptr (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]; root_owner =btrfs_header_owner (parent);
Signature · 1 line
1.7.9
PATCH 7/8 btrfs: clean away stripe_align helper
In reply to David SterbaOnly wraps the ALIGN macro.
--- fs/btrfs/extent-tree.c | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
fs/btrfs/extent-tree.c +1 -10
@@ -6271,14 +6271,6 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,return ret; } -static u64 stripe_align (struct btrfs_root *root, -struct btrfs_block_group_cache *cache, -u64 val,u64 num_bytes) -{ -u64 ret =ALIGN (val, root->stripesize); -return ret; -} -/* * when we wait for progress in the block group caching, its because * our allocation attempt failed at least once. So, we must sleep
@@ -6759,8 +6751,7 @@ unclustered_alloc: goto loop; } checks: - search_start =stripe_align (root, block_group, - offset, num_bytes); + search_start =ALIGN (offset, root->stripesize);/* move on to the next group */ if (search_start + num_bytes >
Signature · 1 line
1.7.9
PATCH 8/8 btrfs: use DIV_ROUND_UP instead of open-coded variants
In reply to David SterbaThe form
(value + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT
is equivalent to
(value + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE
The rest is a simple subsitution, no difference in the generated assembly code.
--- fs/btrfs/check-integrity.c | 3 +-- fs/btrfs/compression.c | 10 ++++------ fs/btrfs/file.c | 19 ++++++++----------- fs/btrfs/free-space-cache.c | 3 +-- fs/btrfs/ioctl.c | 5 ++--- fs/btrfs/lzo.c | 3 +-- fs/btrfs/raid56.c | 8 ++++---- fs/btrfs/zlib.c | 3 +-- 8 files changed, 22 insertions(+), 32 deletions(-)
fs/btrfs/check-integrity.c +1 -2
@@ -1251,8 +1251,7 @@ static void btrfsic_read_from_block_data(while (len >0 ) { cur =min (len, ((size_t )PAGE_CACHE_SIZE - offset_in_page)); -BUG_ON (i >= (block_ctx->len +PAGE_CACHE_SIZE -1 ) >> -PAGE_CACHE_SHIFT ); +BUG_ON (i >=DIV_ROUND_UP (block_ctx->len,PAGE_CACHE_SIZE )); kaddr = block_ctx->datav[i];memcpy (dst, kaddr + offset_in_page, cur);
fs/btrfs/compression.c +4 -6
@@ -91,8 +91,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) * - csum_size; + (DIV_ROUND_UP (disk_size, root->sectorsize)) * csum_size; } static struct bio *compressed_bio_alloc(struct block_device *bdev,
@@ -615,8 +614,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, cb->compress_type =extent_compress_type (bio_flags); cb->orig_bio = bio; - nr_pages = (compressed_len +PAGE_CACHE_SIZE -1 ) / -PAGE_CACHE_SIZE ; + nr_pages =DIV_ROUND_UP (compressed_len,PAGE_CACHE_SIZE ); cb->compressed_pages =kzalloc (sizeof (struct page *) * nr_pages,GFP_NOFS );if (!cb->compressed_pages)
@@ -686,8 +684,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, comp_bio, sums);BUG_ON (ret);/* -ENOMEM */ } - sums += (comp_bio->bi_iter.bi_size + - root->sectorsize -1 ) / root->sectorsize; + sums +=DIV_ROUND_UP (comp_bio->bi_iter.bi_size, + root->sectorsize); ret =btrfs_map_bio (root,READ , comp_bio, mirror_num,0 );
fs/btrfs/file.c +8 -11
@@ -1480,9 +1480,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,bool force_page_uptodate = false;bool need_unlock; - nrptrs =min ((iov_iter_count (i) +PAGE_CACHE_SIZE -1 ) / -PAGE_CACHE_SIZE ,PAGE_CACHE_SIZE / - (sizeof (struct page *))); + nrptrs =min (DIV_ROUND_UP (iov_iter_count (i),PAGE_CACHE_SIZE ), +PAGE_CACHE_SIZE / (sizeof (struct page *))); nrptrs =min (nrptrs, current->nr_dirtied_pause - current->nr_dirtied); nrptrs =max (nrptrs,8 ); pages =kmalloc (nrptrs *sizeof (struct page *),GFP_KERNEL );
@@ -1496,8 +1495,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,size_t write_bytes =min (iov_iter_count (i), nrptrs * (size_t )PAGE_CACHE_SIZE - offset); -size_t num_pages = (write_bytes + offset + -PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; +size_t num_pages =DIV_ROUND_UP (write_bytes + offset, +PAGE_CACHE_SIZE );size_t reserve_bytes;size_t dirty_pages;size_t copied;
@@ -1525,9 +1524,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,* our prealloc extent may be smaller than * write_bytes, so scale down. */ - num_pages = (write_bytes + offset + -PAGE_CACHE_SIZE -1 ) >> -PAGE_CACHE_SHIFT ; + num_pages =DIV_ROUND_UP (write_bytes + offset, +PAGE_CACHE_SIZE ); reserve_bytes = num_pages <<PAGE_CACHE_SHIFT ; ret =0 ; }else {
@@ -1589,9 +1587,8 @@ again: dirty_pages =0 ; }else { force_page_uptodate = false; - dirty_pages = (copied + offset + -PAGE_CACHE_SIZE -1 ) >> -PAGE_CACHE_SHIFT ; + dirty_pages =DIV_ROUND_UP (copied + offset, +PAGE_CACHE_SIZE ); }/*
fs/btrfs/free-space-cache.c +1 -2
@@ -279,8 +279,7 @@ static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,int num_pages;int check_crcs =0 ; - num_pages = (i_size_read (inode) +PAGE_CACHE_SIZE -1 ) >> -PAGE_CACHE_SHIFT ; + num_pages =DIV_ROUND_UP (i_size_read (inode),PAGE_CACHE_SIZE );if (btrfs_ino (inode) !=BTRFS_FREE_INO_OBJECTID ) check_crcs =1 ;
fs/btrfs/ioctl.c +2 -3
@@ -1364,8 +1364,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, inode->i_mapping->writeback_index = i;while (i <= last_index && defrag_count < max_to_defrag && - (i < (i_size_read (inode) +PAGE_CACHE_SIZE -1 ) >> -PAGE_CACHE_SHIFT )) { + (i <DIV_ROUND_UP (i_size_read (inode),PAGE_CACHE_SIZE ))) {/* * make sure we stop running if someone unmounts * the FS
@@ -1388,7 +1387,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,* the should_defrag function tells us how much to skip * bump our counter by the suggested amount */ - next = (skip +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + next =DIV_ROUND_UP (skip,PAGE_CACHE_SIZE ); i =max (i +1 , next);continue ; }
fs/btrfs/lzo.c +1 -2
@@ -266,8 +266,7 @@ static int lzo_decompress_biovec(struct list_head *ws,char *data_in;unsigned long page_in_index =0 ;unsigned long page_out_index =0 ; -unsigned long total_pages_in = (srclen +PAGE_CACHE_SIZE -1 ) / -PAGE_CACHE_SIZE ; +unsigned long total_pages_in =DIV_ROUND_UP (srclen,PAGE_CACHE_SIZE );unsigned long buf_start;unsigned long buf_offset =0 ;unsigned long bytes;
fs/btrfs/raid56.c +4 -4
@@ -912,7 +912,7 @@ static struct page *page_in_rbio(struct btrfs_raid_bio *rbio,static unsigned long rbio_nr_pages (unsigned long stripe_len,int nr_stripes) {unsigned long nr = stripe_len * nr_stripes; -return (nr +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; +return DIV_ROUND_UP (nr,PAGE_CACHE_SIZE ); }/*
@@ -1440,7 +1440,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)struct btrfs_bio *bbio = rbio->bbio;struct bio_list bio_list;int ret; -int nr_pages = (rbio->stripe_len +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; +int nr_pages =DIV_ROUND_UP (rbio->stripe_len,PAGE_CACHE_SIZE );int pagenr;int stripe;struct bio *bio;
@@ -1722,7 +1722,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)int pagenr, stripe;void **pointers;int faila =-1 , failb =-1 ; -int nr_pages = (rbio->stripe_len +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; +int nr_pages =DIV_ROUND_UP (rbio->stripe_len,PAGE_CACHE_SIZE );struct page *page;int err;int i;
@@ -1937,7 +1937,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)struct btrfs_bio *bbio = rbio->bbio;struct bio_list bio_list;int ret; -int nr_pages = (rbio->stripe_len +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; +int nr_pages =DIV_ROUND_UP (rbio->stripe_len,PAGE_CACHE_SIZE );int pagenr;int stripe;struct bio *bio;
fs/btrfs/zlib.c +1 -2
@@ -225,8 +225,7 @@ static int zlib_decompress_biovec(struct list_head *ws, struct page **pages_in,size_t total_out =0 ;unsigned long page_in_index =0 ;unsigned long page_out_index =0 ; -unsigned long total_pages_in = (srclen +PAGE_CACHE_SIZE -1 ) / -PAGE_CACHE_SIZE ; +unsigned long total_pages_in =DIV_ROUND_UP (srclen,PAGE_CACHE_SIZE );unsigned long buf_start;unsigned long pg_offset;
Signature · 1 line
1.7.9