Subject: Re: extent panics
To: None <abs@anim.dreamworks.com>
From: Paul Kranenburg <pk@cs.few.eur.nl>
List: port-sparc
Date: 06/22/1999 11:55:38
> 	Would it be possible to put the patches up before then?
> 	(I have a sparc5 clone that is particularly unstable with
> 	1.4 and it would be good to know if all of the problems
> 	it sees have been fixed :)

Sure, here's the patch set scheduled for 1.4.1 :

--------
Index: kern/subr_extent.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/subr_extent.c,v
retrieving revision 1.24
diff -c -r1.24 subr_extent.c
*** subr_extent.c	1999/02/18 18:52:29	1.24
--- subr_extent.c	1999/06/22 09:52:47
***************
*** 1,4 ****
! /*	$NetBSD: subr_extent.c,v 1.24 1999/02/18 18:52:29 mycroft Exp $	*/
  
  /*-
   * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
--- 1,4 ----
! /*	$NetBSD: subr_extent.c,v 1.25 1999/05/11 11:02:54 drochner Exp $	*/
  
  /*-
   * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
***************
*** 119,124 ****
--- 119,125 ----
  	size_t sz = storagesize;
  	struct extent_region *rp;
  	int fixed_extent = (storage != NULL);
+ 	int s;
  
  #ifdef DIAGNOSTIC
  	/* Check arguments. */
***************
*** 164,172 ****
  			LIST_INSERT_HEAD(&fex->fex_freelist, rp, er_link);
  		}
  	} else {
! 		if ((expool == NULL) &&
! 		    !expool_create())
! 			return NULL;
  
  		ex = (struct extent *)malloc(sizeof(struct extent),
  		    mtype, (flags & EX_WAITOK) ? M_WAITOK : M_NOWAIT);
--- 165,176 ----
  			LIST_INSERT_HEAD(&fex->fex_freelist, rp, er_link);
  		}
  	} else {
! 		s = splhigh();
! 		if (expool == NULL)
! 			expool_create();
! 		splx(s);
! 		if (expool == NULL)
! 			return (NULL);
  
  		ex = (struct extent *)malloc(sizeof(struct extent),
  		    mtype, (flags & EX_WAITOK) ? M_WAITOK : M_NOWAIT);
***************
*** 604,614 ****
  	}
  
  	/*
! 	 * If there are no allocated regions beyond where we want to be,
! 	 * relocate the start of our candidate region to the end of
! 	 * the last allocated region (if there was one).
  	 */
! 	if (rp == NULL && last != NULL)
  		newstart = EXTENT_ALIGN((last->er_end + 1), alignment, skew);
  
  	for (; rp != NULL; rp = rp->er_link.le_next) {
--- 608,618 ----
  	}
  
  	/*
! 	 * Relocate the start of our candidate region to the end of
! 	 * the last allocated region (if there was one overlapping
! 	 * our subrange).
  	 */
! 	if (last != NULL && last->er_end >= newstart)
  		newstart = EXTENT_ALIGN((last->er_end + 1), alignment, skew);
  
  	for (; rp != NULL; rp = rp->er_link.le_next) {
***************
*** 991,996 ****
--- 995,1001 ----
  {
  	struct extent_region *rp;
  	int exflags;
+ 	int s;
  
  	/*
  	 * XXX Make a static, create-time flags word, so we don't
***************
*** 1034,1044 ****
  	}
  
   alloc:
! 	if ((expool == NULL) &&
! 	    !expool_create())
  		return (NULL);
  
  	rp = pool_get(expool, (flags & EX_WAITOK) ? PR_WAITOK : 0);
  
  	if (rp != NULL)
  		rp->er_flags = ER_ALLOC;
--- 1039,1052 ----
  	}
  
   alloc:
! 	s = splhigh();
! 	if (expool == NULL && !expool_create()) {
! 		splx(s);
  		return (NULL);
+ 	}
  
  	rp = pool_get(expool, (flags & EX_WAITOK) ? PR_WAITOK : 0);
+ 	splx(s);
  
  	if (rp != NULL)
  		rp->er_flags = ER_ALLOC;
***************
*** 1055,1060 ****
--- 1063,1069 ----
  	struct extent *ex;
  	struct extent_region *rp;
  {
+ 	int s;
  
  	if (ex->ex_flags & EXF_FIXED) {
  		struct extent_fixed *fex = (struct extent_fixed *)ex;
***************
*** 1072,1078 ****
--- 1081,1089 ----
  				    er_link);
  				goto wake_em_up;
  			} else {
+ 				s = splhigh();
  				pool_put(expool, rp);
+ 				splx(s);
  			}
  		} else {
  			/* Clear all flags. */
***************
*** 1091,1097 ****
--- 1102,1110 ----
  	/*
  	 * We know it's dynamically allocated if we get here.
  	 */
+ 	s = splhigh();
  	pool_put(expool, rp);
+ 	splx(s);
  }
  
  void
Index: kern/subr_pool.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/subr_pool.c,v
retrieving revision 1.21.2.2
diff -c -r1.21.2.2 subr_pool.c
*** subr_pool.c	1999/04/07 00:34:55	1.21.2.2
--- subr_pool.c	1999/06/22 09:52:53
***************
*** 258,265 ****
--- 258,268 ----
  	pp->pr_npagefree++;
  
  	if ((pp->pr_roflags & PR_PHINPAGE) == 0) {
+ 		int s;
  		LIST_REMOVE(ph, ph_hashlist);
+ 		s = splhigh();
  		pool_put(&phpool, ph);
+ 		splx(s);
  	}
  
  	if (pp->pr_curpage == ph) {
***************
*** 938,944 ****
--- 941,949 ----
  	if ((pp->pr_roflags & PR_PHINPAGE) != 0) {
  		ph = (struct pool_item_header *)(cp + pp->pr_phoffset);
  	} else {
+ 		int s = splhigh();
  		ph = pool_get(&phpool, PR_URGENT);
+ 		splx(s);
  		LIST_INSERT_HEAD(&pp->pr_hashtab[PR_HASH_INDEX(pp, cp)],
  				 ph, ph_hashlist);
  	}
Index: dev/rnd.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/rnd.c,v
retrieving revision 1.15
diff -c -r1.15 rnd.c
*** rnd.c	1999/04/01 19:07:40	1.15
--- rnd.c	1999/06/22 09:52:58
***************
*** 671,678 ****
  rnd_sample_allocate(rndsource_t *source)
  {
  	rnd_sample_t *c;
  
! 	c = pool_get(&rnd_mempool, M_WAITOK);
  	if (c == NULL)
  		return (NULL);
  
--- 671,681 ----
  rnd_sample_allocate(rndsource_t *source)
  {
  	rnd_sample_t *c;
+ 	int s;
  
! 	s = splhigh();
! 	c = pool_get(&rnd_mempool, PR_WAITOK);
! 	splx(s);
  	if (c == NULL)
  		return (NULL);
  
***************
*** 690,697 ****
--- 693,703 ----
  rnd_sample_allocate_isr(rndsource_t *source)
  {
  	rnd_sample_t *c;
+ 	int s;
  
+ 	s = splhigh();
  	c = pool_get(&rnd_mempool, 0);
+ 	splx(s);
  	if (c == NULL)
  		return (NULL);
  
***************
*** 705,712 ****
--- 711,722 ----
  static void
  rnd_sample_free(rnd_sample_t *c)
  {
+ 	int s;
+ 
  	memset(c, 0, sizeof(rnd_sample_t));
+ 	s = splhigh();
  	pool_put(&rnd_mempool, c);
+ 	splx(s);
  }
  
  /*
Index: dev/scsipi/scsipi_base.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/scsipi/scsipi_base.c,v
retrieving revision 1.20.2.1
diff -c -r1.20.2.1 scsipi_base.c
*** scsipi_base.c	1999/04/07 15:04:22	1.20.2.1
--- scsipi_base.c	1999/06/22 09:53:03
***************
*** 607,614 ****
  	 * returned SUCCESSFULLY_QUEUED when the command was
  	 * submitted), we need to free the scsipi_xfer here.
  	 */
! 	if (SCSIPI_XFER_ASYNC(xs))
  		scsipi_free_xs(xs, SCSI_NOSLEEP);
  	if (bp)
  		biodone(bp);
  }
--- 607,617 ----
  	 * returned SUCCESSFULLY_QUEUED when the command was
  	 * submitted), we need to free the scsipi_xfer here.
  	 */
! 	if (SCSIPI_XFER_ASYNC(xs)) {
! 		int s = splbio();
  		scsipi_free_xs(xs, SCSI_NOSLEEP);
+ 		splx(s);
+ 	}
  	if (bp)
  		biodone(bp);
  }
Index: dev/scsipi/scsi_base.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/scsipi/scsi_base.c,v
retrieving revision 1.66
diff -c -r1.66 scsi_base.c
*** scsi_base.c	1998/11/17 14:38:42	1.66
--- scsi_base.c	1999/06/22 09:53:09
***************
*** 92,98 ****
  	int flags;
  {
  	struct scsipi_xfer *xs;
! 	int error;
  
  	SC_DEBUG(sc_link, SDEV_DB2, ("scsi_scsipi_cmd\n"));
  
--- 92,98 ----
  	int flags;
  {
  	struct scsipi_xfer *xs;
! 	int error, s;
  
  	SC_DEBUG(sc_link, SDEV_DB2, ("scsi_scsipi_cmd\n"));
  
***************
*** 121,127 ****
--- 121,129 ----
  	 * we have finished with the xfer stuct, free it and
  	 * check if anyone else needs to be started up.
  	 */
+ 	s = splbio();
  	scsipi_free_xs(xs, flags);
+ 	splx(s);
  	return (error);
  }