/* * This file implements multi-threaded decompression in the * decompressor framework
*/
/* * The reason that multiply two is that a CPU can request new I/O * while it is waiting previous request.
*/ #define MAX_DECOMPRESSOR (num_online_cpus() * 2)
/* * We should have a decompressor at least as default * so if we fail to allocate new decompressor dynamically, * we could always fall back to default decompressor and * file system works.
*/
decomp_strm = kmalloc(sizeof(*decomp_strm), GFP_KERNEL); if (!decomp_strm) goto out;
/* There is available decomp_stream */ if (!list_empty(&stream->strm_list)) {
decomp_strm = list_entry(stream->strm_list.prev, struct decomp_stream, list);
list_del(&decomp_strm->list);
mutex_unlock(&stream->mutex); break;
}
/* * If there is no available decomp and already full, * let's wait for releasing decomp from other users.
*/ if (stream->avail_decomp >= msblk->max_thread_num) goto wait;
/* Let's allocate new decomp */
decomp_strm = kmalloc(sizeof(*decomp_strm), GFP_KERNEL); if (!decomp_strm) goto wait;
mutex_unlock(&stream->mutex); break;
wait: /* * If system memory is tough, let's for other's * releasing instead of hurting VM because it could * make page cache thrashing.
*/
mutex_unlock(&stream->mutex);
wait_event(stream->wait,
!list_empty(&stream->strm_list));
}
return decomp_strm;
}
staticint squashfs_decompress(struct squashfs_sb_info *msblk, struct bio *bio, int offset, int length, struct squashfs_page_actor *output)
{ int res; struct squashfs_stream *stream = msblk->stream; struct decomp_stream *decomp_stream = get_decomp_stream(msblk, stream);
res = msblk->decompressor->decompress(msblk, decomp_stream->stream,
bio, offset, length, output);
put_decomp_stream(decomp_stream, stream); if (res < 0)
ERROR("%s decompression failed, data probably corrupt\n",
msblk->decompressor->name); return res;
}
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.