Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Dec 2024 17:46:40 +0800
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        Rick Macklem <rick.macklem@gmail.com>
Cc:        FreeBSD CURRENT <freebsd-current@freebsd.org>
Subject:   Re: Module variable initialization
Message-ID:  <3FBDFCF4-4427-4653-9EE4-EBC44DCB72ED@FreeBSD.org>
In-Reply-To: <CAM5tNy74ZC3FMTBWB1qj_LEhs_mv9ZXw-1SCs3rt=dLx1tkAKQ@mail.gmail.com>
References:  <CAM5tNy74ZC3FMTBWB1qj_LEhs_mv9ZXw-1SCs3rt=dLx1tkAKQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_B2249E63-5891-4707-AE52-79A065BDA57A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii



> On Dec 12, 2024, at 10:44 AM, Rick Macklem <rick.macklem@gmail.com> =
wrote:
>=20
> Hi,
>=20
> Bugzilla pr#282156 reports a crash that appears to be caused by
> a NFS client variable (nfscbd_pool) not being initialized when a
> NFS mount is done.
>=20
> Now, the NFS client module (nfscl.ko) is weird in that it has
> two definitions for the module. There is a VFS_SET() one for
> the file system and a separate DECLARE_MODULE() for nfscl.
> (The latter exists so that the module can refuse to unload and
> define dependencies on other modules.)
>=20
> The variable (nfscbd_pool) is initialized in the modevent() function
> for nfscl in the MOD_LOAD section.
>=20
> Does anyone know if this can somehow result in the variable not
> being initialized when an NFS mount occurs?

I'm not familiar with NFS. =46rom a quick look of the source code I =
think
`nfscbd_pool` is correctly initialized.

I do not know the exact version pr#282156, so I guess and tried 14.1-p1,
```
$ addr2line -fip -e =
/.zfs/snapshot/14.1-p1/usr/lib/debug/boot/kernel/kernel.debug =
0xffffffff80e1c558
svc_run at /usr/src/sys/rpc/svc.c:1414
```

=
https://cgit.freebsd.org/src/tree/sys/rpc/svc.c?h=3Dreleng/14.1&id=3D0892d=
ff104440867956a53e78c12d66090fec36b#n1414

If `nfscbd_pool` is NULL, then I expect the panic should happens =
earlier. Say line 1405 or event earlier line 1389 .

Maybe `svc_run_internal()` is to be blamed ?

>=20
> And, if the above is possible, would doing the initialization in the
> vfs_init function for VFS_SET() be guaranteed to happen before
> a mount is done?

The order of modules seems right to me. nfscl module has order  =
SI_ORDER_FIRST
and VFS_SET(... nfs ... ) has SI_ORDER_MIDDLE.

>=20
> Thanks for any help with this, rick
>=20

Best regards,
Zhenlei


--Apple-Mail=_B2249E63-5891-4707-AE52-79A065BDA57A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><br =
class=3D""><div><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"">On Dec 12, 2024, at 10:44 AM, Rick Macklem &lt;<a =
href=3D"mailto:rick.macklem@gmail.com" =
class=3D"">rick.macklem@gmail.com</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div class=3D"">Hi,<br=
 class=3D""><br class=3D"">Bugzilla pr#282156 reports a crash that =
appears to be caused by<br class=3D"">a NFS client variable =
(nfscbd_pool) not being initialized when a<br class=3D"">NFS mount is =
done.<br class=3D""><br class=3D"">Now, the NFS client module (nfscl.ko) =
is weird in that it has<br class=3D"">two definitions for the module. =
There is a VFS_SET() one for<br class=3D"">the file system and a =
separate DECLARE_MODULE() for nfscl.<br class=3D"">(The latter exists so =
that the module can refuse to unload and<br class=3D"">define =
dependencies on other modules.)<br class=3D""><br class=3D"">The =
variable (nfscbd_pool) is initialized in the modevent() function<br =
class=3D"">for nfscl in the MOD_LOAD =
section.</div></div></blockquote><blockquote type=3D"cite" class=3D""><div=
 class=3D""><div class=3D""><br class=3D"">Does anyone know if this can =
somehow result in the variable not<br class=3D"">being initialized when =
an NFS mount occurs?<br class=3D""></div></div></blockquote><div><br =
class=3D""></div><div><div style=3D"caret-color: rgb(0, 0, 0); color: =
rgb(0, 0, 0);">I'm not familiar with NFS. =46rom a quick look of the =
source code I think</div><div style=3D"caret-color: rgb(0, 0, 0); color: =
rgb(0, 0, 0);">`nfscbd_pool` is correctly initialized.</div><div =
style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br =
class=3D""></div><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, =
0, 0);">I do not know the exact version pr#282156, so I guess and tried =
14.1-p1,</div><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, =
0);">```</div><div><span style=3D"caret-color: rgb(0, 0, 0); color: =
rgb(0, 0, 0);" class=3D"">$ </span><font color=3D"#000000" =
class=3D""><span style=3D"caret-color: rgb(0, 0, 0);" class=3D"">addr2line=
 -fip -e /.zfs/snapshot/14.1-p1/usr/lib/debug/boot/kernel/kernel.debug =
0xffffffff80e1c558</span></font></div><div><font color=3D"#000000" =
class=3D""><span style=3D"caret-color: rgb(0, 0, 0);" class=3D"">svc_run =
at /usr/src/sys/rpc/svc.c:1414</span></font></div><div =
style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">```</div><div =
style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br =
class=3D""></div><div><font color=3D"#000000" class=3D""><span =
style=3D"caret-color: rgb(0, 0, 0);" class=3D""><a =
href=3D"https://cgit.freebsd.org/src/tree/sys/rpc/svc.c?h=3Dreleng/14.1&am=
p;id=3D0892dff104440867956a53e78c12d66090fec36b#n1414" =
class=3D"">https://cgit.freebsd.org/src/tree/sys/rpc/svc.c?h=3Dreleng/14.1=
&amp;id=3D0892dff104440867956a53e78c12d66090fec36b#n1414</a></span></font>=
</div><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br =
class=3D""></div><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, =
0, 0);">If `nfscbd_pool` is NULL, then I expect the panic should happens =
earlier. Say line 1405 or event earlier line 1389 .</div><div =
style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br =
class=3D""></div><div style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, =
0, 0);">Maybe `svc_run_internal()` is to be blamed ?</div></div><br =
class=3D""><blockquote type=3D"cite" class=3D""><div class=3D""><div =
class=3D""><br class=3D"">And, if the above is possible, would doing the =
initialization in the<br class=3D"">vfs_init function for VFS_SET() be =
guaranteed to happen before<br class=3D"">a mount is done?<br =
class=3D""></div></div></blockquote><div><br class=3D""></div><div>The =
order of modules seems right to me. nfscl module has order &nbsp;<span =
style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" =
class=3D"">SI_ORDER_FIRST</span></div><div><span style=3D"caret-color: =
rgb(0, 0, 0); color: rgb(0, 0, 0);" class=3D"">and&nbsp;</span><span =
style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" =
class=3D"">VFS_SET(... nfs ... ) has&nbsp;</span><span =
style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" =
class=3D"">SI_ORDER_MIDDLE.</span></div><br class=3D""><blockquote =
type=3D"cite" class=3D""><div class=3D""><div class=3D""><br =
class=3D"">Thanks for any help with this, rick<br class=3D""><br =
class=3D""></div></div></blockquote></div><br class=3D""><div class=3D"">
<div>Best regards,</div><div>Zhenlei</div>

</div>
<br class=3D""></body></html>=

--Apple-Mail=_B2249E63-5891-4707-AE52-79A065BDA57A--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FBDFCF4-4427-4653-9EE4-EBC44DCB72ED>