Skip to contentSkip to conversation

erofs: don't calculate new start when expanding read length

PATCH In review Yue Hu 2 participants 3 messages May 25, 2023 EROFS file system

lore
Share & tools
lore

Yue Hu

author reviewer
#0 lore raw

PATCH 1/1 erofs: don't calculate new start when expanding read length

From: Yue Hu <[email protected]>

We only expand the trailing edge and not the leading edge. So no need to obtain new start again. Let's use the existing ->headoffset instead.

---
 fs/erofs/zdata.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
fs/erofs/zdata.c +5 -7
index 874fee35af32..bab8dcb8e848 100644
@@ -1828,26 +1828,24 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
 {
 	struct inode *inode = f->inode;
 	struct erofs_map_blocks *map = &f->map;
-	erofs_off_t cur, end;
+	erofs_off_t cur, end, headoffset = f->headoffset;
 	int err;
 
 	if (backmost) {
 		if (rac)
-			end = f->headoffset + readahead_length(rac) - 1;
+			end = headoffset + readahead_length(rac) - 1;
 		else
-			end = f->headoffset + PAGE_SIZE - 1;
+			end = headoffset + PAGE_SIZE - 1;
 		map->m_la = end;
 		err = z_erofs_map_blocks_iter(inode, map,
 					      EROFS_GET_BLOCKS_READMORE);
 		if (err)
 			return;
 
-		/* expend ra for the trailing edge if readahead */
+		/* expand ra for the trailing edge if readahead */
 		if (rac) {
-			loff_t newstart = readahead_pos(rac);
-
 			cur = round_up(map->m_la + map->m_llen, PAGE_SIZE);
-			readahead_expand(rac, newstart, cur - newstart);
+			readahead_expand(rac, headoffset, cur - headoffset);
 			return;
 		}
 		end = round_up(end, PAGE_SIZE);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 15 lines · Yue Hu

From: Yue Hu <[email protected]>

We only expand the trailing edge and not the leading edge. So no need to obtain new start again. Let's use the existing ->headoffset instead.

---
  fs/erofs/zdata.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)
fs/erofs/zdata.c +0 -0
index 874fee35af32..bab8dcb8e848 100644

fs/erofs/zdata.c static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f, · line 1831

Quoted 5 lines
fs/erofs/zdata.c +1 -1
@@ -1828,26 +1828,24 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
  {
  	struct inode *inode = f->inode;
  	struct erofs_map_blocks *map = &f->map;
-	erofs_off_t cur, end;
+	erofs_off_t cur, end, headoffset = f->headoffset;

That is not quite useful, or could you merge this info the original patch?

Thanks,
Gao Xiang

Quoted 26 lines
fs/erofs/zdata.c +4 -6
  	int err;
 
  	if (backmost) {
  		if (rac)
-			end = f->headoffset + readahead_length(rac) - 1;
+			end = headoffset + readahead_length(rac) - 1;
  		else
-			end = f->headoffset + PAGE_SIZE - 1;
+			end = headoffset + PAGE_SIZE - 1;
  		map->m_la = end;
  		err = z_erofs_map_blocks_iter(inode, map,
  					      EROFS_GET_BLOCKS_READMORE);
  		if (err)
  			return;
 
-		/* expend ra for the trailing edge if readahead */
+		/* expand ra for the trailing edge if readahead */
  		if (rac) {
-			loff_t newstart = readahead_pos(rac);
-
  			cur = round_up(map->m_la + map->m_llen, PAGE_SIZE);
-			readahead_expand(rac, newstart, cur - newstart);
+			readahead_expand(rac, headoffset, cur - headoffset);
  			return;
  		}
  		end = round_up(end, PAGE_SIZE);
author reviewer
#2 lore raw
Quoted 11 lines · On Thu, 25 May 2023 13:56:14 +0800 Gao Xiang <[email protected]>…
Quoted 10 lines · Yue Hu

From: Yue Hu <[email protected]>

We only expand the trailing edge and not the leading edge. So no need to obtain new start again. Let's use the existing ->headoffset instead.

---
  fs/erofs/zdata.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)
Quoted 13 lines

fs/erofs/zdata.c static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f, · line 1831

Quoted 10 lines
fs/erofs/zdata.c +1 -1
index 874fee35af32..bab8dcb8e848 100644
@@ -1828,26 +1828,24 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
  {
  	struct inode *inode = f->inode;
  	struct erofs_map_blocks *map = &f->map;
-	erofs_off_t cur, end;
+	erofs_off_t cur, end, headoffset = f->headoffset;  

That is not quite useful, or could you merge this info the original patch?

Okay, i will do the merge later.

Quoted 30 lines

Thanks,
Gao Xiang

Quoted 26 lines
fs/erofs/zdata.c +4 -6
  	int err;
 
  	if (backmost) {
  		if (rac)
-			end = f->headoffset + readahead_length(rac) - 1;
+			end = headoffset + readahead_length(rac) - 1;
  		else
-			end = f->headoffset + PAGE_SIZE - 1;
+			end = headoffset + PAGE_SIZE - 1;
  		map->m_la = end;
  		err = z_erofs_map_blocks_iter(inode, map,
  					      EROFS_GET_BLOCKS_READMORE);
  		if (err)
  			return;
 
-		/* expend ra for the trailing edge if readahead */
+		/* expand ra for the trailing edge if readahead */
  		if (rac) {
-			loff_t newstart = readahead_pos(rac);
-
  			cur = round_up(map->m_la + map->m_llen, PAGE_SIZE);
-			readahead_expand(rac, newstart, cur - newstart);
+			readahead_expand(rac, headoffset, cur - headoffset);
  			return;
  		}
  		end = round_up(end, PAGE_SIZE);