Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/stripe/g_stripe.c
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) | ||||
if (error == 0 && req->newptr != NULL) | if (error == 0 && req->newptr != NULL) | ||||
g_stripe_fast = fast; | g_stripe_fast = fast; | ||||
return (error); | return (error); | ||||
} | } | ||||
SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, | SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, | ||||
CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, NULL, 0, | CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, NULL, 0, | ||||
g_sysctl_stripe_fast, "I", | g_sysctl_stripe_fast, "I", | ||||
"Fast, but memory-consuming, mode"); | "Fast, but memory-consuming, mode"); | ||||
static u_int g_stripe_maxmem = MAXPHYS * 100; | static u_long g_stripe_maxmem; | ||||
SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, maxmem, CTLFLAG_RDTUN, &g_stripe_maxmem, | SYSCTL_ULONG(_kern_geom_stripe, OID_AUTO, maxmem, | ||||
0, "Maximum memory that can be allocated in \"fast\" mode (in bytes)"); | CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &g_stripe_maxmem, 0, | ||||
"Maximum memory that can be allocated in \"fast\" mode (in bytes)"); | |||||
static u_int g_stripe_fast_failed = 0; | static u_int g_stripe_fast_failed = 0; | ||||
SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, fast_failed, CTLFLAG_RD, | SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, fast_failed, CTLFLAG_RD, | ||||
&g_stripe_fast_failed, 0, "How many times \"fast\" mode failed"); | &g_stripe_fast_failed, 0, "How many times \"fast\" mode failed"); | ||||
/* | /* | ||||
* Greatest Common Divisor. | * Greatest Common Divisor. | ||||
*/ | */ | ||||
static u_int | static u_int | ||||
Show All 18 Lines | lcm(u_int a, u_int b) | ||||
return ((a * b) / gcd(a, b)); | return ((a * b) / gcd(a, b)); | ||||
} | } | ||||
static void | static void | ||||
g_stripe_init(struct g_class *mp __unused) | g_stripe_init(struct g_class *mp __unused) | ||||
{ | { | ||||
g_stripe_zone = uma_zcreate("g_stripe_zone", MAXPHYS, NULL, NULL, | g_stripe_maxmem = maxphys * 100; | ||||
TUNABLE_ULONG_FETCH("kern.geom.stripe.maxmem,", &g_stripe_maxmem); | |||||
g_stripe_zone = uma_zcreate("g_stripe_zone", maxphys, NULL, NULL, | |||||
NULL, NULL, 0, 0); | NULL, NULL, 0, 0); | ||||
g_stripe_maxmem -= g_stripe_maxmem % MAXPHYS; | g_stripe_maxmem -= g_stripe_maxmem % maxphys; | ||||
uma_zone_set_max(g_stripe_zone, g_stripe_maxmem / MAXPHYS); | uma_zone_set_max(g_stripe_zone, g_stripe_maxmem / maxphys); | ||||
} | } | ||||
static void | static void | ||||
g_stripe_fini(struct g_class *mp __unused) | g_stripe_fini(struct g_class *mp __unused) | ||||
{ | { | ||||
uma_zdestroy(g_stripe_zone); | uma_zdestroy(g_stripe_zone); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 484 Lines • ▼ Show 20 Lines | g_stripe_start(struct bio *bp) | ||||
offset = ((nstripe / sc->sc_ndisks) << sc->sc_stripebits) + start; | offset = ((nstripe / sc->sc_ndisks) << sc->sc_stripebits) + start; | ||||
/* Length of data to operate. */ | /* Length of data to operate. */ | ||||
length = MIN(bp->bio_length, stripesize - start); | length = MIN(bp->bio_length, stripesize - start); | ||||
/* | /* | ||||
* Do use "fast" mode when: | * Do use "fast" mode when: | ||||
* 1. "Fast" mode is ON. | * 1. "Fast" mode is ON. | ||||
* and | * and | ||||
* 2. Request size is less than or equal to MAXPHYS, | * 2. Request size is less than or equal to maxphys, | ||||
* which should always be true. | * which should always be true. | ||||
* and | * and | ||||
* 3. Request size is bigger than stripesize * ndisks. If it isn't, | * 3. Request size is bigger than stripesize * ndisks. If it isn't, | ||||
* there will be no need to send more than one I/O request to | * there will be no need to send more than one I/O request to | ||||
* a provider, so there is nothing to optmize. | * a provider, so there is nothing to optmize. | ||||
* and | * and | ||||
* 4. Request is not unmapped. | * 4. Request is not unmapped. | ||||
* and | * and | ||||
* 5. It is not a BIO_DELETE. | * 5. It is not a BIO_DELETE. | ||||
*/ | */ | ||||
if (g_stripe_fast && bp->bio_length <= MAXPHYS && | if (g_stripe_fast && bp->bio_length <= maxphys && | ||||
bp->bio_length >= stripesize * sc->sc_ndisks && | bp->bio_length >= stripesize * sc->sc_ndisks && | ||||
(bp->bio_flags & BIO_UNMAPPED) == 0 && | (bp->bio_flags & BIO_UNMAPPED) == 0 && | ||||
bp->bio_cmd != BIO_DELETE) { | bp->bio_cmd != BIO_DELETE) { | ||||
fast = 1; | fast = 1; | ||||
} | } | ||||
error = 0; | error = 0; | ||||
if (fast) { | if (fast) { | ||||
error = g_stripe_start_fast(bp, no, offset, length); | error = g_stripe_start_fast(bp, no, offset, length); | ||||
▲ Show 20 Lines • Show All 615 Lines • Show Last 20 Lines |