Linux-EROFS Archive on lore.kernel.org
 help / color / Atom feed
From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Cc: Zhang Shiming <zhangshiming@oppo.com>, Guo Weichao <guoweichao@oppo.com>
Subject: [WIP] [PATCH 10/12] erofs-utils: fuse: cleanup erofs_read_data_compression()
Date: Sat, 17 Oct 2020 13:16:19 +0800
Message-ID: <20201017051621.7810-11-hsiangkao@aol.com> (raw)
In-Reply-To: <20201017051621.7810-1-hsiangkao@aol.com>

[ let's fold in to the original patch. ]
Signed-off-by: Gao Xiang <hsiangkao@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


  parent reply index

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201017051621.7810-1-hsiangkao.ref@aol.com>
2020-10-17  5:16 ` [WIP] [PATCH 00/12] erofs-utils: introduce fuse implementation Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 01/12] " Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 02/12] erofs-utils: fuse: support read special file Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 03/12] erofs-utils: fuse: support read compressed file Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 04/12] erofs-utils: fuse: adjust larger extent handling Gao Xiang via Linux-erofs
2020-10-19  3:13     ` 回复: " huangjianan
2020-10-19  3:32       ` Gao Xiang via Linux-erofs
2020-10-19  4:49         ` 回复: " Huang Jianan
2020-10-19  3:37     ` 回复: " Huang Jianan
2020-10-19  3:43       ` Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 05/12] erofs-utils: fuse: use proper expression about inode size Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 06/12] erofs-utils: fuse: drop ofs_out Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 07/12] erofs-utils: fuse: refuse a undefined shifted cluster behavior Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 08/12] erofs-utils: fuse: drop z_erofs_shifted_transform() Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 09/12] erofs-utils: fuse: rename ofs_head and outputsize Gao Xiang via Linux-erofs
2020-10-17  5:16   ` Gao Xiang via Linux-erofs [this message]
2020-10-17  5:16   ` [WIP] [PATCH 11/12] erofs-utils: fuse: move up mpage in struct erofs_map_blocks Gao Xiang via Linux-erofs
2020-10-17  5:16   ` [WIP] [PATCH 12/12] erofs-utils: fuse: fix up source headers Gao Xiang via Linux-erofs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201017051621.7810-11-hsiangkao@aol.com \
    --to=linux-erofs@lists.ozlabs.org \
    --cc=guoweichao@oppo.com \
    --cc=hsiangkao@aol.com \
    --cc=zhangshiming@oppo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-EROFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-erofs/0 linux-erofs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-erofs linux-erofs/ https://lore.kernel.org/linux-erofs \
		linux-erofs@lists.ozlabs.org linux-erofs@ozlabs.org
	public-inbox-index linux-erofs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linux-erofs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git