Cleanups for 6.15
Subsystems (2)
David Sterba
maintainercover Cleanups for 6.15
David Sterba (7):
btrfs: add __cold attribute to extent_io_tree_panic()
btrfs: async-thread: switch local variables need_order bool
btrfs: zstd: move zstd_parameters to the workspace
btrfs: zstd: remove local variable for storing page offsets
btrfs: unify ordering of btrfs_key initializations
btrfs: simplify returns and labels in btrfs_init_fs_root()
btrfs: update include and forward declarations in headers
fs/btrfs/accessors.h | 1 + fs/btrfs/acl.h | 2 ++ fs/btrfs/async-thread.c | 11 +++++------ fs/btrfs/backref.c | 4 ++-- fs/btrfs/block-group.c | 6 +++--- fs/btrfs/ctree.h | 2 +- fs/btrfs/delayed-ref.h | 2 ++ fs/btrfs/dir-item.h | 1 + fs/btrfs/direct-io.h | 2 ++ fs/btrfs/discard.h | 1 + fs/btrfs/disk-io.c | 11 +++++------ fs/btrfs/export.c | 2 +- fs/btrfs/extent-io-tree.c | 8 ++++---- fs/btrfs/extent-tree.c | 8 ++++---- fs/btrfs/extent-tree.h | 1 - fs/btrfs/file-item.c | 13 +++++++------ fs/btrfs/file-item.h | 2 ++ fs/btrfs/file.h | 2 ++ fs/btrfs/free-space-cache.c | 8 ++++---- fs/btrfs/fs.c | 1 - fs/btrfs/inode-item.c | 6 +++--- fs/btrfs/inode.c | 8 ++++---- fs/btrfs/ioctl.c | 4 ++-- fs/btrfs/ioctl.h | 2 ++ fs/btrfs/locking.c | 1 - fs/btrfs/ordered-data.h | 1 + fs/btrfs/print-tree.h | 2 ++ fs/btrfs/props.h | 1 + fs/btrfs/qgroup.c | 2 +- fs/btrfs/qgroup.h | 3 +++ fs/btrfs/raid-stripe-tree.h | 1 + fs/btrfs/scrub.c | 4 ++-- fs/btrfs/send.c | 1 - fs/btrfs/space-info.c | 2 +- fs/btrfs/subpage.c | 1 - fs/btrfs/sysfs.h | 1 + fs/btrfs/transaction.c | 2 +- fs/btrfs/tree-log.c | 6 +++--- fs/btrfs/volumes.c | 16 ++++++++-------- fs/btrfs/volumes.h | 4 ++++ fs/btrfs/xattr.h | 2 ++ fs/btrfs/zstd.c | 14 ++++++-------- 42 files changed, 97 insertions(+), 75 deletions(-)
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 1/7 btrfs: add __cold attribute to extent_io_tree_panic()
This is a wrapper that leads to a panic, so add the annotation like the other similar functions have.
--- fs/btrfs/extent-io-tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/extent-io-tree.c +4 -4
@@ -346,10 +346,10 @@ static inline struct extent_state *tree_search(struct extent_io_tree *tree, u64return tree_search_for_insert (tree, offset,NULL ,NULL ); } -static void extent_io_tree_panic (const struct extent_io_tree *tree, -const struct extent_state *state, -const char *opname, -int err) +static void __cold extent_io_tree_panic (const struct extent_io_tree *tree, +const struct extent_state *state, +const char *opname, +int err) { btrfs_panic(extent_io_tree_to_fs_info(tree), err, "extent io tree error on %s state start %llu end %llu",
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 2/7 btrfs: async-thread: switch local variables need_order bool
In reply to David SterbaUse bool for 0/1 indicators in thresh_exec_hook() and btrfs_work_helper().
--- fs/btrfs/async-thread.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/btrfs/async-thread.c +5 -6
@@ -168,7 +168,7 @@ static inline void thresh_exec_hook(struct btrfs_workqueue *wq) {int new_current_active;long pending; -int need_change =0 ; +bool need_change = false;if (wq->thresh ==NO_THRESHOLD )return ;
@@ -196,15 +196,14 @@ static inline void thresh_exec_hook(struct btrfs_workqueue *wq) new_current_active--; new_current_active =clamp_val (new_current_active,1 , wq->limit_active);if (new_current_active != wq->current_active) { - need_change =1 ; + need_change = true; wq->current_active = new_current_active; } out:spin_unlock (&wq->thres_lock); -if (need_change) { +if (need_change)workqueue_set_max_active (wq->normal_wq, wq->current_active); - } } static void run_ordered_work(struct btrfs_workqueue *wq,
@@ -296,7 +295,7 @@ static void btrfs_work_helper(struct work_struct *normal_work) struct btrfs_work *work = container_of(normal_work, struct btrfs_work, normal_work);struct btrfs_workqueue *wq = work->wq; -int need_order =0 ; +bool need_order = false;/* * We should not touch things inside work in the following cases:
@@ -307,7 +306,7 @@ static void btrfs_work_helper(struct work_struct *normal_work)* So we save the needed things here. */ if (work->ordered_func) - need_order =1 ; + need_order = true;trace_btrfs_work_sched (work);thresh_exec_hook (wq);
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 3/7 btrfs: zstd: move zstd_parameters to the workspace
In reply to David SterbaReduce stack consumption of zstd_compress_folios() by 40 bytes (10*sizeof(int)) as we can store struct zstd_parameters in the workspace that is reused for each call.
typedef struct {
ZSTD_compressionParameters cParams;
ZSTD_frameParameters fParams;
} ZSTD_parameters;typedef struct {
unsigned windowLog;
unsigned chainLog;
unsigned hashLog;
unsigned searchLog;
unsigned minMatch;
unsigned targetLength;
ZSTD_strategy strategy;
} ZSTD_compressionParameters;typedef struct {
int contentSizeFlag;
int checksumFlag;
int noDictIDFlag;
} ZSTD_frameParameters;--- fs/btrfs/zstd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/zstd.c +3 -3
@@ -53,6 +53,7 @@ struct workspace {struct list_head lru_list;zstd_in_buffer in_buf;zstd_out_buffer out_buf; +zstd_parameters params; };/*
@@ -402,15 +403,14 @@ int zstd_compress_folios(struct list_head *ws, struct address_space *mapping,unsigned long max_out = nr_dest_folios *PAGE_SIZE ;unsigned int pg_off;unsigned int cur_len; -zstd_parameters params =zstd_get_btrfs_parameters (workspace->req_level, - len); + workspace->params =zstd_get_btrfs_parameters (workspace->req_level, len); *out_folios =0 ; *total_out =0 ; *total_in =0 ;/* Initialize the stream */ - stream =zstd_init_cstream (¶ms, len, workspace->mem, + stream =zstd_init_cstream (&workspace->params, len, workspace->mem, workspace->size);if (unlikely (!stream)) {struct btrfs_inode *inode =BTRFS_I (mapping->host);
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 4/7 btrfs: zstd: remove local variable for storing page offsets
In reply to David SterbaWhen using offset_in_page() it's clear what it means, we don't need to store it in the local variable just to use it right away. There's no change in the generated code, but keeps the declarations smaller.
--- fs/btrfs/zstd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
fs/btrfs/zstd.c +3 -5
@@ -401,7 +401,6 @@ int zstd_compress_folios(struct list_head *ws, struct address_space *mapping,const unsigned long nr_dest_folios = *out_folios;const u64 orig_end = start + len;unsigned long max_out = nr_dest_folios *PAGE_SIZE ; -unsigned int pg_off;unsigned int cur_len; workspace->params =zstd_get_btrfs_parameters (workspace->req_level, len);
@@ -427,9 +426,8 @@ int zstd_compress_folios(struct list_head *ws, struct address_space *mapping, ret =btrfs_compress_filemap_get_folio (mapping, start, &in_folio);if (ret <0 ) goto out; - pg_off =offset_in_page (start); cur_len =btrfs_calc_input_length (orig_end, start); - workspace->in_buf.src =kmap_local_folio (in_folio, pg_off); + workspace->in_buf.src =kmap_local_folio (in_folio,offset_in_page (start)); workspace->in_buf.pos =0 ; workspace->in_buf.size = cur_len;
@@ -513,9 +511,9 @@ int zstd_compress_folios(struct list_head *ws, struct address_space *mapping, ret =btrfs_compress_filemap_get_folio (mapping, start, &in_folio);if (ret <0 ) goto out; - pg_off =offset_in_page (start); cur_len =btrfs_calc_input_length (orig_end, start); - workspace->in_buf.src =kmap_local_folio (in_folio, pg_off); + workspace->in_buf.src =kmap_local_folio (in_folio, +offset_in_page (start)); workspace->in_buf.pos =0 ; workspace->in_buf.size = cur_len; }
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 5/7 btrfs: unify ordering of btrfs_key initializations
In reply to David SterbaThe btrfs_key is defined as objectid/type/offset and the keys are also printed like that. For better readability, update all key initializations to match this order.
--- fs/btrfs/backref.c | 4 ++-- fs/btrfs/block-group.c | 6 +++--- fs/btrfs/export.c | 2 +- fs/btrfs/extent-tree.c | 8 ++++---- fs/btrfs/file-item.c | 13 +++++++------ fs/btrfs/free-space-cache.c | 8 ++++---- fs/btrfs/inode-item.c | 6 +++--- fs/btrfs/inode.c | 8 ++++---- fs/btrfs/ioctl.c | 4 ++-- fs/btrfs/qgroup.c | 2 +- fs/btrfs/scrub.c | 4 ++-- fs/btrfs/transaction.c | 2 +- fs/btrfs/tree-log.c | 6 +++--- fs/btrfs/volumes.c | 16 ++++++++-------- 14 files changed, 45 insertions(+), 44 deletions(-)
fs/btrfs/backref.c +2 -2
@@ -1399,11 +1399,11 @@ static int find_parent_nodes(struct btrfs_backref_walk_ctx *ctx,ASSERT (ctx->roots ==NULL ); key.objectid = ctx->bytenr; - key.offset = (u64)-1 ;if (btrfs_fs_incompat (ctx->fs_info,SKINNY_METADATA )) key.type =BTRFS_METADATA_ITEM_KEY ;else key.type =BTRFS_EXTENT_ITEM_KEY ; + key.offset = (u64)-1 ; path =btrfs_alloc_path ();if (!path)
@@ -2206,11 +2206,11 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,struct btrfs_extent_item *ei;struct btrfs_key key; + key.objectid = logical;if (btrfs_fs_incompat (fs_info,SKINNY_METADATA )) key.type =BTRFS_METADATA_ITEM_KEY ;else key.type =BTRFS_EXTENT_ITEM_KEY ; - key.objectid = logical; key.offset = (u64)-1 ; ret =btrfs_search_slot (NULL , extent_root, &key, path,0 ,0 );
fs/btrfs/block-group.c +3 -3
@@ -738,8 +738,8 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl) path->reada =READA_FORWARD ; key.objectid = last; - key.offset =0 ; key.type =BTRFS_EXTENT_ITEM_KEY ; + key.offset =0 ; next: ret =btrfs_search_slot (NULL , extent_root, &key, path,0 ,0 );
@@ -785,8 +785,8 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)if (key.objectid < last) { key.objectid = last; - key.offset =0 ; key.type =BTRFS_EXTENT_ITEM_KEY ; + key.offset =0 ;btrfs_release_path (path); goto next; }
@@ -2509,8 +2509,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)return fill_dummy_bgs (info); key.objectid =0 ; - key.offset =0 ; key.type =BTRFS_BLOCK_GROUP_ITEM_KEY ; + key.offset =0 ; path =btrfs_alloc_path ();if (!path)return -ENOMEM ;
fs/btrfs/export.c +1 -1
@@ -249,8 +249,8 @@ static int btrfs_get_name(struct dentry *parent, char *name, root = fs_info->tree_root; }else { key.objectid = ino; - key.offset =btrfs_ino (BTRFS_I (dir)); key.type =BTRFS_INODE_REF_KEY ; + key.offset =btrfs_ino (BTRFS_I (dir)); } ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );
fs/btrfs/extent-tree.c +4 -4
@@ -79,8 +79,8 @@ int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len)return -ENOMEM ; key.objectid = start; - key.offset = len; key.type =BTRFS_EXTENT_ITEM_KEY ; + key.offset = len; ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );btrfs_free_path (path);return ret;
@@ -125,11 +125,11 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, search_again: key.objectid = bytenr; - key.offset = offset;if (metadata) key.type =BTRFS_METADATA_ITEM_KEY ;else key.type =BTRFS_EXTENT_ITEM_KEY ; + key.offset = offset; extent_root =btrfs_extent_root (fs_info, bytenr); ret =btrfs_search_slot (NULL , extent_root, &key, path,0 ,0 );
@@ -1679,8 +1679,8 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, metadata =0 ; key.objectid = head->bytenr; - key.offset = head->num_bytes; key.type =BTRFS_EXTENT_ITEM_KEY ; + key.offset = head->num_bytes; goto again; } }else {
@@ -2348,8 +2348,8 @@ static noinline int check_committed_ref(struct btrfs_inode *inode,int ret; key.objectid = bytenr; - key.offset = (u64)-1 ; key.type =BTRFS_EXTENT_ITEM_KEY ; + key.offset = (u64)-1 ; ret =btrfs_search_slot (NULL , extent_root, &key, path,0 ,0 );if (ret <0 )
fs/btrfs/file-item.c +7 -6
@@ -169,9 +169,10 @@ int btrfs_insert_hole_extent(struct btrfs_trans_handle *trans, path =btrfs_alloc_path ();if (!path)return -ENOMEM ; + file_key.objectid = objectid; - file_key.offset = pos; file_key.type =BTRFS_EXTENT_DATA_KEY ; + file_key.offset = pos; ret =btrfs_insert_empty_item (trans, root, path, &file_key,sizeof (*item));
@@ -212,8 +213,8 @@ btrfs_lookup_csum(struct btrfs_trans_handle *trans,int csums_in_item; file_key.objectid =BTRFS_EXTENT_CSUM_OBJECTID ; - file_key.offset = bytenr; file_key.type =BTRFS_EXTENT_CSUM_KEY ; + file_key.offset = bytenr; ret =btrfs_search_slot (trans, root, &file_key, path,0 , cow);if (ret <0 ) goto fail;
@@ -259,8 +260,8 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,int cow = mod !=0 ; file_key.objectid = objectid; - file_key.offset = offset; file_key.type =BTRFS_EXTENT_DATA_KEY ; + file_key.offset = offset;return btrfs_search_slot (trans, root, &file_key, path, ins_len, cow); }
@@ -484,8 +485,8 @@ int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end, path->nowait = nowait; key.objectid =BTRFS_EXTENT_CSUM_OBJECTID ; - key.offset = start; key.type =BTRFS_EXTENT_CSUM_KEY ; + key.offset = start; ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );if (ret <0 )
@@ -892,8 +893,8 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,while (1 ) { key.objectid =BTRFS_EXTENT_CSUM_OBJECTID ; - key.offset = end_byte -1 ; key.type =BTRFS_EXTENT_CSUM_KEY ; + key.offset = end_byte -1 ; ret =btrfs_search_slot (trans, root, &key, path,-1 ,1 );if (ret >0 ) {
@@ -1074,8 +1075,8 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, found_next =0 ; bytenr = sums->logical + total_bytes; file_key.objectid =BTRFS_EXTENT_CSUM_OBJECTID ; - file_key.offset = bytenr; file_key.type =BTRFS_EXTENT_CSUM_KEY ; + file_key.offset = bytenr; item =btrfs_lookup_csum (trans, root, path, bytenr,1 );if (!IS_ERR (item)) {
fs/btrfs/free-space-cache.c +4 -4
@@ -93,8 +93,8 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root,int ret; key.objectid =BTRFS_FREE_SPACE_OBJECTID ; - key.offset = offset; key.type =0 ; + key.offset = offset; ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );if (ret <0 )
@@ -201,8 +201,8 @@ static int __create_free_space_inode(struct btrfs_root *root,btrfs_release_path (path); key.objectid =BTRFS_FREE_SPACE_OBJECTID ; - key.offset = offset; key.type =0 ; + key.offset = offset; ret =btrfs_insert_empty_item (trans, root, path, &key,sizeof (struct btrfs_free_space_header ));if (ret <0 ) {
@@ -755,8 +755,8 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,return 0 ; key.objectid =BTRFS_FREE_SPACE_OBJECTID ; - key.offset = offset; key.type =0 ; + key.offset = offset; ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );if (ret <0 )
@@ -1158,8 +1158,8 @@ update_cache_item(struct btrfs_trans_handle *trans,int ret; key.objectid =BTRFS_FREE_SPACE_OBJECTID ; - key.offset = offset; key.type =0 ; + key.offset = offset; ret =btrfs_search_slot (trans, root, &key, path,0 ,1 );if (ret <0 ) {
fs/btrfs/inode-item.c +3 -3
@@ -191,8 +191,8 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,int del_len = name->len +sizeof (*ref); key.objectid = inode_objectid; - key.offset = ref_objectid; key.type =BTRFS_INODE_REF_KEY ; + key.offset = ref_objectid; path =btrfs_alloc_path ();if (!path)
@@ -317,8 +317,8 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,int ins_len = name->len +sizeof (*ref); key.objectid = inode_objectid; - key.offset = ref_objectid; key.type =BTRFS_INODE_REF_KEY ; + key.offset = ref_objectid; path =btrfs_alloc_path ();if (!path)
@@ -493,8 +493,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, path->reada =READA_BACK ; key.objectid = control->ino; - key.offset = (u64)-1 ; key.type = (u8)-1 ; + key.offset = (u64)-1 ; search_again:/*
fs/btrfs/inode.c +4 -4
@@ -489,8 +489,8 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,size_t datasize; key.objectid =btrfs_ino (inode); - key.offset =0 ; key.type =BTRFS_EXTENT_DATA_KEY ; + key.offset =0 ; datasize =btrfs_file_extent_calc_inline_size (cur_size); ret = btrfs_insert_empty_item(trans, root, path, &key,
@@ -2966,8 +2966,8 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,if (!drop_args.extent_inserted) { ins.objectid =btrfs_ino (inode); - ins.offset = file_pos; ins.type =BTRFS_EXTENT_DATA_KEY ; + ins.offset = file_pos; ret =btrfs_insert_empty_item (trans, root, path, &ins,sizeof (*stack_fi));
@@ -3002,8 +3002,8 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,btrfs_update_inode_bytes (inode, num_bytes, drop_args.bytes_found); ins.objectid = disk_bytenr; - ins.offset = disk_num_bytes; ins.type =BTRFS_EXTENT_ITEM_KEY ; + ins.offset = disk_num_bytes; ret =btrfs_inode_set_file_extent_range (inode, file_pos, ram_bytes);if (ret)
@@ -8715,8 +8715,8 @@ static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir, goto out; } key.objectid =btrfs_ino (BTRFS_I (inode)); - key.offset =0 ; key.type =BTRFS_EXTENT_DATA_KEY ; + key.offset =0 ; datasize =btrfs_file_extent_calc_inline_size (name_len); err =btrfs_insert_empty_item (trans, root, path, &key, datasize);
fs/btrfs/ioctl.c +2 -2
@@ -618,8 +618,8 @@ static noinline int create_subvol(struct mnt_idmap *idmap,btrfs_set_root_dirid (root_item,BTRFS_FIRST_FREE_OBJECTID ); key.objectid = objectid; - key.offset =0 ; key.type =BTRFS_ROOT_ITEM_KEY ; + key.offset =0 ; ret =btrfs_insert_root (trans, fs_info->tree_root, &key, root_item);if (ret) {
@@ -1531,8 +1531,8 @@ static noinline int copy_to_sk(struct btrfs_path *path, } sh.objectid = key->objectid; - sh.offset = key->offset; sh.type = key->type; + sh.offset = key->offset; sh.len = item_len; sh.transid = found_transid;
fs/btrfs/qgroup.c +1 -1
@@ -956,8 +956,8 @@ static int btrfs_clean_quota_tree(struct btrfs_trans_handle *trans,return -ENOMEM ; key.objectid =0 ; - key.offset =0 ; key.type =0 ; + key.offset =0 ;while (1 ) { ret =btrfs_search_slot (trans, root, &key, path,-1 ,1 );
fs/btrfs/scrub.c +2 -2
@@ -1380,11 +1380,11 @@ static int find_first_extent_item(struct btrfs_root *extent_root,if (path->nodes[0 ]) goto search_forward; + key.objectid = search_start;if (btrfs_fs_incompat (fs_info,SKINNY_METADATA )) key.type =BTRFS_METADATA_ITEM_KEY ;else key.type =BTRFS_EXTENT_ITEM_KEY ; - key.objectid = search_start; key.offset = (u64)-1 ; ret =btrfs_search_slot (NULL , extent_root, &key, path,0 ,0 );
@@ -2497,8 +2497,8 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, path->skip_locking =1 ; key.objectid = scrub_dev->devid; - key.offset =0ull ; key.type =BTRFS_DEV_EXTENT_KEY ; + key.offset =0ull ;while (1 ) {u64 dev_extent_len;
fs/btrfs/transaction.c +1 -1
@@ -1690,8 +1690,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, } key.objectid = objectid; - key.offset = (u64)-1 ; key.type =BTRFS_ROOT_ITEM_KEY ; + key.offset = (u64)-1 ; rsv = trans->block_rsv; trans->block_rsv = &pending->block_rsv;
fs/btrfs/tree-log.c +3 -3
@@ -747,8 +747,8 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, (unsigned long)item, sizeof(*item)); ins.objectid =btrfs_file_extent_disk_bytenr (eb, item); - ins.offset =btrfs_file_extent_disk_num_bytes (eb, item); ins.type =BTRFS_EXTENT_ITEM_KEY ; + ins.offset =btrfs_file_extent_disk_num_bytes (eb, item); offset = key->offset -btrfs_file_extent_offset (eb, item);/*
@@ -3560,8 +3560,8 @@ static noinline int insert_dir_log_key(struct btrfs_trans_handle *trans,struct btrfs_dir_log_item *item; key.objectid = dirid; - key.offset = first_offset; key.type =BTRFS_DIR_LOG_INDEX_KEY ; + key.offset = first_offset; ret =btrfs_insert_empty_item (trans, log, path, &key,sizeof (*item));/* * -EEXIST is fine and can happen sporadically when we are logging a
@@ -7247,8 +7247,8 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) again: key.objectid =BTRFS_TREE_LOG_OBJECTID ; - key.offset = (u64)-1 ; key.type =BTRFS_ROOT_ITEM_KEY ; + key.offset = (u64)-1 ;while (1 ) { ret =btrfs_search_slot (NULL , log_root_tree, &key, path,0 ,0 );
fs/btrfs/volumes.c +8 -8
@@ -1798,8 +1798,8 @@ static int find_free_dev_extent(struct btrfs_device *device, u64 num_bytes, path->skip_locking =1 ; key.objectid = device->devid; - key.offset = search_start; key.type =BTRFS_DEV_EXTENT_KEY ; + key.offset = search_start; ret =btrfs_search_backwards (root, &key, path);if (ret <0 )
@@ -1918,8 +1918,8 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,return -ENOMEM ; key.objectid = device->devid; - key.offset = start; key.type =BTRFS_DEV_EXTENT_KEY ; + key.offset = start; again: ret =btrfs_search_slot (trans, root, &key, path,-1 ,1 );if (ret >0 ) {
@@ -2721,8 +2721,8 @@ static int btrfs_finish_sprout(struct btrfs_trans_handle *trans)return -ENOMEM ; key.objectid =BTRFS_DEV_ITEMS_OBJECTID ; - key.offset =0 ; key.type =BTRFS_DEV_ITEM_KEY ; + key.offset =0 ;while (1 ) {btrfs_reserve_chunk_metadata (trans, false);
@@ -3119,8 +3119,8 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)return -ENOMEM ; key.objectid =BTRFS_FIRST_CHUNK_TREE_OBJECTID ; - key.offset = chunk_offset; key.type =BTRFS_CHUNK_ITEM_KEY ; + key.offset = chunk_offset; ret =btrfs_search_slot (trans, root, &key, path,-1 ,1 );if (ret <0 )
@@ -3577,8 +3577,8 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info) again: key.objectid =BTRFS_FIRST_CHUNK_TREE_OBJECTID ; - key.offset = (u64)-1 ; key.type =BTRFS_CHUNK_ITEM_KEY ; + key.offset = (u64)-1 ;while (1 ) {mutex_lock (&fs_info->reclaim_bgs_lock);
@@ -4184,8 +4184,8 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info) bctl->sys.limit = limit_sys; } key.objectid =BTRFS_FIRST_CHUNK_TREE_OBJECTID ; - key.offset = (u64)-1 ; key.type =BTRFS_CHUNK_ITEM_KEY ; + key.offset = (u64)-1 ;while (1 ) { if ((!counting && atomic_read(&fs_info->balance_pause_req)) ||
@@ -5001,8 +5001,8 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) again: key.objectid = device->devid; - key.offset = (u64)-1 ; key.type =BTRFS_DEV_EXTENT_KEY ; + key.offset = (u64)-1 ; do { mutex_lock(&fs_info->reclaim_bgs_lock);
@@ -7534,8 +7534,8 @@ int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info)* item - BTRFS_FIRST_CHUNK_TREE_OBJECTID). */ key.objectid =BTRFS_DEV_ITEMS_OBJECTID ; - key.offset =0 ; key.type =0 ; + key.offset =0 ;btrfs_for_each_slot (root, &key, &found_key, path, iter_ret) {struct extent_buffer *node = path->nodes[1 ];
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 6/7 btrfs: simplify returns and labels in btrfs_init_fs_root()
In reply to David SterbaThere's a label that does nothing else than return, so remove it and also change other gotos to immediate returns as the function is short enough for this pattern.
--- fs/btrfs/disk-io.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/btrfs/disk-io.c +5 -6
@@ -1101,9 +1101,11 @@ struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root, }/* -* Initialize subvolume root in-memory structure +* Initialize subvolume root in-memory structure. * * @anon_dev: anonymous device to attach to the root, if zero, allocate new +* +* In case of failure the caller is responsible to call btrfs_free_fs_root() */ static int btrfs_init_fs_root (struct btrfs_root *root,dev_t anon_dev) {
@@ -1127,7 +1129,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev)if (!anon_dev) { ret =get_anon_bdev (&root->anon_dev);if (ret) - goto fail; +return ret; }else { root->anon_dev = anon_dev; }
@@ -1137,7 +1139,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev) ret =btrfs_init_root_free_objectid (root);if (ret) {mutex_unlock (&root->objectid_mutex); - goto fail; +return ret; }ASSERT (root->free_objectid <=BTRFS_LAST_FREE_OBJECTID );
@@ -1145,9 +1147,6 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev)mutex_unlock (&root->objectid_mutex);return 0 ; -fail: -/* The caller is responsible to call btrfs_free_fs_root */ -return ret; } static struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info,
Signature · 1 line
2.47.1
David Sterba
maintainerPATCH 7/7 btrfs: update include and forward declarations in headers
In reply to David SterbaPass over all header files and add missing forward declarations, includes or fix include types.
--- fs/btrfs/accessors.h | 1 + fs/btrfs/acl.h | 2 ++ fs/btrfs/ctree.h | 2 +- fs/btrfs/delayed-ref.h | 2 ++ fs/btrfs/dir-item.h | 1 + fs/btrfs/direct-io.h | 2 ++ fs/btrfs/discard.h | 1 + fs/btrfs/extent-tree.h | 1 - fs/btrfs/file-item.h | 2 ++ fs/btrfs/file.h | 2 ++ fs/btrfs/fs.c | 1 - fs/btrfs/ioctl.h | 2 ++ fs/btrfs/locking.c | 1 - fs/btrfs/ordered-data.h | 1 + fs/btrfs/print-tree.h | 2 ++ fs/btrfs/props.h | 1 + fs/btrfs/qgroup.h | 3 +++ fs/btrfs/raid-stripe-tree.h | 1 + fs/btrfs/send.c | 1 - fs/btrfs/space-info.c | 2 +- fs/btrfs/subpage.c | 1 - fs/btrfs/sysfs.h | 1 + fs/btrfs/volumes.h | 4 ++++ fs/btrfs/xattr.h | 2 ++ 24 files changed, 32 insertions(+), 7 deletions(-)
fs/btrfs/accessors.h +1 -0
@@ -12,6 +12,7 @@#include <linux/string.h> #include <linux/mm.h> #include <uapi/linux/btrfs_tree.h> +#include "extent_io.h" struct extent_buffer ;
fs/btrfs/acl.h +2 -0
@@ -3,6 +3,8 @@#ifndef BTRFS_ACL_H #define BTRFS_ACL_H +#include <linux/types.h> +struct posix_acl ;struct inode ;struct btrfs_trans_handle ;
fs/btrfs/ctree.h +1 -1
@@ -6,7 +6,7 @@#ifndef BTRFS_CTREE_H #define BTRFS_CTREE_H -#include "linux/cleanup.h" +#include <linux/cleanup.h> #include <linux/spinlock.h> #include <linux/rbtree.h> #include <linux/mutex.h>
fs/btrfs/delayed-ref.h +2 -0
@@ -14,6 +14,8 @@#include <linux/spinlock.h> #include <linux/slab.h> #include <uapi/linux/btrfs_tree.h> +#include "fs.h" +#include "messages.h" struct btrfs_trans_handle ;struct btrfs_fs_info ;
fs/btrfs/dir-item.h +1 -0
@@ -10,6 +10,7 @@ struct fscrypt_str;struct btrfs_fs_info ;struct btrfs_key ;struct btrfs_path ; +struct btrfs_inode ;struct btrfs_root ;struct btrfs_trans_handle ;
fs/btrfs/direct-io.h +2 -0
@@ -5,6 +5,8 @@#include <linux/types.h> +struct kiocb ; +int __init btrfs_init_dio (void );void __cold btrfs_destroy_dio (void );
fs/btrfs/discard.h +1 -0
@@ -3,6 +3,7 @@#ifndef BTRFS_DISCARD_H #define BTRFS_DISCARD_H +#include <linux/types.h> #include <linux/sizes.h> struct btrfs_fs_info ;
fs/btrfs/extent-tree.h +0 -1
@@ -4,7 +4,6 @@#define BTRFS_EXTENT_TREE_H #include <linux/types.h> -#include "misc.h" #include "block-group.h" #include "locking.h"
fs/btrfs/file-item.h +2 -0
@@ -3,8 +3,10 @@#ifndef BTRFS_FILE_ITEM_H #define BTRFS_FILE_ITEM_H +#include <linux/blk_types.h> #include <linux/list.h> #include <uapi/linux/btrfs_tree.h> +#include "ctree.h" #include "accessors.h" struct extent_map ;
fs/btrfs/file.h +2 -0
@@ -9,6 +9,8 @@ struct file;struct extent_state ;struct kiocb ;struct iov_iter ; +struct inode ; +struct folio ;struct page ;struct btrfs_ioctl_encoded_io_args ;struct btrfs_drop_extents_args ;
fs/btrfs/fs.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include "messages.h" -#include "ctree.h" #include "fs.h" #include "accessors.h" #include "volumes.h"
fs/btrfs/ioctl.h +2 -0
@@ -9,6 +9,8 @@ struct file;struct dentry ;struct mnt_idmap ;struct fileattr ; +struct inode ; +struct io_uring_cmd ;struct btrfs_fs_info ;struct btrfs_ioctl_balance_args ;
fs/btrfs/locking.c +0 -1
@@ -9,7 +9,6 @@#include <linux/page-flags.h> #include <asm/bug.h> #include <trace/events/btrfs.h> -#include "misc.h" #include "ctree.h" #include "extent_io.h" #include "locking.h"
fs/btrfs/ordered-data.h +1 -0
@@ -17,6 +17,7 @@struct inode ;struct page ;struct extent_state ; +struct btrfs_block_group ;struct btrfs_inode ;struct btrfs_root ;struct btrfs_fs_info ;
fs/btrfs/print-tree.h +2 -0
@@ -6,6 +6,8 @@#ifndef BTRFS_PRINT_TREE_H #define BTRFS_PRINT_TREE_H +#include <linux/types.h> +/* Buffer size to contain tree name and possibly additional data (offset) */ #define BTRFS_ROOT_NAME_BUF_LEN 48
fs/btrfs/props.h +1 -0
@@ -6,6 +6,7 @@#ifndef BTRFS_PROPS_H #define BTRFS_PROPS_H +#include <linux/types.h> #include <linux/compiler_types.h> struct inode ;
fs/btrfs/qgroup.h +3 -0
@@ -22,6 +22,9 @@ struct btrfs_ioctl_quota_ctl_args;struct btrfs_trans_handle ;struct btrfs_delayed_ref_root ;struct btrfs_inode ; +struct btrfs_transaction ; +struct btrfs_block_group ; +struct btrfs_qgroup_swapped_blocks ;/* * Btrfs qgroup overview
fs/btrfs/raid-stripe-tree.h +1 -0
@@ -9,6 +9,7 @@#include <linux/types.h> #include <uapi/linux/btrfs_tree.h> #include "fs.h" +#include "accessors.h" #define BTRFS_RST_SUPP_BLOCK_GROUP_MASK (BTRFS_BLOCK_GROUP_DUP | \ BTRFS_BLOCK_GROUP_RAID1_MASK | \
fs/btrfs/send.c +0 -1
@@ -16,7 +16,6 @@#include <linux/compat.h> #include <linux/crc32c.h> #include <linux/fsverity.h> -#include "send.h" #include "ctree.h" #include "backref.h"
fs/btrfs/space-info.c +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 -#include "linux/spinlock.h" +#include <linux/spinlock.h> #include <linux/minmax.h> #include "misc.h" #include "ctree.h"
fs/btrfs/subpage.c +0 -1
@@ -2,7 +2,6 @@#include <linux/slab.h> #include "messages.h" -#include "ctree.h" #include "subpage.h" #include "btrfs_inode.h"
fs/btrfs/sysfs.h +1 -0
@@ -7,6 +7,7 @@#include <linux/compiler_types.h> #include <linux/kobject.h> +struct block_device ;struct btrfs_fs_info ;struct btrfs_device ;struct btrfs_fs_devices ;
fs/btrfs/volumes.h +4 -0
@@ -7,6 +7,7 @@#define BTRFS_VOLUMES_H #include <linux/blk_types.h> +#include <linux/blkdev.h> #include <linux/sizes.h> #include <linux/atomic.h> #include <linux/sort.h>
@@ -18,14 +19,17 @@#include <linux/completion.h> #include <linux/rbtree.h> #include <uapi/linux/btrfs.h> +#include <uapi/linux/btrfs_tree.h> #include "messages.h" #include "rcu-string.h" +#include "extent-io-tree.h" struct block_device ;struct bdev_handle ;struct btrfs_fs_info ;struct btrfs_block_group ;struct btrfs_trans_handle ; +struct btrfs_transaction ;struct btrfs_zoned_device_info ;#define BTRFS_MAX_DATA_CHUNK_SIZE (10ULL * SZ_1G)
fs/btrfs/xattr.h +2 -0
@@ -6,6 +6,8 @@#ifndef BTRFS_XATTR_H #define BTRFS_XATTR_H +#include <linux/types.h> +struct dentry ;struct inode ;struct qstr ;
Signature · 1 line
2.47.1