linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs: remove end parameter from z_erofs_pcluster_readmore()
@ 2023-05-24 10:13 Yue Hu
  2023-05-24 10:45 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Yue Hu @ 2023-05-24 10:13 UTC (permalink / raw)
  To: xiang, chao, jefflexu, linux-erofs; +Cc: linux-kernel, huyue2, zhangwen

From: Yue Hu <huyue2@coolpad.com>

The `end` argument is pointless if it's not backmost.  And we already
have `headoffset` in struct `*f`, so let's use this offset to get the
`end` for backmost only instead in this function.

Also, remove linux/prefetch.h since it's not used anymore after commit
386292919c25 ("erofs: introduce readmore decompression strategy").

Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
 fs/erofs/zdata.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 5cd971bcf95e..b7ebdc8f2135 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -5,7 +5,6 @@
  * Copyright (C) 2022 Alibaba Cloud
  */
 #include "compress.h"
-#include <linux/prefetch.h>
 #include <linux/psi.h>
 #include <linux/cpuhotplug.h>
 #include <trace/events/erofs.h>
@@ -1825,16 +1824,16 @@ static void z_erofs_runqueue(struct z_erofs_decompress_frontend *f,
  */
 static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
 				      struct readahead_control *rac,
-				      erofs_off_t end,
-				      struct page **pagepool,
-				      bool backmost)
+				      struct page **pagepool, bool backmost)
 {
 	struct inode *inode = f->inode;
 	struct erofs_map_blocks *map = &f->map;
-	erofs_off_t cur;
+	erofs_off_t cur, end;
 	int err;
 
 	if (backmost) {
+		end = f->headoffset +
+		      rac ? readahead_length(rac) : PAGE_SIZE - 1;
 		map->m_la = end;
 		err = z_erofs_map_blocks_iter(inode, map,
 					      EROFS_GET_BLOCKS_READMORE);
@@ -1894,10 +1893,9 @@ static int z_erofs_read_folio(struct file *file, struct folio *folio)
 	trace_erofs_readpage(page, false);
 	f.headoffset = (erofs_off_t)page->index << PAGE_SHIFT;
 
-	z_erofs_pcluster_readmore(&f, NULL, f.headoffset + PAGE_SIZE - 1,
-				  &pagepool, true);
+	z_erofs_pcluster_readmore(&f, NULL, &pagepool, true);
 	err = z_erofs_do_read_page(&f, page, &pagepool);
-	z_erofs_pcluster_readmore(&f, NULL, 0, &pagepool, false);
+	z_erofs_pcluster_readmore(&f, NULL, &pagepool, false);
 
 	(void)z_erofs_collector_end(&f);
 
@@ -1923,8 +1921,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
 
 	f.headoffset = readahead_pos(rac);
 
-	z_erofs_pcluster_readmore(&f, rac, f.headoffset +
-				  readahead_length(rac) - 1, &pagepool, true);
+	z_erofs_pcluster_readmore(&f, rac, &pagepool, true);
 	nr_pages = readahead_count(rac);
 	trace_erofs_readpages(inode, readahead_index(rac), nr_pages, false);
 
@@ -1947,7 +1944,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
 				  page->index, EROFS_I(inode)->nid);
 		put_page(page);
 	}
-	z_erofs_pcluster_readmore(&f, rac, 0, &pagepool, false);
+	z_erofs_pcluster_readmore(&f, rac, &pagepool, false);
 	(void)z_erofs_collector_end(&f);
 
 	z_erofs_runqueue(&f, &pagepool,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] erofs: remove end parameter from z_erofs_pcluster_readmore()
  2023-05-24 10:13 [PATCH] erofs: remove end parameter from z_erofs_pcluster_readmore() Yue Hu
@ 2023-05-24 10:45 ` Gao Xiang
  2023-05-24 11:15   ` Yue Hu
  0 siblings, 1 reply; 3+ messages in thread
From: Gao Xiang @ 2023-05-24 10:45 UTC (permalink / raw)
  To: Yue Hu, xiang, chao, jefflexu, linux-erofs; +Cc: linux-kernel, huyue2, zhangwen



On 2023/5/24 03:13, Yue Hu wrote:
> From: Yue Hu <huyue2@coolpad.com>
> 
> The `end` argument is pointless if it's not backmost.  And we already
> have `headoffset` in struct `*f`, so let's use this offset to get the
> `end` for backmost only instead in this function.
> 
> Also, remove linux/prefetch.h since it's not used anymore after commit
> 386292919c25 ("erofs: introduce readmore decompression strategy").
> 
> Signed-off-by: Yue Hu <huyue2@coolpad.com>
> --->   fs/erofs/zdata.c | 19 ++++++++-----------
>   1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
> index 5cd971bcf95e..b7ebdc8f2135 100644
> --- a/fs/erofs/zdata.c
> +++ b/fs/erofs/zdata.c
> @@ -5,7 +5,6 @@
>    * Copyright (C) 2022 Alibaba Cloud
>    */
>   #include "compress.h"
> -#include <linux/prefetch.h>
>   #include <linux/psi.h>
>   #include <linux/cpuhotplug.h>
>   #include <trace/events/erofs.h>
> @@ -1825,16 +1824,16 @@ static void z_erofs_runqueue(struct z_erofs_decompress_frontend *f,
>    */
>   static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
>   				      struct readahead_control *rac,
> -				      erofs_off_t end,
> -				      struct page **pagepool,
> -				      bool backmost)
> +				      struct page **pagepool, bool backmost)
>   {
>   	struct inode *inode = f->inode;
>   	struct erofs_map_blocks *map = &f->map;
> -	erofs_off_t cur;
> +	erofs_off_t cur, end;
>   	int err;
>   
>   	if (backmost) {
> +		end = f->headoffset +
> +		      rac ? readahead_length(rac) : PAGE_SIZE - 1;

		could we avoid "?:" here for readability?

Thanks,
Gao Xiang

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] erofs: remove end parameter from z_erofs_pcluster_readmore()
  2023-05-24 10:45 ` Gao Xiang
@ 2023-05-24 11:15   ` Yue Hu
  0 siblings, 0 replies; 3+ messages in thread
From: Yue Hu @ 2023-05-24 11:15 UTC (permalink / raw)
  To: Gao Xiang
  Cc: xiang, chao, jefflexu, linux-erofs, linux-kernel, huyue2, zhangwen

On Wed, 24 May 2023 18:45:48 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:

> On 2023/5/24 03:13, Yue Hu wrote:
> > From: Yue Hu <huyue2@coolpad.com>
> > 
> > The `end` argument is pointless if it's not backmost.  And we already
> > have `headoffset` in struct `*f`, so let's use this offset to get the
> > `end` for backmost only instead in this function.
> > 
> > Also, remove linux/prefetch.h since it's not used anymore after commit
> > 386292919c25 ("erofs: introduce readmore decompression strategy").
> > 
> > Signed-off-by: Yue Hu <huyue2@coolpad.com>  
> > --->   fs/erofs/zdata.c | 19 ++++++++-----------  
> >   1 file changed, 8 insertions(+), 11 deletions(-)
> > 
> > diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
> > index 5cd971bcf95e..b7ebdc8f2135 100644
> > --- a/fs/erofs/zdata.c
> > +++ b/fs/erofs/zdata.c
> > @@ -5,7 +5,6 @@
> >    * Copyright (C) 2022 Alibaba Cloud
> >    */
> >   #include "compress.h"
> > -#include <linux/prefetch.h>
> >   #include <linux/psi.h>
> >   #include <linux/cpuhotplug.h>
> >   #include <trace/events/erofs.h>
> > @@ -1825,16 +1824,16 @@ static void z_erofs_runqueue(struct z_erofs_decompress_frontend *f,
> >    */
> >   static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f,
> >   				      struct readahead_control *rac,
> > -				      erofs_off_t end,
> > -				      struct page **pagepool,
> > -				      bool backmost)
> > +				      struct page **pagepool, bool backmost)
> >   {
> >   	struct inode *inode = f->inode;
> >   	struct erofs_map_blocks *map = &f->map;
> > -	erofs_off_t cur;
> > +	erofs_off_t cur, end;
> >   	int err;
> >   
> >   	if (backmost) {
> > +		end = f->headoffset +
> > +		      rac ? readahead_length(rac) : PAGE_SIZE - 1;  
> 
> 		could we avoid "?:" here for readability?

Ok, let me change to use if-else branch.
And seems 'newstart' should be just `f->headoffset`.
I will send v2 later.

> 
> Thanks,
> Gao Xiang


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-24 11:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 10:13 [PATCH] erofs: remove end parameter from z_erofs_pcluster_readmore() Yue Hu
2023-05-24 10:45 ` Gao Xiang
2023-05-24 11:15   ` Yue Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).