Date: Fri, 13 Apr 2012 04:17:44 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r234198 - stable/9/sys/geom/part Message-ID: <201204130417.q3D4HiMo059568@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ae Date: Fri Apr 13 04:17:43 2012 New Revision: 234198 URL: http://svn.freebsd.org/changeset/base/234198 Log: MFC r233000: Add MODULE_DEPEND() to geom_part modules. MFC r233342: Check that scheme is not already registered. This may happens when a KLD is preloaded with loader(8) and leads to infinity loop. Also do not return EEXIST error code from MOD_LOAD handler, because we have undocumented(?) ability replace kernel's module with preloaded one. And if we have so, then preloaded module will be initialized first. Thus error in MOD_LOAD handler will be triggered for the kernel. PR: kern/165573 Modified: stable/9/sys/geom/part/g_part.c stable/9/sys/geom/part/g_part.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/geom/part/g_part.c ============================================================================== --- stable/9/sys/geom/part/g_part.c Thu Apr 12 23:06:07 2012 (r234197) +++ stable/9/sys/geom/part/g_part.c Fri Apr 13 04:17:43 2012 (r234198) @@ -145,6 +145,7 @@ static struct g_class g_part_class = { }; DECLARE_GEOM_CLASS(g_part_class, g_part); +MODULE_VERSION(g_part, 0); /* * Support functions. @@ -2208,23 +2209,32 @@ g_part_unload_event(void *arg, int flag) int g_part_modevent(module_t mod, int type, struct g_part_scheme *scheme) { + struct g_part_scheme *iter; uintptr_t arg; int error; + error = 0; switch (type) { case MOD_LOAD: - TAILQ_INSERT_TAIL(&g_part_schemes, scheme, scheme_list); - - error = g_retaste(&g_part_class); - if (error) - TAILQ_REMOVE(&g_part_schemes, scheme, scheme_list); + TAILQ_FOREACH(iter, &g_part_schemes, scheme_list) { + if (scheme == iter) { + printf("GEOM_PART: scheme %s is already " + "registered!\n", scheme->name); + break; + } + } + if (iter == NULL) { + TAILQ_INSERT_TAIL(&g_part_schemes, scheme, + scheme_list); + g_retaste(&g_part_class); + } break; case MOD_UNLOAD: arg = (uintptr_t)scheme; error = g_waitfor_event(g_part_unload_event, &arg, M_WAITOK, NULL); - if (!error) - error = (arg == (uintptr_t)scheme) ? EDOOFUS : arg; + if (error == 0) + error = arg; break; default: error = EOPNOTSUPP; Modified: stable/9/sys/geom/part/g_part.h ============================================================================== --- stable/9/sys/geom/part/g_part.h Thu Apr 12 23:06:07 2012 (r234197) +++ stable/9/sys/geom/part/g_part.h Fri Apr 13 04:17:43 2012 (r234198) @@ -208,6 +208,7 @@ int g_part_modevent(module_t, int, struc name##_modevent, \ &name##_scheme \ }; \ - DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY) + DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY); \ + MODULE_DEPEND(name, g_part, 0, 0, 0) #endif /* !_GEOM_PART_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204130417.q3D4HiMo059568>