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>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] > On Dec 12, 2024, at 10:44 AM, Rick Macklem <rick.macklem@gmail.com> wrote: > > Hi, > > 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. > > 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.) > > The variable (nfscbd_pool) is initialized in the modevent() function > for nfscl in the MOD_LOAD section. > > 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. From 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=releng/14.1&id=0892dff104440867956a53e78c12d66090fec36b#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 ? > > 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. > > Thanks for any help with this, rick > Best regards, Zhenlei [-- Attachment #2 --] <html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 12, 2024, at 10:44 AM, Rick Macklem <<a href="mailto:rick.macklem@gmail.com" class="">rick.macklem@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi,<br class=""><br class="">Bugzilla pr#282156 reports a crash that appears to be caused by<br class="">a NFS client variable (nfscbd_pool) not being initialized when a<br class="">NFS mount is done.<br class=""><br class="">Now, the NFS client module (nfscl.ko) is weird in that it has<br class="">two definitions for the module. There is a VFS_SET() one for<br class="">the file system and a separate DECLARE_MODULE() for nfscl.<br class="">(The latter exists so that the module can refuse to unload and<br class="">define dependencies on other modules.)<br class=""><br class="">The variable (nfscbd_pool) is initialized in the modevent() function<br class="">for nfscl in the MOD_LOAD section.</div></div></blockquote><blockquote type="cite" class=""><div class=""><div class=""><br class="">Does anyone know if this can somehow result in the variable not<br class="">being initialized when an NFS mount occurs?<br class=""></div></div></blockquote><div><br class=""></div><div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">I'm not familiar with NFS. From a quick look of the source code I think</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">`nfscbd_pool` is correctly initialized.</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div style="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="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">```</div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">$ </span><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">addr2line -fip -e /.zfs/snapshot/14.1-p1/usr/lib/debug/boot/kernel/kernel.debug 0xffffffff80e1c558</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">svc_run at /usr/src/sys/rpc/svc.c:1414</span></font></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">```</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""><a href="https://cgit.freebsd.org/src/tree/sys/rpc/svc.c?h=releng/14.1&id=0892dff104440867956a53e78c12d66090fec36b#n1414" class="">https://cgit.freebsd.org/src/tree/sys/rpc/svc.c?h=releng/14.1&id=0892dff104440867956a53e78c12d66090fec36b#n1414</a></span></font></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div style="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="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Maybe `svc_run_internal()` is to be blamed ?</div></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">And, if the above is possible, would doing the initialization in the<br class="">vfs_init function for VFS_SET() be guaranteed to happen before<br class="">a mount is done?<br class=""></div></div></blockquote><div><br class=""></div><div>The order of modules seems right to me. nfscl module has order <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">SI_ORDER_FIRST</span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">and </span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">VFS_SET(... nfs ... ) has </span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">SI_ORDER_MIDDLE.</span></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">Thanks for any help with this, rick<br class=""><br class=""></div></div></blockquote></div><br class=""><div class=""> <div>Best regards,</div><div>Zhenlei</div> </div> <br class=""></body></html>home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FBDFCF4-4427-4653-9EE4-EBC44DCB72ED>
