diff options
| author | tls <tls@NetBSD.org> | 2006-10-05 17:35:19 +0000 |
|---|---|---|
| committer | tls <tls@NetBSD.org> | 2006-10-05 17:35:19 +0000 |
| commit | 8cc016b4bc94011851575476ae1639dc845d26f7 (patch) | |
| tree | 1a7966e8c619474a48c1615dc125730f4fed14ae /sys/dev/raidframe/rf_diskqueue.c | |
| parent | 47f7700709eedf0a6b3ac9fb2ecfe966cbca3633 (diff) | |
Protect calls to pool_put/pool_get that may occur in interrupt context
with spl used to protect other allocations and frees, or datastructure
element insertion and removal, in adjacent code.
It is almost unquestionably the case that some of the spl()/splx() calls
added here are superfluous, but it really seems wrong to see:
s=splfoo();
/* frob data structure */
splx(s);
pool_put(x);
and if we think we need to protect the first operation, then it is hard
to see why we should not think we need to protect the next. "Better
safe than sorry".
It is also almost unquestionably the case that I missed some pool
gets/puts from interrupt context with my strategy for finding these
calls; use of PR_NOWAIT is a strong hint that a pool may be used from
interrupt context but many callers in the kernel pass a "can wait/can't
wait" flag down such that my searches might not have found them. One
notable area that needs to be looked at is pf.
See also:
http://mail-index.netbsd.org/tech-kern/2006/07/19/0003.html
http://mail-index.netbsd.org/tech-kern/2006/07/19/0009.html
Diffstat (limited to 'sys/dev/raidframe/rf_diskqueue.c')
| -rw-r--r-- | sys/dev/raidframe/rf_diskqueue.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/dev/raidframe/rf_diskqueue.c b/sys/dev/raidframe/rf_diskqueue.c index 8d52c148c9d..5b43641e21b 100644 --- a/sys/dev/raidframe/rf_diskqueue.c +++ b/sys/dev/raidframe/rf_diskqueue.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_diskqueue.c,v 1.45 2006/01/08 21:53:26 oster Exp $ */ +/* $NetBSD: rf_diskqueue.c,v 1.46 2006/10/05 17:35:19 tls Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -66,7 +66,7 @@ ****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.45 2006/01/08 21:53:26 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.46 2006/10/05 17:35:19 tls Exp $"); #include <dev/raidframe/raidframevar.h> @@ -449,8 +449,11 @@ rf_CreateDiskQueueData(RF_IoType_t typ, RF_SectorNum_t ssect, int waitflag) { RF_DiskQueueData_t *p; + int s; + s = splbio(); p = pool_get(&rf_pools.dqd, waitflag); + splx(s); if (p == NULL) return (NULL); @@ -462,7 +465,9 @@ rf_CreateDiskQueueData(RF_IoType_t typ, RF_SectorNum_t ssect, } if (p->bp == NULL) { /* no memory for the buffer!?!? */ + s = splbio(); pool_put(&rf_pools.dqd, p); + splx(s); return (NULL); } @@ -486,7 +491,9 @@ rf_CreateDiskQueueData(RF_IoType_t typ, RF_SectorNum_t ssect, void rf_FreeDiskQueueData(RF_DiskQueueData_t *p) { - + int s; + s = splbio(); /* XXX protect only pool_put, or neither? */ putiobuf(p->bp); pool_put(&rf_pools.dqd, p); + splx(s); } |
