[WIP] [PATCH 04/12] erofs-utils: fuse: adjust larger extent handling

Gao Xiang hsiangkao at aol.com
Sat Oct 17 16:16:13 AEDT 2020


so more easy to understand.

[ let's fold in to the original patch. ]
Cc: Huang Jianan <huangjianan at oppo.com>
Signed-off-by: Gao Xiang <hsiangkao at aol.com>
---
 fuse/read.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fuse/read.c b/fuse/read.c
index 0d0e3b0fa468..dd44adaa1c40 100644
--- a/fuse/read.c
+++ b/fuse/read.c
@@ -112,12 +112,17 @@ size_t erofs_read_data_compression(struct erofs_vnode *vnode, char *buffer,
 						Z_EROFS_COMPRESSION_LZ4 :
 						Z_EROFS_COMPRESSION_SHIFTED;
 
-		if (end >= map.m_la + map.m_llen) {
-			count = map.m_llen;
-			partial = !(map.m_flags & EROFS_MAP_FULL_MAPPED);
-		} else {
+		/*
+		 * trim to the needed size if the returned extent is quite
+		 * larger than requested, and set up partial flag as well.
+		 */
+		if (end < map.m_la + map.m_llen) {
 			count = end - map.m_la;
 			partial = true;
+		} else {
+			ASSERT(end == map.m_la + map_m_llen);
+			count = map.m_llen;
+			partial = !(map.m_flags & EROFS_MAP_FULL_MAPPED);
 		}
 
 		if ((off_t)map.m_la < offset) {
-- 
2.24.0



More information about the Linux-erofs mailing list