Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 233681
b: refs/heads/master
c: ca9b688
h: refs/heads/master
i:
  233679: 5567736
v: v3
  • Loading branch information
Li Zefan authored and Chris Mason committed Feb 16, 2011
1 parent 1ad49ef commit 0e7f835
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b4dc2b8c694ead005b828f5fb7fa1134db5b6275
refs/heads/master: ca9b688c1c9a21635cfc8af8b68565b154185196
21 changes: 14 additions & 7 deletions trunk/fs/btrfs/lzo.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static int lzo_decompress_biovec(struct list_head *ws,
unsigned long tot_out;
unsigned long tot_len;
char *buf;
bool may_late_unmap, need_unmap;

data_in = kmap(pages_in[0]);
tot_len = read_compress_length(data_in);
Expand All @@ -300,11 +301,13 @@ static int lzo_decompress_biovec(struct list_head *ws,

tot_in += in_len;
working_bytes = in_len;
may_late_unmap = need_unmap = false;

/* fast path: avoid using the working buffer */
if (in_page_bytes_left >= in_len) {
buf = data_in + in_offset;
bytes = in_len;
may_late_unmap = true;
goto cont;
}

Expand All @@ -329,14 +332,17 @@ static int lzo_decompress_biovec(struct list_head *ws,
if (working_bytes == 0 && tot_in >= tot_len)
break;

kunmap(pages_in[page_in_index]);
page_in_index++;
if (page_in_index >= total_pages_in) {
if (page_in_index + 1 >= total_pages_in) {
ret = -1;
data_in = NULL;
goto done;
}
data_in = kmap(pages_in[page_in_index]);

if (may_late_unmap)
need_unmap = true;
else
kunmap(pages_in[page_in_index]);

data_in = kmap(pages_in[++page_in_index]);

in_page_bytes_left = PAGE_CACHE_SIZE;
in_offset = 0;
Expand All @@ -346,6 +352,8 @@ static int lzo_decompress_biovec(struct list_head *ws,
out_len = lzo1x_worst_compress(PAGE_CACHE_SIZE);
ret = lzo1x_decompress_safe(buf, in_len, workspace->buf,
&out_len);
if (need_unmap)
kunmap(pages_in[page_in_index - 1]);
if (ret != LZO_E_OK) {
printk(KERN_WARNING "btrfs decompress failed\n");
ret = -1;
Expand All @@ -363,8 +371,7 @@ static int lzo_decompress_biovec(struct list_head *ws,
break;
}
done:
if (data_in)
kunmap(pages_in[page_in_index]);
kunmap(pages_in[page_in_index]);
return ret;
}

Expand Down

0 comments on commit 0e7f835

Please sign in to comment.