Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zfs-2.1.3/module/zfs/arc.c:1208:17: error: unused variable ‘hdr’ #13194

Closed
dniasoff opened this issue Mar 11, 2022 · 11 comments · Fixed by #13195
Closed

zfs-2.1.3/module/zfs/arc.c:1208:17: error: unused variable ‘hdr’ #13194

dniasoff opened this issue Mar 11, 2022 · 11 comments · Fixed by #13195
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@dniasoff
Copy link

Compiling on Centos 8 Stream with latest elrep kernel-ml 5.16.13-1.el8.elrepo.x86_64 fails

Making all in module
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4)
  You are using:           gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10)
/root/zfs-2.1.3/module/zfs/arc.c: In function ‘hdr_l2only_dest’:
/root/zfs-2.1.3/module/zfs/arc.c:1208:17: error: unused variable ‘hdr’ [-Werror=unused-variable]
  arc_buf_hdr_t *hdr = vbuf;
                 ^~~
cc1: all warnings being treated as errors
make[5]: *** [scripts/Makefile.build:287: /root/zfs-2.1.3/module/zfs/arc.o] Error 1
make[4]: *** [scripts/Makefile.build:549: /root/zfs-2.1.3/module/zfs] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [Makefile:1846: /root/zfs-2.1.3/module] Error 2
make[2]: *** [Makefile:55: modules-Linux] Error 2
make[1]: *** [Makefile:920: all-recursive] Error 1

System information

Distribution Name | Centos-Stream
Distribution Version | 8
Kernel Version | 5.16.13-1.el8.elrepo.x86_64
Architecture | x886_64
OpenZFS Version | 2.1.3

@dniasoff dniasoff added the Type: Defect Incorrect behavior (e.g. crash, hang) label Mar 11, 2022
@Space2Man
Copy link

Hi!

I am running into the same issue on gentoo x86_64, x86_64-pc-linux-gnu-11.2.1.

@TheUbuntuGuy
Copy link

A quick fix to get things building:

--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -1206,7 +1206,7 @@ hdr_l2only_dest(void *vbuf, void *unused)
 {
 	(void) unused;
 	arc_buf_hdr_t *hdr = vbuf;
-
+	(void) hdr;
 	ASSERT(HDR_EMPTY(hdr));
 	arc_space_return(HDR_L2ONLY_SIZE, ARC_SPACE_L2HDRS);
 }

@dniasoff
Copy link
Author

works for me. Thanks @TheUbuntuGuy

nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Mar 11, 2022
This explodes as -Wunused-variable on GCC 8.5.0, despite it being used,
just not in an evaulated context

Closes openzfs#13194
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
@nabijaczleweli
Copy link
Contributor

Heh. I'd say that GCC is wrong to say this, since hdr is used, just in an unevaluated context. Fixed in #13195

@dniasoff
Copy link
Author

tried your patch @nabijaczleweli but

../../module/zfs/arc.c: In function 'buf_dest':
../../module/zfs/arc.c:1220:17: error: 'buf' undeclared (first use in this function); did you mean 'vbuf'?
  mutex_destroy(&buf->b_evict_lock);
                 ^~~
                 vbuf
../../module/zfs/arc.c:1220:17: note: each undeclared identifier is reported only once for each function it appears in
  CC       bqueue.lo
  CC       cityhash.lo
make[5]: *** [Makefile:1336: arc.lo] Error 1
make[5]: *** Waiting for unfinished jobs....

@TheUbuntuGuy
Copy link

The patch is for the v2.1.3 release, not master. The file offset is wrong and it's patching the wrong function.

@ghost
Copy link

ghost commented Mar 11, 2022

I've run into this on FreeBSD as well. I'm working on a PR against zfs-2.1-release.

@ghost
Copy link

ghost commented Mar 11, 2022

Please try this patch:

diff --git a/module/zfs/arc.c b/module/zfs/arc.c
index 9984c2d27..47b58b6c2 100644
--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -1205,7 +1205,7 @@ static void
 hdr_l2only_dest(void *vbuf, void *unused)
 {
        (void) unused;
-       arc_buf_hdr_t *hdr = vbuf;
+       arc_buf_hdr_t *hdr __maybe_unused = vbuf;
 
        ASSERT(HDR_EMPTY(hdr));
        arc_space_return(HDR_L2ONLY_SIZE, ARC_SPACE_L2HDRS);

@ghost
Copy link

ghost commented Mar 11, 2022

Ah right there was already a working patch posted here. I'm sure this will work then.

@ghost ghost mentioned this issue Mar 11, 2022
13 tasks
@nabijaczleweli
Copy link
Contributor

Oh, yeah #13195 is a different thing, I hadn't realised 2.1.x still has non-void-casted ASSERTs. In that case __maybe_unused is the only option.

behlendorf pushed a commit that referenced this issue Mar 17, 2022
This is a direct commit to zfs-2.1-release to fix release builds that
error out on an unused variable.  The issue is avoided on master by a
huge series of commits that change how the ASSERT macros work, but that
is not feasible to backport.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #13194 
Closes #13196
@bugalo
Copy link

bugalo commented Mar 22, 2022

A quick fix to get things building:

--- a/module/zfs/arc.c
+++ b/module/zfs/arc.c
@@ -1206,7 +1206,7 @@ hdr_l2only_dest(void *vbuf, void *unused)
 {
 	(void) unused;
 	arc_buf_hdr_t *hdr = vbuf;
-
+	(void) hdr;
 	ASSERT(HDR_EMPTY(hdr));
 	arc_space_return(HDR_L2ONLY_SIZE, ARC_SPACE_L2HDRS);
 }

Thanks! Your patch works in Gentoo, for zfs-2.1.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants