/** * tcp_sigpool_alloc_ahash - allocates pool for ahash requests * @alg: name of async hash algorithm * @scratch_size: reserve a tcp_sigpool::scratch buffer of this size
*/ int tcp_sigpool_alloc_ahash(constchar *alg, size_t scratch_size)
{ int i, ret;
/* slow-path */
mutex_lock(&cpool_mutex);
ret = sigpool_reserve_scratch(scratch_size); if (ret) goto out; for (i = 0; i < cpool_populated; i++) { if (!cpool[i].alg) continue; if (strcmp(cpool[i].alg, alg)) continue;
/* pairs with tcp_sigpool_release() */ if (!kref_get_unless_zero(&cpool[i].kref))
kref_init(&cpool[i].kref);
ret = i; goto out;
}
for (i = 0; i < cpool_populated; i++) { if (!cpool[i].alg) break;
} if (i >= CPOOL_SIZE) {
ret = -ENOSPC; goto out;
}
ret = __cpool_alloc_ahash(&cpool[i], alg); if (!ret) {
ret = i; if (i == cpool_populated)
cpool_populated++;
}
out:
mutex_unlock(&cpool_mutex); return ret;
}
EXPORT_SYMBOL_GPL(tcp_sigpool_alloc_ahash);
mutex_lock(&cpool_mutex); for (i = 0; i < cpool_populated; i++) { if (kref_read(&cpool[i].kref) > 0) {
free_scratch = false; continue;
} if (!cpool[i].alg) continue;
__cpool_free_entry(&cpool[i]);
} if (free_scratch)
sigpool_scratch_free();
mutex_unlock(&cpool_mutex);
}
/** * tcp_sigpool_release - decreases number of users for a pool. If it was * the last user of the pool, releases any memory that was consumed. * @id: tcp_sigpool that was previously allocated by tcp_sigpool_alloc_ahash()
*/ void tcp_sigpool_release(unsignedint id)
{ if (WARN_ON_ONCE(id >= cpool_populated || !cpool[id].alg)) return;
/** * tcp_sigpool_get - increases number of users (refcounter) for a pool * @id: tcp_sigpool that was previously allocated by tcp_sigpool_alloc_ahash()
*/ void tcp_sigpool_get(unsignedint id)
{ if (WARN_ON_ONCE(id >= cpool_populated || !cpool[id].alg)) return;
kref_get(&cpool[id].kref);
}
EXPORT_SYMBOL_GPL(tcp_sigpool_get);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.