mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] erofs: Revert "erofs: fix kvcalloc() misuse with __GFP_NOFAIL"
@ 2023-03-09  5:31 Gao Xiang
  2023-03-09  5:31 ` [PATCH 2/2] erofs: get rid of an useless DBG_BUGON Gao Xiang
  2023-03-09 14:30 ` [PATCH 1/2] erofs: Revert "erofs: fix kvcalloc() misuse with __GFP_NOFAIL" Chao Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Gao Xiang @ 2023-03-09  5:31 UTC (permalink / raw)
  To: linux-erofs; +Cc: LKML, Gao Xiang

Let's revert commit 12724ba38992 ("erofs: fix kvcalloc() misuse with
__GFP_NOFAIL") since kvmalloc() already supports __GFP_NOFAIL in commit
a421ef303008 ("mm: allow !GFP_KERNEL allocations for kvmalloc").  So
the original fix was wrong.

Actually there was some issue as [1] discussed, so before that mm fix
is landed, the warn could still happen but applying this commit first
will cause less.

[1] https://lore.kernel.org/r/20230305053035.1911-1-hsiangkao@linux.alibaba.com
Fixes: 12724ba38992 ("erofs: fix kvcalloc() misuse with __GFP_NOFAIL")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 fs/erofs/zdata.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 3247d2422bea..f1708c77a991 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1312,12 +1312,12 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
 
 	if (!be->decompressed_pages)
 		be->decompressed_pages =
-			kcalloc(be->nr_pages, sizeof(struct page *),
-				GFP_KERNEL | __GFP_NOFAIL);
+			kvcalloc(be->nr_pages, sizeof(struct page *),
+				 GFP_KERNEL | __GFP_NOFAIL);
 	if (!be->compressed_pages)
 		be->compressed_pages =
-			kcalloc(pclusterpages, sizeof(struct page *),
-				GFP_KERNEL | __GFP_NOFAIL);
+			kvcalloc(pclusterpages, sizeof(struct page *),
+				 GFP_KERNEL | __GFP_NOFAIL);
 
 	z_erofs_parse_out_bvecs(be);
 	err2 = z_erofs_parse_in_bvecs(be, &overlapped);
@@ -1365,7 +1365,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
 	}
 	if (be->compressed_pages < be->onstack_pages ||
 	    be->compressed_pages >= be->onstack_pages + Z_EROFS_ONSTACK_PAGES)
-		kfree(be->compressed_pages);
+		kvfree(be->compressed_pages);
 	z_erofs_fill_other_copies(be, err);
 
 	for (i = 0; i < be->nr_pages; ++i) {
@@ -1384,7 +1384,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
 	}
 
 	if (be->decompressed_pages != be->onstack_pages)
-		kfree(be->decompressed_pages);
+		kvfree(be->decompressed_pages);
 
 	pcl->length = 0;
 	pcl->partial = true;
-- 
2.24.4


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

* [PATCH 2/2] erofs: get rid of an useless DBG_BUGON
  2023-03-09  5:31 [PATCH 1/2] erofs: Revert "erofs: fix kvcalloc() misuse with __GFP_NOFAIL" Gao Xiang
@ 2023-03-09  5:31 ` Gao Xiang
  2023-03-09 14:34   ` Chao Yu
  2023-03-09 14:30 ` [PATCH 1/2] erofs: Revert "erofs: fix kvcalloc() misuse with __GFP_NOFAIL" Chao Yu
  1 sibling, 1 reply; 4+ messages in thread
From: Gao Xiang @ 2023-03-09  5:31 UTC (permalink / raw)
  To: linux-erofs; +Cc: LKML, Gao Xiang

`err` could be -EINTR and it should not be the case.  Actually such
DBG_BUGON is useless.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 fs/erofs/zmap.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index 8bf6d30518b6..655da4d739cb 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -757,9 +757,6 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
 	err = z_erofs_do_map_blocks(inode, map, flags);
 out:
 	trace_z_erofs_map_blocks_iter_exit(inode, map, flags, err);
-
-	/* aggressively BUG_ON iff CONFIG_EROFS_FS_DEBUG is on */
-	DBG_BUGON(err < 0 && err != -ENOMEM);
 	return err;
 }
 
-- 
2.24.4


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

* Re: [PATCH 1/2] erofs: Revert "erofs: fix kvcalloc() misuse with __GFP_NOFAIL"
  2023-03-09  5:31 [PATCH 1/2] erofs: Revert "erofs: fix kvcalloc() misuse with __GFP_NOFAIL" Gao Xiang
  2023-03-09  5:31 ` [PATCH 2/2] erofs: get rid of an useless DBG_BUGON Gao Xiang
@ 2023-03-09 14:30 ` Chao Yu
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2023-03-09 14:30 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs; +Cc: LKML



On 2023/3/9 13:31, Gao Xiang wrote:
> Let's revert commit 12724ba38992 ("erofs: fix kvcalloc() misuse with
> __GFP_NOFAIL") since kvmalloc() already supports __GFP_NOFAIL in commit
> a421ef303008 ("mm: allow !GFP_KERNEL allocations for kvmalloc").  So
> the original fix was wrong.
> 
> Actually there was some issue as [1] discussed, so before that mm fix
> is landed, the warn could still happen but applying this commit first
> will cause less.
> 
> [1] https://lore.kernel.org/r/20230305053035.1911-1-hsiangkao@linux.alibaba.com
> Fixes: 12724ba38992 ("erofs: fix kvcalloc() misuse with __GFP_NOFAIL")
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

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

* Re: [PATCH 2/2] erofs: get rid of an useless DBG_BUGON
  2023-03-09  5:31 ` [PATCH 2/2] erofs: get rid of an useless DBG_BUGON Gao Xiang
@ 2023-03-09 14:34   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2023-03-09 14:34 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs; +Cc: LKML

On 2023/3/9 13:31, Gao Xiang wrote:
> `err` could be -EINTR and it should not be the case.  Actually such
> DBG_BUGON is useless.
> 
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

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

end of thread, other threads:[~2023-03-09 14:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09  5:31 [PATCH 1/2] erofs: Revert "erofs: fix kvcalloc() misuse with __GFP_NOFAIL" Gao Xiang
2023-03-09  5:31 ` [PATCH 2/2] erofs: get rid of an useless DBG_BUGON Gao Xiang
2023-03-09 14:34   ` Chao Yu
2023-03-09 14:30 ` [PATCH 1/2] erofs: Revert "erofs: fix kvcalloc() misuse with __GFP_NOFAIL" Chao Yu

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®