Lines 82-87
u_int g_eli_batch = 0;
Link Here
|
82 |
SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RWTUN, &g_eli_batch, 0, |
82 |
SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RWTUN, &g_eli_batch, 0, |
83 |
"Use crypto operations batching"); |
83 |
"Use crypto operations batching"); |
84 |
|
84 |
|
|
|
85 |
uma_zone_t g_eli_zone; |
86 |
static u_int g_eli_uma_reserve = 1; |
87 |
SYSCTL_UINT(_kern_geom_eli, OID_AUTO, uma_reserve, CTLFLAG_RDTUN, |
88 |
&g_eli_uma_reserve, 0, "Items to pre-allocate in dedicated uma zone " |
89 |
"and reserve for unauthenticated writes to onetime disks"); |
90 |
|
91 |
u_int g_eli_all_writes_use_uma = 0; |
92 |
SYSCTL_UINT(_kern_geom_eli, OID_AUTO, use_uma_for_all_writes, CTLFLAG_RDTUN, |
93 |
&g_eli_all_writes_use_uma, 0, "Use the dedicated uma zone for all " |
94 |
"unauthenticated writes that fit, not just for writes to onetime " |
95 |
"providers. May reduce write latency but also increases memory usage."); |
96 |
|
97 |
/* |
98 |
* Items in the dedicated uma zone have a fixed size and need |
99 |
* to be big enough for all bio lengths for which it is being used. |
100 |
* |
101 |
* g_eli_max_uma_bio_length is the largest amount of data geli can receive |
102 |
* in a row and fit into an uma zone item, it is used to calculate |
103 |
* g_eli_zone_item_size which additionally accounts for the encryption |
104 |
* overhead, which depends on the number of sectors. |
105 |
*/ |
106 |
u_int g_eli_max_uma_bio_length = MAXPHYS; |
107 |
SYSCTL_UINT(_kern_geom_eli, OID_AUTO, max_uma_bio_length, CTLFLAG_RDTUN, |
108 |
&g_eli_max_uma_bio_length, 0, |
109 |
"Maximum bio length for which the uma zone is being used."); |
110 |
u_int g_eli_zone_item_size; |
111 |
|
85 |
/* |
112 |
/* |
86 |
* Passphrase cached during boot, in order to be more user-friendly if |
113 |
* Passphrase cached during boot, in order to be more user-friendly if |
87 |
* there are multiple providers using the same passphrase. |
114 |
* there are multiple providers using the same passphrase. |
Lines 246-253
g_eli_write_done(struct bio *bp)
Link Here
|
246 |
pbp->bio_inbed++; |
273 |
pbp->bio_inbed++; |
247 |
if (pbp->bio_inbed < pbp->bio_children) |
274 |
if (pbp->bio_inbed < pbp->bio_children) |
248 |
return; |
275 |
return; |
249 |
free(pbp->bio_driver2, M_ELI); |
276 |
sc = pbp->bio_to->geom->softc; |
250 |
pbp->bio_driver2 = NULL; |
277 |
g_eli_free_driver2(pbp, sc->sc_flags); |
251 |
if (pbp->bio_error != 0) { |
278 |
if (pbp->bio_error != 0) { |
252 |
G_ELI_LOGREQ(0, pbp, "%s() failed (error=%d)", __func__, |
279 |
G_ELI_LOGREQ(0, pbp, "%s() failed (error=%d)", __func__, |
253 |
pbp->bio_error); |
280 |
pbp->bio_error); |
Lines 258-264
g_eli_write_done(struct bio *bp)
Link Here
|
258 |
/* |
285 |
/* |
259 |
* Write is finished, send it up. |
286 |
* Write is finished, send it up. |
260 |
*/ |
287 |
*/ |
261 |
sc = pbp->bio_to->geom->softc; |
|
|
262 |
g_io_deliver(pbp, pbp->bio_error); |
288 |
g_io_deliver(pbp, pbp->bio_error); |
263 |
if (sc != NULL) |
289 |
if (sc != NULL) |
264 |
atomic_subtract_int(&sc->sc_inflight, 1); |
290 |
atomic_subtract_int(&sc->sc_inflight, 1); |
Lines 1254-1259
static void
Link Here
|
1254 |
g_eli_init(struct g_class *mp) |
1280 |
g_eli_init(struct g_class *mp) |
1255 |
{ |
1281 |
{ |
1256 |
|
1282 |
|
|
|
1283 |
/* |
1284 |
* Calculate uma zone item size based on the largest bio length |
1285 |
* we need to use it for. |
1286 |
* |
1287 |
* 512 bytes is the smallest sector size supported and results in the |
1288 |
* largest overhead. If larger sectors are being used, we'll just waste |
1289 |
* a bit more memory. |
1290 |
* |
1291 |
* We currently only use the zone for unauthenticated writes, |
1292 |
* otherwise the item size would have to be even bigger. |
1293 |
*/ |
1294 |
g_eli_zone_item_size = (g_eli_max_uma_bio_length + \ |
1295 |
(g_eli_max_uma_bio_length / 512) * \ |
1296 |
(sizeof(struct cryptop) + sizeof(struct cryptodesc))); |
1297 |
|
1298 |
G_ELI_DEBUG(3, "Using uma zone item size %d for max bio length %d", |
1299 |
g_eli_zone_item_size, g_eli_max_uma_bio_length); |
1300 |
g_eli_zone = uma_zcreate("g_eli", g_eli_zone_item_size, NULL, NULL, |
1301 |
NULL, NULL, 0, UMA_ZONE_NOFREE); |
1302 |
if (0 < g_eli_uma_reserve) { |
1303 |
/* Increase the chances that items are available when needed. */ |
1304 |
uma_prealloc(g_eli_zone, g_eli_uma_reserve); |
1305 |
uma_zone_reserve(g_eli_zone, g_eli_uma_reserve); |
1306 |
} |
1307 |
|
1257 |
g_eli_pre_sync = EVENTHANDLER_REGISTER(shutdown_pre_sync, |
1308 |
g_eli_pre_sync = EVENTHANDLER_REGISTER(shutdown_pre_sync, |
1258 |
g_eli_shutdown_pre_sync, mp, SHUTDOWN_PRI_FIRST); |
1309 |
g_eli_shutdown_pre_sync, mp, SHUTDOWN_PRI_FIRST); |
1259 |
if (g_eli_pre_sync == NULL) |
1310 |
if (g_eli_pre_sync == NULL) |
Lines 1264-1269
static void
Link Here
|
1264 |
g_eli_fini(struct g_class *mp) |
1315 |
g_eli_fini(struct g_class *mp) |
1265 |
{ |
1316 |
{ |
1266 |
|
1317 |
|
|
|
1318 |
uma_zdestroy(g_eli_zone); |
1267 |
if (g_eli_pre_sync != NULL) |
1319 |
if (g_eli_pre_sync != NULL) |
1268 |
EVENTHANDLER_DEREGISTER(shutdown_pre_sync, g_eli_pre_sync); |
1320 |
EVENTHANDLER_DEREGISTER(shutdown_pre_sync, g_eli_pre_sync); |
1269 |
} |
1321 |
} |