erofs: fix missing continue for !shouldalloc in z_erofs_bind_cache()

Message ID 20221206053633.4251-1-zbestahu@gmail.com
State New
Headers
Series erofs: fix missing continue for !shouldalloc in z_erofs_bind_cache() |

Commit Message

Yue Hu Dec. 6, 2022, 5:36 a.m. UTC
  From: Yue Hu <huyue2@coolpad.com>

Do cmpxchg_relaxed() is only for successful allocation if I/O is needed.

Fixes: 69b511baa0be ("erofs: clean up cached I/O strategies")
Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
 fs/erofs/zdata.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
  

Comments

Gao Xiang Dec. 6, 2022, 5:59 a.m. UTC | #1
Hi Yue,

On Tue, Dec 06, 2022 at 01:36:33PM +0800, Yue Hu wrote:
> From: Yue Hu <huyue2@coolpad.com>
> 
> Do cmpxchg_relaxed() is only for successful allocation if I/O is needed.
> 
> Fixes: 69b511baa0be ("erofs: clean up cached I/O strategies")
> Signed-off-by: Yue Hu <huyue2@coolpad.com>

Thanks for the catch, it looks good to me.

Let's fold this into the original patch.

Thanks,
Gao Xiang
  

Patch

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 2584a62c9d28..b66c16473273 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -333,19 +333,19 @@  static void z_erofs_bind_cache(struct z_erofs_decompress_frontend *fe,
 		} else {
 			/* I/O is needed, no possible to decompress directly */
 			standalone = false;
-			if (shouldalloc) {
-				/*
-				 * try to use cached I/O if page allocation
-				 * succeeds or fallback to in-place I/O instead
-				 * to avoid any direct reclaim.
-				 */
-				newpage = erofs_allocpage(pagepool, gfp);
-				if (!newpage)
-					continue;
-				set_page_private(newpage,
-						 Z_EROFS_PREALLOCATED_PAGE);
-				t = tag_compressed_page_justfound(newpage);
-			}
+			if (!shouldalloc)
+				continue;
+
+			/*
+			 * try to use cached I/O if page allocation
+			 * succeeds or fallback to in-place I/O instead
+			 * to avoid any direct reclaim.
+			 */
+			newpage = erofs_allocpage(pagepool, gfp);
+			if (!newpage)
+				continue;
+			set_page_private(newpage, Z_EROFS_PREALLOCATED_PAGE);
+			t = tag_compressed_page_justfound(newpage);
 		}
 
 		if (!cmpxchg_relaxed(&pcl->compressed_bvecs[i].page, NULL,