diff mbox series

[v3,02/15] btrfs: move assert helpers out of ctree.h

Message ID d89ffe6bc0dd3fa90d5567a9a790a00acbf3d1e9.1666190849.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs: split out larger chunks of ctree.h | expand

Commit Message

Josef Bacik Oct. 19, 2022, 2:50 p.m. UTC
These call functions that aren't defined in, or will be moved out of,
ctree.h  Move them to super.c where the other assert/error message code
is defined.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/ctree.h | 18 +++---------------
 fs/btrfs/super.c | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 15 deletions(-)

Comments

Johannes Thumshirn Oct. 20, 2022, 6:09 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
David Sterba Oct. 20, 2022, 3:49 p.m. UTC | #2
On Wed, Oct 19, 2022 at 10:50:48AM -0400, Josef Bacik wrote:
> These call functions that aren't defined in, or will be moved out of,
> ctree.h  Move them to super.c where the other assert/error message code
> is defined.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/btrfs/ctree.h | 18 +++---------------
>  fs/btrfs/super.c | 14 ++++++++++++++
>  2 files changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 52987ee61c72..c97a02a81517 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -3320,18 +3320,11 @@ do {								\
>  } while (0)
>  
>  #ifdef CONFIG_BTRFS_ASSERT
> -__cold __noreturn

I think __noreturn should be preserved as BUG() is called in the new
function too

> -static inline void assertfail(const char *expr, const char *file, int line)
> -{
> -	pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
> -	BUG();
> -}

> +void __cold btrfs_assertfail(const char *expr, const char *file, int line)
> +{
> +	pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
> +	BUG();
> +}
David Sterba Oct. 20, 2022, 3:52 p.m. UTC | #3
On Thu, Oct 20, 2022 at 05:49:57PM +0200, David Sterba wrote:
> On Wed, Oct 19, 2022 at 10:50:48AM -0400, Josef Bacik wrote:
> > These call functions that aren't defined in, or will be moved out of,
> > ctree.h  Move them to super.c where the other assert/error message code
> > is defined.
> > 
> > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> > ---
> >  fs/btrfs/ctree.h | 18 +++---------------
> >  fs/btrfs/super.c | 14 ++++++++++++++
> >  2 files changed, 17 insertions(+), 15 deletions(-)
> > 
> > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> > index 52987ee61c72..c97a02a81517 100644
> > --- a/fs/btrfs/ctree.h
> > +++ b/fs/btrfs/ctree.h
> > @@ -3320,18 +3320,11 @@ do {								\
> >  } while (0)
> >  
> >  #ifdef CONFIG_BTRFS_ASSERT
> > -__cold __noreturn
> 
> I think __noreturn should be preserved as BUG() is called in the new
> function too

But objtool for some reason does not like it, tons of warnings like

fs/btrfs/dir-item.o: warning: objtool: .text.unlikely: unexpected end of section
fs/btrfs/xattr.o: warning: objtool: btrfs_setxattr() falls through to next function btrfs_setxattr_trans.cold()
fs/btrfs/xattr.o: warning: objtool: .text.unlikely: unexpected end of section

so I'll drop the attribute.
diff mbox series

Patch

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 52987ee61c72..c97a02a81517 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3320,18 +3320,11 @@  do {								\
 } while (0)
 
 #ifdef CONFIG_BTRFS_ASSERT
-__cold __noreturn
-static inline void assertfail(const char *expr, const char *file, int line)
-{
-	pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
-	BUG();
-}
+void __cold btrfs_assertfail(const char *expr, const char *file, int line);
 
 #define ASSERT(expr)						\
-	(likely(expr) ? (void)0 : assertfail(#expr, __FILE__, __LINE__))
-
+	(likely(expr) ? (void)0 : btrfs_assertfail(#expr, __FILE__, __LINE__))
 #else
-static inline void assertfail(const char *expr, const char* file, int line) { }
 #define ASSERT(expr)	(void)(expr)
 #endif
 
@@ -3391,12 +3384,7 @@  static inline unsigned long get_eb_page_index(unsigned long offset)
 #define EXPORT_FOR_TESTS
 #endif
 
-__cold
-static inline void 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");
-}
+void __cold btrfs_print_v0_err(struct btrfs_fs_info *fs_info);
 
 __printf(5, 6)
 __cold
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index ebd59dc448dd..9aa14ac3a7ff 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -306,6 +306,20 @@  void __cold _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt,
 }
 #endif
 
+#ifdef CONFIG_BTRFS_ASSERT
+void __cold btrfs_assertfail(const char *expr, const char *file, int line)
+{
+	pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
+	BUG();
+}
+#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)
 {