Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Apr 2012 04:20:16 GMT
From:      dfilter@FreeBSD.ORG (dfilter service)
To:        freebsd-geom@FreeBSD.org
Subject:   Re: kern/165573: commit references a PR
Message-ID:  <201204130420.q3D4KGPE062552@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/165573; it has been noted by GNATS.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/165573: commit references a PR
Date: Fri, 13 Apr 2012 04:18:21 +0000 (UTC)

 Author: ae
 Date: Fri Apr 13 04:18:12 2012
 New Revision: 234199
 URL: http://svn.freebsd.org/changeset/base/234199
 
 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/8/sys/geom/part/g_part.c
   stable/8/sys/geom/part/g_part.h
 Directory Properties:
   stable/8/sys/   (props changed)
 
 Modified: stable/8/sys/geom/part/g_part.c
 ==============================================================================
 --- stable/8/sys/geom/part/g_part.c	Fri Apr 13 04:17:43 2012	(r234198)
 +++ stable/8/sys/geom/part/g_part.c	Fri Apr 13 04:18:12 2012	(r234199)
 @@ -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.
 @@ -2135,23 +2136,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/8/sys/geom/part/g_part.h
 ==============================================================================
 --- stable/8/sys/geom/part/g_part.h	Fri Apr 13 04:17:43 2012	(r234198)
 +++ stable/8/sys/geom/part/g_part.h	Fri Apr 13 04:18:12 2012	(r234199)
 @@ -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_ */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204130420.q3D4KGPE062552>