diff options
author | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2002-02-25 04:53:17 +0000 |
---|---|---|
committer | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2002-02-25 04:53:17 +0000 |
commit | f7848364f2a1ee9cef20b19f1396e5796a1b5c6f (patch) | |
tree | 81fc6f5369cf786c5f1cd932eddbdf58dfa6c64b /sys | |
parent | 0f17b0b30f9e5187cb51ca2a7a7d427e5f66a350 (diff) |
Make pool_sethardlimit() check that it doesn't decrease the limit below
the current size of the pool. ok art@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_pool.c | 19 | ||||
-rw-r--r-- | sys/kern/uipc_mbuf.c | 4 | ||||
-rw-r--r-- | sys/sys/pool.h | 4 |
3 files changed, 18 insertions, 9 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index e9ea1657039..d6cb4495ad6 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.27 2002/02/23 02:52:56 art Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.28 2002/02/25 04:53:16 dhartmei Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -1217,12 +1217,18 @@ pool_sethiwat(struct pool *pp, int n) simple_unlock(&pp->pr_slock); } -void -pool_sethardlimit(struct pool *pp, int n, const char *warnmess, int ratecap) +int +pool_sethardlimit(struct pool *pp, unsigned n, const char *warnmess, int ratecap) { + int error = 0; simple_lock(&pp->pr_slock); + if (n < pp->pr_nout) { + error = EINVAL; + goto done; + } + pp->pr_hardlimit = n; pp->pr_hardlimit_warning = warnmess; pp->pr_hardlimit_ratecap.tv_sec = ratecap; @@ -1233,11 +1239,14 @@ pool_sethardlimit(struct pool *pp, int n, const char *warnmess, int ratecap) * In-line version of pool_sethiwat(), because we don't want to * release the lock. */ - pp->pr_maxpages = (n == 0) - ? 0 + pp->pr_maxpages = (n == 0 || n == UINT_MAX) + ? n : roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage; + done: simple_unlock(&pp->pr_slock); + + return (error); } /* diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 6a913bb0e98..8aaddd83194 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.55 2002/02/17 22:59:53 maja Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.56 2002/02/25 04:53:16 dhartmei Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -130,7 +130,7 @@ mbinit() * mbuf clusters the kernel is to support. Log the limit * reached message max once a minute. */ - pool_sethardlimit(&mclpool, nmbclust, mclpool_warnmsg, 60); + (void)pool_sethardlimit(&mclpool, nmbclust, mclpool_warnmsg, 60); /* * Set a low water mark for both mbufs and clusters. This should diff --git a/sys/sys/pool.h b/sys/sys/pool.h index 18c25df4cf5..bf1a1a46023 100644 --- a/sys/sys/pool.h +++ b/sys/sys/pool.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pool.h,v 1.10 2002/02/23 02:52:56 art Exp $ */ +/* $OpenBSD: pool.h,v 1.11 2002/02/25 04:53:16 dhartmei Exp $ */ /* $NetBSD: pool.h,v 1.27 2001/06/06 22:00:17 rafal Exp $ */ /*- @@ -224,7 +224,7 @@ void _pool_reclaim(struct pool *, const char *, long); int pool_prime(struct pool *, int); void pool_setlowat(struct pool *, int); void pool_sethiwat(struct pool *, int); -void pool_sethardlimit(struct pool *, int, const char *, int); +int pool_sethardlimit(struct pool *, unsigned, const char *, int); void pool_drain(void *); /* |