Unused parameter cleanup
cover Unused parameter cleanup
Hello,
Here is a series that I've been sitting on for a while. It removes unused parameter in various functions, no functional changes. Patch 09/10 reworks some error handling to eliminate an if branch in __btrfs_alloc_chunk, but it's still a minor refactoring.
Nikolay Borisov (10):
btrfs: Remove chunk_objectid parameter of btrfs_alloc_dev_extent
btrfs: remove superfluous chunk_tree argument from
btrfs_alloc_dev_extent
btrfs: Remove unused variable
btrfs: Remove unused parameters from various functions
btrfs: Remove unused arguments from btrfs_changed_cb_t
btrfs: Remove unused parameter from check_direct_IO
btrfs: Remove unused parameter from extent_clear_unlock_delalloc
btrfs: remove unused parameter in cow_file_range
btrfs: Rework error handling of add_extent_mapping in
__btrfs_alloc_chunk
btrfs: Remove redundant argument of __link_block_group
fs/btrfs/ctree.c | 15 +++++---------- fs/btrfs/ctree.h | 4 +--- fs/btrfs/extent-tree.c | 8 ++++---- fs/btrfs/extent_io.c | 3 +-- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 47 ++++++++++++++++++----------------------------- fs/btrfs/send.c | 33 ++++++++++++++------------------- fs/btrfs/tree-log.c | 4 +--- fs/btrfs/volumes.c | 24 +++++++++++------------- 9 files changed, 56 insertions(+), 84 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/10 btrfs: Remove chunk_objectid parameter of btrfs_alloc_dev_extent
THe function is always called with chunk_objectid set to BTRFS_FIRST_CHUNK_TREE_OBJECTID. Let's collapse the parameter in the function itself. No functional changes
--- fs/btrfs/volumes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/volumes.c +4 -4
@@ -1571,8 +1571,8 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,static int btrfs_alloc_dev_extent (struct btrfs_trans_handle *trans,struct btrfs_device *device, -u64 chunk_tree,u64 chunk_objectid, -u64 chunk_offset,u64 start,u64 num_bytes) +u64 chunk_tree,u64 chunk_offset,u64 start, +u64 num_bytes) {int ret;struct btrfs_path *path;
@@ -1600,7 +1600,8 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans, extent =btrfs_item_ptr (leaf, path->slots[0 ], struct btrfs_dev_extent);btrfs_set_dev_extent_chunk_tree (leaf, extent, chunk_tree); -btrfs_set_dev_extent_chunk_objectid (leaf, extent, chunk_objectid); +btrfs_set_dev_extent_chunk_objectid (leaf, extent, +BTRFS_FIRST_CHUNK_TREE_OBJECTID );btrfs_set_dev_extent_chunk_offset (leaf, extent, chunk_offset);btrfs_set_dev_extent_length (leaf, extent, num_bytes);
@@ -4904,7 +4905,6 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,break ; ret =btrfs_alloc_dev_extent (trans, device, chunk_root->root_key.objectid, -BTRFS_FIRST_CHUNK_TREE_OBJECTID , chunk_offset, dev_offset, stripe_size);if (ret)
Signature · 1 line
2.7.4
PATCH 2/10 btrfs: remove superfluous chunk_tree argument from btrfs_alloc_dev_extent
In reply to Nikolay BorisovCurrently this function is always called with the object id of the root key of the chunk_tree, which is always BTRFS_CHUNK_TREE_OBJECTID. So let's subsume it straight into the function itself. No functional change.
--- fs/btrfs/volumes.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
fs/btrfs/volumes.c +5 -7
@@ -1571,8 +1571,7 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,static int btrfs_alloc_dev_extent (struct btrfs_trans_handle *trans,struct btrfs_device *device, -u64 chunk_tree,u64 chunk_offset,u64 start, -u64 num_bytes) +u64 chunk_offset,u64 start,u64 num_bytes) {int ret;struct btrfs_path *path;
@@ -1599,7 +1598,8 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans, leaf = path->nodes[0 ]; extent =btrfs_item_ptr (leaf, path->slots[0 ], struct btrfs_dev_extent); -btrfs_set_dev_extent_chunk_tree (leaf, extent, chunk_tree); +btrfs_set_dev_extent_chunk_tree (leaf, extent, +BTRFS_CHUNK_TREE_OBJECTID );btrfs_set_dev_extent_chunk_objectid (leaf, extent,BTRFS_FIRST_CHUNK_TREE_OBJECTID );btrfs_set_dev_extent_chunk_offset (leaf, extent, chunk_offset);
@@ -4903,10 +4903,8 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, ret =btrfs_update_device (trans, device);if (ret)break ; - ret =btrfs_alloc_dev_extent (trans, device, - chunk_root->root_key.objectid, - chunk_offset, dev_offset, - stripe_size); + ret =btrfs_alloc_dev_extent (trans, device, chunk_offset, + dev_offset, stripe_size);if (ret)break ; }
Signature · 1 line
2.7.4
PATCH 3/10 btrfs: Remove unused variable
In reply to Nikolay BorisovSrc was initially part of 31ff1cd25d37 ("Btrfs: Copy into the log tree in
big batches"), however 16e7549f045d ("Btrfs: incompatible format change to remove hole extents") changed parameters passed to copy_items which made the src variable redundant.
--- fs/btrfs/tree-log.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/btrfs/tree-log.c +1 -3
@@ -2740,7 +2740,7 @@ static inline void btrfs_remove_log_ctx(struct btrfs_root *root,mutex_unlock (&root->log_mutex); } -/* +/* * Invoked in log mutex context, or be sure there is no other task which * can access the list. */
@@ -4637,7 +4637,6 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,struct btrfs_key min_key;struct btrfs_key max_key;struct btrfs_root *log = root->log_root; -struct extent_buffer *src =NULL ;LIST_HEAD (logged_list);u64 last_extent =0 ;int err =0 ;
@@ -4880,7 +4879,6 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, goto next_slot; } - src = path->nodes[0 ];if (ins_nr && ins_start_slot + ins_nr == path->slots[0 ]) { ins_nr++; goto next_slot;
Signature · 1 line
2.7.4
PATCH 4/10 btrfs: Remove unused parameters from various functions
In reply to Nikolay Borisoviterate_dir_item:found_key - introduced in 31db9f7c23fb ("Btrfs: introduce BTRFS_IOC_SEND for btrfs send/receive"), yet never used.
record_ref:num - ditto
This is a first pass with the low-hanging fruit. There are still quite a few unsued parameters in some function which have to abide by a callback interface.
--- fs/btrfs/send.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
fs/btrfs/send.c +11 -14
@@ -1002,7 +1002,6 @@ typedef int (*iterate_dir_item_t)(int num, struct btrfs_key *di_key,* path must point to the dir item when called. */ static int iterate_dir_item (struct btrfs_root *root,struct btrfs_path *path, -struct btrfs_key *found_key,iterate_dir_item_t iterate,void *ctx) {int ret =0 ;
@@ -4116,8 +4115,8 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)return ret; } -static int record_ref (struct btrfs_root *root,int num,u64 dir,int index, -struct fs_path *name,void *ctx,struct list_head *refs) +static int record_ref (struct btrfs_root *root,u64 dir,struct fs_path *name, +void *ctx,struct list_head *refs) {int ret =0 ;struct send_ctx *sctx = ctx;
@@ -4153,8 +4152,7 @@ static int __record_new_ref(int num, u64 dir, int index, void *ctx) {struct send_ctx *sctx = ctx; -return record_ref (sctx->send_root, num, dir, index, name, - ctx, &sctx->new_refs); +return record_ref (sctx->send_root, dir, name, ctx, &sctx->new_refs); }
@@ -4163,8 +4161,8 @@ static int __record_deleted_ref(int num, u64 dir, int index, void *ctx) {struct send_ctx *sctx = ctx; -return record_ref (sctx->parent_root, num, dir, index, name, - ctx, &sctx->deleted_refs); +return record_ref (sctx->parent_root, dir, name, ctx, + &sctx->deleted_refs); }static int record_new_ref (struct send_ctx *sctx)
@@ -4508,7 +4506,7 @@ static int process_new_xattr(struct send_ctx *sctx)int ret =0 ; ret =iterate_dir_item (sctx->send_root, sctx->left_path, - sctx->cmp_key, __process_new_xattr, sctx); + __process_new_xattr, sctx);return ret; }
@@ -4516,7 +4514,7 @@ static int process_new_xattr(struct send_ctx *sctx)static int process_deleted_xattr (struct send_ctx *sctx) {return iterate_dir_item (sctx->parent_root, sctx->right_path, - sctx->cmp_key, __process_deleted_xattr, sctx); + __process_deleted_xattr, sctx); }struct find_xattr_ctx {
@@ -4561,7 +4559,7 @@ static int find_xattr(struct btrfs_root *root, ctx.found_data =NULL ; ctx.found_data_len =0 ; - ret =iterate_dir_item (root, path, key, __find_xattr, &ctx); + ret =iterate_dir_item (root, path, __find_xattr, &ctx);if (ret <0 )return ret;
@@ -4631,11 +4629,11 @@ static int process_changed_xattr(struct send_ctx *sctx)int ret =0 ; ret =iterate_dir_item (sctx->send_root, sctx->left_path, - sctx->cmp_key, __process_changed_new_xattr, sctx); + __process_changed_new_xattr, sctx);if (ret <0 ) goto out; ret =iterate_dir_item (sctx->parent_root, sctx->right_path, - sctx->cmp_key, __process_changed_deleted_xattr, sctx); + __process_changed_deleted_xattr, sctx); out:return ret;
@@ -4685,8 +4683,7 @@ static int process_all_new_xattrs(struct send_ctx *sctx) goto out; } - ret =iterate_dir_item (root, path, &found_key, - __process_new_xattr, sctx); + ret =iterate_dir_item (root, path, __process_new_xattr, sctx);if (ret <0 ) goto out;
Signature · 1 line
2.7.4
PATCH 5/10 btrfs: Remove unused arguments from btrfs_changed_cb_t
In reply to Nikolay Borisovbtrfs_changed_cb_t represents the signature of the callback being passed to btrfs_compare_trees. Currently there is only one such callback, namely changed_cb in send.c. This function doesn't really uses the first 2 parameters, i.e. the roots. Since there are not other functions implementing the btrfs_changed_cb_t let's remove the unused parameters from the prototype and implementation
--- fs/btrfs/ctree.c | 15 +++++---------- fs/btrfs/ctree.h | 4 +--- fs/btrfs/send.c | 8 +++----- 3 files changed, 9 insertions(+), 18 deletions(-)
fs/btrfs/ctree.c +5 -10
@@ -5496,8 +5496,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root, goto out; }else if (left_end_reached) {if (right_level ==0 ) { - ret =changed_cb (left_root, right_root, - left_path, right_path, + ret =changed_cb (left_path, right_path, &right_key,BTRFS_COMPARE_TREE_DELETED , ctx);
@@ -5508,8 +5507,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root,continue ; }else if (right_end_reached) {if (left_level ==0 ) { - ret =changed_cb (left_root, right_root, - left_path, right_path, + ret =changed_cb (left_path, right_path, &left_key,BTRFS_COMPARE_TREE_NEW , ctx);
@@ -5523,8 +5521,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root,if (left_level ==0 && right_level ==0 ) { cmp =btrfs_comp_cpu_keys (&left_key, &right_key);if (cmp <0 ) { - ret =changed_cb (left_root, right_root, - left_path, right_path, + ret =changed_cb (left_path, right_path, &left_key,BTRFS_COMPARE_TREE_NEW , ctx);
@@ -5532,8 +5529,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root, goto out; advance_left =ADVANCE ; }else if (cmp >0 ) { - ret =changed_cb (left_root, right_root, - left_path, right_path, + ret =changed_cb (left_path, right_path, &right_key,BTRFS_COMPARE_TREE_DELETED , ctx);
@@ -5550,8 +5546,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root, result =BTRFS_COMPARE_TREE_CHANGED ; else result =BTRFS_COMPARE_TREE_SAME ; - ret =changed_cb (left_root, right_root, - left_path, right_path, + ret =changed_cb (left_path, right_path, &left_key, result, ctx);if (ret <0 ) goto out;
fs/btrfs/ctree.h +1 -3
@@ -2811,9 +2811,7 @@ enum btrfs_compare_tree_result {BTRFS_COMPARE_TREE_CHANGED , BTRFS_COMPARE_TREE_SAME, }; -typedef int (*btrfs_changed_cb_t)(struct btrfs_root *left_root, - struct btrfs_root *right_root, - struct btrfs_path *left_path, +typedef int (*btrfs_changed_cb_t)(struct btrfs_path *left_path, struct btrfs_path *right_path, struct btrfs_key *key, enum btrfs_compare_tree_result result,
fs/btrfs/send.c +3 -5
@@ -6169,9 +6169,7 @@ static int compare_refs(struct send_ctx *sctx, struct btrfs_path *path,* Updates compare related fields in sctx and simply forwards to the actual * changed_xxx functions. */ -static int changed_cb(struct btrfs_root *left_root, - struct btrfs_root *right_root, - struct btrfs_path *left_path, +static int changed_cb(struct btrfs_path *left_path, struct btrfs_path *right_path, struct btrfs_key *key, enum btrfs_compare_tree_result result,
@@ -6253,8 +6251,8 @@ static int full_send_tree(struct send_ctx *sctx) slot = path->slots[0 ];btrfs_item_key_to_cpu (eb, &found_key, slot); - ret =changed_cb (send_root,NULL , path,NULL , - &found_key,BTRFS_COMPARE_TREE_NEW , sctx); + ret =changed_cb (path,NULL , &found_key, +BTRFS_COMPARE_TREE_NEW , sctx);if (ret <0 ) goto out;
Signature · 1 line
2.7.4
PATCH 6/10 btrfs: Remove unused parameter from check_direct_IO
In reply to Nikolay BorisovIntroduced by 5a5f79b57069 ("Btrfs: allow unaligned DIO") and never used,
--- fs/btrfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/inode.c +1 -2
@@ -8764,7 +8764,6 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode, }static ssize_t check_direct_IO (struct btrfs_fs_info *fs_info, -struct kiocb *iocb,const struct iov_iter *iter,loff_t offset) {int seg;
@@ -8811,7 +8810,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)bool relock = false;ssize_t ret; -if (check_direct_IO (fs_info, iocb, iter, offset)) +if (check_direct_IO (fs_info, iter, offset))return 0 ;inode_dio_begin (inode);
Signature · 1 line
2.7.4
PATCH 7/10 btrfs: Remove unused parameter from extent_clear_unlock_delalloc
In reply to Nikolay BorisovThis variable was added as part of ba8b04c1d4ad ("btrfs: extend btrfs_set_extent_delalloc and its friends to support in-band dedupe and subpage size patchset") however those patchsets haven't materialized yet. Let's remove the argument and when the time comes (e.g. whiever patchset lands first) should introduce all of its pre-requisites in the same series.
---
Hello David,
I was a ambivalent whether I should send this one since it removes some preparatory work. However, the said patchsets haven't really moved anywhere for quite some time and will likely require substantial amount of rebasing effort, so let's remove *possibly* outdated leftovers. But then again, I have no strong opinion on this.
fs/btrfs/extent_io.c | 3 +-- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 24 ++++++++---------------- 3 files changed, 10 insertions(+), 19 deletions(-)
fs/btrfs/extent_io.c +1 -2
@@ -1739,8 +1739,7 @@ static int __process_pages_contig(struct address_space *mapping, }void extent_clear_unlock_delalloc (struct inode *inode,u64 start,u64 end, -u64 delalloc_end,struct page *locked_page, -unsigned clear_bits, +struct page *locked_page,unsigned clear_bits,unsigned long page_ops) { clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, clear_bits, 1, 0,
fs/btrfs/extent_io.h +1 -1
@@ -492,7 +492,7 @@ int map_private_extent_buffer(const struct extent_buffer *eb,void extent_range_clear_dirty_for_io (struct inode *inode,u64 start,u64 end);void extent_range_redirty_for_io (struct inode *inode,u64 start,u64 end);void extent_clear_unlock_delalloc (struct inode *inode,u64 start,u64 end, -u64 delalloc_end,struct page *locked_page, +struct page *locked_page,unsigned bits_to_clear,unsigned long page_ops);struct bio *btrfs_bio_alloc (struct block_device *bdev,u64 first_byte);
fs/btrfs/inode.c +8 -16
@@ -583,7 +583,7 @@ static noinline void compress_file_range(struct inode *inode,* we don't need to create any more async work items. * Unlock and free up our temp pages. */ - extent_clear_unlock_delalloc(inode, start, end, end, + extent_clear_unlock_delalloc(inode, start, end, NULL, clear_flags, PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
@@ -836,8 +836,6 @@ static noinline void submit_compressed_extents(struct inode *inode,extent_clear_unlock_delalloc (inode, async_extent->start, async_extent->start + async_extent->ram_size -1 , - async_extent->start + - async_extent->ram_size -1 ,NULL ,EXTENT_LOCKED |EXTENT_DELALLOC ,PAGE_UNLOCK |PAGE_CLEAR_DIRTY |PAGE_SET_WRITEBACK );
@@ -856,7 +854,7 @@ static noinline void submit_compressed_extents(struct inode *inode, tree->ops->writepage_end_io_hook (p, start, end,NULL ,0 ); p->mapping =NULL ; -extent_clear_unlock_delalloc (inode, start, end, end, +extent_clear_unlock_delalloc (inode, start, end,NULL ,0 ,PAGE_END_WRITEBACK |PAGE_SET_ERROR );
@@ -874,8 +872,6 @@ static noinline void submit_compressed_extents(struct inode *inode, extent_clear_unlock_delalloc(inode, async_extent->start, async_extent->start + async_extent->ram_size - 1, - async_extent->start + - async_extent->ram_size - 1, NULL, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DELALLOC_NEW | EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING,
@@ -970,8 +966,7 @@ static noinline int cow_file_range(struct inode *inode, ret =cow_file_range_inline (root, inode, start, end,0 ,BTRFS_COMPRESS_NONE ,NULL );if (ret ==0 ) { - extent_clear_unlock_delalloc(inode, start, end, - delalloc_end, NULL, + extent_clear_unlock_delalloc(inode, start, end, NULL, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DELALLOC_NEW | EXTENT_DEFRAG, PAGE_UNLOCK |
@@ -1057,7 +1052,7 @@ static noinline int cow_file_range(struct inode *inode,extent_clear_unlock_delalloc (inode, start, start + ram_size -1 , - delalloc_end, locked_page, + locked_page,EXTENT_LOCKED |EXTENT_DELALLOC , page_ops);if (disk_num_bytes < cur_alloc_size)
@@ -1103,7 +1098,6 @@ static noinline int cow_file_range(struct inode *inode,if (extent_reserved) {extent_clear_unlock_delalloc (inode, start, start + cur_alloc_size, - start + cur_alloc_size, locked_page, clear_bits, page_ops);
@@ -1111,8 +1105,7 @@ static noinline int cow_file_range(struct inode *inode,if (start >= end) goto out; } -extent_clear_unlock_delalloc (inode, start, end, delalloc_end, - locked_page, +extent_clear_unlock_delalloc (inode, start, end, locked_page, clear_bits |EXTENT_CLEAR_DATA_RESV , page_ops); goto out;
@@ -1285,8 +1278,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, path =btrfs_alloc_path ();if (!path) { - extent_clear_unlock_delalloc(inode, start, end, end, - locked_page, + extent_clear_unlock_delalloc(inode, start, end, locked_page, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, PAGE_UNLOCK |
@@ -1497,7 +1489,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, num_bytes); extent_clear_unlock_delalloc(inode, cur_offset, - cur_offset + num_bytes - 1, end, + cur_offset + num_bytes - 1, locked_page, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_CLEAR_DATA_RESV,
@@ -1533,7 +1525,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, error:if (ret && cur_offset < end) - extent_clear_unlock_delalloc(inode, cur_offset, end, end, + extent_clear_unlock_delalloc(inode, cur_offset, end, locked_page, EXTENT_LOCKED | EXTENT_DELALLOC | EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
Signature · 1 line
2.7.4
PATCH 8/10 btrfs: remove unused parameter in cow_file_range
In reply to Nikolay BorisovThe delalloc_end parameter was only passed to extent_clear_unlock_delalloc, but since its usage was removed form that function let's also remove it from the caller's parameter list.
--- fs/btrfs/inode.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
fs/btrfs/inode.c +9 -11
@@ -105,9 +105,9 @@ static int btrfs_truncate(struct inode *inode);static int btrfs_finish_ordered_io (struct btrfs_ordered_extent *ordered_extent); static noinline int cow_file_range(struct inode *inode,struct page *locked_page, -u64 start,u64 end,u64 delalloc_end, -int *page_started,unsigned long *nr_written, -int unlock,struct btrfs_dedupe_hash *hash); +u64 start,u64 end,int *page_started, +unsigned long *nr_written,int unlock, +struct btrfs_dedupe_hash *hash); static struct extent_map *create_io_em(struct inode *inode, u64 start, u64 len, u64 orig_start, u64 block_start, u64 block_len, u64 orig_block_len,
@@ -739,8 +739,6 @@ static noinline void submit_compressed_extents(struct inode *inode, async_extent->start, async_extent->start + async_extent->ram_size -1 , - async_extent->start + - async_extent->ram_size -1 , &page_started, &nr_written,0 , NULL);
@@ -930,9 +928,9 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start,*/ static noinline int cow_file_range(struct inode *inode,struct page *locked_page, -u64 start,u64 end,u64 delalloc_end, -int *page_started,unsigned long *nr_written, -int unlock,struct btrfs_dedupe_hash *hash) +u64 start,u64 end,int *page_started, +unsigned long *nr_written,int unlock, +struct btrfs_dedupe_hash *hash) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_root *root =BTRFS_I (inode)->root;
@@ -1431,7 +1429,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,if (cow_start != (u64)-1 ) { ret =cow_file_range (inode, locked_page, cow_start, found_key.offset -1 , - end, page_started, nr_written,1 , + page_started, nr_written,1 ,NULL );if (ret) {if (!nolock && nocow)
@@ -1517,7 +1515,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, }if (cow_start != (u64)-1 ) { - ret =cow_file_range (inode, locked_page, cow_start, end, end, + ret =cow_file_range (inode, locked_page, cow_start, end, page_started, nr_written,1 ,NULL );if (ret) goto error;
@@ -1574,7 +1572,7 @@ static int run_delalloc_range(void *private_data, struct page *locked_page, ret =run_delalloc_nocow (inode, locked_page, start, end, page_started,0 , nr_written); }else if (!inode_need_compress (inode, start, end)) { - ret =cow_file_range (inode, locked_page, start, end, end, + ret =cow_file_range (inode, locked_page, start, end, page_started, nr_written,1 ,NULL ); }else { set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
Signature · 1 line
2.7.4
PATCH 9/10 btrfs: Rework error handling of add_extent_mapping in __btrfs_alloc_chunk
In reply to Nikolay BorisovCurrently the code executes add_extent_mapping and if it is successful it links the new mapping, it then proceeds to unlock the extent mapping tree and check for failure and handle them. Instead, rework the code to only perform a single check if add_extent_mapping has failed and handle it, otherwise the code continues in a linear fashion. No functional changes
--- fs/btrfs/volumes.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/volumes.c +5 -5
@@ -4813,16 +4813,16 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, em_tree = &info->mapping_tree.map_tree;write_lock (&em_tree->lock); ret =add_extent_mapping (em_tree, em,0 ); -if (!ret) { -list_add_tail (&em->list, &trans->transaction->pending_chunks); -refcount_inc (&em->refs); - } -write_unlock (&em_tree->lock);if (ret) { +write_unlock (&em_tree->lock);free_extent_map (em); goto error; } +list_add_tail (&em->list, &trans->transaction->pending_chunks); +refcount_inc (&em->refs); +write_unlock (&em_tree->lock); + ret =btrfs_make_block_group (trans, info,0 , type, start, num_bytes);if (ret) goto error_del_extent;
Signature · 1 line
2.7.4
PATCH 10/10 btrfs: Remove redundant argument of __link_block_group
In reply to Nikolay Borisov__link_block_group is called from only 2 places and at each call site the space_info being passed is the same as the space info assigned to the passed cache struct. Let's remove the redundant argument and make the function reference the space_info from the passed block_group_cache. No functional changes
--- fs/btrfs/extent-tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/extent-tree.c +4 -4
@@ -9886,9 +9886,9 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)return 0 ; } -static void __link_block_group (struct btrfs_space_info *space_info, -struct btrfs_block_group_cache *cache) +static void __link_block_group (struct btrfs_block_group_cache *cache) { +struct btrfs_space_info *space_info = cache->space_info;int index =get_block_group_index (cache);bool first = false;
@@ -10096,7 +10096,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info) cache->space_info = space_info; -__link_block_group (space_info, cache); +__link_block_group (cache);set_avail_alloc_bits (info, cache->flags);if (btrfs_chunk_readonly (info, cache->key.objectid)) {
@@ -10255,7 +10255,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, cache->bytes_super, &cache->space_info);update_global_block_rsv (fs_info); -__link_block_group (cache->space_info, cache); +__link_block_group (cache);list_add_tail (&cache->bg_list, &trans->new_bgs);
Signature · 1 line
2.7.4
Re: [PATCH 06/10] btrfs: Remove unused parameter from check_direct_IO
In reply to Nikolay Borisov2017-08-21 12:43 GMT+03:00 Nikolay Borisov <[email protected]>:
Quoted 35 lines
Introduced by
5a5f79b57069("Btrfs: allow unaligned DIO") and never used,Signed-off-by Nikolay Borisov <[email protected]>--- fs/btrfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/inode.c +1
-3@@ -8764,7 +8764,6 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode, }static ssize_t check_direct_IO (struct btrfs_fs_info *fs_info, -struct kiocb *iocb,const struct iov_iter *iter,loff_t offset) {int seg;@@ -8811,7 +8810,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)bool relock = false;ssize_t ret; -if (check_direct_IO (fs_info, iocb, iter, offset)) +if (check_direct_IO (fs_info, iter, offset))return 0 ;inode_dio_begin (inode); --2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Have a nice day, Timofey.
Re: [PATCH 01/10] btrfs: Remove chunk_objectid parameter of btrfs_alloc_dev_extent
In reply to Nikolay Borisov2017-08-21 12:43 GMT+03:00 Nikolay Borisov <[email protected]>:
Quoted 49 lines
THe function is always called with
chunk_objectidset toBTRFS_FIRST_CHUNK_TREE_OBJECTID. Let's collapse the parameter in the function itself. No functional changesSigned-off-by Nikolay Borisov <[email protected]>--- fs/btrfs/volumes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/btrfs/volumes.c +4
-5@@ -1571,8 +1571,8 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,static int btrfs_alloc_dev_extent (struct btrfs_trans_handle *trans,struct btrfs_device *device, -u64 chunk_tree,u64 chunk_objectid, -u64 chunk_offset,u64 start,u64 num_bytes) +u64 chunk_tree,u64 chunk_offset,u64 start, +u64 num_bytes) {int ret;struct btrfs_path *path;@@ -1600,7 +1600,8 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans, extent =btrfs_item_ptr (leaf, path->slots[0 ], struct btrfs_dev_extent);btrfs_set_dev_extent_chunk_tree (leaf, extent, chunk_tree); -btrfs_set_dev_extent_chunk_objectid (leaf, extent, chunk_objectid); +btrfs_set_dev_extent_chunk_objectid (leaf, extent, +BTRFS_FIRST_CHUNK_TREE_OBJECTID );btrfs_set_dev_extent_chunk_offset (leaf, extent, chunk_offset);btrfs_set_dev_extent_length (leaf, extent, num_bytes);@@ -4904,7 +4905,6 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,break ; ret =btrfs_alloc_dev_extent (trans, device, chunk_root->root_key.objectid, -BTRFS_FIRST_CHUNK_TREE_OBJECTID , chunk_offset, dev_offset, stripe_size);if (ret) --2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Have a nice day, Timofey.
Re: [PATCH 03/10] btrfs: Remove unused variable
In reply to Nikolay Borisov2017-08-21 12:43 GMT+03:00 Nikolay Borisov <[email protected]>:
Quoted 45 lines
Src was initially part of
31ff1cd25d37("Btrfs: Copy into the log tree in
big batches"), however16e7549f045d("Btrfs: incompatible format change to remove hole extents") changed parameters passed tocopy_itemswhich made the src variable redundant.Signed-off-by Nikolay Borisov <[email protected]>--- fs/btrfs/tree-log.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fs/btrfs/tree-log.c +1
-4@@ -2740,7 +2740,7 @@ static inline void btrfs_remove_log_ctx(struct btrfs_root *root,mutex_unlock (&root->log_mutex); } -/* +/* * Invoked in log mutex context, or be sure there is no other task which * can access the list. */ @@ -4637,7 +4637,6 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,struct btrfs_key min_key;struct btrfs_key max_key;struct btrfs_root *log = root->log_root; -struct extent_buffer *src =NULL ;LIST_HEAD (logged_list);u64 last_extent =0 ;int err =0 ;@@ -4880,7 +4879,6 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, goto next_slot; } - src = path->nodes[0 ];if (ins_nr && ins_start_slot + ins_nr == path->slots[0 ]) { ins_nr++; goto next_slot; --2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Have a nice day, Timofey.
Quoted 7 lines · Nikolay Borisov
Hello,
Here is a series that I've been sitting on for a while. It removes unused parameter in various functions, no functional changes. Patch 09/10 reworks some error handling to eliminate an if branch in
__btrfs_alloc_chunk, but it's still a minor refactoring.
Quoted 14 lines
Nikolay Borisov (10):
btrfs: Removechunk_objectidparameter ofbtrfs_alloc_dev_extent
btrfs: remove superfluouschunk_treeargument from
btrfs_alloc_dev_extent
btrfs: Remove unused variable
btrfs: Remove unused parameters from various functions
btrfs: Remove unused arguments frombtrfs_changed_cb_t
btrfs: Remove unused parameter fromcheck_direct_IO
btrfs: Remove unused parameter fromextent_clear_unlock_delalloc
btrfs: remove unused parameter incow_file_range
btrfs: Rework error handling ofadd_extent_mappingin
__btrfs_alloc_chunk
btrfs: Remove redundant argument of__link_block_group
You can add
to the whole series. Thanks,
Josef
Re: [PATCH 06/10] btrfs: Remove unused parameter from check_direct_IO
In reply to Nikolay BorisovQuoted 1 line · Nikolay Borisov
Introduced by
5a5f79b57069("Btrfs: allow unaligned DIO") and never used,
The unaligned DIO -> buffered works as expected, so this parameter is indeend redundant.
Re: [PATCH 07/10] btrfs: Remove unused parameter from extent_clear_unlock_delalloc
In reply to Nikolay BorisovQuoted 10 lines · Nikolay Borisov
This variable was added as part of
ba8b04c1d4ad("btrfs: extendbtrfs_set_extent_delallocand its friends to support in-band dedupe and subpage size patchset") however those patchsets haven't materialized yet.
Let's remove the argument and
when the time comes (e.g. whiever patchset lands first) should introduce all of its pre-requisites in the same series.Signed-off-by Nikolay Borisov <[email protected]>---
Quoted 7 lines
Hello David,
I was a ambivalent whether I should send this one since it removes some preparatory work. However, the said patchsets haven't really moved anywhere for quite some time and will likely require substantial amount of rebasing effort, so let's remove *possibly* outdated leftovers. But then again, I have no strong opinion on this.
The parameter extension is there so we have chance to merge both patchsets for testing purposes, which has happened in the past before it was known that the subpage would need to depend on the other core changes.
I haven't looked at the recent in-band patches, but I assume it makes use of the parameter so I'm not going to remove it. Merging patchset that touches some core functions means lots of manual conflict resolutions that we've decided to keep the useless parameter just to make our lives easier.
So, delalloc_end shall be the most irritating unused parameter for now.
Re: [PATCH 09/10] btrfs: Rework error handling of add_extent_mapping in __btrfs_alloc_chunk
In reply to Nikolay BorisovQuoted 5 lines · Nikolay Borisov
Currently the code executes
add_extent_mappingand if it is successful it links the new mapping, it then proceeds to unlock the extent mapping tree and check for failure and handle them. Instead, rework the code to only perform a single check ifadd_extent_mappinghas failed and handle it, otherwise the code continues in a linear fashion. No functional changes
I like the new version.
Re: [PATCH 10/10] btrfs: Remove redundant argument of __link_block_group
In reply to Nikolay BorisovQuoted 7 lines · Nikolay Borisov
__link_block_groupis called from only 2 places and at each call site thespace_infobeing passed is the same as the space info assigned to the passed cache struct. Let's remove the redundant argument and make the function reference thespace_infofrom the passedblock_group_cache. No functional changesSigned-off-by Nikolay Borisov <[email protected]>
I took the cleanup a bit further and removed the double underscore from the function name.
Quoted 5 lines · Nikolay Borisov
Here is a series that I've been sitting on for a while. It removes unused parameter in various functions, no functional changes. Patch 09/10 reworks some error handling to eliminate an if branch in
__btrfs_alloc_chunk, but it's still a minor refactoring.
Quoted 13 lines
Nikolay Borisov (10):
btrfs: Removechunk_objectidparameter ofbtrfs_alloc_dev_extent
btrfs: remove superfluouschunk_treeargument from
btrfs_alloc_dev_extent
btrfs: Remove unused variable
btrfs: Remove unused parameters from various functions
btrfs: Remove unused arguments frombtrfs_changed_cb_t
btrfs: Remove unused parameter fromcheck_direct_IO
btrfs: Remove unused parameter fromextent_clear_unlock_delalloc
btrfs: remove unused parameter incow_file_range
btrfs: Rework error handling ofadd_extent_mappingin
__btrfs_alloc_chunk
btrfs: Remove redundant argument of__link_block_group
Some of the patches have been applied earlier and are now in the frozen branch for the pull request so I did not update them with the reviewed tags.
The remaining patches are now in the 4.15 devel queue, with the reviewed tags that have been sent.
Re: [PATCH 08/10] btrfs: remove unused parameter in cow_file_range
In reply to Nikolay BorisovQuoted 5 lines · Nikolay Borisov
The
delalloc_endparameter was only passed toextent_clear_unlock_delalloc, but since its usage was removed form that function let's also remove it from the caller's parameter list.Signed-off-by Nikolay Borisov <[email protected]>
ping, since most of the series has been merged but this one has been left out I assume it could have been missed.
Quoted 71 lines
--- fs/btrfs/inode.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)fs/btrfs/inode.c +9
-11@@ -105,9 +105,9 @@ static int btrfs_truncate(struct inode *inode);static int btrfs_finish_ordered_io (struct btrfs_ordered_extent *ordered_extent); static noinline int cow_file_range(struct inode *inode,struct page *locked_page, -u64 start,u64 end,u64 delalloc_end, -int *page_started,unsigned long *nr_written, -int unlock,struct btrfs_dedupe_hash *hash); +u64 start,u64 end,int *page_started, +unsigned long *nr_written,int unlock, +struct btrfs_dedupe_hash *hash); static struct extent_map *create_io_em(struct inode *inode, u64 start, u64 len, u64 orig_start, u64 block_start, u64 block_len, u64 orig_block_len,@@ -739,8 +739,6 @@ static noinline void submit_compressed_extents(struct inode *inode, async_extent->start, async_extent->start + async_extent->ram_size -1 , - async_extent->start + - async_extent->ram_size -1 , &page_started, &nr_written,0 , NULL);@@ -930,9 +928,9 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start,*/ static noinline int cow_file_range(struct inode *inode,struct page *locked_page, -u64 start,u64 end,u64 delalloc_end, -int *page_started,unsigned long *nr_written, -int unlock,struct btrfs_dedupe_hash *hash) +u64 start,u64 end,int *page_started, +unsigned long *nr_written,int unlock, +struct btrfs_dedupe_hash *hash) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_root *root =BTRFS_I (inode)->root;@@ -1431,7 +1429,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,if (cow_start != (u64)-1 ) { ret =cow_file_range (inode, locked_page, cow_start, found_key.offset -1 , - end, page_started, nr_written,1 , + page_started, nr_written,1 ,NULL );if (ret) {if (!nolock && nocow)@@ -1517,7 +1515,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, }if (cow_start != (u64)-1 ) { - ret =cow_file_range (inode, locked_page, cow_start, end, end, + ret =cow_file_range (inode, locked_page, cow_start, end, page_started, nr_written,1 ,NULL );if (ret) goto error;@@ -1574,7 +1572,7 @@ static int run_delalloc_range(void *private_data, struct page *locked_page, ret =run_delalloc_nocow (inode, locked_page, start, end, page_started,0 , nr_written); }else if (!inode_need_compress (inode, start, end)) { - ret =cow_file_range (inode, locked_page, start, end, end, + ret =cow_file_range (inode, locked_page, start, end, page_started, nr_written,1 ,NULL ); }else { set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
Re: [PATCH 08/10] btrfs: remove unused parameter in cow_file_range
Quoted 11 lines · Nikolay Borisov
Quoted 5 lines · Nikolay Borisov
The
delalloc_endparameter was only passed toextent_clear_unlock_delalloc, but since its usage was removed form that function let's also remove it from the caller's parameter list.Signed-off-by Nikolay Borisov <[email protected]>ping, since most of the series has been merged but this one has been left out I assume it could have been missed.
Commit 897a41b1167955bd543bb252fd3f06f5844f2177
btrfs: extend btrfs_set_extent_delalloc and its friends to support in-band dedupe and subpage size patchset
That line is added to support subpage sized sectorsize. (BTW, inband dedupe is not really using it IIRC)
It's my fault since at that time I believed subpage size patchset would be merged before inband dedupe, but the truth is neither is going to be merged soon.
I think it's better to revert that commit until we really have a schedule for sub page size patchset.
(BTW, according to the update internal of patchset "Allow I/O on blocks whose size is less than page size", it may be updated in recent month if it gets updated)
Thanks,
Qu
Quoted 77 lines
Quoted 64 lines
--- fs/btrfs/inode.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)fs/btrfs/inode.c +8
-10@@ -105,9 +105,9 @@ static int btrfs_truncate(struct inode *inode);static int btrfs_finish_ordered_io (struct btrfs_ordered_extent *ordered_extent); static noinline int cow_file_range(struct inode *inode,struct page *locked_page, -u64 start,u64 end,u64 delalloc_end, -int *page_started,unsigned long *nr_written, -int unlock,struct btrfs_dedupe_hash *hash); +u64 start,u64 end,int *page_started, +unsigned long *nr_written,int unlock, +struct btrfs_dedupe_hash *hash); static struct extent_map *create_io_em(struct inode *inode, u64 start, u64 len, u64 orig_start, u64 block_start, u64 block_len, u64 orig_block_len,@@ -739,8 +739,6 @@ static noinline void submit_compressed_extents(struct inode *inode, async_extent->start, async_extent->start + async_extent->ram_size -1 , - async_extent->start + - async_extent->ram_size -1 , &page_started, &nr_written,0 , NULL);@@ -930,9 +928,9 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start,*/ static noinline int cow_file_range(struct inode *inode,struct page *locked_page, -u64 start,u64 end,u64 delalloc_end, -int *page_started,unsigned long *nr_written, -int unlock,struct btrfs_dedupe_hash *hash) +u64 start,u64 end,int *page_started, +unsigned long *nr_written,int unlock, +struct btrfs_dedupe_hash *hash) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_root *root =BTRFS_I (inode)->root;@@ -1431,7 +1429,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,if (cow_start != (u64)-1 ) { ret =cow_file_range (inode, locked_page, cow_start, found_key.offset -1 , - end, page_started, nr_written,1 , + page_started, nr_written,1 ,NULL );if (ret) {if (!nolock && nocow)@@ -1517,7 +1515,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, }if (cow_start != (u64)-1 ) { - ret =cow_file_range (inode, locked_page, cow_start, end, end, + ret =cow_file_range (inode, locked_page, cow_start, end, page_started, nr_written,1 ,NULL );if (ret) goto error;fs/btrfs/inode.c static int run_delalloc_range(void *private_data, struct page *locked_page, · line 1578
Quoted 8 lines
fs/btrfs/inode.c +1
-1@@ -1574,7 +1572,7 @@ static int run_delalloc_range(void *private_data, struct page *locked_page, ret =run_delalloc_nocow (inode, locked_page, start, end, page_started,0 , nr_written); }else if (!inode_need_compress (inode, start, end)) { - ret =cow_file_range (inode, locked_page, start, end, end, + ret =cow_file_range (inode, locked_page, start, end, page_started, nr_written,1 ,NULL ); }else { set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 08/10] btrfs: remove unused parameter in cow_file_range
In reply to Nikolay BorisovQuoted 9 lines · Nikolay Borisov
Quoted 5 lines · Nikolay Borisov
The
delalloc_endparameter was only passed toextent_clear_unlock_delalloc, but since its usage was removed form that function let's also remove it from the caller's parameter list.Signed-off-by Nikolay Borisov <[email protected]>ping, since most of the series has been merged but this one has been left out I assume it could have been missed.
https://marc.info/?l=linux-btrfs&m=150481210920815
Dependent change, so not merged.