mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-19 15:33:56 +00:00
gbde: replace malloc_last_fail with a kludge
This facilitates removal of malloc_last_fail without really impacting anything.
This commit is contained in:
parent
46fbd8004f
commit
d5127d1ae2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=367626
@ -77,6 +77,20 @@
|
||||
#include <geom/geom.h>
|
||||
#include <geom/bde/g_bde.h>
|
||||
|
||||
/*
|
||||
* FIXME: This used to call malloc_last_fail which in practice was almost
|
||||
* guaranteed to return time_uptime even in face of severe memory shortage.
|
||||
* As GBDE is the only consumer the kludge below was added to facilitate the
|
||||
* removal with minimial changes. The code should be fixed to respond to memory
|
||||
* pressure (e.g., by using lowmem eventhandler) instead.
|
||||
*/
|
||||
static int
|
||||
g_bde_malloc_last_fail(void)
|
||||
{
|
||||
|
||||
return (time_uptime);
|
||||
}
|
||||
|
||||
static void g_bde_delete_sector(struct g_bde_softc *wp, struct g_bde_sector *sp);
|
||||
static struct g_bde_sector * g_bde_new_sector(struct g_bde_work *wp, u_int len);
|
||||
static void g_bde_release_keysector(struct g_bde_work *wp);
|
||||
@ -210,7 +224,7 @@ g_bde_get_keysector(struct g_bde_work *wp)
|
||||
g_trace(G_T_TOPOLOGY, "g_bde_get_keysector(%p, %jd)", wp, (intmax_t)offset);
|
||||
sc = wp->softc;
|
||||
|
||||
if (malloc_last_fail() < g_bde_ncache)
|
||||
if (g_bde_malloc_last_fail() < g_bde_ncache)
|
||||
g_bde_purge_sector(sc, -1);
|
||||
|
||||
sp = TAILQ_FIRST(&sc->freelist);
|
||||
@ -228,7 +242,7 @@ g_bde_get_keysector(struct g_bde_work *wp)
|
||||
if (sp->ref == 1)
|
||||
sp->owner = wp;
|
||||
} else {
|
||||
if (malloc_last_fail() < g_bde_ncache) {
|
||||
if (g_bde_malloc_last_fail() < g_bde_ncache) {
|
||||
TAILQ_FOREACH(sp, &sc->freelist, list)
|
||||
if (sp->ref == 0)
|
||||
break;
|
||||
@ -311,7 +325,7 @@ g_bde_purge_sector(struct g_bde_softc *sc, int fraction)
|
||||
if (fraction > 0)
|
||||
n = sc->ncache / fraction + 1;
|
||||
else
|
||||
n = g_bde_ncache - malloc_last_fail();
|
||||
n = g_bde_ncache - g_bde_malloc_last_fail();
|
||||
if (n < 0)
|
||||
return;
|
||||
if (n > sc->ncache)
|
||||
|
Loading…
Reference in New Issue
Block a user