From da6c288dfc9c275ff52c7764d8e0ae69c02afa87 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 25 Jun 2021 19:38:31 -0400 Subject: [PATCH] Help compiller optimize out abd_verify() While abd_verify() does nothing when built without debug, compiler can't optimize it out by itself due to calls to external list_*() and abd_verify_scatter(). This commit makes it explicit. Reviewed-by: Brian Behlendorf Reviewed-by: Adam Moss Reviewed-by: George Melikov Signed-off-by: Alexander Motin Sponsored-By: iXsystems, Inc. Closes #12280 --- module/zfs/abd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/zfs/abd.c b/module/zfs/abd.c index 2d1be9752d..d5fafccd08 100644 --- a/module/zfs/abd.c +++ b/module/zfs/abd.c @@ -108,15 +108,14 @@ int zfs_abd_scatter_enabled = B_TRUE; void abd_verify(abd_t *abd) { +#ifdef ZFS_DEBUG ASSERT3U(abd->abd_size, >, 0); ASSERT3U(abd->abd_size, <=, SPA_MAXBLOCKSIZE); ASSERT3U(abd->abd_flags, ==, abd->abd_flags & (ABD_FLAG_LINEAR | ABD_FLAG_OWNER | ABD_FLAG_META | ABD_FLAG_MULTI_ZONE | ABD_FLAG_MULTI_CHUNK | ABD_FLAG_LINEAR_PAGE | ABD_FLAG_GANG | ABD_FLAG_GANG_FREE | ABD_FLAG_ZEROS | ABD_FLAG_ALLOCD)); -#ifdef ZFS_DEBUG IMPLY(abd->abd_parent != NULL, !(abd->abd_flags & ABD_FLAG_OWNER)); -#endif IMPLY(abd->abd_flags & ABD_FLAG_META, abd->abd_flags & ABD_FLAG_OWNER); if (abd_is_linear(abd)) { ASSERT3P(ABD_LINEAR_BUF(abd), !=, NULL); @@ -133,6 +132,7 @@ abd_verify(abd_t *abd) } else { abd_verify_scatter(abd); } +#endif } static void