/** * sg_free_table_chained - Free a previously mapped sg table * @table: The sg table header to use * @nents_first_chunk: size of the first_chunk SGL passed to * sg_alloc_table_chained * * Description: * Free an sg table previously allocated and setup with * sg_alloc_table_chained(). * * @nents_first_chunk has to be same with that same parameter passed * to sg_alloc_table_chained(). *
**/ void sg_free_table_chained(struct sg_table *table, unsigned nents_first_chunk)
{ if (table->orig_nents <= nents_first_chunk) return;
if (nents_first_chunk == 1)
nents_first_chunk = 0;
/** * sg_alloc_table_chained - Allocate and chain SGLs in an sg table * @table: The sg table header to use * @nents: Number of entries in sg list * @first_chunk: first SGL * @nents_first_chunk: number of the SGL of @first_chunk * * Description: * Allocate and chain SGLs in an sg table. If @nents@ is larger than * @nents_first_chunk a chained sg table will be setup. @first_chunk is * ignored if nents_first_chunk <= 1 because user expects the SGL points * non-chain SGL. *
**/ int sg_alloc_table_chained(struct sg_table *table, int nents, struct scatterlist *first_chunk, unsigned nents_first_chunk)
{ int ret;
BUG_ON(!nents);
if (first_chunk && nents_first_chunk) { if (nents <= nents_first_chunk) {
table->nents = table->orig_nents = nents;
sg_init_table(table->sgl, nents); return0;
}
}
/* User supposes that the 1st SGL includes real entry */ if (nents_first_chunk <= 1) {
first_chunk = NULL;
nents_first_chunk = 0;
}
ret = __sg_alloc_table(table, nents, SG_CHUNK_SIZE,
first_chunk, nents_first_chunk,
GFP_ATOMIC, sg_pool_alloc); if (unlikely(ret))
sg_free_table_chained(table, nents_first_chunk); return ret;
}
EXPORT_SYMBOL_GPL(sg_alloc_table_chained);
static __init int sg_pool_init(void)
{ int i;
for (i = 0; i < SG_MEMPOOL_NR; i++) { struct sg_pool *sgp = sg_pools + i; int size = sgp->size * sizeof(struct scatterlist);
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.