mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 3/4] erofs: Don't use certain internal folio_*() functions
@ 2024-01-15  8:33 Gao Xiang
  2024-01-15 14:06 ` Matthew Wilcox
  2024-01-15 14:46 ` [PATCH v3 3/4] erofs: Don't use certain unnecessary " Gao Xiang
  0 siblings, 2 replies; 4+ messages in thread
From: Gao Xiang @ 2024-01-15  8:33 UTC (permalink / raw)
  To: linux-cachefs, linux-fsdevel, linux-erofs, David Howells,
	Christian Brauner, Jeff Layton
  Cc: LKML, Matthew Wilcox, Chao Yu, Yue Hu, Jeffle Xu, Gao Xiang

From: David Howells <dhowells@redhat.com>

Filesystems should use folio->index and folio->mapping, instead of
folio_index(folio), folio_mapping() and folio_file_mapping() since
they know that it's in the pagecache.

Change this automagically with:

perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/erofs/*.c

Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Cc: Chao Yu <chao@kernel.org>
Cc: Yue Hu <huyue2@coolpad.com>
Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: linux-erofs@lists.ozlabs.org
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
Hi folks,

I tend to apply this patch upstream since compressed data fscache
adaption touches this part too.  If there is no objection, I'm
going to take this patch separately for -next shortly..

Thanks,
Gao Xiang

Change since v1:
 - a better commit message pointed out by Jeff Layton.

 fs/erofs/fscache.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 87ff35bff8d5..bc12030393b2 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -165,10 +165,10 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
 static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
 {
 	int ret;
-	struct erofs_fscache *ctx = folio_mapping(folio)->host->i_private;
+	struct erofs_fscache *ctx = folio->mapping->host->i_private;
 	struct erofs_fscache_request *req;
 
-	req = erofs_fscache_req_alloc(folio_mapping(folio),
+	req = erofs_fscache_req_alloc(folio->mapping,
 				folio_pos(folio), folio_size(folio));
 	if (IS_ERR(req)) {
 		folio_unlock(folio);
@@ -276,7 +276,7 @@ static int erofs_fscache_read_folio(struct file *file, struct folio *folio)
 	struct erofs_fscache_request *req;
 	int ret;
 
-	req = erofs_fscache_req_alloc(folio_mapping(folio),
+	req = erofs_fscache_req_alloc(folio->mapping,
 			folio_pos(folio), folio_size(folio));
 	if (IS_ERR(req)) {
 		folio_unlock(folio);
-- 
2.39.3


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

* Re: [PATCH v2 3/4] erofs: Don't use certain internal folio_*() functions
  2024-01-15  8:33 [PATCH v2 3/4] erofs: Don't use certain internal folio_*() functions Gao Xiang
@ 2024-01-15 14:06 ` Matthew Wilcox
  2024-01-15 14:39   ` Gao Xiang
  2024-01-15 14:46 ` [PATCH v3 3/4] erofs: Don't use certain unnecessary " Gao Xiang
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Wilcox @ 2024-01-15 14:06 UTC (permalink / raw)
  To: Gao Xiang
  Cc: linux-cachefs, linux-fsdevel, linux-erofs, David Howells,
	Christian Brauner, Jeff Layton, LKML, Chao Yu, Yue Hu, Jeffle Xu

On Mon, Jan 15, 2024 at 04:33:37PM +0800, Gao Xiang wrote:
> From: David Howells <dhowells@redhat.com>
> 
> Filesystems should use folio->index and folio->mapping, instead of
> folio_index(folio), folio_mapping() and folio_file_mapping() since
> they know that it's in the pagecache.
> 
> Change this automagically with:
> 
> perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
> perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
> perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/erofs/*.c
> 
> Reported-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: David Howells <dhowells@redhat.com>
> Reviewed-by: Jeff Layton <jlayton@kernel.org>
> Cc: Chao Yu <chao@kernel.org>
> Cc: Yue Hu <huyue2@coolpad.com>
> Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
> Cc: linux-erofs@lists.ozlabs.org
> Cc: linux-fsdevel@vger.kernel.org
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> ---
> Hi folks,
> 
> I tend to apply this patch upstream since compressed data fscache
> adaption touches this part too.  If there is no objection, I'm
> going to take this patch separately for -next shortly..

Could you change the subject?  It's not that the functions are
"internal", it's that filesystems don't need to use them because they're
guaranteed to not see swap pages.  Maybe just s/internal/unnecessary/

> Thanks,
> Gao Xiang
> 
> Change since v1:
>  - a better commit message pointed out by Jeff Layton.
> 
>  fs/erofs/fscache.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 87ff35bff8d5..bc12030393b2 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -165,10 +165,10 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
>  static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
>  {
>  	int ret;
> -	struct erofs_fscache *ctx = folio_mapping(folio)->host->i_private;
> +	struct erofs_fscache *ctx = folio->mapping->host->i_private;
>  	struct erofs_fscache_request *req;
>  
> -	req = erofs_fscache_req_alloc(folio_mapping(folio),
> +	req = erofs_fscache_req_alloc(folio->mapping,
>  				folio_pos(folio), folio_size(folio));
>  	if (IS_ERR(req)) {
>  		folio_unlock(folio);
> @@ -276,7 +276,7 @@ static int erofs_fscache_read_folio(struct file *file, struct folio *folio)
>  	struct erofs_fscache_request *req;
>  	int ret;
>  
> -	req = erofs_fscache_req_alloc(folio_mapping(folio),
> +	req = erofs_fscache_req_alloc(folio->mapping,
>  			folio_pos(folio), folio_size(folio));
>  	if (IS_ERR(req)) {
>  		folio_unlock(folio);
> -- 
> 2.39.3
> 

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

* Re: [PATCH v2 3/4] erofs: Don't use certain internal folio_*() functions
  2024-01-15 14:06 ` Matthew Wilcox
@ 2024-01-15 14:39   ` Gao Xiang
  0 siblings, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2024-01-15 14:39 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-cachefs, linux-fsdevel, linux-erofs, David Howells,
	Christian Brauner, Jeff Layton, LKML, Chao Yu, Yue Hu, Jeffle Xu

Hi Matthew,

On 2024/1/15 22:06, Matthew Wilcox wrote:
> On Mon, Jan 15, 2024 at 04:33:37PM +0800, Gao Xiang wrote:
>> From: David Howells <dhowells@redhat.com>
>>
>> Filesystems should use folio->index and folio->mapping, instead of
>> folio_index(folio), folio_mapping() and folio_file_mapping() since
>> they know that it's in the pagecache.
>>
>> Change this automagically with:
>>
>> perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
>> perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
>> perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/erofs/*.c
>>
>> Reported-by: Matthew Wilcox <willy@infradead.org>
>> Signed-off-by: David Howells <dhowells@redhat.com>
>> Reviewed-by: Jeff Layton <jlayton@kernel.org>
>> Cc: Chao Yu <chao@kernel.org>
>> Cc: Yue Hu <huyue2@coolpad.com>
>> Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
>> Cc: linux-erofs@lists.ozlabs.org
>> Cc: linux-fsdevel@vger.kernel.org
>> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
>> ---
>> Hi folks,
>>
>> I tend to apply this patch upstream since compressed data fscache
>> adaption touches this part too.  If there is no objection, I'm
>> going to take this patch separately for -next shortly..
> 
> Could you change the subject?  It's not that the functions are
> "internal", it's that filesystems don't need to use them because they're
> guaranteed to not see swap pages.  Maybe just s/internal/unnecessary/

Yes, the subject line was inherited from the original one.

Such helpers are useful if the type of a folio is unknown,
let me revise it.

Thanks,
Gao Xiang

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

* [PATCH v3 3/4] erofs: Don't use certain unnecessary folio_*() functions
  2024-01-15  8:33 [PATCH v2 3/4] erofs: Don't use certain internal folio_*() functions Gao Xiang
  2024-01-15 14:06 ` Matthew Wilcox
@ 2024-01-15 14:46 ` Gao Xiang
  1 sibling, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2024-01-15 14:46 UTC (permalink / raw)
  To: linux-cachefs, linux-fsdevel, linux-erofs, David Howells,
	Christian Brauner, Jeff Layton, Matthew Wilcox
  Cc: LKML, Chao Yu, Yue Hu, Jeffle Xu, Gao Xiang

From: David Howells <dhowells@redhat.com>

Filesystems should use folio->index and folio->mapping, instead of
folio_index(folio), folio_mapping() and folio_file_mapping() since
they know that it's in the pagecache.

Change this automagically with:

perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/erofs/*.c

Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Cc: Chao Yu <chao@kernel.org>
Cc: Yue Hu <huyue2@coolpad.com>
Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: linux-erofs@lists.ozlabs.org
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
change since v2:
 - update the words s/internal/unnecessary/ in the subject line
   pointed out by Matthew.

 fs/erofs/fscache.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 87ff35bff8d5..bc12030393b2 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -165,10 +165,10 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
 static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
 {
 	int ret;
-	struct erofs_fscache *ctx = folio_mapping(folio)->host->i_private;
+	struct erofs_fscache *ctx = folio->mapping->host->i_private;
 	struct erofs_fscache_request *req;
 
-	req = erofs_fscache_req_alloc(folio_mapping(folio),
+	req = erofs_fscache_req_alloc(folio->mapping,
 				folio_pos(folio), folio_size(folio));
 	if (IS_ERR(req)) {
 		folio_unlock(folio);
@@ -276,7 +276,7 @@ static int erofs_fscache_read_folio(struct file *file, struct folio *folio)
 	struct erofs_fscache_request *req;
 	int ret;
 
-	req = erofs_fscache_req_alloc(folio_mapping(folio),
+	req = erofs_fscache_req_alloc(folio->mapping,
 			folio_pos(folio), folio_size(folio));
 	if (IS_ERR(req)) {
 		folio_unlock(folio);
-- 
2.39.3


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

end of thread, other threads:[~2024-01-15 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-15  8:33 [PATCH v2 3/4] erofs: Don't use certain internal folio_*() functions Gao Xiang
2024-01-15 14:06 ` Matthew Wilcox
2024-01-15 14:39   ` Gao Xiang
2024-01-15 14:46 ` [PATCH v3 3/4] erofs: Don't use certain unnecessary " Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®