Lines Matching defs:workspace

23 /* workspace buffer size for s390 zlib hardware support */
26 struct workspace {
39 struct workspace *workspace = list_entry(ws, struct workspace, list);
41 workspace->level = level;
48 struct workspace *workspace = list_entry(ws, struct workspace, list);
50 kvfree(workspace->strm.workspace);
51 kfree(workspace->buf);
52 kfree(workspace);
57 struct workspace *workspace;
60 workspace = kzalloc(sizeof(*workspace), GFP_KERNEL);
61 if (!workspace)
66 workspace->strm.workspace = kvzalloc(workspacesize, GFP_KERNEL | __GFP_NOWARN);
67 workspace->level = level;
68 workspace->buf = NULL;
70 * In case of s390 zlib hardware support, allocate lager workspace
74 workspace->buf = kmalloc(ZLIB_DFLTCC_BUF_SIZE,
77 workspace->buf_size = ZLIB_DFLTCC_BUF_SIZE;
79 if (!workspace->buf) {
80 workspace->buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
81 workspace->buf_size = PAGE_SIZE;
83 if (!workspace->strm.workspace || !workspace->buf)
86 INIT_LIST_HEAD(&workspace->list);
88 return &workspace->list;
90 zlib_free_workspace(&workspace->list);
98 struct workspace *workspace = list_entry(ws, struct workspace, list);
115 if (Z_OK != zlib_deflateInit(&workspace->strm, workspace->level)) {
121 workspace->strm.total_in = 0;
122 workspace->strm.total_out = 0;
133 workspace->strm.next_in = workspace->buf;
134 workspace->strm.avail_in = 0;
135 workspace->strm.next_out = cpage_out;
136 workspace->strm.avail_out = PAGE_SIZE;
138 while (workspace->strm.total_in < len) {
141 * the workspace buffer if required.
143 if (workspace->strm.avail_in == 0) {
144 bytes_left = len - workspace->strm.total_in;
146 workspace->buf_size / PAGE_SIZE);
158 copy_page(workspace->buf + i * PAGE_SIZE,
162 workspace->strm.next_in = workspace->buf;
172 workspace->strm.next_in = data_in;
174 workspace->strm.avail_in = min(bytes_left,
175 (unsigned long) workspace->buf_size);
178 ret = zlib_deflate(&workspace->strm, Z_SYNC_FLUSH);
182 zlib_deflateEnd(&workspace->strm);
188 if (workspace->strm.total_in > 8192 &&
189 workspace->strm.total_in <
190 workspace->strm.total_out) {
198 if (workspace->strm.avail_out == 0) {
211 workspace->strm.avail_out = PAGE_SIZE;
212 workspace->strm.next_out = cpage_out;
215 if (workspace->strm.total_in >= len)
217 if (workspace->strm.total_out > max_out)
220 workspace->strm.avail_in = 0;
226 ret = zlib_deflate(&workspace->strm, Z_FINISH);
230 zlib_deflateEnd(&workspace->strm);
233 } else if (workspace->strm.avail_out == 0) {
247 workspace->strm.avail_out = PAGE_SIZE;
248 workspace->strm.next_out = cpage_out;
251 zlib_deflateEnd(&workspace->strm);
253 if (workspace->strm.total_out >= workspace->strm.total_in) {
259 *total_out = workspace->strm.total_out;
260 *total_in = workspace->strm.total_in;
273 struct workspace *workspace = list_entry(ws, struct workspace, list);
285 workspace->strm.next_in = data_in;
286 workspace->strm.avail_in = min_t(size_t, srclen, PAGE_SIZE);
287 workspace->strm.total_in = 0;
289 workspace->strm.total_out = 0;
290 workspace->strm.next_out = workspace->buf;
291 workspace->strm.avail_out = workspace->buf_size;
300 workspace->strm.next_in += 2;
301 workspace->strm.avail_in -= 2;
304 if (Z_OK != zlib_inflateInit2(&workspace->strm, wbits)) {
309 while (workspace->strm.total_in < srclen) {
310 ret = zlib_inflate(&workspace->strm, Z_NO_FLUSH);
315 total_out = workspace->strm.total_out;
321 ret2 = btrfs_decompress_buf2page(workspace->buf,
328 workspace->strm.next_out = workspace->buf;
329 workspace->strm.avail_out = workspace->buf_size;
331 if (workspace->strm.avail_in == 0) {
340 workspace->strm.next_in = data_in;
341 tmp = srclen - workspace->strm.total_in;
342 workspace->strm.avail_in = min(tmp, PAGE_SIZE);
350 zlib_inflateEnd(&workspace->strm);
360 struct workspace *workspace = list_entry(ws, struct workspace, list);
365 workspace->strm.next_in = data_in;
366 workspace->strm.avail_in = srclen;
367 workspace->strm.total_in = 0;
369 workspace->strm.next_out = workspace->buf;
370 workspace->strm.avail_out = workspace->buf_size;
371 workspace->strm.total_out = 0;
379 workspace->strm.next_in += 2;
380 workspace->strm.avail_in -= 2;
383 if (Z_OK != zlib_inflateInit2(&workspace->strm, wbits)) {
392 ret = zlib_inflate(&workspace->strm, Z_FINISH);
393 to_copy = min(workspace->strm.total_out, destlen);
397 memcpy_to_page(dest_page, dest_pgoff, workspace->buf, to_copy);
408 zlib_inflateEnd(&workspace->strm);