* [PATCH v2] btrfs: remove v0 extent handling
@ 2023-08-11 7:47 Qu Wenruo
2023-08-11 10:32 ` kernel test robot
0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2023-08-11 7:47 UTC (permalink / raw)
To: linux-btrfs
The v0 extent item has been deprecated for a long time, and we don't have
any report from the community either.
So it's time to remove the v0 extent specific error handling, and just
treat them as regular extent tree corruption.
This patch would remove the btrfs_print_v0_err() helper, and enhance the
involved error handling to treat them just as any extent tree
corruption.
This involves:
- btrfs_backref_add_tree_node()
This change is a little tricky, the new code is changed to only handle
BTRFS_TREE_BLOCK_REF_KEY and BTRFS_SHARED_BLOCK_REF_KEY.
But this is safe, as we have rejected any unknown inline refs through
btrfs_get_extent_inline_ref_type().
For keyed backrefs, we're safe to skip anything we don't know (that's
if it can pass tree-checker in the first place).
- btrfs_lookup_extent_info()
- lookup_inline_extent_backref()
- run_delayed_extent_op()
- __btrfs_free_extent()
- add_tree_block()
Regular error handling of unexpected extent tree item, and abort
transaction (if we have a trans handle).
- remove_extent_data_ref()
It's pretty much the same as the regular rejection of unknown backref
key.
But for this particular case, we can also remove a BUG_ON().
- extent_data_ref_count()
We can remove the BTRFS_EXTENT_REF_V0_key BUG_ON(), as it would be
rejected by the only caller.
- btrfs_print_leaf()
Remove the handling for BTRFS_EXTENT_REF_V0_key.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Changelog:
v2:
- Remove one unused @fs_info
---
fs/btrfs/backref.c | 29 ++++++++++++-----------------
fs/btrfs/extent-tree.c | 35 +++++++++++++++++++++--------------
fs/btrfs/messages.c | 6 ------
fs/btrfs/messages.h | 2 --
fs/btrfs/print-tree.c | 10 ++++------
fs/btrfs/relocation.c | 11 ++++++-----
6 files changed, 43 insertions(+), 50 deletions(-)
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 79336fa853db..b7d54efb4728 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -3373,7 +3373,6 @@ int btrfs_backref_add_tree_node(struct btrfs_backref_cache *cache,
struct btrfs_key *node_key,
struct btrfs_backref_node *cur)
{
- struct btrfs_fs_info *fs_info = cache->fs_info;
struct btrfs_backref_edge *edge;
struct btrfs_backref_node *exist;
int ret;
@@ -3462,25 +3461,21 @@ int btrfs_backref_add_tree_node(struct btrfs_backref_cache *cache,
ret = handle_direct_tree_backref(cache, &key, cur);
if (ret < 0)
goto out;
- continue;
- } else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
- ret = -EINVAL;
- btrfs_print_v0_err(fs_info);
- btrfs_handle_fs_error(fs_info, ret, NULL);
- goto out;
- } else if (key.type != BTRFS_TREE_BLOCK_REF_KEY) {
- continue;
+ } else if (key.type == BTRFS_TREE_BLOCK_REF_KEY) {
+ /*
+ * key.type == BTRFS_TREE_BLOCK_REF_KEY, inline ref
+ * offset means the root objectid. We need to search
+ * the tree to get its parent bytenr.
+ */
+ ret = handle_indirect_tree_backref(cache, path, &key, node_key,
+ cur);
+ if (ret < 0)
+ goto out;
}
-
/*
- * key.type == BTRFS_TREE_BLOCK_REF_KEY, inline ref offset
- * means the root objectid. We need to search the tree to get
- * its parent bytenr.
+ * Unrecognized tree backref items (if it can pass tree-checker)
+ * would be ignored.
*/
- ret = handle_indirect_tree_backref(cache, path, &key, node_key,
- cur);
- if (ret < 0)
- goto out;
}
ret = 0;
cur->checked = 1;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 112f6684a192..594c8a2e7296 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -166,8 +166,10 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
num_refs = btrfs_extent_refs(leaf, ei);
extent_flags = btrfs_extent_flags(leaf, ei);
} else {
- ret = -EINVAL;
- btrfs_print_v0_err(fs_info);
+ ret = -EUCLEAN;
+ btrfs_err(fs_info,
+ "unexpected extent item size, has %u expect >= %lu",
+ item_size, sizeof(*ei));
if (trans)
btrfs_abort_transaction(trans, ret);
else
@@ -603,12 +605,12 @@ static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans,
ref2 = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_shared_data_ref);
num_refs = btrfs_shared_data_ref_count(leaf, ref2);
- } else if (unlikely(key.type == BTRFS_EXTENT_REF_V0_KEY)) {
- btrfs_print_v0_err(trans->fs_info);
- btrfs_abort_transaction(trans, -EINVAL);
- return -EINVAL;
} else {
- BUG();
+ btrfs_err(trans->fs_info,
+ "unrecognized backref key (%llu %u %llu)",
+ key.objectid, key.type, key.offset);
+ btrfs_abort_transaction(trans, -EUCLEAN);
+ return -EUCLEAN;
}
BUG_ON(num_refs < refs_to_drop);
@@ -639,7 +641,6 @@ static noinline u32 extent_data_ref_count(struct btrfs_path *path,
leaf = path->nodes[0];
btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
- BUG_ON(key.type == BTRFS_EXTENT_REF_V0_KEY);
if (iref) {
/*
* If type is invalid, we should have bailed out earlier than
@@ -860,8 +861,10 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
leaf = path->nodes[0];
item_size = btrfs_item_size(leaf, path->slots[0]);
if (unlikely(item_size < sizeof(*ei))) {
- err = -EINVAL;
- btrfs_print_v0_err(fs_info);
+ err = -EUCLEAN;
+ btrfs_err(fs_info,
+ "unexpected extent item size, has %llu expect >= %lu",
+ item_size, sizeof(*ei));
btrfs_abort_transaction(trans, err);
goto out;
}
@@ -1662,8 +1665,10 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
item_size = btrfs_item_size(leaf, path->slots[0]);
if (unlikely(item_size < sizeof(*ei))) {
- err = -EINVAL;
- btrfs_print_v0_err(fs_info);
+ err = -EUCLEAN;
+ btrfs_err(fs_info,
+ "unexpected extent item size, has %u expect >= %lu",
+ item_size, sizeof(*ei));
btrfs_abort_transaction(trans, err);
goto out;
}
@@ -3091,8 +3096,10 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
leaf = path->nodes[0];
item_size = btrfs_item_size(leaf, extent_slot);
if (unlikely(item_size < sizeof(*ei))) {
- ret = -EINVAL;
- btrfs_print_v0_err(info);
+ ret = -EUCLEAN;
+ btrfs_err(trans->fs_info,
+ "unexpected extent item size, has %u expect >= %lu",
+ item_size, sizeof(*ei));
btrfs_abort_transaction(trans, ret);
goto out;
}
diff --git a/fs/btrfs/messages.c b/fs/btrfs/messages.c
index e3c9d2706341..7695decc7243 100644
--- a/fs/btrfs/messages.c
+++ b/fs/btrfs/messages.c
@@ -256,12 +256,6 @@ void __cold _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt,
}
#endif
-void __cold btrfs_print_v0_err(struct btrfs_fs_info *fs_info)
-{
- btrfs_err(fs_info,
-"Unsupported V0 extent filesystem detected. Aborting. Please re-create your filesystem with a newer kernel");
-}
-
#if BITS_PER_LONG == 32
void __cold btrfs_warn_32bit_limit(struct btrfs_fs_info *fs_info)
{
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index deedc1a168e2..1ae6f8e23e07 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -181,8 +181,6 @@ do { \
#define ASSERT(expr) (void)(expr)
#endif
-void __cold btrfs_print_v0_err(struct btrfs_fs_info *fs_info);
-
__printf(5, 6)
__cold
void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function,
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index aa06d9ca911d..a97615799ced 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -95,8 +95,10 @@ static void print_extent_item(const struct extent_buffer *eb, int slot, int type
int ref_index = 0;
if (unlikely(item_size < sizeof(*ei))) {
- btrfs_print_v0_err(eb->fs_info);
- btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL);
+ btrfs_err(eb->fs_info,
+ "unexpected extent item size, has %u expect >= %lu",
+ item_size, sizeof(*ei));
+ btrfs_handle_fs_error(eb->fs_info, -EUCLEAN, NULL);
}
ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item);
@@ -291,10 +293,6 @@ void btrfs_print_leaf(const struct extent_buffer *l)
btrfs_file_extent_num_bytes(l, fi),
btrfs_file_extent_ram_bytes(l, fi));
break;
- case BTRFS_EXTENT_REF_V0_KEY:
- btrfs_print_v0_err(fs_info);
- btrfs_handle_fs_error(fs_info, -EINVAL, NULL);
- break;
case BTRFS_BLOCK_GROUP_ITEM_KEY:
bi = btrfs_item_ptr(l, i,
struct btrfs_block_group_item);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 7408e48d45bc..9951a0caf5bb 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3256,12 +3256,13 @@ static int add_tree_block(struct reloc_control *rc,
if (type == BTRFS_TREE_BLOCK_REF_KEY)
owner = btrfs_extent_inline_ref_offset(eb, iref);
}
- } else if (unlikely(item_size == sizeof(struct btrfs_extent_item_v0))) {
- btrfs_print_v0_err(eb->fs_info);
- btrfs_handle_fs_error(eb->fs_info, -EINVAL, NULL);
- return -EINVAL;
} else {
- BUG();
+ btrfs_print_leaf(eb);
+ btrfs_err(rc->block_group->fs_info,
+ "unrecognized tree backref at tree block %llu slot %u",
+ eb->start, path->slots[0]);
+ btrfs_release_path(path);
+ return -EUCLEAN;
}
btrfs_release_path(path);
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] btrfs: remove v0 extent handling
2023-08-11 7:47 [PATCH v2] btrfs: remove v0 extent handling Qu Wenruo
@ 2023-08-11 10:32 ` kernel test robot
2023-08-11 10:42 ` Qu Wenruo
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2023-08-11 10:32 UTC (permalink / raw)
To: Qu Wenruo, linux-btrfs; +Cc: llvm, oe-kbuild-all
Hi Qu,
kernel test robot noticed the following build warnings:
[auto build test WARNING on kdave/for-next]
[also build test WARNING on linus/master v6.5-rc5 next-20230809]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Qu-Wenruo/btrfs-remove-v0-extent-handling/20230811-154905
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
patch link: https://lore.kernel.org/r/6258b0bf5e41e52ca0e163e34650d186363628c6.1691740017.git.wqu%40suse.com
patch subject: [PATCH v2] btrfs: remove v0 extent handling
config: powerpc-randconfig-r034-20230811 (https://download.01.org/0day-ci/archive/20230811/202308111815.mJwoiury-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230811/202308111815.mJwoiury-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308111815.mJwoiury-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/btrfs/print-tree.c:100:17: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
100 | "unexpected extent item size, has %u expect >= %lu",
| ~~~
| %u
101 | item_size, sizeof(*ei));
| ^~~~~~~~~~~
fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
| ~~~ ^~~~
fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
27 | _btrfs_printk(fs_info, fmt, ##args)
| ~~~ ^~~~
1 warning generated.
--
>> fs/btrfs/extent-tree.c:172:18: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
172 | "unexpected extent item size, has %u expect >= %lu",
| ~~~
| %u
173 | item_size, sizeof(*ei));
| ^~~~~~~~~~~
fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
| ~~~ ^~~~
fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
27 | _btrfs_printk(fs_info, fmt, ##args)
| ~~~ ^~~~
fs/btrfs/extent-tree.c:867:17: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
867 | "unexpected extent item size, has %llu expect >= %lu",
| ~~~
| %u
868 | item_size, sizeof(*ei));
| ^~~~~~~~~~~
fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
| ~~~ ^~~~
fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
27 | _btrfs_printk(fs_info, fmt, ##args)
| ~~~ ^~~~
fs/btrfs/extent-tree.c:1671:17: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
1671 | "unexpected extent item size, has %u expect >= %lu",
| ~~~
| %u
1672 | item_size, sizeof(*ei));
| ^~~~~~~~~~~
fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
| ~~~ ^~~~
fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
27 | _btrfs_printk(fs_info, fmt, ##args)
| ~~~ ^~~~
fs/btrfs/extent-tree.c:3102:17: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
3102 | "unexpected extent item size, has %u expect >= %lu",
| ~~~
| %u
3103 | item_size, sizeof(*ei));
| ^~~~~~~~~~~
fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
| ~~~ ^~~~
fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
27 | _btrfs_printk(fs_info, fmt, ##args)
| ~~~ ^~~~
4 warnings generated.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for HOTPLUG_CPU
Depends on [n]: SMP [=y] && (PPC_PSERIES [=n] || PPC_PMAC [=n] || PPC_POWERNV [=n] || FSL_SOC_BOOKE [=n])
Selected by [y]:
- PM_SLEEP_SMP [=y] && SMP [=y] && (ARCH_SUSPEND_POSSIBLE [=y] || ARCH_HIBERNATION_POSSIBLE [=y]) && PM_SLEEP [=y]
vim +100 fs/btrfs/print-tree.c
82
83 static void print_extent_item(const struct extent_buffer *eb, int slot, int type)
84 {
85 struct btrfs_extent_item *ei;
86 struct btrfs_extent_inline_ref *iref;
87 struct btrfs_extent_data_ref *dref;
88 struct btrfs_shared_data_ref *sref;
89 struct btrfs_disk_key key;
90 unsigned long end;
91 unsigned long ptr;
92 u32 item_size = btrfs_item_size(eb, slot);
93 u64 flags;
94 u64 offset;
95 int ref_index = 0;
96
97 if (unlikely(item_size < sizeof(*ei))) {
98 btrfs_err(eb->fs_info,
99 "unexpected extent item size, has %u expect >= %lu",
> 100 item_size, sizeof(*ei));
101 btrfs_handle_fs_error(eb->fs_info, -EUCLEAN, NULL);
102 }
103
104 ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item);
105 flags = btrfs_extent_flags(eb, ei);
106
107 pr_info("\t\textent refs %llu gen %llu flags %llu\n",
108 btrfs_extent_refs(eb, ei), btrfs_extent_generation(eb, ei),
109 flags);
110
111 if ((type == BTRFS_EXTENT_ITEM_KEY) &&
112 flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
113 struct btrfs_tree_block_info *info;
114 info = (struct btrfs_tree_block_info *)(ei + 1);
115 btrfs_tree_block_key(eb, info, &key);
116 pr_info("\t\ttree block key (%llu %u %llu) level %d\n",
117 btrfs_disk_key_objectid(&key), key.type,
118 btrfs_disk_key_offset(&key),
119 btrfs_tree_block_level(eb, info));
120 iref = (struct btrfs_extent_inline_ref *)(info + 1);
121 } else {
122 iref = (struct btrfs_extent_inline_ref *)(ei + 1);
123 }
124
125 ptr = (unsigned long)iref;
126 end = (unsigned long)ei + item_size;
127 while (ptr < end) {
128 iref = (struct btrfs_extent_inline_ref *)ptr;
129 type = btrfs_extent_inline_ref_type(eb, iref);
130 offset = btrfs_extent_inline_ref_offset(eb, iref);
131 pr_info("\t\tref#%d: ", ref_index++);
132 switch (type) {
133 case BTRFS_TREE_BLOCK_REF_KEY:
134 pr_cont("tree block backref root %llu\n", offset);
135 break;
136 case BTRFS_SHARED_BLOCK_REF_KEY:
137 pr_cont("shared block backref parent %llu\n", offset);
138 /*
139 * offset is supposed to be a tree block which
140 * must be aligned to nodesize.
141 */
142 if (!IS_ALIGNED(offset, eb->fs_info->sectorsize))
143 pr_info(
144 "\t\t\t(parent %llu not aligned to sectorsize %u)\n",
145 offset, eb->fs_info->sectorsize);
146 break;
147 case BTRFS_EXTENT_DATA_REF_KEY:
148 dref = (struct btrfs_extent_data_ref *)(&iref->offset);
149 print_extent_data_ref(eb, dref);
150 break;
151 case BTRFS_SHARED_DATA_REF_KEY:
152 sref = (struct btrfs_shared_data_ref *)(iref + 1);
153 pr_cont("shared data backref parent %llu count %u\n",
154 offset, btrfs_shared_data_ref_count(eb, sref));
155 /*
156 * Offset is supposed to be a tree block which must be
157 * aligned to sectorsize.
158 */
159 if (!IS_ALIGNED(offset, eb->fs_info->sectorsize))
160 pr_info(
161 "\t\t\t(parent %llu not aligned to sectorsize %u)\n",
162 offset, eb->fs_info->sectorsize);
163 break;
164 default:
165 pr_cont("(extent %llu has INVALID ref type %d)\n",
166 eb->start, type);
167 return;
168 }
169 ptr += btrfs_extent_inline_ref_size(type);
170 }
171 WARN_ON(ptr > end);
172 }
173
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] btrfs: remove v0 extent handling
2023-08-11 10:32 ` kernel test robot
@ 2023-08-11 10:42 ` Qu Wenruo
0 siblings, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2023-08-11 10:42 UTC (permalink / raw)
To: kernel test robot, Qu Wenruo, linux-btrfs; +Cc: llvm, oe-kbuild-all
On 2023/8/11 18:32, kernel test robot wrote:
> Hi Qu,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on kdave/for-next]
> [also build test WARNING on linus/master v6.5-rc5 next-20230809]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Qu-Wenruo/btrfs-remove-v0-extent-handling/20230811-154905
> base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
> patch link: https://lore.kernel.org/r/6258b0bf5e41e52ca0e163e34650d186363628c6.1691740017.git.wqu%40suse.com
> patch subject: [PATCH v2] btrfs: remove v0 extent handling
> config: powerpc-randconfig-r034-20230811 (https://download.01.org/0day-ci/archive/20230811/202308111815.mJwoiury-lkp@intel.com/config)
OK, ppc, that's why we need a different format for sizeof() return values.
> compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
> reproduce: (https://download.01.org/0day-ci/archive/20230811/202308111815.mJwoiury-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202308111815.mJwoiury-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
>>> fs/btrfs/print-tree.c:100:17: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
> 100 | "unexpected extent item size, has %u expect >= %lu",
> | ~~~
> | %u
The more proper format would be %zu.
Would be updated soon.
Thanks for the report as usual,
Qu
> 101 | item_size, sizeof(*ei));
> | ^~~~~~~~~~~
> fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
> 46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
> | ~~~ ^~~~
> fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
> 27 | _btrfs_printk(fs_info, fmt, ##args)
> | ~~~ ^~~~
> 1 warning generated.
> --
>>> fs/btrfs/extent-tree.c:172:18: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
> 172 | "unexpected extent item size, has %u expect >= %lu",
> | ~~~
> | %u
> 173 | item_size, sizeof(*ei));
> | ^~~~~~~~~~~
> fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
> 46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
> | ~~~ ^~~~
> fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
> 27 | _btrfs_printk(fs_info, fmt, ##args)
> | ~~~ ^~~~
> fs/btrfs/extent-tree.c:867:17: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
> 867 | "unexpected extent item size, has %llu expect >= %lu",
> | ~~~
> | %u
> 868 | item_size, sizeof(*ei));
> | ^~~~~~~~~~~
> fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
> 46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
> | ~~~ ^~~~
> fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
> 27 | _btrfs_printk(fs_info, fmt, ##args)
> | ~~~ ^~~~
> fs/btrfs/extent-tree.c:1671:17: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
> 1671 | "unexpected extent item size, has %u expect >= %lu",
> | ~~~
> | %u
> 1672 | item_size, sizeof(*ei));
> | ^~~~~~~~~~~
> fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
> 46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
> | ~~~ ^~~~
> fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
> 27 | _btrfs_printk(fs_info, fmt, ##args)
> | ~~~ ^~~~
> fs/btrfs/extent-tree.c:3102:17: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
> 3102 | "unexpected extent item size, has %u expect >= %lu",
> | ~~~
> | %u
> 3103 | item_size, sizeof(*ei));
> | ^~~~~~~~~~~
> fs/btrfs/messages.h:46:40: note: expanded from macro 'btrfs_err'
> 46 | btrfs_printk(fs_info, KERN_ERR fmt, ##args)
> | ~~~ ^~~~
> fs/btrfs/messages.h:27:32: note: expanded from macro 'btrfs_printk'
> 27 | _btrfs_printk(fs_info, fmt, ##args)
> | ~~~ ^~~~
> 4 warnings generated.
>
> Kconfig warnings: (for reference only)
> WARNING: unmet direct dependencies detected for HOTPLUG_CPU
> Depends on [n]: SMP [=y] && (PPC_PSERIES [=n] || PPC_PMAC [=n] || PPC_POWERNV [=n] || FSL_SOC_BOOKE [=n])
> Selected by [y]:
> - PM_SLEEP_SMP [=y] && SMP [=y] && (ARCH_SUSPEND_POSSIBLE [=y] || ARCH_HIBERNATION_POSSIBLE [=y]) && PM_SLEEP [=y]
>
>
> vim +100 fs/btrfs/print-tree.c
>
> 82
> 83 static void print_extent_item(const struct extent_buffer *eb, int slot, int type)
> 84 {
> 85 struct btrfs_extent_item *ei;
> 86 struct btrfs_extent_inline_ref *iref;
> 87 struct btrfs_extent_data_ref *dref;
> 88 struct btrfs_shared_data_ref *sref;
> 89 struct btrfs_disk_key key;
> 90 unsigned long end;
> 91 unsigned long ptr;
> 92 u32 item_size = btrfs_item_size(eb, slot);
> 93 u64 flags;
> 94 u64 offset;
> 95 int ref_index = 0;
> 96
> 97 if (unlikely(item_size < sizeof(*ei))) {
> 98 btrfs_err(eb->fs_info,
> 99 "unexpected extent item size, has %u expect >= %lu",
> > 100 item_size, sizeof(*ei));
> 101 btrfs_handle_fs_error(eb->fs_info, -EUCLEAN, NULL);
> 102 }
> 103
> 104 ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item);
> 105 flags = btrfs_extent_flags(eb, ei);
> 106
> 107 pr_info("\t\textent refs %llu gen %llu flags %llu\n",
> 108 btrfs_extent_refs(eb, ei), btrfs_extent_generation(eb, ei),
> 109 flags);
> 110
> 111 if ((type == BTRFS_EXTENT_ITEM_KEY) &&
> 112 flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
> 113 struct btrfs_tree_block_info *info;
> 114 info = (struct btrfs_tree_block_info *)(ei + 1);
> 115 btrfs_tree_block_key(eb, info, &key);
> 116 pr_info("\t\ttree block key (%llu %u %llu) level %d\n",
> 117 btrfs_disk_key_objectid(&key), key.type,
> 118 btrfs_disk_key_offset(&key),
> 119 btrfs_tree_block_level(eb, info));
> 120 iref = (struct btrfs_extent_inline_ref *)(info + 1);
> 121 } else {
> 122 iref = (struct btrfs_extent_inline_ref *)(ei + 1);
> 123 }
> 124
> 125 ptr = (unsigned long)iref;
> 126 end = (unsigned long)ei + item_size;
> 127 while (ptr < end) {
> 128 iref = (struct btrfs_extent_inline_ref *)ptr;
> 129 type = btrfs_extent_inline_ref_type(eb, iref);
> 130 offset = btrfs_extent_inline_ref_offset(eb, iref);
> 131 pr_info("\t\tref#%d: ", ref_index++);
> 132 switch (type) {
> 133 case BTRFS_TREE_BLOCK_REF_KEY:
> 134 pr_cont("tree block backref root %llu\n", offset);
> 135 break;
> 136 case BTRFS_SHARED_BLOCK_REF_KEY:
> 137 pr_cont("shared block backref parent %llu\n", offset);
> 138 /*
> 139 * offset is supposed to be a tree block which
> 140 * must be aligned to nodesize.
> 141 */
> 142 if (!IS_ALIGNED(offset, eb->fs_info->sectorsize))
> 143 pr_info(
> 144 "\t\t\t(parent %llu not aligned to sectorsize %u)\n",
> 145 offset, eb->fs_info->sectorsize);
> 146 break;
> 147 case BTRFS_EXTENT_DATA_REF_KEY:
> 148 dref = (struct btrfs_extent_data_ref *)(&iref->offset);
> 149 print_extent_data_ref(eb, dref);
> 150 break;
> 151 case BTRFS_SHARED_DATA_REF_KEY:
> 152 sref = (struct btrfs_shared_data_ref *)(iref + 1);
> 153 pr_cont("shared data backref parent %llu count %u\n",
> 154 offset, btrfs_shared_data_ref_count(eb, sref));
> 155 /*
> 156 * Offset is supposed to be a tree block which must be
> 157 * aligned to sectorsize.
> 158 */
> 159 if (!IS_ALIGNED(offset, eb->fs_info->sectorsize))
> 160 pr_info(
> 161 "\t\t\t(parent %llu not aligned to sectorsize %u)\n",
> 162 offset, eb->fs_info->sectorsize);
> 163 break;
> 164 default:
> 165 pr_cont("(extent %llu has INVALID ref type %d)\n",
> 166 eb->start, type);
> 167 return;
> 168 }
> 169 ptr += btrfs_extent_inline_ref_size(type);
> 170 }
> 171 WARN_ON(ptr > end);
> 172 }
> 173
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-11 10:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 7:47 [PATCH v2] btrfs: remove v0 extent handling Qu Wenruo
2023-08-11 10:32 ` kernel test robot
2023-08-11 10:42 ` Qu Wenruo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox