[WIP] [PATCH 10/12] erofs-utils: fuse: cleanup erofs_read_data_compression()
Gao Xiang
hsiangkao at aol.com
Sat Oct 17 16:16:19 AEDT 2020
[ let's fold in to the original patch. ]
Signed-off-by: Gao Xiang <hsiangkao at aol.com>
---
fuse/read.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/fuse/read.c b/fuse/read.c
index 46be5cc64a90..f3aa628945e3 100644
--- a/fuse/read.c
+++ b/fuse/read.c
@@ -80,10 +80,10 @@ finished:
}
size_t erofs_read_data_compression(struct erofs_vnode *vnode, char *buffer,
- size_t size, off_t offset)
+ erofs_off_t size, erofs_off_t offset)
{
int ret;
- size_t end, count, ofs, sum = size;
+ erofs_off_t end, length, skip;
struct erofs_map_blocks map = {
.index = UINT_MAX,
};
@@ -91,8 +91,8 @@ size_t erofs_read_data_compression(struct erofs_vnode *vnode, char *buffer,
unsigned int algorithmformat;
char raw[EROFS_BLKSIZ];
- while (sum) {
- end = offset + sum;
+ end = offset + size;
+ while (end > offset) {
map.m_la = end - 1;
ret = z_erofs_map_blocks_iter(vnode, &map);
@@ -100,7 +100,7 @@ size_t erofs_read_data_compression(struct erofs_vnode *vnode, char *buffer,
return ret;
if (!(map.m_flags & EROFS_MAP_MAPPED)) {
- sum -= map.m_llen;
+ end = map.m_la;
continue;
}
@@ -117,28 +117,28 @@ size_t erofs_read_data_compression(struct erofs_vnode *vnode, char *buffer,
* larger than requested, and set up partial flag as well.
*/
if (end < map.m_la + map.m_llen) {
- count = end - map.m_la;
+ length = end - map.m_la;
partial = true;
} else {
ASSERT(end == map.m_la + map_m_llen);
- count = map.m_llen;
+ length = map.m_llen;
partial = !(map.m_flags & EROFS_MAP_FULL_MAPPED);
}
- if ((off_t)map.m_la < offset) {
- ofs = offset - map.m_la;
- sum = 0;
+ if (map.m_la < offset) {
+ skip = offset - map.m_la;
+ end = offset;
} else {
- ofs = 0;
- sum -= count;
+ skip = 0;
+ end = map.m_la;
}
ret = z_erofs_decompress(&(struct z_erofs_decompress_req) {
.in = raw,
- .out = buffer + sum,
- .decodedskip = ofs,
- .inputsize = EROFS_BLKSIZ,
- .decodedlength = count,
+ .out = buffer + end - offset,
+ .decodedskip = skip,
+ .inputsize = map.m_plen,
+ .decodedlength = length,
.alg = algorithmformat,
.partial_decoding = partial
});
--
2.24.0
More information about the Linux-erofs
mailing list