linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4
@ 2019-07-29  6:51 Gao Xiang
  2019-07-29  6:51 ` [PATCH 01/22] staging: erofs: update source file headers Gao Xiang
                   ` (21 more replies)
  0 siblings, 22 replies; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

This patchset includes all meaningful modifications till now according
to erofs-outofstaging v4:
https://lore.kernel.org/linux-fsdevel/20190725095658.155779-1-gaoxiang25@huawei.com/

Some empty lines which were add or delete are not included in this
patchset, I will send erofs-outofstaging v5 later in order to keep
main code bit-for-bit identical with this staging patchset.

Thanks,
Gao Xiang

Gao Xiang (22):
  staging: erofs: update source file headers
  staging: erofs: rename source files for better understanding
  staging: erofs: fix dummy functions erofs_{get,list}xattr
  staging: erofs: keep up erofs_fs.h with erofs-outofstaging patchset
  staging: erofs: sunset erofs_workstn_{lock,unlock}
  staging: erofs: clean up internal.h
  staging: erofs: remove redundant #include "internal.h"
  staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES
  staging: erofs: clean up shrinker stuffs
  staging: erofs: kill sbi->dev_name
  staging: erofs: kill all failure handling in fill_super()
  staging: erofs: refine erofs_allocpage()
  staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM
  staging: erofs: tidy up zpvec.h
  staging: erofs: remove redundant braces in inode.c
  staging: erofs: tidy up decompression frontend
  staging: erofs: remove clusterbits in sbi
  staging: erofs: turn cache strategies into mount options
  staging: erofs: tidy up utils.c
  staging: erofs: tidy up internal.h
  staging: erofs: update super.c
  staging: erofs: update Kconfig

 .../erofs/Documentation/filesystems/erofs.txt |   10 +
 drivers/staging/erofs/Kconfig                 |  111 +-
 drivers/staging/erofs/Makefile                |    4 +-
 drivers/staging/erofs/compress.h              |    2 +-
 drivers/staging/erofs/data.c                  |    8 +-
 drivers/staging/erofs/decompressor.c          |   44 +-
 drivers/staging/erofs/dir.c                   |    6 +-
 drivers/staging/erofs/erofs_fs.h              |   47 +-
 .../erofs/include/trace/events/erofs.h        |    2 +-
 drivers/staging/erofs/inode.c                 |   24 +-
 drivers/staging/erofs/internal.h              |  244 +--
 drivers/staging/erofs/namei.c                 |    7 +-
 drivers/staging/erofs/super.c                 |  268 ++-
 .../erofs/{include/linux => }/tagptr.h        |   12 +-
 drivers/staging/erofs/unzip_vle.c             | 1591 -----------------
 drivers/staging/erofs/utils.c                 |  112 +-
 drivers/staging/erofs/xattr.c                 |    6 +-
 drivers/staging/erofs/xattr.h                 |   22 +-
 drivers/staging/erofs/zdata.c                 | 1408 +++++++++++++++
 .../staging/erofs/{unzip_vle.h => zdata.h}    |  119 +-
 drivers/staging/erofs/zmap.c                  |    5 +-
 .../erofs/{unzip_pagevec.h => zpvec.h}        |   41 +-
 22 files changed, 1853 insertions(+), 2240 deletions(-)
 rename drivers/staging/erofs/{include/linux => }/tagptr.h (94%)
 delete mode 100644 drivers/staging/erofs/unzip_vle.c
 create mode 100644 drivers/staging/erofs/zdata.c
 rename drivers/staging/erofs/{unzip_vle.h => zdata.h} (56%)
 rename drivers/staging/erofs/{unzip_pagevec.h => zpvec.h} (78%)

-- 
2.17.1


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

* [PATCH 01/22] staging: erofs: update source file headers
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-30  7:20   ` Greg Kroah-Hartman
  2019-07-31  6:36   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 02/22] staging: erofs: rename source files for better understanding Gao Xiang
                   ` (20 subsequent siblings)
  21 siblings, 2 replies; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

- Use the correct style for all SPDX License Identifiers;
- Get rid of the unnecessary license boilerplate;
- Use "GPL-2.0-only" instead of "GPL-2.0" suggested-by Stephen.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/Kconfig                      | 2 +-
 drivers/staging/erofs/Makefile                     | 2 +-
 drivers/staging/erofs/compress.h                   | 2 +-
 drivers/staging/erofs/data.c                       | 6 +-----
 drivers/staging/erofs/decompressor.c               | 2 +-
 drivers/staging/erofs/dir.c                        | 6 +-----
 drivers/staging/erofs/erofs_fs.h                   | 8 ++------
 drivers/staging/erofs/include/linux/tagptr.h       | 6 +++---
 drivers/staging/erofs/include/trace/events/erofs.h | 2 +-
 drivers/staging/erofs/inode.c                      | 6 +-----
 drivers/staging/erofs/internal.h                   | 8 ++------
 drivers/staging/erofs/namei.c                      | 6 +-----
 drivers/staging/erofs/super.c                      | 6 +-----
 drivers/staging/erofs/unzip_pagevec.h              | 8 ++------
 drivers/staging/erofs/unzip_vle.c                  | 6 +-----
 drivers/staging/erofs/unzip_vle.h                  | 8 ++------
 drivers/staging/erofs/utils.c                      | 7 +------
 drivers/staging/erofs/xattr.c                      | 6 +-----
 drivers/staging/erofs/xattr.h                      | 8 ++------
 drivers/staging/erofs/zmap.c                       | 2 +-
 20 files changed, 27 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig
index d04b798a8efb..2577cbb46a5b 100644
--- a/drivers/staging/erofs/Kconfig
+++ b/drivers/staging/erofs/Kconfig
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: GPL-2.0
+# SPDX-License-Identifier: GPL-2.0-only
 
 config EROFS_FS
 	tristate "EROFS filesystem support"
diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile
index e704d9e51514..3ade87e78d06 100644
--- a/drivers/staging/erofs/Makefile
+++ b/drivers/staging/erofs/Makefile
@@ -1,4 +1,4 @@
-# SPDX-License-Identifier: GPL-2.0
+# SPDX-License-Identifier: GPL-2.0-only
 
 EROFS_VERSION = "1.0pre1"
 
diff --git a/drivers/staging/erofs/compress.h b/drivers/staging/erofs/compress.h
index c43aa3374d28..043013f9ef1b 100644
--- a/drivers/staging/erofs/compress.h
+++ b/drivers/staging/erofs/compress.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * linux/drivers/staging/erofs/compress.h
  *
diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index f73e4720cd3e..75b859e48084 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -1,14 +1,10 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/data.c
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #include "internal.h"
 #include <linux/prefetch.h>
diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c
index 1fb0abb98dff..b75524d0b322 100644
--- a/drivers/staging/erofs/decompressor.c
+++ b/drivers/staging/erofs/decompressor.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/decompressor.c
  *
diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c
index dbf6a151886c..2fbfc4935077 100644
--- a/drivers/staging/erofs/dir.c
+++ b/drivers/staging/erofs/dir.c
@@ -1,14 +1,10 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/dir.c
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #include "internal.h"
 
diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h
index 9f61abb7c1ca..9cd749d56920 100644
--- a/drivers/staging/erofs/erofs_fs.h
+++ b/drivers/staging/erofs/erofs_fs.h
@@ -1,14 +1,10 @@
-/* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0
- *
+/* SPDX-License-Identifier: GPL-2.0-only OR Apache-2.0 */
+/*
  * linux/drivers/staging/erofs/erofs_fs.h
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is dual-licensed; you may select either the GNU General Public
- * License version 2 or Apache License, Version 2.0. See the file COPYING
- * in the main directory of the Linux distribution for more details.
  */
 #ifndef __EROFS_FS_H
 #define __EROFS_FS_H
diff --git a/drivers/staging/erofs/include/linux/tagptr.h b/drivers/staging/erofs/include/linux/tagptr.h
index ccd106dbd48e..b3f13773fb99 100644
--- a/drivers/staging/erofs/include/linux/tagptr.h
+++ b/drivers/staging/erofs/include/linux/tagptr.h
@@ -1,6 +1,6 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
- * Tagged pointer implementation
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * A tagged pointer implementation
  *
  * Copyright (C) 2018 Gao Xiang <gaoxiang25@huawei.com>
  */
diff --git a/drivers/staging/erofs/include/trace/events/erofs.h b/drivers/staging/erofs/include/trace/events/erofs.h
index 660c92fc1803..bfb2da9c4eee 100644
--- a/drivers/staging/erofs/include/trace/events/erofs.h
+++ b/drivers/staging/erofs/include/trace/events/erofs.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0-only */
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM erofs
 
diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c
index 4c3d8bf8d249..c13d66ccc74a 100644
--- a/drivers/staging/erofs/inode.c
+++ b/drivers/staging/erofs/inode.c
@@ -1,14 +1,10 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/inode.c
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #include "xattr.h"
 
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 0ebc294120c2..501429ec0f91 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -1,14 +1,10 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
  * linux/drivers/staging/erofs/internal.h
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #ifndef __INTERNAL_H
 #define __INTERNAL_H
diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c
index fd3ae78d0ba5..50816b4c05fc 100644
--- a/drivers/staging/erofs/namei.c
+++ b/drivers/staging/erofs/namei.c
@@ -1,14 +1,10 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/namei.c
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #include "internal.h"
 #include "xattr.h"
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index 3e2a65ba1945..38cd7a59750a 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -1,14 +1,10 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/super.c
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #include <linux/module.h>
 #include <linux/buffer_head.h>
diff --git a/drivers/staging/erofs/unzip_pagevec.h b/drivers/staging/erofs/unzip_pagevec.h
index e65dbca93ae8..f07302c3c3f5 100644
--- a/drivers/staging/erofs/unzip_pagevec.h
+++ b/drivers/staging/erofs/unzip_pagevec.h
@@ -1,14 +1,10 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
  * linux/drivers/staging/erofs/unzip_pagevec.h
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #ifndef __EROFS_UNZIP_PAGEVEC_H
 #define __EROFS_UNZIP_PAGEVEC_H
diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
index 56c009cf611e..28a98e79c1e9 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -1,14 +1,10 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/unzip_vle.c
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #include "unzip_vle.h"
 #include "compress.h"
diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h
index df91ad149439..d92515cd1c06 100644
--- a/drivers/staging/erofs/unzip_vle.h
+++ b/drivers/staging/erofs/unzip_vle.h
@@ -1,14 +1,10 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
  * linux/drivers/staging/erofs/unzip_vle.h
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #ifndef __EROFS_FS_UNZIP_VLE_H
 #define __EROFS_FS_UNZIP_VLE_H
diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index 4bbd3bf34acd..a68dbe375fa0 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -1,16 +1,11 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/utils.c
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
-
 #include "internal.h"
 #include <linux/pagevec.h>
 
diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
index df40654b9fbb..b29177a17347 100644
--- a/drivers/staging/erofs/xattr.c
+++ b/drivers/staging/erofs/xattr.c
@@ -1,14 +1,10 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/xattr.c
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #include <linux/security.h>
 #include "xattr.h"
diff --git a/drivers/staging/erofs/xattr.h b/drivers/staging/erofs/xattr.h
index 3990805dfc6c..fbcd57bdf886 100644
--- a/drivers/staging/erofs/xattr.h
+++ b/drivers/staging/erofs/xattr.h
@@ -1,14 +1,10 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
  * linux/drivers/staging/erofs/xattr.h
  *
  * Copyright (C) 2017-2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of the Linux
- * distribution for more details.
  */
 #ifndef __EROFS_XATTR_H
 #define __EROFS_XATTR_H
diff --git a/drivers/staging/erofs/zmap.c b/drivers/staging/erofs/zmap.c
index 9c0bd65c46bf..205e884ca4e0 100644
--- a/drivers/staging/erofs/zmap.c
+++ b/drivers/staging/erofs/zmap.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * linux/drivers/staging/erofs/zmap.c
  *
-- 
2.17.1


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

* [PATCH 02/22] staging: erofs: rename source files for better understanding
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
  2019-07-29  6:51 ` [PATCH 01/22] staging: erofs: update source file headers Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  6:43   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 03/22] staging: erofs: fix dummy functions erofs_{get,list}xattr Gao Xiang
                   ` (19 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Keep in line with erofs-outofstaging patchset as well, see
https://lore.kernel.org/linux-fsdevel/20190725095658.155779-1-gaoxiang25@huawei.com/

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/Makefile                     | 2 +-
 drivers/staging/erofs/{include/linux => }/tagptr.h | 6 +++---
 drivers/staging/erofs/{unzip_vle.c => zdata.c}     | 4 ++--
 drivers/staging/erofs/{unzip_vle.h => zdata.h}     | 8 ++++----
 drivers/staging/erofs/{unzip_pagevec.h => zpvec.h} | 8 ++++----
 5 files changed, 14 insertions(+), 14 deletions(-)
 rename drivers/staging/erofs/{include/linux => }/tagptr.h (97%)
 rename drivers/staging/erofs/{unzip_vle.c => zdata.c} (99%)
 rename drivers/staging/erofs/{unzip_vle.h => zdata.h} (97%)
 rename drivers/staging/erofs/{unzip_pagevec.h => zpvec.h} (96%)

diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile
index 3ade87e78d06..5cdae21cb5af 100644
--- a/drivers/staging/erofs/Makefile
+++ b/drivers/staging/erofs/Makefile
@@ -9,5 +9,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o
 ccflags-y += -I $(srctree)/$(src)/include
 erofs-objs := super.o inode.o data.o namei.o dir.o utils.o
 erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o
-erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o zmap.o decompressor.o
+erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o
 
diff --git a/drivers/staging/erofs/include/linux/tagptr.h b/drivers/staging/erofs/tagptr.h
similarity index 97%
rename from drivers/staging/erofs/include/linux/tagptr.h
rename to drivers/staging/erofs/tagptr.h
index b3f13773fb99..a72897c86744 100644
--- a/drivers/staging/erofs/include/linux/tagptr.h
+++ b/drivers/staging/erofs/tagptr.h
@@ -4,8 +4,8 @@
  *
  * Copyright (C) 2018 Gao Xiang <gaoxiang25@huawei.com>
  */
-#ifndef _LINUX_TAGPTR_H
-#define _LINUX_TAGPTR_H
+#ifndef __EROFS_FS_TAGPTR_H
+#define __EROFS_FS_TAGPTR_H
 
 #include <linux/types.h>
 #include <linux/build_bug.h>
@@ -106,5 +106,5 @@ tagptr_init(o, cmpxchg(&ptptr->v, o.v, n.v)); })
 	ptptr->v &= ~tags; \
 *ptptr; })
 
-#endif
+#endif	/* __EROFS_FS_TAGPTR_H */
 
diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/zdata.c
similarity index 99%
rename from drivers/staging/erofs/unzip_vle.c
rename to drivers/staging/erofs/zdata.c
index 28a98e79c1e9..f7667628bbf1 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/zdata.c
@@ -1,12 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * linux/drivers/staging/erofs/unzip_vle.c
+ * linux/drivers/staging/erofs/zdata.c
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
  */
-#include "unzip_vle.h"
+#include "zdata.h"
 #include "compress.h"
 #include <linux/prefetch.h>
 
diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/zdata.h
similarity index 97%
rename from drivers/staging/erofs/unzip_vle.h
rename to drivers/staging/erofs/zdata.h
index d92515cd1c06..8d0119d697da 100644
--- a/drivers/staging/erofs/unzip_vle.h
+++ b/drivers/staging/erofs/zdata.h
@@ -1,16 +1,16 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * linux/drivers/staging/erofs/unzip_vle.h
+ * linux/drivers/staging/erofs/zdata.h
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
  */
-#ifndef __EROFS_FS_UNZIP_VLE_H
-#define __EROFS_FS_UNZIP_VLE_H
+#ifndef __EROFS_FS_ZDATA_H
+#define __EROFS_FS_ZDATA_H
 
 #include "internal.h"
-#include "unzip_pagevec.h"
+#include "zpvec.h"
 
 #define Z_EROFS_NR_INLINE_PAGEVECS      3
 
diff --git a/drivers/staging/erofs/unzip_pagevec.h b/drivers/staging/erofs/zpvec.h
similarity index 96%
rename from drivers/staging/erofs/unzip_pagevec.h
rename to drivers/staging/erofs/zpvec.h
index f07302c3c3f5..77bf6877bad8 100644
--- a/drivers/staging/erofs/unzip_pagevec.h
+++ b/drivers/staging/erofs/zpvec.h
@@ -1,15 +1,15 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * linux/drivers/staging/erofs/unzip_pagevec.h
+ * linux/drivers/staging/erofs/zpvec.h
  *
  * Copyright (C) 2018 HUAWEI, Inc.
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
  */
-#ifndef __EROFS_UNZIP_PAGEVEC_H
-#define __EROFS_UNZIP_PAGEVEC_H
+#ifndef __EROFS_FS_ZPVEC_H
+#define __EROFS_FS_ZPVEC_H
 
-#include <linux/tagptr.h>
+#include "tagptr.h"
 
 /* page type in pagevec for unzip subsystem */
 enum z_erofs_page_type {
-- 
2.17.1


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

* [PATCH 03/22] staging: erofs: fix dummy functions erofs_{get,list}xattr
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
  2019-07-29  6:51 ` [PATCH 01/22] staging: erofs: update source file headers Gao Xiang
  2019-07-29  6:51 ` [PATCH 02/22] staging: erofs: rename source files for better understanding Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  6:44   ` [PATCH 03/22] staging: erofs: fix dummy functions erofs_{get, list}xattr Chao Yu
  2019-07-29  6:51 ` [PATCH 04/22] staging: erofs: keep up erofs_fs.h with erofs-outofstaging patchset Gao Xiang
                   ` (18 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei,
	Gao Xiang, Yue Hu

dummy functions erofs_{get,list}xattr should be inlined
without xattr enabled.

Signed-off-by: Yue Hu <zbestahu@gmail.com>
[ Gao Xiang : this patch was "staging: erofs: remove needless
              dummy functions of erofs_{get,list}xattr. "]
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/xattr.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/erofs/xattr.h b/drivers/staging/erofs/xattr.h
index fbcd57bdf886..63cc87e3d3f4 100644
--- a/drivers/staging/erofs/xattr.h
+++ b/drivers/staging/erofs/xattr.h
@@ -39,6 +39,7 @@ static inline unsigned int xattrblock_offset(struct erofs_sb_info *sbi,
 	return (xattr_id * sizeof(__u32)) % EROFS_BLKSIZ;
 }
 
+#ifdef CONFIG_EROFS_FS_XATTR
 extern const struct xattr_handler erofs_xattr_user_handler;
 extern const struct xattr_handler erofs_xattr_trusted_handler;
 #ifdef CONFIG_EROFS_FS_SECURITY
@@ -64,25 +65,24 @@ static const struct xattr_handler *xattr_handler_map[] = {
 		xattr_handler_map[idx] : NULL;
 }
 
-#ifdef CONFIG_EROFS_FS_XATTR
 extern const struct xattr_handler *erofs_xattr_handlers[];
 
 int erofs_getxattr(struct inode *, int, const char *, void *, size_t);
 ssize_t erofs_listxattr(struct dentry *, char *, size_t);
 #else
-static int __maybe_unused erofs_getxattr(struct inode *inode, int index,
-	const char *name,
-	void *buffer, size_t buffer_size)
+static inline int erofs_getxattr(struct inode *inode, int index,
+				 const char *name, void *buffer,
+				 size_t buffer_size)
 {
 	return -ENOTSUPP;
 }
 
-static ssize_t __maybe_unused erofs_listxattr(struct dentry *dentry,
-	char *buffer, size_t buffer_size)
+static inline ssize_t erofs_listxattr(struct dentry *dentry,
+				      char *buffer, size_t buffer_size)
 {
 	return -ENOTSUPP;
 }
-#endif
+#endif	/* !CONFIG_EROFS_FS_XATTR */
 
 #ifdef CONFIG_EROFS_FS_POSIX_ACL
 struct posix_acl *erofs_get_acl(struct inode *inode, int type);
-- 
2.17.1


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

* [PATCH 04/22] staging: erofs: keep up erofs_fs.h with erofs-outofstaging patchset
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (2 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 03/22] staging: erofs: fix dummy functions erofs_{get,list}xattr Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  6:46   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 05/22] staging: erofs: sunset erofs_workstn_{lock,unlock} Gao Xiang
                   ` (17 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

The main change is to reserve all checksums except for superblock,
since it's more useful to do block-based verity for read-only fs.

Some comments change as well, which is minor.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/erofs_fs.h | 39 ++++++++++++++++----------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h
index 9cd749d56920..e82e833985e4 100644
--- a/drivers/staging/erofs/erofs_fs.h
+++ b/drivers/staging/erofs/erofs_fs.h
@@ -96,7 +96,7 @@ struct erofs_inode_v1 {
 /* 20 */__le32 i_ino;           /* only used for 32-bit stat compatibility */
 /* 24 */__le16 i_uid;
 /* 26 */__le16 i_gid;
-/* 28 */__le32 i_checksum;
+/* 28 */__le32 i_reserved2;
 } __packed;
 
 /* 32 bytes on-disk inode */
@@ -105,14 +105,14 @@ struct erofs_inode_v1 {
 #define EROFS_INODE_LAYOUT_V2   1
 
 struct erofs_inode_v2 {
-	__le16 i_advise;
+/*  0 */__le16 i_advise;
 
-	/* 1 header + n-1 * 4 bytes inline xattr to keep continuity */
-	__le16 i_xattr_icount;
-	__le16 i_mode;
-	__le16 i_reserved;      /* 8 bytes */
-	__le64 i_size;          /* 16 bytes */
-	union {
+/* 1 header + n-1 * 4 bytes inline xattr to keep continuity */
+/*  2 */__le16 i_xattr_icount;
+/*  4 */__le16 i_mode;
+/*  6 */__le16 i_reserved;
+/*  8 */__le64 i_size;
+/* 16 */union {
 		/* file total compressed blocks for data mapping 1 */
 		__le32 compressed_blocks;
 		__le32 raw_blkaddr;
@@ -122,16 +122,15 @@ struct erofs_inode_v2 {
 	} i_u __packed;
 
 	/* only used for 32-bit stat compatibility */
-	__le32 i_ino;           /* 24 bytes */
-
-	__le32 i_uid;
-	__le32 i_gid;
-	__le64 i_ctime;         /* 32 bytes */
-	__le32 i_ctime_nsec;
-	__le32 i_nlink;
-	__u8   i_reserved2[12];
-	__le32 i_checksum;      /* 64 bytes */
-} __packed;
+/* 20 */__le32 i_ino;
+
+/* 24 */__le32 i_uid;
+/* 28 */__le32 i_gid;
+/* 32 */__le64 i_ctime;
+/* 40 */__le32 i_ctime_nsec;
+/* 44 */__le32 i_nlink;
+/* 48 */__u8   i_reserved2[16];
+} __packed;                     /* 64 bytes */
 
 #define EROFS_MAX_SHARED_XATTRS         (128)
 /* h_shared_count between 129 ... 255 are special # */
@@ -149,9 +148,9 @@ struct erofs_inode_v2 {
  * for read-only fs, no need to introduce h_refcount
  */
 struct erofs_xattr_ibody_header {
-	__le32 h_checksum;
+	__le32 h_reserved;
 	__u8   h_shared_count;
-	__u8   h_reserved[7];
+	__u8   h_reserved2[7];
 	__le32 h_shared_xattrs[0];      /* shared xattr id array */
 } __packed;
 
-- 
2.17.1


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

* [PATCH 05/22] staging: erofs: sunset erofs_workstn_{lock,unlock}
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (3 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 04/22] staging: erofs: keep up erofs_fs.h with erofs-outofstaging patchset Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  6:49   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 06/22] staging: erofs: clean up internal.h Gao Xiang
                   ` (16 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

It was used for Linux backward compatibility, and no use
for upstream kernel.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/internal.h |  3 ---
 drivers/staging/erofs/utils.c    | 10 +++++-----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 501429ec0f91..ed487ee56f74 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -179,9 +179,6 @@ static inline void *erofs_kmalloc(struct erofs_sb_info *sbi,
 #define test_opt(sbi, option)	((sbi)->mount_opt & EROFS_MOUNT_##option)
 
 #ifdef CONFIG_EROFS_FS_ZIP
-#define erofs_workstn_lock(sbi)         xa_lock(&(sbi)->workstn_tree)
-#define erofs_workstn_unlock(sbi)       xa_unlock(&(sbi)->workstn_tree)
-
 /* basic unit of the workstation of a super_block */
 struct erofs_workgroup {
 	/* the workgroup index in the workstation */
diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index a68dbe375fa0..024806003297 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -102,14 +102,14 @@ int erofs_register_workgroup(struct super_block *sb,
 		return err;
 
 	sbi = EROFS_SB(sb);
-	erofs_workstn_lock(sbi);
+	xa_lock(&sbi->workstn_tree);
 
 	grp = xa_tag_pointer(grp, tag);
 
 	/*
 	 * Bump up reference count before making this workgroup
 	 * visible to other users in order to avoid potential UAF
-	 * without serialized by erofs_workstn_lock.
+	 * without serialized by workstn_lock.
 	 */
 	__erofs_workgroup_get(grp);
 
@@ -122,7 +122,7 @@ int erofs_register_workgroup(struct super_block *sb,
 		 */
 		__erofs_workgroup_put(grp);
 
-	erofs_workstn_unlock(sbi);
+	xa_unlock(&sbi->workstn_tree);
 	radix_tree_preload_end();
 	return err;
 }
@@ -225,7 +225,7 @@ unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
 
 	int i, found;
 repeat:
-	erofs_workstn_lock(sbi);
+	xa_lock(&sbi->workstn_tree);
 
 	found = radix_tree_gang_lookup(&sbi->workstn_tree,
 				       batch, first_index, PAGEVEC_SIZE);
@@ -243,7 +243,7 @@ unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
 		if (unlikely(!--nr_shrink))
 			break;
 	}
-	erofs_workstn_unlock(sbi);
+	xa_unlock(&sbi->workstn_tree);
 
 	if (i && nr_shrink)
 		goto repeat;
-- 
2.17.1


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

* [PATCH 06/22] staging: erofs: clean up internal.h
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (4 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 05/22] staging: erofs: sunset erofs_workstn_{lock,unlock} Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  6:53   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 07/22] staging: erofs: remove redundant #include "internal.h" Gao Xiang
                   ` (15 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Tidy up relative order of variables / declarations in internal.h,
and moving some local static functions out to other files.

No logic change.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/decompressor.c |  27 ++++++
 drivers/staging/erofs/internal.h     | 130 +++++++--------------------
 drivers/staging/erofs/super.c        |   2 +-
 drivers/staging/erofs/zdata.c        |   8 +-
 drivers/staging/erofs/zdata.h        |  13 +++
 5 files changed, 80 insertions(+), 100 deletions(-)

diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c
index b75524d0b322..ee5762351f80 100644
--- a/drivers/staging/erofs/decompressor.c
+++ b/drivers/staging/erofs/decompressor.c
@@ -223,6 +223,33 @@ static void copy_from_pcpubuf(struct page **out, const char *dst,
 	}
 }
 
+static void *erofs_vmap(struct page **pages, unsigned int count)
+{
+#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
+	int i = 0;
+
+	while (1) {
+		void *addr = vm_map_ram(pages, count, -1, PAGE_KERNEL);
+		/* retry two more times (totally 3 times) */
+		if (addr || ++i >= 3)
+			return addr;
+		vm_unmap_aliases();
+	}
+	return NULL;
+#else
+	return vmap(pages, count, VM_MAP, PAGE_KERNEL);
+#endif
+}
+
+static void erofs_vunmap(const void *mem, unsigned int count)
+{
+#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
+	vm_unmap_ram(mem, count);
+#else
+	vunmap(mem);
+#endif
+}
+
 static int decompress_generic(struct z_erofs_decompress_req *rq,
 			      struct list_head *pagepool)
 {
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index ed487ee56f74..ffd4b1a3fc25 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -6,8 +6,8 @@
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
  */
-#ifndef __INTERNAL_H
-#define __INTERNAL_H
+#ifndef __EROFS_INTERNAL_H
+#define __EROFS_INTERNAL_H
 
 #include <linux/fs.h>
 #include <linux/dcache.h>
@@ -28,15 +28,11 @@
 #define infoln(x, ...)  pr_info(x "\n", ##__VA_ARGS__)
 #ifdef CONFIG_EROFS_FS_DEBUG
 #define debugln(x, ...) pr_debug(x "\n", ##__VA_ARGS__)
-
-#define dbg_might_sleep         might_sleep
 #define DBG_BUGON               BUG_ON
 #else
 #define debugln(x, ...)         ((void)0)
-
-#define dbg_might_sleep()       ((void)0)
 #define DBG_BUGON(x)            ((void)(x))
-#endif
+#endif	/* !CONFIG_EROFS_FS_DEBUG */
 
 enum {
 	FAULT_KMALLOC,
@@ -71,6 +67,9 @@ struct erofs_fault_info {
 #define EROFS_SUPER_MAGIC   EROFS_SUPER_MAGIC_V1
 
 typedef u64 erofs_nid_t;
+typedef u64 erofs_off_t;
+/* data type for filesystem-wide blocks number */
+typedef u32 erofs_blk_t;
 
 struct erofs_sb_info {
 	/* list for all registered superblocks, mainly for shrinker */
@@ -179,6 +178,8 @@ static inline void *erofs_kmalloc(struct erofs_sb_info *sbi,
 #define test_opt(sbi, option)	((sbi)->mount_opt & EROFS_MOUNT_##option)
 
 #ifdef CONFIG_EROFS_FS_ZIP
+#define EROFS_LOCKED_MAGIC     (INT_MIN | 0xE0F510CCL)
+
 /* basic unit of the workstation of a super_block */
 struct erofs_workgroup {
 	/* the workgroup index in the workstation */
@@ -188,8 +189,6 @@ struct erofs_workgroup {
 	atomic_t refcount;
 };
 
-#define EROFS_LOCKED_MAGIC     (INT_MIN | 0xE0F510CCL)
-
 #if defined(CONFIG_SMP)
 static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp,
 						 int val)
@@ -248,48 +247,13 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
 }
 #endif
 
-int erofs_workgroup_put(struct erofs_workgroup *grp);
-struct erofs_workgroup *erofs_find_workgroup(struct super_block *sb,
-					     pgoff_t index, bool *tag);
-int erofs_register_workgroup(struct super_block *sb,
-			     struct erofs_workgroup *grp, bool tag);
-unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
-				       unsigned long nr_shrink, bool cleanup);
-void erofs_workgroup_free_rcu(struct erofs_workgroup *grp);
-
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
-				       struct erofs_workgroup *egrp);
-int erofs_try_to_free_cached_page(struct address_space *mapping,
-				  struct page *page);
-
-#define MNGD_MAPPING(sbi)	((sbi)->managed_cache->i_mapping)
-static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
-					 struct page *page)
-{
-	return page->mapping == MNGD_MAPPING(sbi);
-}
-#else
-#define MNGD_MAPPING(sbi)	(NULL)
-static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
-					 struct page *page) { return false; }
-#endif
-
-#define DEFAULT_MAX_SYNC_DECOMPRESS_PAGES	3
-
-static inline bool __should_decompress_synchronously(struct erofs_sb_info *sbi,
-						     unsigned int nr)
-{
-	return nr <= sbi->max_sync_decompress_pages;
-}
-
 int __init z_erofs_init_zip_subsystem(void);
 void z_erofs_exit_zip_subsystem(void);
 #else
 /* dummy initializer/finalizer for the decompression subsystem */
 static inline int z_erofs_init_zip_subsystem(void) { return 0; }
 static inline void z_erofs_exit_zip_subsystem(void) {}
-#endif
+#endif	/* CONFIG_EROFS_FS_ZIP */
 
 /* we strictly follow PAGE_SIZE and no buffer head yet */
 #define LOG_BLOCK_SIZE		PAGE_SHIFT
@@ -320,11 +284,6 @@ static inline void z_erofs_exit_zip_subsystem(void) {}
 #define EROFS_PCPUBUF_NR_PAGES          0
 #endif
 
-typedef u64 erofs_off_t;
-
-/* data type for filesystem-wide blocks number */
-typedef u32 erofs_blk_t;
-
 #define erofs_blknr(addr)       ((addr) / EROFS_BLKSIZ)
 #define erofs_blkoff(addr)      ((addr) % EROFS_BLKSIZ)
 #define blknr_to_addr(nr)       ((erofs_off_t)(nr) * EROFS_BLKSIZ)
@@ -475,10 +434,11 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
 #endif
 
 /* data.c */
-static inline struct bio *
-erofs_grab_bio(struct super_block *sb,
-	       erofs_blk_t blkaddr, unsigned int nr_pages, void *bi_private,
-	       bio_end_io_t endio, bool nofail)
+static inline struct bio *erofs_grab_bio(struct super_block *sb,
+					 erofs_blk_t blkaddr,
+					 unsigned int nr_pages,
+					 void *bi_private, bio_end_io_t endio,
+					 bool nofail)
 {
 	const gfp_t gfp = GFP_NOIO;
 	struct bio *bio;
@@ -525,20 +485,13 @@ static inline struct page *erofs_get_meta_page(struct super_block *sb,
 	return __erofs_get_meta_page(sb, blkaddr, prio, false);
 }
 
-static inline struct page *erofs_get_meta_page_nofail(struct super_block *sb,
-	erofs_blk_t blkaddr, bool prio)
-{
-	return __erofs_get_meta_page(sb, blkaddr, prio, true);
-}
-
 int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
 
-static inline struct page *
-erofs_get_inline_page(struct inode *inode,
-		      erofs_blk_t blkaddr)
+static inline struct page *erofs_get_inline_page(struct inode *inode,
+						 erofs_blk_t blkaddr)
 {
-	return erofs_get_meta_page(inode->i_sb,
-		blkaddr, S_ISDIR(inode->i_mode));
+	return erofs_get_meta_page(inode->i_sb, blkaddr,
+				   S_ISDIR(inode->i_mode));
 }
 
 /* inode.c */
@@ -578,34 +531,7 @@ int erofs_namei(struct inode *dir, struct qstr *name,
 /* dir.c */
 extern const struct file_operations erofs_dir_fops;
 
-static inline void *erofs_vmap(struct page **pages, unsigned int count)
-{
-#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
-	int i = 0;
-
-	while (1) {
-		void *addr = vm_map_ram(pages, count, -1, PAGE_KERNEL);
-		/* retry two more times (totally 3 times) */
-		if (addr || ++i >= 3)
-			return addr;
-		vm_unmap_aliases();
-	}
-	return NULL;
-#else
-	return vmap(pages, count, VM_MAP, PAGE_KERNEL);
-#endif
-}
-
-static inline void erofs_vunmap(const void *mem, unsigned int count)
-{
-#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
-	vm_unmap_ram(mem, count);
-#else
-	vunmap(mem);
-#endif
-}
-
-/* utils.c */
+/* utils.c / zdata.c */
 extern struct shrinker erofs_shrinker_info;
 
 struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp);
@@ -625,12 +551,20 @@ static inline void *erofs_get_pcpubuf(unsigned int pagenr)
 #define erofs_put_pcpubuf(buf) do {} while (0)
 #endif
 
+int erofs_workgroup_put(struct erofs_workgroup *grp);
+struct erofs_workgroup *erofs_find_workgroup(struct super_block *sb,
+					     pgoff_t index, bool *tag);
+int erofs_register_workgroup(struct super_block *sb,
+			     struct erofs_workgroup *grp, bool tag);
+unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
+				       unsigned long nr_shrink, bool cleanup);
+void erofs_workgroup_free_rcu(struct erofs_workgroup *grp);
+int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
+				       struct erofs_workgroup *egrp);
+int erofs_try_to_free_cached_page(struct address_space *mapping,
+				  struct page *page);
 void erofs_register_super(struct super_block *sb);
 void erofs_unregister_super(struct super_block *sb);
 
-#ifndef lru_to_page
-#define lru_to_page(head) (list_entry((head)->prev, struct page, lru))
-#endif
-
-#endif
+#endif	/* __EROFS_INTERNAL_H */
 
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index 38cd7a59750a..55f51d2b3930 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -211,7 +211,7 @@ static void default_options(struct erofs_sb_info *sbi)
 {
 	/* set up some FS parameters */
 #ifdef CONFIG_EROFS_FS_ZIP
-	sbi->max_sync_decompress_pages = DEFAULT_MAX_SYNC_DECOMPRESS_PAGES;
+	sbi->max_sync_decompress_pages = 3;
 #endif
 
 #ifdef CONFIG_EROFS_FS_XATTR
diff --git a/drivers/staging/erofs/zdata.c b/drivers/staging/erofs/zdata.c
index f7667628bbf1..bc478eebf509 100644
--- a/drivers/staging/erofs/zdata.c
+++ b/drivers/staging/erofs/zdata.c
@@ -1509,6 +1509,12 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file,
 	return 0;
 }
 
+static bool should_decompress_synchronously(struct erofs_sb_info *sbi,
+					    unsigned int nr)
+{
+	return nr <= sbi->max_sync_decompress_pages;
+}
+
 static int z_erofs_vle_normalaccess_readpages(struct file *filp,
 					      struct address_space *mapping,
 					      struct list_head *pages,
@@ -1517,7 +1523,7 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp,
 	struct inode *const inode = mapping->host;
 	struct erofs_sb_info *const sbi = EROFS_I_SB(inode);
 
-	bool sync = __should_decompress_synchronously(sbi, nr_pages);
+	bool sync = should_decompress_synchronously(sbi, nr_pages);
 	struct z_erofs_vle_frontend f = VLE_FRONTEND_INIT(inode);
 	gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL);
 	struct page *head = NULL;
diff --git a/drivers/staging/erofs/zdata.h b/drivers/staging/erofs/zdata.h
index 8d0119d697da..6574d43ba877 100644
--- a/drivers/staging/erofs/zdata.h
+++ b/drivers/staging/erofs/zdata.h
@@ -104,6 +104,19 @@ struct z_erofs_vle_unzip_io_sb {
 	struct super_block *sb;
 };
 
+#ifdef EROFS_FS_HAS_MANAGED_CACHE
+#define MNGD_MAPPING(sbi)	((sbi)->managed_cache->i_mapping)
+static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
+					 struct page *page)
+{
+	return page->mapping == MNGD_MAPPING(sbi);
+}
+#else
+#define MNGD_MAPPING(sbi)	(NULL)
+static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
+					 struct page *page) { return false; }
+#endif	/* !EROFS_FS_HAS_MANAGED_CACHE */
+
 #define Z_EROFS_ONLINEPAGE_COUNT_BITS 2
 #define Z_EROFS_ONLINEPAGE_COUNT_MASK ((1 << Z_EROFS_ONLINEPAGE_COUNT_BITS) - 1)
 #define Z_EROFS_ONLINEPAGE_INDEX_SHIFT  (Z_EROFS_ONLINEPAGE_COUNT_BITS)
-- 
2.17.1


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

* [PATCH 07/22] staging: erofs: remove redundant #include "internal.h"
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (5 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 06/22] staging: erofs: clean up internal.h Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  7:03   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES Gao Xiang
                   ` (14 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Because #include "internal.h" is included in xattr.h

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/namei.c | 1 -
 drivers/staging/erofs/super.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c
index 50816b4c05fc..8e06526da023 100644
--- a/drivers/staging/erofs/namei.c
+++ b/drivers/staging/erofs/namei.c
@@ -6,7 +6,6 @@
  *             http://www.huawei.com/
  * Created by Gao Xiang <gaoxiang25@huawei.com>
  */
-#include "internal.h"
 #include "xattr.h"
 
 #include <trace/events/erofs.h>
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index 55f51d2b3930..c20a94b035a7 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -11,7 +11,6 @@
 #include <linux/statfs.h>
 #include <linux/parser.h>
 #include <linux/seq_file.h>
-#include "internal.h"
 #include "xattr.h"
 
 #define CREATE_TRACE_POINTS
-- 
2.17.1


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

* [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (6 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 07/22] staging: erofs: remove redundant #include "internal.h" Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  7:05   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 09/22] staging: erofs: clean up shrinker stuffs Gao Xiang
                   ` (13 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

CONFIG_EROFS_FS_IO_MAX_RETRIES seems a runtime setting
and users have no idea about the change in behaviour.

Let's remove the setting currently and fold it into code,
turn it into a module parameter if it's really needed.

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/Kconfig    | 9 ---------
 drivers/staging/erofs/data.c     | 2 +-
 drivers/staging/erofs/internal.h | 6 ------
 3 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig
index 2577cbb46a5b..747e9eebfaa5 100644
--- a/drivers/staging/erofs/Kconfig
+++ b/drivers/staging/erofs/Kconfig
@@ -78,15 +78,6 @@ config EROFS_FAULT_INJECTION
 	  Test EROFS to inject faults such as ENOMEM, EIO, and so on.
 	  If unsure, say N.
 
-config EROFS_FS_IO_MAX_RETRIES
-	int "EROFS IO Maximum Retries"
-	depends on EROFS_FS
-	default "5"
-	help
-	  Maximum retry count of IO Errors.
-
-	  If unsure, leave the default value (5 retries, 6 IOs at most).
-
 config EROFS_FS_ZIP
 	bool "EROFS Data Compresssion Support"
 	depends on EROFS_FS
diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index 75b859e48084..65e0d288e2a1 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -49,7 +49,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb,
 	/* prefer retrying in the allocator to blindly looping below */
 	const gfp_t gfp = mapping_gfp_constraint(mapping, ~__GFP_FS) |
 		(nofail ? __GFP_NOFAIL : 0);
-	unsigned int io_retries = nofail ? EROFS_IO_MAX_RETRIES_NOFAIL : 0;
+	unsigned int io_retries = nofail ? 5 : 0;
 	struct page *page;
 	int err;
 
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index ffd4b1a3fc25..58b8bb9cbb9f 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -470,12 +470,6 @@ static inline void __submit_bio(struct bio *bio, unsigned int op,
 	submit_bio(bio);
 }
 
-#ifndef CONFIG_EROFS_FS_IO_MAX_RETRIES
-#define EROFS_IO_MAX_RETRIES_NOFAIL	0
-#else
-#define EROFS_IO_MAX_RETRIES_NOFAIL	CONFIG_EROFS_FS_IO_MAX_RETRIES
-#endif
-
 struct page *__erofs_get_meta_page(struct super_block *sb, erofs_blk_t blkaddr,
 				   bool prio, bool nofail);
 
-- 
2.17.1


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

* [PATCH 09/22] staging: erofs: clean up shrinker stuffs
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (7 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  7:41   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 10/22] staging: erofs: kill sbi->dev_name Gao Xiang
                   ` (12 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

- rename erofs_register_super / erofs_unregister_super
  to erofs_shrinker_register / erofs_shrinker_unregister;
- fold the only erofs_shrink_workstation external call
  to erofs_shrinker_unregister;
- localize erofs_shrink_workstation;
- localize erofs_shrinker_info by introducing
  erofs_init_shrinker and erofs_exit_shrinker.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/internal.h | 50 +++++++++++++++++---------------
 drivers/staging/erofs/super.c    | 20 ++++---------
 drivers/staging/erofs/utils.c    | 37 +++++++++++++++--------
 3 files changed, 56 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 58b8bb9cbb9f..c082a462baf6 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -72,34 +72,35 @@ typedef u64 erofs_off_t;
 typedef u32 erofs_blk_t;
 
 struct erofs_sb_info {
+#ifdef CONFIG_EROFS_FS_ZIP
 	/* list for all registered superblocks, mainly for shrinker */
 	struct list_head list;
 	struct mutex umount_mutex;
 
-	u32 blocks;
-	u32 meta_blkaddr;
-#ifdef CONFIG_EROFS_FS_XATTR
-	u32 xattr_blkaddr;
-#endif
-
-	/* inode slot unit size in bit shift */
-	unsigned char islotbits;
-#ifdef CONFIG_EROFS_FS_ZIP
 	/* cluster size in bit shift */
 	unsigned char clusterbits;
-
 	/* the dedicated workstation for compression */
 	struct radix_tree_root workstn_tree;
 
 	/* threshold for decompression synchronously */
 	unsigned int max_sync_decompress_pages;
 
+	unsigned int shrinker_run_no;
+
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
 	struct inode *managed_cache;
 #endif
 
+#endif	/* CONFIG_EROFS_FS_ZIP */
+	u32 blocks;
+	u32 meta_blkaddr;
+#ifdef CONFIG_EROFS_FS_XATTR
+	u32 xattr_blkaddr;
 #endif
 
+	/* inode slot unit size in bit shift */
+	unsigned char islotbits;
+
 	u32 build_time_nsec;
 	u64 build_time;
 
@@ -115,7 +116,6 @@ struct erofs_sb_info {
 	char *dev_name;
 
 	unsigned int mount_opt;
-	unsigned int shrinker_run_no;
 
 #ifdef CONFIG_EROFS_FAULT_INJECTION
 	struct erofs_fault_info fault_info;	/* For fault injection */
@@ -246,13 +246,6 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
 	return v;
 }
 #endif
-
-int __init z_erofs_init_zip_subsystem(void);
-void z_erofs_exit_zip_subsystem(void);
-#else
-/* dummy initializer/finalizer for the decompression subsystem */
-static inline int z_erofs_init_zip_subsystem(void) { return 0; }
-static inline void z_erofs_exit_zip_subsystem(void) {}
 #endif	/* CONFIG_EROFS_FS_ZIP */
 
 /* we strictly follow PAGE_SIZE and no buffer head yet */
@@ -526,8 +519,6 @@ int erofs_namei(struct inode *dir, struct qstr *name,
 extern const struct file_operations erofs_dir_fops;
 
 /* utils.c / zdata.c */
-extern struct shrinker erofs_shrinker_info;
-
 struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp);
 
 #if (EROFS_PCPUBUF_NR_PAGES > 0)
@@ -545,20 +536,31 @@ static inline void *erofs_get_pcpubuf(unsigned int pagenr)
 #define erofs_put_pcpubuf(buf) do {} while (0)
 #endif
 
+#ifdef CONFIG_EROFS_FS_ZIP
 int erofs_workgroup_put(struct erofs_workgroup *grp);
 struct erofs_workgroup *erofs_find_workgroup(struct super_block *sb,
 					     pgoff_t index, bool *tag);
 int erofs_register_workgroup(struct super_block *sb,
 			     struct erofs_workgroup *grp, bool tag);
-unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
-				       unsigned long nr_shrink, bool cleanup);
 void erofs_workgroup_free_rcu(struct erofs_workgroup *grp);
+void erofs_shrinker_register(struct super_block *sb);
+void erofs_shrinker_unregister(struct super_block *sb);
+int __init erofs_init_shrinker(void);
+void erofs_exit_shrinker(void);
+int __init z_erofs_init_zip_subsystem(void);
+void z_erofs_exit_zip_subsystem(void);
 int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
 				       struct erofs_workgroup *egrp);
 int erofs_try_to_free_cached_page(struct address_space *mapping,
 				  struct page *page);
-void erofs_register_super(struct super_block *sb);
-void erofs_unregister_super(struct super_block *sb);
+#else
+static inline void erofs_shrinker_register(struct super_block *sb) {}
+static inline void erofs_shrinker_unregister(struct super_block *sb) {}
+static inline int erofs_init_shrinker(void) { return 0; }
+static inline void erofs_exit_shrinker(void) {}
+static inline int z_erofs_init_zip_subsystem(void) { return 0; }
+static inline void z_erofs_exit_zip_subsystem(void) {}
+#endif
 
 #endif	/* __EROFS_INTERNAL_H */
 
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index c20a94b035a7..7e6fe9cd45e7 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -458,7 +458,7 @@ static int erofs_read_super(struct super_block *sb,
 	snprintf(sbi->dev_name, PATH_MAX, "%s", dev_name);
 	sbi->dev_name[PATH_MAX - 1] = '\0';
 
-	erofs_register_super(sb);
+	erofs_shrinker_register(sb);
 
 	if (!silent)
 		infoln("mounted on %s with opts: %s.", dev_name,
@@ -502,20 +502,10 @@ static void erofs_put_super(struct super_block *sb)
 	infoln("unmounted for %s", sbi->dev_name);
 	__putname(sbi->dev_name);
 
+	erofs_shrinker_unregister(sb);
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
 	iput(sbi->managed_cache);
 #endif
-
-	mutex_lock(&sbi->umount_mutex);
-
-#ifdef CONFIG_EROFS_FS_ZIP
-	/* clean up the compression space of this sb */
-	erofs_shrink_workstation(EROFS_SB(sb), ~0UL, true);
-#endif
-
-	erofs_unregister_super(sb);
-	mutex_unlock(&sbi->umount_mutex);
-
 	kfree(sbi);
 	sb->s_fs_info = NULL;
 }
@@ -569,7 +559,7 @@ static int __init erofs_module_init(void)
 	if (err)
 		goto icache_err;
 
-	err = register_shrinker(&erofs_shrinker_info);
+	err = erofs_init_shrinker();
 	if (err)
 		goto shrinker_err;
 
@@ -587,7 +577,7 @@ static int __init erofs_module_init(void)
 fs_err:
 	z_erofs_exit_zip_subsystem();
 zip_err:
-	unregister_shrinker(&erofs_shrinker_info);
+	erofs_exit_shrinker();
 shrinker_err:
 	erofs_exit_inode_cache();
 icache_err:
@@ -598,7 +588,7 @@ static void __exit erofs_module_exit(void)
 {
 	unregister_filesystem(&erofs_fs_type);
 	z_erofs_exit_zip_subsystem();
-	unregister_shrinker(&erofs_shrinker_info);
+	erofs_exit_shrinker();
 	erofs_exit_inode_cache();
 	infoln("successfully finalize erofs");
 }
diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index 024806003297..0e86e44d60d0 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -34,10 +34,10 @@ void *erofs_get_pcpubuf(unsigned int pagenr)
 }
 #endif
 
+#ifdef CONFIG_EROFS_FS_ZIP
 /* global shrink count (for all mounted EROFS instances) */
 static atomic_long_t erofs_global_shrink_cnt;
 
-#ifdef CONFIG_EROFS_FS_ZIP
 #define __erofs_workgroup_get(grp)	atomic_inc(&(grp)->refcount)
 #define __erofs_workgroup_put(grp)	atomic_dec(&(grp)->refcount)
 
@@ -215,9 +215,9 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
 
 #endif
 
-unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
-				       unsigned long nr_shrink,
-				       bool cleanup)
+static unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
+					      unsigned long nr_shrink,
+					      bool cleanup)
 {
 	pgoff_t first_index = 0;
 	void *batch[PAGEVEC_SIZE];
@@ -250,8 +250,6 @@ unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
 	return freed;
 }
 
-#endif
-
 /* protected by 'erofs_sb_list_lock' */
 static unsigned int shrinker_run_no;
 
@@ -259,7 +257,7 @@ static unsigned int shrinker_run_no;
 static DEFINE_SPINLOCK(erofs_sb_list_lock);
 static LIST_HEAD(erofs_sb_list);
 
-void erofs_register_super(struct super_block *sb)
+void erofs_shrinker_register(struct super_block *sb)
 {
 	struct erofs_sb_info *sbi = EROFS_SB(sb);
 
@@ -270,11 +268,17 @@ void erofs_register_super(struct super_block *sb)
 	spin_unlock(&erofs_sb_list_lock);
 }
 
-void erofs_unregister_super(struct super_block *sb)
+void erofs_shrinker_unregister(struct super_block *sb)
 {
+	struct erofs_sb_info *const sbi = EROFS_SB(sb);
+
+	mutex_lock(&sbi->umount_mutex);
+	erofs_shrink_workstation(sbi, ~0UL, true);
+
 	spin_lock(&erofs_sb_list_lock);
-	list_del(&EROFS_SB(sb)->list);
+	list_del(&sbi->list);
 	spin_unlock(&erofs_sb_list_lock);
+	mutex_unlock(&sbi->umount_mutex);
 }
 
 static unsigned long erofs_shrink_count(struct shrinker *shrink,
@@ -318,9 +322,7 @@ static unsigned long erofs_shrink_scan(struct shrinker *shrink,
 		spin_unlock(&erofs_sb_list_lock);
 		sbi->shrinker_run_no = run_no;
 
-#ifdef CONFIG_EROFS_FS_ZIP
 		freed += erofs_shrink_workstation(sbi, nr, false);
-#endif
 
 		spin_lock(&erofs_sb_list_lock);
 		/* Get the next list element before we move this one */
@@ -340,9 +342,20 @@ static unsigned long erofs_shrink_scan(struct shrinker *shrink,
 	return freed;
 }
 
-struct shrinker erofs_shrinker_info = {
+static struct shrinker erofs_shrinker_info = {
 	.scan_objects = erofs_shrink_scan,
 	.count_objects = erofs_shrink_count,
 	.seeks = DEFAULT_SEEKS,
 };
 
+int __init erofs_init_shrinker(void)
+{
+	return register_shrinker(&erofs_shrinker_info);
+}
+
+void erofs_exit_shrinker(void)
+{
+	unregister_shrinker(&erofs_shrinker_info);
+}
+#endif	/* !CONFIG_EROFS_FS_ZIP */
+
-- 
2.17.1


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

* [PATCH 10/22] staging: erofs: kill sbi->dev_name
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (8 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 09/22] staging: erofs: clean up shrinker stuffs Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  7:46   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 11/22] staging: erofs: kill all failure handling in fill_super() Gao Xiang
                   ` (11 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

As Al said, "the only use of sbi->dev_name is debugging
printks and all of those have sb->s_id available, with
device name stored in there.  Which makes the whole
thing bloody weird".

sbi->dev_name was used for our debugging use and it's
better to just use s_id in community and delete
the whole erofs_mount_private stuff.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/internal.h |  2 --
 drivers/staging/erofs/super.c    | 54 +++++---------------------------
 2 files changed, 7 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index c082a462baf6..b206a85776b4 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -113,8 +113,6 @@ struct erofs_sb_info {
 	u8 volume_name[16];             /* volume name */
 	u32 requirements;
 
-	char *dev_name;
-
 	unsigned int mount_opt;
 
 #ifdef CONFIG_EROFS_FAULT_INJECTION
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index 7e6fe9cd45e7..bfb6e1e09781 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -362,15 +362,13 @@ static struct inode *erofs_init_managed_cache(struct super_block *sb)
 
 #endif
 
-static int erofs_read_super(struct super_block *sb,
-			    const char *dev_name,
-			    void *data, int silent)
+static int erofs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct inode *inode;
 	struct erofs_sb_info *sbi;
 	int err = -EINVAL;
 
-	infoln("read_super, device -> %s", dev_name);
+	infoln("fill_super, device -> %s", sb->s_id);
 	infoln("options -> %s", (char *)data);
 
 	if (unlikely(!sb_set_blocksize(sb, EROFS_BLKSIZ))) {
@@ -448,30 +446,16 @@ static int erofs_read_super(struct super_block *sb,
 		goto err_iget;
 	}
 
-	/* save the device name to sbi */
-	sbi->dev_name = __getname();
-	if (!sbi->dev_name) {
-		err = -ENOMEM;
-		goto err_devname;
-	}
-
-	snprintf(sbi->dev_name, PATH_MAX, "%s", dev_name);
-	sbi->dev_name[PATH_MAX - 1] = '\0';
-
 	erofs_shrinker_register(sb);
 
 	if (!silent)
-		infoln("mounted on %s with opts: %s.", dev_name,
-		       (char *)data);
+		infoln("mounted on %s with opts: %s.", sb->s_id, (char *)data);
 	return 0;
 	/*
 	 * please add a label for each exit point and use
 	 * the following name convention, thus new features
 	 * can be integrated easily without renaming labels.
 	 */
-err_devname:
-	dput(sb->s_root);
-	sb->s_root = NULL;
 err_iget:
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
 	iput(sbi->managed_cache);
@@ -499,8 +483,7 @@ static void erofs_put_super(struct super_block *sb)
 
 	WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
 
-	infoln("unmounted for %s", sbi->dev_name);
-	__putname(sbi->dev_name);
+	infoln("unmounted for %s", sb->s_id);
 
 	erofs_shrinker_unregister(sb);
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
@@ -510,33 +493,10 @@ static void erofs_put_super(struct super_block *sb)
 	sb->s_fs_info = NULL;
 }
 
-
-struct erofs_mount_private {
-	const char *dev_name;
-	char *options;
-};
-
-/* support mount_bdev() with options */
-static int erofs_fill_super(struct super_block *sb,
-			    void *_priv, int silent)
-{
-	struct erofs_mount_private *priv = _priv;
-
-	return erofs_read_super(sb, priv->dev_name,
-		priv->options, silent);
-}
-
-static struct dentry *erofs_mount(
-	struct file_system_type *fs_type, int flags,
-	const char *dev_name, void *data)
+static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags,
+				  const char *dev_name, void *data)
 {
-	struct erofs_mount_private priv = {
-		.dev_name = dev_name,
-		.options = data
-	};
-
-	return mount_bdev(fs_type, flags, dev_name,
-		&priv, erofs_fill_super);
+	return mount_bdev(fs_type, flags, dev_name, data, erofs_fill_super);
 }
 
 static struct file_system_type erofs_fs_type = {
-- 
2.17.1


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

* [PATCH 11/22] staging: erofs: kill all failure handling in fill_super()
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (9 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 10/22] staging: erofs: kill sbi->dev_name Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  8:15   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 12/22] staging: erofs: refine erofs_allocpage() Gao Xiang
                   ` (10 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

.kill_sb() will do that instead in order to remove duplicated code.

Note that the initialzation of managed_cache is now moved
after s_root is assigned since it's more preferred to iput()
in .put_super() and all inodes should be evicted before
the end of generic_shutdown_super(sb).

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/super.c | 121 +++++++++++++++-------------------
 1 file changed, 53 insertions(+), 68 deletions(-)

diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index bfb6e1e09781..af5d87793e4d 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -343,51 +343,52 @@ static const struct address_space_operations managed_cache_aops = {
 	.invalidatepage = managed_cache_invalidatepage,
 };
 
-static struct inode *erofs_init_managed_cache(struct super_block *sb)
+static int erofs_init_managed_cache(struct super_block *sb)
 {
-	struct inode *inode = new_inode(sb);
+	struct erofs_sb_info *const sbi = EROFS_SB(sb);
+	struct inode *const inode = new_inode(sb);
 
 	if (unlikely(!inode))
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	set_nlink(inode, 1);
 	inode->i_size = OFFSET_MAX;
 
 	inode->i_mapping->a_ops = &managed_cache_aops;
 	mapping_set_gfp_mask(inode->i_mapping,
-			     GFP_NOFS | __GFP_HIGHMEM |
-			     __GFP_MOVABLE |  __GFP_NOFAIL);
-	return inode;
+			     GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE);
+	sbi->managed_cache = inode;
+	return 0;
 }
-
+#else
+static int erofs_init_managed_cache(struct super_block *sb) { return 0; }
 #endif
 
 static int erofs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct inode *inode;
 	struct erofs_sb_info *sbi;
-	int err = -EINVAL;
+	int err;
 
 	infoln("fill_super, device -> %s", sb->s_id);
 	infoln("options -> %s", (char *)data);
 
+	sb->s_magic = EROFS_SUPER_MAGIC;
+
 	if (unlikely(!sb_set_blocksize(sb, EROFS_BLKSIZ))) {
 		errln("failed to set erofs blksize");
-		goto err;
+		return -EINVAL;
 	}
 
 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
-	if (unlikely(!sbi)) {
-		err = -ENOMEM;
-		goto err;
-	}
-	sb->s_fs_info = sbi;
+	if (unlikely(!sbi))
+		return -ENOMEM;
 
+	sb->s_fs_info = sbi;
 	err = superblock_read(sb);
 	if (err)
-		goto err_sbread;
+		return err;
 
-	sb->s_magic = EROFS_SUPER_MAGIC;
 	sb->s_flags |= SB_RDONLY | SB_NOATIME;
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
 	sb->s_time_gran = 1;
@@ -397,13 +398,12 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
 #ifdef CONFIG_EROFS_FS_XATTR
 	sb->s_xattr = erofs_xattr_handlers;
 #endif
-
 	/* set erofs default mount options */
 	default_options(sbi);
 
 	err = parse_options(sb, data);
-	if (err)
-		goto err_parseopt;
+	if (unlikely(err))
+		return err;
 
 	if (!silent)
 		infoln("root inode @ nid %llu", ROOT_NID(sbi));
@@ -417,93 +417,78 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
 	INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC);
 #endif
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-	sbi->managed_cache = erofs_init_managed_cache(sb);
-	if (IS_ERR(sbi->managed_cache)) {
-		err = PTR_ERR(sbi->managed_cache);
-		goto err_init_managed_cache;
-	}
-#endif
-
 	/* get the root inode */
 	inode = erofs_iget(sb, ROOT_NID(sbi), true);
-	if (IS_ERR(inode)) {
-		err = PTR_ERR(inode);
-		goto err_iget;
-	}
+	if (IS_ERR(inode))
+		return PTR_ERR(inode);
 
-	if (!S_ISDIR(inode->i_mode)) {
+	if (unlikely(!S_ISDIR(inode->i_mode))) {
 		errln("rootino(nid %llu) is not a directory(i_mode %o)",
 		      ROOT_NID(sbi), inode->i_mode);
-		err = -EINVAL;
 		iput(inode);
-		goto err_iget;
+		return -EINVAL;
 	}
 
 	sb->s_root = d_make_root(inode);
-	if (!sb->s_root) {
-		err = -ENOMEM;
-		goto err_iget;
-	}
+	if (unlikely(!sb->s_root))
+		return -ENOMEM;
 
 	erofs_shrinker_register(sb);
+	/* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */
+	err = erofs_init_managed_cache(sb);
+	if (unlikely(err))
+		return err;
 
 	if (!silent)
 		infoln("mounted on %s with opts: %s.", sb->s_id, (char *)data);
 	return 0;
-	/*
-	 * please add a label for each exit point and use
-	 * the following name convention, thus new features
-	 * can be integrated easily without renaming labels.
-	 */
-err_iget:
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-	iput(sbi->managed_cache);
-err_init_managed_cache:
-#endif
-err_parseopt:
-err_sbread:
-	sb->s_fs_info = NULL;
-	kfree(sbi);
-err:
-	return err;
+}
+
+static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags,
+				  const char *dev_name, void *data)
+{
+	return mount_bdev(fs_type, flags, dev_name, data, erofs_fill_super);
 }
 
 /*
  * could be triggered after deactivate_locked_super()
  * is called, thus including umount and failed to initialize.
  */
-static void erofs_put_super(struct super_block *sb)
+static void erofs_kill_sb(struct super_block *sb)
 {
-	struct erofs_sb_info *sbi = EROFS_SB(sb);
+	struct erofs_sb_info *sbi;
+
+	WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
+	infoln("unmounting for %s", sb->s_id);
 
-	/* for cases which are failed in "read_super" */
+	kill_block_super(sb);
+
+	sbi = EROFS_SB(sb);
 	if (!sbi)
 		return;
+	kfree(sbi);
+	sb->s_fs_info = NULL;
+}
 
-	WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
+/* called when ->s_root is non-NULL */
+static void erofs_put_super(struct super_block *sb)
+{
+	struct erofs_sb_info *const sbi = EROFS_SB(sb);
 
-	infoln("unmounted for %s", sb->s_id);
+	DBG_BUGON(!sbi);
 
 	erofs_shrinker_unregister(sb);
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
 	iput(sbi->managed_cache);
+	sbi->managed_cache = NULL;
 #endif
-	kfree(sbi);
-	sb->s_fs_info = NULL;
-}
-
-static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags,
-				  const char *dev_name, void *data)
-{
-	return mount_bdev(fs_type, flags, dev_name, data, erofs_fill_super);
 }
 
 static struct file_system_type erofs_fs_type = {
 	.owner          = THIS_MODULE,
 	.name           = "erofs",
 	.mount          = erofs_mount,
-	.kill_sb        = kill_block_super,
+	.kill_sb        = erofs_kill_sb,
 	.fs_flags       = FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("erofs");
-- 
2.17.1


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

* [PATCH 12/22] staging: erofs: refine erofs_allocpage()
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (10 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 11/22] staging: erofs: kill all failure handling in fill_super() Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  8:20   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 13/22] staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM Gao Xiang
                   ` (9 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

remove duplicated code in decompressor by introducing
failable erofs_allocpage().

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/decompressor.c | 12 +++---------
 drivers/staging/erofs/internal.h     |  2 +-
 drivers/staging/erofs/utils.c        |  5 +++--
 drivers/staging/erofs/zdata.c        |  2 +-
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c
index ee5762351f80..744c43a456e9 100644
--- a/drivers/staging/erofs/decompressor.c
+++ b/drivers/staging/erofs/decompressor.c
@@ -74,15 +74,9 @@ static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
 			victim = availables[--top];
 			get_page(victim);
 		} else {
-			if (!list_empty(pagepool)) {
-				victim = lru_to_page(pagepool);
-				list_del(&victim->lru);
-				DBG_BUGON(page_ref_count(victim) != 1);
-			} else {
-				victim = alloc_pages(GFP_KERNEL, 0);
-				if (!victim)
-					return -ENOMEM;
-			}
+			victim = erofs_allocpage(pagepool, GFP_KERNEL, false);
+			if (unlikely(!victim))
+				return -ENOMEM;
 			victim->mapping = Z_EROFS_MAPPING_STAGING;
 		}
 		rq->out[i] = victim;
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index b206a85776b4..e35c7d8f75d2 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -517,7 +517,7 @@ int erofs_namei(struct inode *dir, struct qstr *name,
 extern const struct file_operations erofs_dir_fops;
 
 /* utils.c / zdata.c */
-struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp);
+struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp, bool nofail);
 
 #if (EROFS_PCPUBUF_NR_PAGES > 0)
 void *erofs_get_pcpubuf(unsigned int pagenr);
diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index 0e86e44d60d0..260ea2970b4b 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -9,15 +9,16 @@
 #include "internal.h"
 #include <linux/pagevec.h>
 
-struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp)
+struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp, bool nofail)
 {
 	struct page *page;
 
 	if (!list_empty(pool)) {
 		page = lru_to_page(pool);
+		DBG_BUGON(page_ref_count(page) != 1);
 		list_del(&page->lru);
 	} else {
-		page = alloc_pages(gfp | __GFP_NOFAIL, 0);
+		page = alloc_pages(gfp | (nofail ? __GFP_NOFAIL : 0), 0);
 	}
 	return page;
 }
diff --git a/drivers/staging/erofs/zdata.c b/drivers/staging/erofs/zdata.c
index bc478eebf509..02560b940558 100644
--- a/drivers/staging/erofs/zdata.c
+++ b/drivers/staging/erofs/zdata.c
@@ -634,7 +634,7 @@ z_erofs_vle_work_iter_end(struct z_erofs_vle_work_builder *builder)
 static inline struct page *__stagingpage_alloc(struct list_head *pagepool,
 					       gfp_t gfp)
 {
-	struct page *page = erofs_allocpage(pagepool, gfp);
+	struct page *page = erofs_allocpage(pagepool, gfp, true);
 
 	if (unlikely(!page))
 		return NULL;
-- 
2.17.1


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

* [PATCH 13/22] staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (11 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 12/22] staging: erofs: refine erofs_allocpage() Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  8:27   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 14/22] staging: erofs: tidy up zpvec.h Gao Xiang
                   ` (8 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Turn into a module parameter ("use_vmap") as it
can be set at runtime.

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/Kconfig        |  8 ------
 drivers/staging/erofs/decompressor.c | 37 +++++++++++++++-------------
 2 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig
index 747e9eebfaa5..788beebf3f7d 100644
--- a/drivers/staging/erofs/Kconfig
+++ b/drivers/staging/erofs/Kconfig
@@ -63,14 +63,6 @@ config EROFS_FS_SECURITY
 
 	  If you are not using a security module, say N.
 
-config EROFS_FS_USE_VM_MAP_RAM
-	bool "EROFS VM_MAP_RAM Support"
-	depends on EROFS_FS
-	help
-	  use vm_map_ram/vm_unmap_ram instead of vmap/vunmap.
-
-	  If you don't know what these are, say N.
-
 config EROFS_FAULT_INJECTION
 	bool "EROFS fault injection facility"
 	depends on EROFS_FS
diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c
index 744c43a456e9..5352a50981cb 100644
--- a/drivers/staging/erofs/decompressor.c
+++ b/drivers/staging/erofs/decompressor.c
@@ -7,6 +7,7 @@
  * Created by Gao Xiang <gaoxiang25@huawei.com>
  */
 #include "compress.h"
+#include <linux/module.h>
 #include <linux/lz4.h>
 
 #ifndef LZ4_DISTANCE_MAX	/* history window size */
@@ -29,6 +30,10 @@ struct z_erofs_decompressor {
 	char *name;
 };
 
+static bool use_vmap;
+module_param(use_vmap, bool, 0444);
+MODULE_PARM_DESC(use_vmap, "Use vmap() instead of vm_map_ram() (default 0)");
+
 static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
 				 struct list_head *pagepool)
 {
@@ -219,29 +224,27 @@ static void copy_from_pcpubuf(struct page **out, const char *dst,
 
 static void *erofs_vmap(struct page **pages, unsigned int count)
 {
-#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
-	int i = 0;
-
-	while (1) {
-		void *addr = vm_map_ram(pages, count, -1, PAGE_KERNEL);
-		/* retry two more times (totally 3 times) */
-		if (addr || ++i >= 3)
-			return addr;
-		vm_unmap_aliases();
+	if (!use_vmap) {
+		int i = 0;
+
+		while (1) {
+			void *addr = vm_map_ram(pages, count, -1, PAGE_KERNEL);
+			/* retry two more times (totally 3 times) */
+			if (addr || ++i >= 3)
+				return addr;
+			vm_unmap_aliases();
+		}
+		return NULL;
 	}
-	return NULL;
-#else
 	return vmap(pages, count, VM_MAP, PAGE_KERNEL);
-#endif
 }
 
 static void erofs_vunmap(const void *mem, unsigned int count)
 {
-#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
-	vm_unmap_ram(mem, count);
-#else
-	vunmap(mem);
-#endif
+	if (!use_vmap)
+		vm_unmap_ram(mem, count);
+	else
+		vunmap(mem);
 }
 
 static int decompress_generic(struct z_erofs_decompress_req *rq,
-- 
2.17.1


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

* [PATCH 14/22] staging: erofs: tidy up zpvec.h
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (12 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 13/22] staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  8:28   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 15/22] staging: erofs: remove redundant braces in inode.c Gao Xiang
                   ` (7 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

- use shorter function names:
  z_erofs_pagevec_enqueue and z_erofs_pagevec_dequeue;
- minor code cleanup.

In order to keep in line with erofs-outofstaging patchset.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/zdata.c |  6 +++---
 drivers/staging/erofs/zpvec.h | 25 +++++++++----------------
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/erofs/zdata.c b/drivers/staging/erofs/zdata.c
index 02560b940558..29900ca7c9d4 100644
--- a/drivers/staging/erofs/zdata.c
+++ b/drivers/staging/erofs/zdata.c
@@ -314,8 +314,8 @@ static int z_erofs_vle_work_add_page(
 	    try_to_reuse_as_compressed_page(builder, page))
 		return 0;
 
-	ret = z_erofs_pagevec_ctor_enqueue(&builder->vector,
-					   page, type, &occupied);
+	ret = z_erofs_pagevec_enqueue(&builder->vector,
+				      page, type, &occupied);
 	builder->work->vcnt += (unsigned int)ret;
 
 	return ret ? 0 : -EAGAIN;
@@ -941,7 +941,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 	for (i = 0; i < work->vcnt; ++i) {
 		unsigned int pagenr;
 
-		page = z_erofs_pagevec_ctor_dequeue(&ctor, &page_type);
+		page = z_erofs_pagevec_dequeue(&ctor, &page_type);
 
 		/* all pages in pagevec ought to be valid */
 		DBG_BUGON(!page);
diff --git a/drivers/staging/erofs/zpvec.h b/drivers/staging/erofs/zpvec.h
index 77bf6877bad8..9798f5627786 100644
--- a/drivers/staging/erofs/zpvec.h
+++ b/drivers/staging/erofs/zpvec.h
@@ -11,7 +11,7 @@
 
 #include "tagptr.h"
 
-/* page type in pagevec for unzip subsystem */
+/* page type in pagevec for decompress subsystem */
 enum z_erofs_page_type {
 	/* including Z_EROFS_VLE_PAGE_TAIL_EXCLUSIVE */
 	Z_EROFS_PAGE_TYPE_EXCLUSIVE,
@@ -103,16 +103,14 @@ static inline void z_erofs_pagevec_ctor_init(struct z_erofs_pagevec_ctor *ctor,
 			z_erofs_pagevec_ctor_pagedown(ctor, false);
 		}
 	}
-
 	ctor->next = z_erofs_pagevec_ctor_next_page(ctor, i);
 	ctor->index = i;
 }
 
-static inline bool
-z_erofs_pagevec_ctor_enqueue(struct z_erofs_pagevec_ctor *ctor,
-			     struct page *page,
-			     enum z_erofs_page_type type,
-			     bool *occupied)
+static inline bool z_erofs_pagevec_enqueue(struct z_erofs_pagevec_ctor *ctor,
+					   struct page *page,
+					   enum z_erofs_page_type type,
+					   bool *occupied)
 {
 	*occupied = false;
 	if (unlikely(!ctor->next && type))
@@ -131,15 +129,13 @@ z_erofs_pagevec_ctor_enqueue(struct z_erofs_pagevec_ctor *ctor,
 		ctor->next = page;
 		*occupied = true;
 	}
-
-	ctor->pages[ctor->index++] =
-		tagptr_fold(erofs_vtptr_t, page, type);
+	ctor->pages[ctor->index++] = tagptr_fold(erofs_vtptr_t, page, type);
 	return true;
 }
 
 static inline struct page *
-z_erofs_pagevec_ctor_dequeue(struct z_erofs_pagevec_ctor *ctor,
-			     enum z_erofs_page_type *type)
+z_erofs_pagevec_dequeue(struct z_erofs_pagevec_ctor *ctor,
+			enum z_erofs_page_type *type)
 {
 	erofs_vtptr_t t;
 
@@ -156,11 +152,8 @@ z_erofs_pagevec_ctor_dequeue(struct z_erofs_pagevec_ctor *ctor,
 	if (*type == (uintptr_t)ctor->next)
 		ctor->next = tagptr_unfold_ptr(t);
 
-	ctor->pages[ctor->index++] =
-		tagptr_fold(erofs_vtptr_t, NULL, 0);
-
+	ctor->pages[ctor->index++] = tagptr_fold(erofs_vtptr_t, NULL, 0);
 	return tagptr_unfold_ptr(t);
 }
-
 #endif
 
-- 
2.17.1


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

* [PATCH 15/22] staging: erofs: remove redundant braces in inode.c
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (13 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 14/22] staging: erofs: tidy up zpvec.h Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  8:29   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 16/22] staging: erofs: tidy up decompression frontend Gao Xiang
                   ` (6 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Remove redundant braces in inode.c since
these are all single statements.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/inode.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c
index c13d66ccc74a..286729143365 100644
--- a/drivers/staging/erofs/inode.c
+++ b/drivers/staging/erofs/inode.c
@@ -35,16 +35,15 @@ static int read_inode(struct inode *inode, void *data)
 
 		inode->i_mode = le16_to_cpu(v2->i_mode);
 		if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
-		    S_ISLNK(inode->i_mode)) {
+		    S_ISLNK(inode->i_mode))
 			vi->raw_blkaddr = le32_to_cpu(v2->i_u.raw_blkaddr);
-		} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
+		else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
 			inode->i_rdev =
 				new_decode_dev(le32_to_cpu(v2->i_u.rdev));
-		} else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
+		else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode))
 			inode->i_rdev = 0;
-		} else {
+		else
 			return -EIO;
-		}
 
 		i_uid_write(inode, le32_to_cpu(v2->i_uid));
 		i_gid_write(inode, le32_to_cpu(v2->i_gid));
@@ -69,16 +68,15 @@ static int read_inode(struct inode *inode, void *data)
 
 		inode->i_mode = le16_to_cpu(v1->i_mode);
 		if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
-		    S_ISLNK(inode->i_mode)) {
+		    S_ISLNK(inode->i_mode))
 			vi->raw_blkaddr = le32_to_cpu(v1->i_u.raw_blkaddr);
-		} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
+		else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
 			inode->i_rdev =
 				new_decode_dev(le32_to_cpu(v1->i_u.rdev));
-		} else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
+		else if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode))
 			inode->i_rdev = 0;
-		} else {
+		else
 			return -EIO;
-		}
 
 		i_uid_write(inode, le16_to_cpu(v1->i_uid));
 		i_gid_write(inode, le16_to_cpu(v1->i_gid));
-- 
2.17.1


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

* [PATCH 16/22] staging: erofs: tidy up decompression frontend
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (14 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 15/22] staging: erofs: remove redundant braces in inode.c Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  9:07   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 17/22] staging: erofs: remove clusterbits in sbi Gao Xiang
                   ` (5 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Although this patch has an amount of changes, it is hard to
separate into smaller patches.

Most changes are due to structure renaming for better understand
and straightforward,
 z_erofs_vle_workgroup to z_erofs_pcluster
             since it represents a physical cluster;
 z_erofs_vle_work to z_erofs_collection
             since it represents a collection of logical pages;
 z_erofs_vle_work_builder to z_erofs_collector
             since it's used to fill z_erofs_{pcluster,collection}.

struct z_erofs_vle_work_finder has no extra use compared with
struct z_erofs_collector, delete it.

FULL_LENGTH bit is integrated into .length of pcluster so that it
can be updated with the corresponding length change in atomic.

Minor, add comments for better description.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/zdata.c | 983 +++++++++++++++-------------------
 drivers/staging/erofs/zdata.h |  96 ++--
 2 files changed, 465 insertions(+), 614 deletions(-)

diff --git a/drivers/staging/erofs/zdata.c b/drivers/staging/erofs/zdata.c
index 29900ca7c9d4..34ee19b4721d 100644
--- a/drivers/staging/erofs/zdata.c
+++ b/drivers/staging/erofs/zdata.c
@@ -18,7 +18,7 @@
  */
 #define PAGE_UNALLOCATED     ((void *)0x5F0E4B1D)
 
-/* how to allocate cached pages for a workgroup */
+/* how to allocate cached pages for a pcluster */
 enum z_erofs_cache_alloctype {
 	DONTALLOC,	/* don't allocate any cached pages */
 	DELAYEDALLOC,	/* delayed allocation (at the time of submitting io) */
@@ -34,156 +34,158 @@ typedef tagptr1_t compressed_page_t;
 	tagptr_fold(compressed_page_t, page, 1)
 
 static struct workqueue_struct *z_erofs_workqueue __read_mostly;
-static struct kmem_cache *z_erofs_workgroup_cachep __read_mostly;
+static struct kmem_cache *pcluster_cachep __read_mostly;
 
 void z_erofs_exit_zip_subsystem(void)
 {
 	destroy_workqueue(z_erofs_workqueue);
-	kmem_cache_destroy(z_erofs_workgroup_cachep);
+	kmem_cache_destroy(pcluster_cachep);
 }
 
 static inline int init_unzip_workqueue(void)
 {
 	const unsigned int onlinecpus = num_possible_cpus();
+	const unsigned int flags = WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE;
 
 	/*
-	 * we don't need too many threads, limiting threads
-	 * could improve scheduling performance.
+	 * no need to spawn too many threads, limiting threads could minimum
+	 * scheduling overhead, perhaps per-CPU threads should be better?
 	 */
-	z_erofs_workqueue =
-		alloc_workqueue("erofs_unzipd",
-				WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE,
-				onlinecpus + onlinecpus / 4);
-
+	z_erofs_workqueue = alloc_workqueue("erofs_unzipd", flags,
+					    onlinecpus + onlinecpus / 4);
 	return z_erofs_workqueue ? 0 : -ENOMEM;
 }
 
 static void init_once(void *ptr)
 {
-	struct z_erofs_vle_workgroup *grp = ptr;
-	struct z_erofs_vle_work *const work =
-		z_erofs_vle_grab_primary_work(grp);
+	struct z_erofs_pcluster *pcl = ptr;
+	struct z_erofs_collection *cl = z_erofs_primarycollection(pcl);
 	unsigned int i;
 
-	mutex_init(&work->lock);
-	work->nr_pages = 0;
-	work->vcnt = 0;
+	mutex_init(&cl->lock);
+	cl->nr_pages = 0;
+	cl->vcnt = 0;
 	for (i = 0; i < Z_EROFS_CLUSTER_MAX_PAGES; ++i)
-		grp->compressed_pages[i] = NULL;
+		pcl->compressed_pages[i] = NULL;
 }
 
-static void init_always(struct z_erofs_vle_workgroup *grp)
+static void init_always(struct z_erofs_pcluster *pcl)
 {
-	struct z_erofs_vle_work *const work =
-		z_erofs_vle_grab_primary_work(grp);
+	struct z_erofs_collection *cl = z_erofs_primarycollection(pcl);
 
-	atomic_set(&grp->obj.refcount, 1);
-	grp->flags = 0;
+	atomic_set(&pcl->obj.refcount, 1);
 
-	DBG_BUGON(work->nr_pages);
-	DBG_BUGON(work->vcnt);
+	DBG_BUGON(cl->nr_pages);
+	DBG_BUGON(cl->vcnt);
 }
 
 int __init z_erofs_init_zip_subsystem(void)
 {
-	z_erofs_workgroup_cachep =
-		kmem_cache_create("erofs_compress",
-				  Z_EROFS_WORKGROUP_SIZE, 0,
-				  SLAB_RECLAIM_ACCOUNT, init_once);
-
-	if (z_erofs_workgroup_cachep) {
+	pcluster_cachep = kmem_cache_create("erofs_compress",
+					    Z_EROFS_WORKGROUP_SIZE, 0,
+					    SLAB_RECLAIM_ACCOUNT, init_once);
+	if (pcluster_cachep) {
 		if (!init_unzip_workqueue())
 			return 0;
 
-		kmem_cache_destroy(z_erofs_workgroup_cachep);
+		kmem_cache_destroy(pcluster_cachep);
 	}
 	return -ENOMEM;
 }
 
-enum z_erofs_vle_work_role {
-	Z_EROFS_VLE_WORK_SECONDARY,
-	Z_EROFS_VLE_WORK_PRIMARY,
+enum z_erofs_collectmode {
+	COLLECT_SECONDARY,
+	COLLECT_PRIMARY,
 	/*
-	 * The current work was the tail of an exist chain, and the previous
-	 * processed chained works are all decided to be hooked up to it.
-	 * A new chain should be created for the remaining unprocessed works,
-	 * therefore different from Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED,
-	 * the next work cannot reuse the whole page in the following scenario:
+	 * The current collection was the tail of an exist chain, in addition
+	 * that the previous processed chained collections are all decided to
+	 * be hooked up to it.
+	 * A new chain will be created for the remaining collections which are
+	 * not processed yet, therefore different from COLLECT_PRIMARY_FOLLOWED,
+	 * the next collection cannot reuse the whole page safely in
+	 * the following scenario:
 	 *  ________________________________________________________________
 	 * |      tail (partial) page     |       head (partial) page       |
-	 * |  (belongs to the next work)  |  (belongs to the current work)  |
+	 * |   (belongs to the next cl)   |   (belongs to the current cl)   |
 	 * |_______PRIMARY_FOLLOWED_______|________PRIMARY_HOOKED___________|
 	 */
-	Z_EROFS_VLE_WORK_PRIMARY_HOOKED,
+	COLLECT_PRIMARY_HOOKED,
+	COLLECT_PRIMARY_FOLLOWED_NOINPLACE,
 	/*
-	 * The current work has been linked with the processed chained works,
-	 * and could be also linked with the potential remaining works, which
-	 * means if the processing page is the tail partial page of the work,
-	 * the current work can safely use the whole page (since the next work
-	 * is under control) for in-place decompression, as illustrated below:
+	 * The current collection has been linked with the owned chain, and
+	 * could also be linked with the remaining collections, which means
+	 * if the processing page is the tail page of the collection, thus
+	 * the current collection can safely use the whole page (since
+	 * the previous collection is under control) for in-place I/O, as
+	 * illustrated below:
 	 *  ________________________________________________________________
-	 * |  tail (partial) page  |          head (partial) page           |
-	 * | (of the current work) |         (of the previous work)         |
-	 * |  PRIMARY_FOLLOWED or  |                                        |
-	 * |_____PRIMARY_HOOKED____|____________PRIMARY_FOLLOWED____________|
+	 * |  tail (partial) page |          head (partial) page           |
+	 * |  (of the current cl) |      (of the previous collection)      |
+	 * |  PRIMARY_FOLLOWED or |                                        |
+	 * |_____PRIMARY_HOOKED___|____________PRIMARY_FOLLOWED____________|
 	 *
-	 * [  (*) the above page can be used for the current work itself.  ]
+	 * [  (*) the above page can be used as inplace I/O.               ]
 	 */
-	Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED,
-	Z_EROFS_VLE_WORK_MAX
+	COLLECT_PRIMARY_FOLLOWED,
 };
 
-struct z_erofs_vle_work_builder {
-	enum z_erofs_vle_work_role role;
-	/*
-	 * 'hosted = false' means that the current workgroup doesn't belong to
-	 * the owned chained workgroups. In the other words, it is none of our
-	 * business to submit this workgroup.
-	 */
-	bool hosted;
-
-	struct z_erofs_vle_workgroup *grp;
-	struct z_erofs_vle_work *work;
+struct z_erofs_collector {
 	struct z_erofs_pagevec_ctor vector;
 
-	/* pages used for reading the compressed data */
-	struct page **compressed_pages;
-	unsigned int compressed_deficit;
+	struct z_erofs_pcluster *pcl;
+	struct z_erofs_collection *cl;
+	struct page **compressedpages;
+	z_erofs_next_pcluster_t owned_head;
+
+	enum z_erofs_collectmode mode;
 };
 
-#define VLE_WORK_BUILDER_INIT()	\
-	{ .work = NULL, .role = Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED }
+struct z_erofs_decompress_frontend {
+	struct inode *const inode;
+
+	struct z_erofs_collector clt;
+	struct erofs_map_blocks map;
+
+	/* used for applying cache strategy on the fly */
+	bool backmost;
+	erofs_off_t headoffset;
+};
+
+#define COLLECTOR_INIT() { \
+	.owned_head = Z_EROFS_PCLUSTER_TAIL, \
+	.mode = COLLECT_PRIMARY_FOLLOWED }
+
+#define DECOMPRESS_FRONTEND_INIT(__i) { \
+	.inode = __i, .clt = COLLECTOR_INIT(), \
+	.backmost = true, }
+
+static struct page *z_pagemap_global[Z_EROFS_VMAP_GLOBAL_PAGES];
+static DEFINE_MUTEX(z_pagemap_global_lock);
 
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
-static void preload_compressed_pages(struct z_erofs_vle_work_builder *bl,
+static void preload_compressed_pages(struct z_erofs_collector *clt,
 				     struct address_space *mc,
-				     pgoff_t index,
-				     unsigned int clusterpages,
 				     enum z_erofs_cache_alloctype type,
-				     struct list_head *pagepool,
-				     gfp_t gfp)
+				     struct list_head *pagepool)
 {
-	struct page **const pages = bl->compressed_pages;
-	const unsigned int remaining = bl->compressed_deficit;
+	const struct z_erofs_pcluster *pcl = clt->pcl;
+	const unsigned int clusterpages = BIT(pcl->clusterbits);
+	struct page **pages = clt->compressedpages;
+	pgoff_t index = pcl->obj.index + (pages - pcl->compressed_pages);
 	bool standalone = true;
-	unsigned int i, j = 0;
 
-	if (bl->role < Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED)
+	if (clt->mode < COLLECT_PRIMARY_FOLLOWED)
 		return;
 
-	gfp = mapping_gfp_constraint(mc, gfp) & ~__GFP_RECLAIM;
-
-	index += clusterpages - remaining;
-
-	for (i = 0; i < remaining; ++i) {
+	for (; pages < pcl->compressed_pages + clusterpages; ++pages) {
 		struct page *page;
 		compressed_page_t t;
 
 		/* the compressed page was loaded before */
-		if (READ_ONCE(pages[i]))
+		if (READ_ONCE(*pages))
 			continue;
 
-		page = find_get_page(mc, index + i);
+		page = find_get_page(mc, index);
 
 		if (page) {
 			t = tag_compressed_page_justfound(page);
@@ -191,32 +193,30 @@ static void preload_compressed_pages(struct z_erofs_vle_work_builder *bl,
 			t = tagptr_init(compressed_page_t, PAGE_UNALLOCATED);
 		} else {	/* DONTALLOC */
 			if (standalone)
-				j = i;
+				clt->compressedpages = pages;
 			standalone = false;
 			continue;
 		}
 
-		if (!cmpxchg_relaxed(&pages[i], NULL, tagptr_cast_ptr(t)))
+		if (!cmpxchg_relaxed(pages, NULL, tagptr_cast_ptr(t)))
 			continue;
 
 		if (page)
 			put_page(page);
 	}
-	bl->compressed_pages += j;
-	bl->compressed_deficit = remaining - j;
 
-	if (standalone)
-		bl->role = Z_EROFS_VLE_WORK_PRIMARY;
+	if (standalone)		/* downgrade to PRIMARY_FOLLOWED_NOINPLACE */
+		clt->mode = COLLECT_PRIMARY_FOLLOWED_NOINPLACE;
 }
 
 /* called by erofs_shrinker to get rid of all compressed_pages */
 int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
-				       struct erofs_workgroup *egrp)
+				       struct erofs_workgroup *grp)
 {
-	struct z_erofs_vle_workgroup *const grp =
-		container_of(egrp, struct z_erofs_vle_workgroup, obj);
+	struct z_erofs_pcluster *const pcl =
+		container_of(grp, struct z_erofs_pcluster, obj);
 	struct address_space *const mapping = MNGD_MAPPING(sbi);
-	const int clusterpages = erofs_clusterpages(sbi);
+	const unsigned int clusterpages = BIT(pcl->clusterbits);
 	int i;
 
 	/*
@@ -224,18 +224,20 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
 	 * therefore no need to worry about available decompression users.
 	 */
 	for (i = 0; i < clusterpages; ++i) {
-		struct page *page = grp->compressed_pages[i];
+		struct page *page = pcl->compressed_pages[i];
 
-		if (!page || page->mapping != mapping)
+		if (!page)
 			continue;
 
 		/* block other users from reclaiming or migrating the page */
 		if (!trylock_page(page))
 			return -EBUSY;
 
-		/* barrier is implied in the following 'unlock_page' */
-		WRITE_ONCE(grp->compressed_pages[i], NULL);
+		if (unlikely(page->mapping != mapping))
+			continue;
 
+		/* barrier is implied in the following 'unlock_page' */
+		WRITE_ONCE(pcl->compressed_pages[i], NULL);
 		set_page_private(page, 0);
 		ClearPagePrivate(page);
 
@@ -248,22 +250,21 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
 int erofs_try_to_free_cached_page(struct address_space *mapping,
 				  struct page *page)
 {
-	struct erofs_sb_info *const sbi = EROFS_SB(mapping->host->i_sb);
-	const unsigned int clusterpages = erofs_clusterpages(sbi);
-	struct z_erofs_vle_workgroup *const grp = (void *)page_private(page);
+	struct z_erofs_pcluster *const pcl = (void *)page_private(page);
+	const unsigned int clusterpages = BIT(pcl->clusterbits);
 	int ret = 0;	/* 0 - busy */
 
-	if (erofs_workgroup_try_to_freeze(&grp->obj, 1)) {
+	if (erofs_workgroup_try_to_freeze(&pcl->obj, 1)) {
 		unsigned int i;
 
 		for (i = 0; i < clusterpages; ++i) {
-			if (grp->compressed_pages[i] == page) {
-				WRITE_ONCE(grp->compressed_pages[i], NULL);
+			if (pcl->compressed_pages[i] == page) {
+				WRITE_ONCE(pcl->compressed_pages[i], NULL);
 				ret = 1;
 				break;
 			}
 		}
-		erofs_workgroup_unfreeze(&grp->obj, 1);
+		erofs_workgroup_unfreeze(&pcl->obj, 1);
 
 		if (ret) {
 			ClearPagePrivate(page);
@@ -273,361 +274,267 @@ int erofs_try_to_free_cached_page(struct address_space *mapping,
 	return ret;
 }
 #else
-static void preload_compressed_pages(struct z_erofs_vle_work_builder *bl,
+static void preload_compressed_pages(struct z_erofs_collector *clt,
 				     struct address_space *mc,
-				     pgoff_t index,
-				     unsigned int clusterpages,
 				     enum z_erofs_cache_alloctype type,
-				     struct list_head *pagepool,
-				     gfp_t gfp)
+				     struct list_head *pagepool)
 {
 	/* nowhere to load compressed pages from */
 }
 #endif
 
 /* page_type must be Z_EROFS_PAGE_TYPE_EXCLUSIVE */
-static inline bool try_to_reuse_as_compressed_page(
-	struct z_erofs_vle_work_builder *b,
-	struct page *page)
+static inline bool try_inplace_io(struct z_erofs_collector *clt,
+				  struct page *page)
 {
-	while (b->compressed_deficit) {
-		--b->compressed_deficit;
-		if (!cmpxchg(b->compressed_pages++, NULL, page))
+	struct z_erofs_pcluster *const pcl = clt->pcl;
+	const unsigned int clusterpages = BIT(pcl->clusterbits);
+
+	while (clt->compressedpages < pcl->compressed_pages + clusterpages) {
+		if (!cmpxchg(clt->compressedpages++, NULL, page))
 			return true;
 	}
-
 	return false;
 }
 
-/* callers must be with work->lock held */
-static int z_erofs_vle_work_add_page(
-	struct z_erofs_vle_work_builder *builder,
-	struct page *page,
-	enum z_erofs_page_type type)
+/* callers must be with collection lock held */
+static int z_erofs_attach_page(struct z_erofs_collector *clt,
+			       struct page *page,
+			       enum z_erofs_page_type type)
 {
 	int ret;
 	bool occupied;
 
-	/* give priority for the compressed data storage */
-	if (builder->role >= Z_EROFS_VLE_WORK_PRIMARY &&
+	/* give priority for inplaceio */
+	if (clt->mode >= COLLECT_PRIMARY &&
 	    type == Z_EROFS_PAGE_TYPE_EXCLUSIVE &&
-	    try_to_reuse_as_compressed_page(builder, page))
+	    try_inplace_io(clt, page))
 		return 0;
 
-	ret = z_erofs_pagevec_enqueue(&builder->vector,
+	ret = z_erofs_pagevec_enqueue(&clt->vector,
 				      page, type, &occupied);
-	builder->work->vcnt += (unsigned int)ret;
+	clt->cl->vcnt += (unsigned int)ret;
 
 	return ret ? 0 : -EAGAIN;
 }
 
-static enum z_erofs_vle_work_role
-try_to_claim_workgroup(struct z_erofs_vle_workgroup *grp,
-		       z_erofs_vle_owned_workgrp_t *owned_head,
-		       bool *hosted)
+static enum z_erofs_collectmode
+try_to_claim_pcluster(struct z_erofs_pcluster *pcl,
+		      z_erofs_next_pcluster_t *owned_head)
 {
-	DBG_BUGON(*hosted);
-
-	/* let's claim these following types of workgroup */
+	/* let's claim these following types of pclusters */
 retry:
-	if (grp->next == Z_EROFS_VLE_WORKGRP_NIL) {
-		/* type 1, nil workgroup */
-		if (cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_NIL,
-			    *owned_head) != Z_EROFS_VLE_WORKGRP_NIL)
+	if (pcl->next == Z_EROFS_PCLUSTER_NIL) {
+		/* type 1, nil pcluster */
+		if (cmpxchg(&pcl->next, Z_EROFS_PCLUSTER_NIL,
+			    *owned_head) != Z_EROFS_PCLUSTER_NIL)
 			goto retry;
 
-		*owned_head = &grp->next;
-		*hosted = true;
+		*owned_head = &pcl->next;
 		/* lucky, I am the followee :) */
-		return Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED;
-
-	} else if (grp->next == Z_EROFS_VLE_WORKGRP_TAIL) {
+		return COLLECT_PRIMARY_FOLLOWED;
+	} else if (pcl->next == Z_EROFS_PCLUSTER_TAIL) {
 		/*
 		 * type 2, link to the end of a existing open chain,
 		 * be careful that its submission itself is governed
 		 * by the original owned chain.
 		 */
-		if (cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_TAIL,
-			    *owned_head) != Z_EROFS_VLE_WORKGRP_TAIL)
+		if (cmpxchg(&pcl->next, Z_EROFS_PCLUSTER_TAIL,
+			    *owned_head) != Z_EROFS_PCLUSTER_TAIL)
 			goto retry;
-		*owned_head = Z_EROFS_VLE_WORKGRP_TAIL;
-		return Z_EROFS_VLE_WORK_PRIMARY_HOOKED;
+		*owned_head = Z_EROFS_PCLUSTER_TAIL;
+		return COLLECT_PRIMARY_HOOKED;
 	}
-
-	return Z_EROFS_VLE_WORK_PRIMARY; /* :( better luck next time */
+	return COLLECT_PRIMARY;	/* :( better luck next time */
 }
 
-struct z_erofs_vle_work_finder {
-	struct super_block *sb;
-	pgoff_t idx;
-	unsigned int pageofs;
-
-	struct z_erofs_vle_workgroup **grp_ret;
-	enum z_erofs_vle_work_role *role;
-	z_erofs_vle_owned_workgrp_t *owned_head;
-	bool *hosted;
-};
-
-static struct z_erofs_vle_work *
-z_erofs_vle_work_lookup(const struct z_erofs_vle_work_finder *f)
+static struct z_erofs_collection *cllookup(struct z_erofs_collector *clt,
+					   struct inode *inode,
+					   struct erofs_map_blocks *map)
 {
-	bool tag, primary;
-	struct erofs_workgroup *egrp;
-	struct z_erofs_vle_workgroup *grp;
-	struct z_erofs_vle_work *work;
-
-	egrp = erofs_find_workgroup(f->sb, f->idx, &tag);
-	if (!egrp) {
-		*f->grp_ret = NULL;
+	struct erofs_workgroup *grp;
+	struct z_erofs_pcluster *pcl;
+	struct z_erofs_collection *cl;
+	unsigned int length;
+	bool tag;
+
+	grp = erofs_find_workgroup(inode->i_sb, map->m_pa >> PAGE_SHIFT, &tag);
+	if (!grp)
 		return NULL;
-	}
 
-	grp = container_of(egrp, struct z_erofs_vle_workgroup, obj);
-	*f->grp_ret = grp;
+	pcl = container_of(grp, struct z_erofs_pcluster, obj);
+
+	cl = z_erofs_primarycollection(pcl);
+	if (unlikely(cl->pageofs != (map->m_la & ~PAGE_MASK))) {
+		DBG_BUGON(1);
+		return ERR_PTR(-EIO);
+	}
 
-	work = z_erofs_vle_grab_work(grp, f->pageofs);
-	/* if multiref is disabled, `primary' is always true */
-	primary = true;
+	length = READ_ONCE(pcl->length);
+	if (length & Z_EROFS_PCLUSTER_FULL_LENGTH) {
+		if ((map->m_llen << Z_EROFS_PCLUSTER_LENGTH_BIT) > length) {
+			DBG_BUGON(1);
+			return ERR_PTR(-EIO);
+		}
+	} else {
+		unsigned int llen = map->m_llen << Z_EROFS_PCLUSTER_LENGTH_BIT;
 
-	DBG_BUGON(work->pageofs != f->pageofs);
+		if (map->m_flags & EROFS_MAP_FULL_MAPPED)
+			llen |= Z_EROFS_PCLUSTER_FULL_LENGTH;
 
-	/*
-	 * lock must be taken first to avoid grp->next == NIL between
-	 * claiming workgroup and adding pages:
-	 *                        grp->next != NIL
-	 *   grp->next = NIL
-	 *   mutex_unlock_all
-	 *                        mutex_lock(&work->lock)
-	 *                        add all pages to pagevec
-	 *
-	 * [correct locking case 1]:
-	 *   mutex_lock(grp->work[a])
-	 *   ...
-	 *   mutex_lock(grp->work[b])     mutex_lock(grp->work[c])
-	 *   ...                          *role = SECONDARY
-	 *                                add all pages to pagevec
-	 *                                ...
-	 *                                mutex_unlock(grp->work[c])
-	 *   mutex_lock(grp->work[c])
-	 *   ...
-	 *   grp->next = NIL
-	 *   mutex_unlock_all
-	 *
-	 * [correct locking case 2]:
-	 *   mutex_lock(grp->work[b])
-	 *   ...
-	 *   mutex_lock(grp->work[a])
-	 *   ...
-	 *   mutex_lock(grp->work[c])
-	 *   ...
-	 *   grp->next = NIL
-	 *   mutex_unlock_all
-	 *                                mutex_lock(grp->work[a])
-	 *                                *role = PRIMARY_OWNER
-	 *                                add all pages to pagevec
-	 *                                ...
-	 */
-	mutex_lock(&work->lock);
-
-	*f->hosted = false;
-	if (!primary)
-		*f->role = Z_EROFS_VLE_WORK_SECONDARY;
-	else	/* claim the workgroup if possible */
-		*f->role = try_to_claim_workgroup(grp, f->owned_head,
-						  f->hosted);
-	return work;
+		while (llen > length &&
+		       length != cmpxchg_relaxed(&pcl->length, length, llen)) {
+			cpu_relax();
+			length = READ_ONCE(pcl->length);
+		}
+	}
+	mutex_lock(&cl->lock);
+	clt->mode = try_to_claim_pcluster(pcl, &clt->owned_head);
+	clt->pcl = pcl;
+	clt->cl = cl;
+	return cl;
 }
 
-static struct z_erofs_vle_work *
-z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f,
-			  struct erofs_map_blocks *map)
+static struct z_erofs_collection *clregister(struct z_erofs_collector *clt,
+					     struct inode *inode,
+					     struct erofs_map_blocks *map)
 {
-	bool gnew = false;
-	struct z_erofs_vle_workgroup *grp = *f->grp_ret;
-	struct z_erofs_vle_work *work;
-
-	/* if multiref is disabled, grp should never be nullptr */
-	if (unlikely(grp)) {
-		DBG_BUGON(1);
-		return ERR_PTR(-EINVAL);
-	}
+	struct z_erofs_pcluster *pcl;
+	struct z_erofs_collection *cl;
+	int err;
 
 	/* no available workgroup, let's allocate one */
-	grp = kmem_cache_alloc(z_erofs_workgroup_cachep, GFP_NOFS);
-	if (unlikely(!grp))
+	pcl = kmem_cache_alloc(pcluster_cachep, GFP_NOFS);
+	if (unlikely(!pcl))
 		return ERR_PTR(-ENOMEM);
 
-	init_always(grp);
-	grp->obj.index = f->idx;
-	grp->llen = map->m_llen;
+	init_always(pcl);
+	pcl->obj.index = map->m_pa >> PAGE_SHIFT;
 
-	z_erofs_vle_set_workgrp_fmt(grp, (map->m_flags & EROFS_MAP_ZIPPED) ?
-				    Z_EROFS_VLE_WORKGRP_FMT_LZ4 :
-				    Z_EROFS_VLE_WORKGRP_FMT_PLAIN);
+	pcl->length = (map->m_llen << Z_EROFS_PCLUSTER_LENGTH_BIT) |
+		(map->m_flags & EROFS_MAP_FULL_MAPPED ?
+			Z_EROFS_PCLUSTER_FULL_LENGTH : 0);
 
-	if (map->m_flags & EROFS_MAP_FULL_MAPPED)
-		grp->flags |= Z_EROFS_VLE_WORKGRP_FULL_LENGTH;
+	if (map->m_flags & EROFS_MAP_ZIPPED)
+		pcl->algorithmformat = Z_EROFS_COMPRESSION_LZ4;
+	else
+		pcl->algorithmformat = Z_EROFS_COMPRESSION_SHIFTED;
+
+	pcl->clusterbits = EROFS_V(inode)->z_physical_clusterbits[0];
+	pcl->clusterbits -= PAGE_SHIFT;
 
-	/* new workgrps have been claimed as type 1 */
-	WRITE_ONCE(grp->next, *f->owned_head);
-	/* primary and followed work for all new workgrps */
-	*f->role = Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED;
-	/* it should be submitted by ourselves */
-	*f->hosted = true;
+	/* new pclusters should be claimed as type 1, primary and followed */
+	pcl->next = clt->owned_head;
+	clt->mode = COLLECT_PRIMARY_FOLLOWED;
 
-	gnew = true;
-	work = z_erofs_vle_grab_primary_work(grp);
-	work->pageofs = f->pageofs;
+	cl = z_erofs_primarycollection(pcl);
+	cl->pageofs = map->m_la & ~PAGE_MASK;
 
 	/*
 	 * lock all primary followed works before visible to others
-	 * and mutex_trylock *never* fails for a new workgroup.
+	 * and mutex_trylock *never* fails for a new pcluster.
 	 */
-	mutex_trylock(&work->lock);
+	mutex_trylock(&cl->lock);
 
-	if (gnew) {
-		int err = erofs_register_workgroup(f->sb, &grp->obj, 0);
-
-		if (err) {
-			mutex_unlock(&work->lock);
-			kmem_cache_free(z_erofs_workgroup_cachep, grp);
-			return ERR_PTR(-EAGAIN);
-		}
+	err = erofs_register_workgroup(inode->i_sb, &pcl->obj, 0);
+	if (err) {
+		mutex_unlock(&cl->lock);
+		kmem_cache_free(pcluster_cachep, pcl);
+		return ERR_PTR(-EAGAIN);
 	}
-
-	*f->owned_head = &grp->next;
-	*f->grp_ret = grp;
-	return work;
+	clt->owned_head = &pcl->next;
+	clt->pcl = pcl;
+	clt->cl = cl;
+	return cl;
 }
 
-#define builder_is_hooked(builder) \
-	((builder)->role >= Z_EROFS_VLE_WORK_PRIMARY_HOOKED)
+static int z_erofs_collector_begin(struct z_erofs_collector *clt,
+				   struct inode *inode,
+				   struct erofs_map_blocks *map)
+{
+	struct z_erofs_collection *cl;
 
-#define builder_is_followed(builder) \
-	((builder)->role >= Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED)
+	DBG_BUGON(clt->cl);
 
-static int z_erofs_vle_work_iter_begin(struct z_erofs_vle_work_builder *builder,
-				       struct super_block *sb,
-				       struct erofs_map_blocks *map,
-				       z_erofs_vle_owned_workgrp_t *owned_head)
-{
-	const unsigned int clusterpages = erofs_clusterpages(EROFS_SB(sb));
-	struct z_erofs_vle_workgroup *grp;
-	const struct z_erofs_vle_work_finder finder = {
-		.sb = sb,
-		.idx = erofs_blknr(map->m_pa),
-		.pageofs = map->m_la & ~PAGE_MASK,
-		.grp_ret = &grp,
-		.role = &builder->role,
-		.owned_head = owned_head,
-		.hosted = &builder->hosted
-	};
-	struct z_erofs_vle_work *work;
-
-	DBG_BUGON(builder->work);
-
-	/* must be Z_EROFS_WORK_TAIL or the next chained work */
-	DBG_BUGON(*owned_head == Z_EROFS_VLE_WORKGRP_NIL);
-	DBG_BUGON(*owned_head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
-
-	DBG_BUGON(erofs_blkoff(map->m_pa));
+	/* must be Z_EROFS_PCLUSTER_TAIL or pointed to previous collection */
+	DBG_BUGON(clt->owned_head == Z_EROFS_PCLUSTER_NIL);
+	DBG_BUGON(clt->owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED);
 
-repeat:
-	work = z_erofs_vle_work_lookup(&finder);
-	if (work) {
-		unsigned int orig_llen;
-
-		/* increase workgroup `llen' if needed */
-		while ((orig_llen = READ_ONCE(grp->llen)) < map->m_llen &&
-		       orig_llen != cmpxchg_relaxed(&grp->llen,
-						    orig_llen, map->m_llen))
-			cpu_relax();
-		goto got_it;
+	if (!PAGE_ALIGNED(map->m_pa)) {
+		DBG_BUGON(1);
+		return -EINVAL;
 	}
 
-	work = z_erofs_vle_work_register(&finder, map);
-	if (unlikely(work == ERR_PTR(-EAGAIN)))
-		goto repeat;
-
-	if (IS_ERR(work))
-		return PTR_ERR(work);
-got_it:
-	z_erofs_pagevec_ctor_init(&builder->vector, Z_EROFS_NR_INLINE_PAGEVECS,
-				  work->pagevec, work->vcnt);
+repeat:
+	cl = cllookup(clt, inode, map);
+	if (!cl) {
+		cl = clregister(clt, inode, map);
 
-	if (builder->role >= Z_EROFS_VLE_WORK_PRIMARY) {
-		/* enable possibly in-place decompression */
-		builder->compressed_pages = grp->compressed_pages;
-		builder->compressed_deficit = clusterpages;
-	} else {
-		builder->compressed_pages = NULL;
-		builder->compressed_deficit = 0;
+		if (unlikely(cl == ERR_PTR(-EAGAIN)))
+			goto repeat;
 	}
 
-	builder->grp = grp;
-	builder->work = work;
+	if (IS_ERR(cl))
+		return PTR_ERR(cl);
+
+	z_erofs_pagevec_ctor_init(&clt->vector, Z_EROFS_NR_INLINE_PAGEVECS,
+				  cl->pagevec, cl->vcnt);
+
+	clt->compressedpages = clt->pcl->compressed_pages;
+	if (clt->mode <= COLLECT_PRIMARY) /* cannot do in-place I/O */
+		clt->compressedpages += Z_EROFS_CLUSTER_MAX_PAGES;
 	return 0;
 }
 
 /*
- * keep in mind that no referenced workgroups will be freed
- * only after a RCU grace period, so rcu_read_lock() could
- * prevent a workgroup from being freed.
+ * keep in mind that no referenced pclusters will be freed
+ * only after a RCU grace period.
  */
 static void z_erofs_rcu_callback(struct rcu_head *head)
 {
-	struct z_erofs_vle_work *work =	container_of(head,
-		struct z_erofs_vle_work, rcu);
-	struct z_erofs_vle_workgroup *grp =
-		z_erofs_vle_work_workgroup(work, true);
+	struct z_erofs_collection *const cl =
+		container_of(head, struct z_erofs_collection, rcu);
 
-	kmem_cache_free(z_erofs_workgroup_cachep, grp);
+	kmem_cache_free(pcluster_cachep,
+			container_of(cl, struct z_erofs_pcluster,
+				     primary_collection));
 }
 
 void erofs_workgroup_free_rcu(struct erofs_workgroup *grp)
 {
-	struct z_erofs_vle_workgroup *const vgrp = container_of(grp,
-		struct z_erofs_vle_workgroup, obj);
-	struct z_erofs_vle_work *const work = &vgrp->work;
+	struct z_erofs_pcluster *const pcl =
+		container_of(grp, struct z_erofs_pcluster, obj);
+	struct z_erofs_collection *const cl = z_erofs_primarycollection(pcl);
 
-	call_rcu(&work->rcu, z_erofs_rcu_callback);
+	call_rcu(&cl->rcu, z_erofs_rcu_callback);
 }
 
-static void
-__z_erofs_vle_work_release(struct z_erofs_vle_workgroup *grp,
-			   struct z_erofs_vle_work *work __maybe_unused)
+static void z_erofs_collection_put(struct z_erofs_collection *cl)
 {
-	erofs_workgroup_put(&grp->obj);
-}
+	struct z_erofs_pcluster *const pcl =
+		container_of(cl, struct z_erofs_pcluster, primary_collection);
 
-static void z_erofs_vle_work_release(struct z_erofs_vle_work *work)
-{
-	struct z_erofs_vle_workgroup *grp =
-		z_erofs_vle_work_workgroup(work, true);
-
-	__z_erofs_vle_work_release(grp, work);
+	erofs_workgroup_put(&pcl->obj);
 }
 
-static inline bool
-z_erofs_vle_work_iter_end(struct z_erofs_vle_work_builder *builder)
+static bool z_erofs_collector_end(struct z_erofs_collector *clt)
 {
-	struct z_erofs_vle_work *work = builder->work;
+	struct z_erofs_collection *cl = clt->cl;
 
-	if (!work)
+	if (!cl)
 		return false;
 
-	z_erofs_pagevec_ctor_exit(&builder->vector, false);
-	mutex_unlock(&work->lock);
+	z_erofs_pagevec_ctor_exit(&clt->vector, false);
+	mutex_unlock(&cl->lock);
 
 	/*
-	 * if all pending pages are added, don't hold work reference
-	 * any longer if the current work isn't hosted by ourselves.
+	 * if all pending pages are added, don't hold its reference
+	 * any longer if the pcluster isn't hosted by ourselves.
 	 */
-	if (!builder->hosted)
-		__z_erofs_vle_work_release(builder->grp, work);
+	if (clt->mode < COLLECT_PRIMARY_FOLLOWED_NOINPLACE)
+		z_erofs_collection_put(cl);
 
-	builder->work = NULL;
-	builder->grp = NULL;
+	clt->cl = NULL;
 	return true;
 }
 
@@ -643,33 +550,9 @@ static inline struct page *__stagingpage_alloc(struct list_head *pagepool,
 	return page;
 }
 
-struct z_erofs_vle_frontend {
-	struct inode *const inode;
-
-	struct z_erofs_vle_work_builder builder;
-	struct erofs_map_blocks map;
-
-	z_erofs_vle_owned_workgrp_t owned_head;
-
-	/* used for applying cache strategy on the fly */
-	bool backmost;
-	erofs_off_t headoffset;
-};
-
-#define VLE_FRONTEND_INIT(__i) { \
-	.inode = __i, \
-	.map = { \
-		.m_llen = 0, \
-		.m_plen = 0, \
-		.mpage = NULL \
-	}, \
-	.builder = VLE_WORK_BUILDER_INIT(), \
-	.owned_head = Z_EROFS_VLE_WORKGRP_TAIL, \
-	.backmost = true, }
-
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
-static inline bool
-should_alloc_managed_pages(struct z_erofs_vle_frontend *fe, erofs_off_t la)
+static bool should_alloc_managed_pages(struct z_erofs_decompress_frontend *fe,
+				       erofs_off_t la)
 {
 	if (fe->backmost)
 		return true;
@@ -680,25 +563,23 @@ should_alloc_managed_pages(struct z_erofs_vle_frontend *fe, erofs_off_t la)
 	return false;
 }
 #else
-static inline bool
-should_alloc_managed_pages(struct z_erofs_vle_frontend *fe, erofs_off_t la)
+static bool should_alloc_managed_pages(struct z_erofs_decompress_frontend *fe,
+				       erofs_off_t la)
 {
 	return false;
 }
 #endif
 
-static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
+static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
 				struct page *page,
-				struct list_head *page_pool)
+				struct list_head *pagepool)
 {
-	struct super_block *const sb = fe->inode->i_sb;
-	struct erofs_sb_info *const sbi __maybe_unused = EROFS_SB(sb);
+	struct inode *const inode = fe->inode;
+	struct erofs_sb_info *const sbi __maybe_unused = EROFS_I_SB(inode);
 	struct erofs_map_blocks *const map = &fe->map;
-	struct z_erofs_vle_work_builder *const builder = &fe->builder;
+	struct z_erofs_collector *const clt = &fe->clt;
 	const loff_t offset = page_offset(page);
-
-	bool tight = builder_is_hooked(builder);
-	struct z_erofs_vle_work *work = builder->work;
+	bool tight = (clt->mode >= COLLECT_PRIMARY_HOOKED);
 
 	enum z_erofs_cache_alloctype cache_strategy;
 	enum z_erofs_page_type page_type;
@@ -716,8 +597,8 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 	/* lucky, within the range of the current map_blocks */
 	if (offset + cur >= map->m_la &&
 	    offset + cur < map->m_la + map->m_llen) {
-		/* didn't get a valid unzip work previously (very rare) */
-		if (!builder->work)
+		/* didn't get a valid collection previously (very rare) */
+		if (!clt->cl)
 			goto restart_now;
 		goto hitted;
 	}
@@ -725,12 +606,12 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 	/* go ahead the next map_blocks */
 	debugln("%s: [out-of-range] pos %llu", __func__, offset + cur);
 
-	if (z_erofs_vle_work_iter_end(builder))
+	if (z_erofs_collector_end(clt))
 		fe->backmost = false;
 
 	map->m_la = offset + cur;
 	map->m_llen = 0;
-	err = z_erofs_map_blocks_iter(fe->inode, map, 0);
+	err = z_erofs_map_blocks_iter(inode, map, 0);
 	if (unlikely(err))
 		goto err_out;
 
@@ -738,10 +619,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 	if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED)))
 		goto hitted;
 
-	DBG_BUGON(map->m_plen != 1 << sbi->clusterbits);
-	DBG_BUGON(erofs_blkoff(map->m_pa));
-
-	err = z_erofs_vle_work_iter_begin(builder, sb, map, &fe->owned_head);
+	err = z_erofs_collector_begin(clt, inode, map);
 	if (unlikely(err))
 		goto err_out;
 
@@ -751,13 +629,10 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 	else
 		cache_strategy = DONTALLOC;
 
-	preload_compressed_pages(builder, MNGD_MAPPING(sbi),
-				 map->m_pa / PAGE_SIZE,
-				 map->m_plen / PAGE_SIZE,
-				 cache_strategy, page_pool, GFP_KERNEL);
+	preload_compressed_pages(clt, MNGD_MAPPING(sbi),
+				 cache_strategy, pagepool);
 
-	tight &= builder_is_hooked(builder);
-	work = builder->work;
+	tight &= (clt->mode >= COLLECT_PRIMARY_HOOKED);
 hitted:
 	cur = end - min_t(unsigned int, offset + end - map->m_la, end);
 	if (unlikely(!(map->m_flags & EROFS_MAP_MAPPED))) {
@@ -772,17 +647,17 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 				Z_EROFS_VLE_PAGE_TYPE_TAIL_SHARED));
 
 	if (cur)
-		tight &= builder_is_followed(builder);
+		tight &= (clt->mode >= COLLECT_PRIMARY_FOLLOWED);
 
 retry:
-	err = z_erofs_vle_work_add_page(builder, page, page_type);
+	err = z_erofs_attach_page(clt, page, page_type);
 	/* should allocate an additional staging page for pagevec */
 	if (err == -EAGAIN) {
 		struct page *const newpage =
-			__stagingpage_alloc(page_pool, GFP_NOFS);
+			__stagingpage_alloc(pagepool, GFP_NOFS);
 
-		err = z_erofs_vle_work_add_page(builder, newpage,
-						Z_EROFS_PAGE_TYPE_EXCLUSIVE);
+		err = z_erofs_attach_page(clt, newpage,
+					  Z_EROFS_PAGE_TYPE_EXCLUSIVE);
 		if (likely(!err))
 			goto retry;
 	}
@@ -790,15 +665,14 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 	if (unlikely(err))
 		goto err_out;
 
-	index = page->index - map->m_la / PAGE_SIZE;
+	index = page->index - (map->m_la >> PAGE_SHIFT);
 
-	/* FIXME! avoid the last relundant fixup & endio */
 	z_erofs_onlinepage_fixup(page, index, true);
 
 	/* bump up the number of spiltted parts of a page */
 	++spiltted;
 	/* also update nr_pages */
-	work->nr_pages = max_t(pgoff_t, work->nr_pages, index + 1);
+	clt->cl->nr_pages = max_t(pgoff_t, clt->cl->nr_pages, index + 1);
 next_part:
 	/* can be used for verification */
 	map->m_llen = offset + cur - map->m_la;
@@ -808,7 +682,6 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 		goto repeat;
 
 out:
-	/* FIXME! avoid the last relundant fixup & endio */
 	z_erofs_onlinepage_endio(page);
 
 	debugln("%s, finish page: %pK spiltted: %u map->m_llen %llu",
@@ -824,7 +697,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe,
 static void z_erofs_vle_unzip_kickoff(void *ptr, int bios)
 {
 	tagptr1_t t = tagptr_init(tagptr1_t, ptr);
-	struct z_erofs_vle_unzip_io *io = tagptr_unfold_ptr(t);
+	struct z_erofs_unzip_io *io = tagptr_unfold_ptr(t);
 	bool background = tagptr_unfold_tags(t);
 
 	if (!background) {
@@ -881,45 +754,38 @@ static inline void z_erofs_vle_read_endio(struct bio *bio)
 	bio_put(bio);
 }
 
-static struct page *z_pagemap_global[Z_EROFS_VLE_VMAP_GLOBAL_PAGES];
-static DEFINE_MUTEX(z_pagemap_global_lock);
-
-static int z_erofs_vle_unzip(struct super_block *sb,
-			     struct z_erofs_vle_workgroup *grp,
-			     struct list_head *page_pool)
+static int z_erofs_decompress_pcluster(struct super_block *sb,
+				       struct z_erofs_pcluster *pcl,
+				       struct list_head *pagepool)
 {
 	struct erofs_sb_info *const sbi = EROFS_SB(sb);
-	const unsigned int clusterpages = erofs_clusterpages(sbi);
-
+	const unsigned int clusterpages = BIT(pcl->clusterbits);
 	struct z_erofs_pagevec_ctor ctor;
-	unsigned int nr_pages;
-	unsigned int sparsemem_pages = 0;
-	struct page *pages_onstack[Z_EROFS_VLE_VMAP_ONSTACK_PAGES];
+	unsigned int i, outputsize, llen, nr_pages;
+	struct page *pages_onstack[Z_EROFS_VMAP_ONSTACK_PAGES];
 	struct page **pages, **compressed_pages, *page;
-	unsigned int algorithm;
-	unsigned int i, outputsize;
 
 	enum z_erofs_page_type page_type;
 	bool overlapped, partial;
-	struct z_erofs_vle_work *work;
+	struct z_erofs_collection *cl;
 	int err;
 
 	might_sleep();
-	work = z_erofs_vle_grab_primary_work(grp);
-	DBG_BUGON(!READ_ONCE(work->nr_pages));
+	cl = z_erofs_primarycollection(pcl);
+	DBG_BUGON(!READ_ONCE(cl->nr_pages));
 
-	mutex_lock(&work->lock);
-	nr_pages = work->nr_pages;
+	mutex_lock(&cl->lock);
+	nr_pages = cl->nr_pages;
 
-	if (likely(nr_pages <= Z_EROFS_VLE_VMAP_ONSTACK_PAGES))
+	if (likely(nr_pages <= Z_EROFS_VMAP_ONSTACK_PAGES)) {
 		pages = pages_onstack;
-	else if (nr_pages <= Z_EROFS_VLE_VMAP_GLOBAL_PAGES &&
-		 mutex_trylock(&z_pagemap_global_lock))
+	} else if (nr_pages <= Z_EROFS_VMAP_GLOBAL_PAGES &&
+		   mutex_trylock(&z_pagemap_global_lock)) {
 		pages = z_pagemap_global;
-	else {
+	} else {
 		gfp_t gfp_flags = GFP_KERNEL;
 
-		if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES)
+		if (nr_pages > Z_EROFS_VMAP_GLOBAL_PAGES)
 			gfp_flags |= __GFP_NOFAIL;
 
 		pages = kvmalloc_array(nr_pages, sizeof(struct page *),
@@ -936,9 +802,9 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 		pages[i] = NULL;
 
 	z_erofs_pagevec_ctor_init(&ctor, Z_EROFS_NR_INLINE_PAGEVECS,
-				  work->pagevec, 0);
+				  cl->pagevec, 0);
 
-	for (i = 0; i < work->vcnt; ++i) {
+	for (i = 0; i < cl->vcnt; ++i) {
 		unsigned int pagenr;
 
 		page = z_erofs_pagevec_dequeue(&ctor, &page_type);
@@ -947,7 +813,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 		DBG_BUGON(!page);
 		DBG_BUGON(!page->mapping);
 
-		if (z_erofs_put_stagingpage(page_pool, page))
+		if (z_erofs_put_stagingpage(pagepool, page))
 			continue;
 
 		if (page_type == Z_EROFS_VLE_PAGE_TYPE_HEAD)
@@ -960,12 +826,10 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 
 		pages[pagenr] = page;
 	}
-	sparsemem_pages = i;
-
 	z_erofs_pagevec_ctor_exit(&ctor, true);
 
 	overlapped = false;
-	compressed_pages = grp->compressed_pages;
+	compressed_pages = pcl->compressed_pages;
 
 	err = 0;
 	for (i = 0; i < clusterpages; ++i) {
@@ -992,7 +856,6 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 
 			DBG_BUGON(pagenr >= nr_pages);
 			DBG_BUGON(pages[pagenr]);
-			++sparsemem_pages;
 			pages[pagenr] = page;
 
 			overlapped = true;
@@ -1008,30 +871,26 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 	if (unlikely(err))
 		goto out;
 
-	if (nr_pages << PAGE_SHIFT >= work->pageofs + grp->llen) {
-		outputsize = grp->llen;
-		partial = !(grp->flags & Z_EROFS_VLE_WORKGRP_FULL_LENGTH);
+	llen = pcl->length >> Z_EROFS_PCLUSTER_LENGTH_BIT;
+	if (nr_pages << PAGE_SHIFT >= cl->pageofs + llen) {
+		outputsize = llen;
+		partial = !(pcl->length & Z_EROFS_PCLUSTER_FULL_LENGTH);
 	} else {
-		outputsize = (nr_pages << PAGE_SHIFT) - work->pageofs;
+		outputsize = (nr_pages << PAGE_SHIFT) - cl->pageofs;
 		partial = true;
 	}
 
-	if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN)
-		algorithm = Z_EROFS_COMPRESSION_SHIFTED;
-	else
-		algorithm = Z_EROFS_COMPRESSION_LZ4;
-
 	err = z_erofs_decompress(&(struct z_erofs_decompress_req) {
 					.sb = sb,
 					.in = compressed_pages,
 					.out = pages,
-					.pageofs_out = work->pageofs,
+					.pageofs_out = cl->pageofs,
 					.inputsize = PAGE_SIZE,
 					.outputsize = outputsize,
-					.alg = algorithm,
+					.alg = pcl->algorithmformat,
 					.inplace_io = overlapped,
 					.partial_decoding = partial
-				 }, page_pool);
+				 }, pagepool);
 
 out:
 	/* must handle all compressed pages before endding pages */
@@ -1042,7 +901,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 			continue;
 
 		/* recycle all individual staging pages */
-		(void)z_erofs_put_stagingpage(page_pool, page);
+		(void)z_erofs_put_stagingpage(pagepool, page);
 
 		WRITE_ONCE(compressed_pages[i], NULL);
 	}
@@ -1055,7 +914,7 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 		DBG_BUGON(!page->mapping);
 
 		/* recycle all individual staging pages */
-		if (z_erofs_put_stagingpage(page_pool, page))
+		if (z_erofs_put_stagingpage(pagepool, page))
 			continue;
 
 		if (unlikely(err < 0))
@@ -1069,65 +928,63 @@ static int z_erofs_vle_unzip(struct super_block *sb,
 	else if (unlikely(pages != pages_onstack))
 		kvfree(pages);
 
-	work->nr_pages = 0;
-	work->vcnt = 0;
+	cl->nr_pages = 0;
+	cl->vcnt = 0;
 
-	/* all work locks MUST be taken before the following line */
+	/* all cl locks MUST be taken before the following line */
+	WRITE_ONCE(pcl->next, Z_EROFS_PCLUSTER_NIL);
 
-	WRITE_ONCE(grp->next, Z_EROFS_VLE_WORKGRP_NIL);
+	/* all cl locks SHOULD be released right now */
+	mutex_unlock(&cl->lock);
 
-	/* all work locks SHOULD be released right now */
-	mutex_unlock(&work->lock);
-
-	z_erofs_vle_work_release(work);
+	z_erofs_collection_put(cl);
 	return err;
 }
 
 static void z_erofs_vle_unzip_all(struct super_block *sb,
-				  struct z_erofs_vle_unzip_io *io,
-				  struct list_head *page_pool)
+				  struct z_erofs_unzip_io *io,
+				  struct list_head *pagepool)
 {
-	z_erofs_vle_owned_workgrp_t owned = io->head;
+	z_erofs_next_pcluster_t owned = io->head;
 
-	while (owned != Z_EROFS_VLE_WORKGRP_TAIL_CLOSED) {
-		struct z_erofs_vle_workgroup *grp;
+	while (owned != Z_EROFS_PCLUSTER_TAIL_CLOSED) {
+		struct z_erofs_pcluster *pcl;
 
 		/* no possible that 'owned' equals Z_EROFS_WORK_TPTR_TAIL */
-		DBG_BUGON(owned == Z_EROFS_VLE_WORKGRP_TAIL);
+		DBG_BUGON(owned == Z_EROFS_PCLUSTER_TAIL);
 
 		/* no possible that 'owned' equals NULL */
-		DBG_BUGON(owned == Z_EROFS_VLE_WORKGRP_NIL);
+		DBG_BUGON(owned == Z_EROFS_PCLUSTER_NIL);
 
-		grp = container_of(owned, struct z_erofs_vle_workgroup, next);
-		owned = READ_ONCE(grp->next);
+		pcl = container_of(owned, struct z_erofs_pcluster, next);
+		owned = READ_ONCE(pcl->next);
 
-		z_erofs_vle_unzip(sb, grp, page_pool);
+		z_erofs_decompress_pcluster(sb, pcl, pagepool);
 	}
 }
 
 static void z_erofs_vle_unzip_wq(struct work_struct *work)
 {
-	struct z_erofs_vle_unzip_io_sb *iosb = container_of(work,
-		struct z_erofs_vle_unzip_io_sb, io.u.work);
-	LIST_HEAD(page_pool);
+	struct z_erofs_unzip_io_sb *iosb =
+		container_of(work, struct z_erofs_unzip_io_sb, io.u.work);
+	LIST_HEAD(pagepool);
 
-	DBG_BUGON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
-	z_erofs_vle_unzip_all(iosb->sb, &iosb->io, &page_pool);
+	DBG_BUGON(iosb->io.head == Z_EROFS_PCLUSTER_TAIL_CLOSED);
+	z_erofs_vle_unzip_all(iosb->sb, &iosb->io, &pagepool);
 
-	put_pages_list(&page_pool);
+	put_pages_list(&pagepool);
 	kvfree(iosb);
 }
 
-static struct page *
-pickup_page_for_submission(struct z_erofs_vle_workgroup *grp,
-			   unsigned int nr,
-			   struct list_head *pagepool,
-			   struct address_space *mc,
-			   gfp_t gfp)
+static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl,
+					       unsigned int nr,
+					       struct list_head *pagepool,
+					       struct address_space *mc,
+					       gfp_t gfp)
 {
 	/* determined at compile time to avoid too many #ifdefs */
 	const bool nocache = __builtin_constant_p(mc) ? !mc : false;
-	const pgoff_t index = grp->obj.index;
+	const pgoff_t index = pcl->obj.index;
 	bool tocache = false;
 
 	struct address_space *mapping;
@@ -1137,7 +994,7 @@ pickup_page_for_submission(struct z_erofs_vle_workgroup *grp,
 	int justfound;
 
 repeat:
-	page = READ_ONCE(grp->compressed_pages[nr]);
+	page = READ_ONCE(pcl->compressed_pages[nr]);
 	oldpage = page;
 
 	if (!page)
@@ -1189,7 +1046,7 @@ pickup_page_for_submission(struct z_erofs_vle_workgroup *grp,
 
 	/* the page is still in manage cache */
 	if (page->mapping == mc) {
-		WRITE_ONCE(grp->compressed_pages[nr], page);
+		WRITE_ONCE(pcl->compressed_pages[nr], page);
 
 		ClearPageError(page);
 		if (!PagePrivate(page)) {
@@ -1201,7 +1058,7 @@ pickup_page_for_submission(struct z_erofs_vle_workgroup *grp,
 			DBG_BUGON(!justfound);
 
 			justfound = 0;
-			set_page_private(page, (unsigned long)grp);
+			set_page_private(page, (unsigned long)pcl);
 			SetPagePrivate(page);
 		}
 
@@ -1225,7 +1082,7 @@ pickup_page_for_submission(struct z_erofs_vle_workgroup *grp,
 	put_page(page);
 out_allocpage:
 	page = __stagingpage_alloc(pagepool, gfp);
-	if (oldpage != cmpxchg(&grp->compressed_pages[nr], oldpage, page)) {
+	if (oldpage != cmpxchg(&pcl->compressed_pages[nr], oldpage, page)) {
 		list_add(&page->lru, pagepool);
 		cpu_relax();
 		goto repeat;
@@ -1237,18 +1094,17 @@ pickup_page_for_submission(struct z_erofs_vle_workgroup *grp,
 		goto out;
 	}
 
-	set_page_private(page, (unsigned long)grp);
+	set_page_private(page, (unsigned long)pcl);
 	SetPagePrivate(page);
 out:	/* the only exit (for tracing and debugging) */
 	return page;
 }
 
-static struct z_erofs_vle_unzip_io *
-jobqueue_init(struct super_block *sb,
-	      struct z_erofs_vle_unzip_io *io,
-	      bool foreground)
+static struct z_erofs_unzip_io *jobqueue_init(struct super_block *sb,
+					      struct z_erofs_unzip_io *io,
+					      bool foreground)
 {
-	struct z_erofs_vle_unzip_io_sb *iosb;
+	struct z_erofs_unzip_io_sb *iosb;
 
 	if (foreground) {
 		/* waitqueue available for foreground io */
@@ -1267,11 +1123,11 @@ jobqueue_init(struct super_block *sb,
 	iosb->sb = sb;
 	INIT_WORK(&io->u.work, z_erofs_vle_unzip_wq);
 out:
-	io->head = Z_EROFS_VLE_WORKGRP_TAIL_CLOSED;
+	io->head = Z_EROFS_PCLUSTER_TAIL_CLOSED;
 	return io;
 }
 
-/* define workgroup jobqueue types */
+/* define decompression jobqueue types */
 enum {
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
 	JQ_BYPASS,
@@ -1281,15 +1137,15 @@ enum {
 };
 
 static void *jobqueueset_init(struct super_block *sb,
-			      z_erofs_vle_owned_workgrp_t qtail[],
-			      struct z_erofs_vle_unzip_io *q[],
-			      struct z_erofs_vle_unzip_io *fgq,
+			      z_erofs_next_pcluster_t qtail[],
+			      struct z_erofs_unzip_io *q[],
+			      struct z_erofs_unzip_io *fgq,
 			      bool forcefg)
 {
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
 	/*
 	 * if managed cache is enabled, bypass jobqueue is needed,
-	 * no need to read from device for all workgroups in this queue.
+	 * no need to read from device for all pclusters in this queue.
 	 */
 	q[JQ_BYPASS] = jobqueue_init(sb, fgq + JQ_BYPASS, true);
 	qtail[JQ_BYPASS] = &q[JQ_BYPASS]->head;
@@ -1302,26 +1158,26 @@ static void *jobqueueset_init(struct super_block *sb,
 }
 
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
-static void move_to_bypass_jobqueue(struct z_erofs_vle_workgroup *grp,
-				    z_erofs_vle_owned_workgrp_t qtail[],
-				    z_erofs_vle_owned_workgrp_t owned_head)
+static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl,
+				    z_erofs_next_pcluster_t qtail[],
+				    z_erofs_next_pcluster_t owned_head)
 {
-	z_erofs_vle_owned_workgrp_t *const submit_qtail = qtail[JQ_SUBMIT];
-	z_erofs_vle_owned_workgrp_t *const bypass_qtail = qtail[JQ_BYPASS];
+	z_erofs_next_pcluster_t *const submit_qtail = qtail[JQ_SUBMIT];
+	z_erofs_next_pcluster_t *const bypass_qtail = qtail[JQ_BYPASS];
 
-	DBG_BUGON(owned_head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
-	if (owned_head == Z_EROFS_VLE_WORKGRP_TAIL)
-		owned_head = Z_EROFS_VLE_WORKGRP_TAIL_CLOSED;
+	DBG_BUGON(owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED);
+	if (owned_head == Z_EROFS_PCLUSTER_TAIL)
+		owned_head = Z_EROFS_PCLUSTER_TAIL_CLOSED;
 
-	WRITE_ONCE(grp->next, Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
+	WRITE_ONCE(pcl->next, Z_EROFS_PCLUSTER_TAIL_CLOSED);
 
 	WRITE_ONCE(*submit_qtail, owned_head);
-	WRITE_ONCE(*bypass_qtail, &grp->next);
+	WRITE_ONCE(*bypass_qtail, &pcl->next);
 
-	qtail[JQ_BYPASS] = &grp->next;
+	qtail[JQ_BYPASS] = &pcl->next;
 }
 
-static bool postsubmit_is_all_bypassed(struct z_erofs_vle_unzip_io *q[],
+static bool postsubmit_is_all_bypassed(struct z_erofs_unzip_io *q[],
 				       unsigned int nr_bios,
 				       bool force_fg)
 {
@@ -1332,21 +1188,19 @@ static bool postsubmit_is_all_bypassed(struct z_erofs_vle_unzip_io *q[],
 	if (force_fg || nr_bios)
 		return false;
 
-	kvfree(container_of(q[JQ_SUBMIT],
-			    struct z_erofs_vle_unzip_io_sb,
-			    io));
+	kvfree(container_of(q[JQ_SUBMIT], struct z_erofs_unzip_io_sb, io));
 	return true;
 }
 #else
-static void move_to_bypass_jobqueue(struct z_erofs_vle_workgroup *grp,
-				    z_erofs_vle_owned_workgrp_t qtail[],
-				    z_erofs_vle_owned_workgrp_t owned_head)
+static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl,
+				    z_erofs_next_pcluster_t qtail[],
+				    z_erofs_next_pcluster_t owned_head)
 {
 	/* impossible to bypass submission for managed cache disabled */
 	DBG_BUGON(1);
 }
 
-static bool postsubmit_is_all_bypassed(struct z_erofs_vle_unzip_io *q[],
+static bool postsubmit_is_all_bypassed(struct z_erofs_unzip_io *q[],
 				       unsigned int nr_bios,
 				       bool force_fg)
 {
@@ -1357,17 +1211,14 @@ static bool postsubmit_is_all_bypassed(struct z_erofs_vle_unzip_io *q[],
 #endif
 
 static bool z_erofs_vle_submit_all(struct super_block *sb,
-				   z_erofs_vle_owned_workgrp_t owned_head,
+				   z_erofs_next_pcluster_t owned_head,
 				   struct list_head *pagepool,
-				   struct z_erofs_vle_unzip_io *fgq,
+				   struct z_erofs_unzip_io *fgq,
 				   bool force_fg)
 {
-	struct erofs_sb_info *const sbi = EROFS_SB(sb);
-	const unsigned int clusterpages = erofs_clusterpages(sbi);
-	const gfp_t gfp = GFP_NOFS;
-
-	z_erofs_vle_owned_workgrp_t qtail[NR_JOBQUEUES];
-	struct z_erofs_vle_unzip_io *q[NR_JOBQUEUES];
+	struct erofs_sb_info *const sbi __maybe_unused = EROFS_SB(sb);
+	z_erofs_next_pcluster_t qtail[NR_JOBQUEUES];
+	struct z_erofs_unzip_io *q[NR_JOBQUEUES];
 	struct bio *bio;
 	void *bi_private;
 	/* since bio will be NULL, no need to initialize last_index */
@@ -1375,7 +1226,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
 	bool force_submit = false;
 	unsigned int nr_bios;
 
-	if (unlikely(owned_head == Z_EROFS_VLE_WORKGRP_TAIL))
+	if (unlikely(owned_head == Z_EROFS_PCLUSTER_TAIL))
 		return false;
 
 	force_submit = false;
@@ -1387,29 +1238,32 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
 	q[JQ_SUBMIT]->head = owned_head;
 
 	do {
-		struct z_erofs_vle_workgroup *grp;
+		struct z_erofs_pcluster *pcl;
+		unsigned int clusterpages;
 		pgoff_t first_index;
 		struct page *page;
 		unsigned int i = 0, bypass = 0;
 		int err;
 
 		/* no possible 'owned_head' equals the following */
-		DBG_BUGON(owned_head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
-		DBG_BUGON(owned_head == Z_EROFS_VLE_WORKGRP_NIL);
+		DBG_BUGON(owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED);
+		DBG_BUGON(owned_head == Z_EROFS_PCLUSTER_NIL);
+
+		pcl = container_of(owned_head, struct z_erofs_pcluster, next);
 
-		grp = container_of(owned_head,
-				   struct z_erofs_vle_workgroup, next);
+		clusterpages = BIT(pcl->clusterbits);
 
 		/* close the main owned chain at first */
-		owned_head = cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_TAIL,
-				     Z_EROFS_VLE_WORKGRP_TAIL_CLOSED);
+		owned_head = cmpxchg(&pcl->next, Z_EROFS_PCLUSTER_TAIL,
+				     Z_EROFS_PCLUSTER_TAIL_CLOSED);
 
-		first_index = grp->obj.index;
+		first_index = pcl->obj.index;
 		force_submit |= (first_index != last_index + 1);
 
 repeat:
-		page = pickup_page_for_submission(grp, i, pagepool,
-						  MNGD_MAPPING(sbi), gfp);
+		page = pickup_page_for_submission(pcl, i, pagepool,
+						  MNGD_MAPPING(sbi),
+						  GFP_NOFS);
 		if (!page) {
 			force_submit = true;
 			++bypass;
@@ -1440,10 +1294,10 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
 			goto repeat;
 
 		if (bypass < clusterpages)
-			qtail[JQ_SUBMIT] = &grp->next;
+			qtail[JQ_SUBMIT] = &pcl->next;
 		else
-			move_to_bypass_jobqueue(grp, qtail, owned_head);
-	} while (owned_head != Z_EROFS_VLE_WORKGRP_TAIL);
+			move_to_bypass_jobqueue(pcl, qtail, owned_head);
+	} while (owned_head != Z_EROFS_PCLUSTER_TAIL);
 
 	if (bio)
 		__submit_bio(bio, REQ_OP_READ, 0);
@@ -1455,17 +1309,19 @@ static bool z_erofs_vle_submit_all(struct super_block *sb,
 	return true;
 }
 
-static void z_erofs_submit_and_unzip(struct z_erofs_vle_frontend *f,
+static void z_erofs_submit_and_unzip(struct super_block *sb,
+				     struct z_erofs_collector *clt,
 				     struct list_head *pagepool,
 				     bool force_fg)
 {
-	struct super_block *sb = f->inode->i_sb;
-	struct z_erofs_vle_unzip_io io[NR_JOBQUEUES];
+	struct z_erofs_unzip_io io[NR_JOBQUEUES];
 
-	if (!z_erofs_vle_submit_all(sb, f->owned_head, pagepool, io, force_fg))
+	if (!z_erofs_vle_submit_all(sb, clt->owned_head,
+				    pagepool, io, force_fg))
 		return;
 
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
+	/* decompress no I/O pclusters immediately */
 	z_erofs_vle_unzip_all(sb, &io[JQ_BYPASS], pagepool);
 #endif
 	if (!force_fg)
@@ -1483,7 +1339,7 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file,
 					     struct page *page)
 {
 	struct inode *const inode = page->mapping->host;
-	struct z_erofs_vle_frontend f = VLE_FRONTEND_INIT(inode);
+	struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode);
 	int err;
 	LIST_HEAD(pagepool);
 
@@ -1492,14 +1348,14 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file,
 	f.headoffset = (erofs_off_t)page->index << PAGE_SHIFT;
 
 	err = z_erofs_do_read_page(&f, page, &pagepool);
-	(void)z_erofs_vle_work_iter_end(&f.builder);
+	(void)z_erofs_collector_end(&f.clt);
 
 	if (err) {
 		errln("%s, failed to read, err [%d]", __func__, err);
 		goto out;
 	}
 
-	z_erofs_submit_and_unzip(&f, &pagepool, true);
+	z_erofs_submit_and_unzip(inode->i_sb, &f.clt, &pagepool, true);
 out:
 	if (f.map.mpage)
 		put_page(f.map.mpage);
@@ -1524,7 +1380,7 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp,
 	struct erofs_sb_info *const sbi = EROFS_I_SB(inode);
 
 	bool sync = should_decompress_synchronously(sbi, nr_pages);
-	struct z_erofs_vle_frontend f = VLE_FRONTEND_INIT(inode);
+	struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode);
 	gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL);
 	struct page *head = NULL;
 	LIST_HEAD(pagepool);
@@ -1570,13 +1426,12 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp,
 			errln("%s, readahead error at page %lu of nid %llu",
 			      __func__, page->index, vi->nid);
 		}
-
 		put_page(page);
 	}
 
-	(void)z_erofs_vle_work_iter_end(&f.builder);
+	(void)z_erofs_collector_end(&f.clt);
 
-	z_erofs_submit_and_unzip(&f, &pagepool, sync);
+	z_erofs_submit_and_unzip(inode->i_sb, &f.clt, &pagepool, sync);
 
 	if (f.map.mpage)
 		put_page(f.map.mpage);
diff --git a/drivers/staging/erofs/zdata.h b/drivers/staging/erofs/zdata.h
index 6574d43ba877..1f51d80fa89f 100644
--- a/drivers/staging/erofs/zdata.h
+++ b/drivers/staging/erofs/zdata.h
@@ -18,80 +18,77 @@
  * Structure fields follow one of the following exclusion rules.
  *
  * I: Modifiable by initialization/destruction paths and read-only
- *    for everyone else.
+ *    for everyone else;
  *
+ * L: Field should be protected by pageset lock;
+ *
+ * A: Field should be accessed / updated in atomic for parallelized code.
  */
-
-struct z_erofs_vle_work {
+struct z_erofs_collection {
 	struct mutex lock;
 
-	/* I: decompression offset in page */
+	/* I: page offset of start position of decompression */
 	unsigned short pageofs;
+
+	/* L: maximum relative page index in pagevec[] */
 	unsigned short nr_pages;
 
-	/* L: queued pages in pagevec[] */
+	/* L: total number of pages in pagevec[] */
 	unsigned int vcnt;
 
 	union {
-		/* L: pagevec */
+		/* L: inline a certain number of pagevecs for bootstrap */
 		erofs_vtptr_t pagevec[Z_EROFS_NR_INLINE_PAGEVECS];
+
+		/* I: can be used to free the pcluster by RCU. */
 		struct rcu_head rcu;
 	};
 };
 
-#define Z_EROFS_VLE_WORKGRP_FMT_PLAIN        0
-#define Z_EROFS_VLE_WORKGRP_FMT_LZ4          1
-#define Z_EROFS_VLE_WORKGRP_FMT_MASK         1
-#define Z_EROFS_VLE_WORKGRP_FULL_LENGTH      2
+#define Z_EROFS_PCLUSTER_FULL_LENGTH    0x00000001
+#define Z_EROFS_PCLUSTER_LENGTH_BIT     1
 
-typedef void *z_erofs_vle_owned_workgrp_t;
+/*
+ * let's leave a type here in case of introducing
+ * another tagged pointer later.
+ */
+typedef void *z_erofs_next_pcluster_t;
 
-struct z_erofs_vle_workgroup {
+struct z_erofs_pcluster {
 	struct erofs_workgroup obj;
-	struct z_erofs_vle_work work;
+	struct z_erofs_collection primary_collection;
 
-	/* point to next owned_workgrp_t */
-	z_erofs_vle_owned_workgrp_t next;
+	/* A: point to next chained pcluster or TAILs */
+	z_erofs_next_pcluster_t next;
 
-	/* compressed pages (including multi-usage pages) */
+	/* A: compressed pages (including multi-usage pages) */
 	struct page *compressed_pages[Z_EROFS_CLUSTER_MAX_PAGES];
-	unsigned int llen, flags;
+
+	/* A: lower limit of decompressed length and if full length or not */
+	unsigned int length;
+
+	/* I: compression algorithm format */
+	unsigned char algorithmformat;
+	/* I: bit shift of physical cluster size */
+	unsigned char clusterbits;
 };
 
+#define z_erofs_primarycollection(pcluster) (&(pcluster)->primary_collection)
+
 /* let's avoid the valid 32-bit kernel addresses */
 
 /* the chained workgroup has't submitted io (still open) */
-#define Z_EROFS_VLE_WORKGRP_TAIL        ((void *)0x5F0ECAFE)
+#define Z_EROFS_PCLUSTER_TAIL           ((void *)0x5F0ECAFE)
 /* the chained workgroup has already submitted io */
-#define Z_EROFS_VLE_WORKGRP_TAIL_CLOSED ((void *)0x5F0EDEAD)
+#define Z_EROFS_PCLUSTER_TAIL_CLOSED    ((void *)0x5F0EDEAD)
 
-#define Z_EROFS_VLE_WORKGRP_NIL         (NULL)
+#define Z_EROFS_PCLUSTER_NIL            (NULL)
 
-#define z_erofs_vle_workgrp_fmt(grp)	\
-	((grp)->flags & Z_EROFS_VLE_WORKGRP_FMT_MASK)
+#define Z_EROFS_WORKGROUP_SIZE  sizeof(struct z_erofs_pcluster)
 
-static inline void z_erofs_vle_set_workgrp_fmt(
-	struct z_erofs_vle_workgroup *grp,
-	unsigned int fmt)
-{
-	grp->flags = fmt | (grp->flags & ~Z_EROFS_VLE_WORKGRP_FMT_MASK);
-}
-
-
-/* definitions if multiref is disabled */
-#define z_erofs_vle_grab_primary_work(grp)	(&(grp)->work)
-#define z_erofs_vle_grab_work(grp, pageofs)	(&(grp)->work)
-#define z_erofs_vle_work_workgroup(wrk, primary)	\
-	((primary) ? container_of(wrk,	\
-		struct z_erofs_vle_workgroup, work) : \
-		({ BUG(); (void *)NULL; }))
-
-
-#define Z_EROFS_WORKGROUP_SIZE       sizeof(struct z_erofs_vle_workgroup)
-
-struct z_erofs_vle_unzip_io {
+struct z_erofs_unzip_io {
 	atomic_t pending_bios;
-	z_erofs_vle_owned_workgrp_t head;
+	z_erofs_next_pcluster_t head;
 
 	union {
 		wait_queue_head_t wait;
@@ -99,8 +96,8 @@ struct z_erofs_vle_unzip_io {
 	} u;
 };
 
-struct z_erofs_vle_unzip_io_sb {
-	struct z_erofs_vle_unzip_io io;
+struct z_erofs_unzip_io_sb {
+	struct z_erofs_unzip_io io;
 	struct super_block *sb;
 };
 
@@ -117,8 +114,8 @@ static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
 					 struct page *page) { return false; }
 #endif	/* !EROFS_FS_HAS_MANAGED_CACHE */
 
-#define Z_EROFS_ONLINEPAGE_COUNT_BITS 2
-#define Z_EROFS_ONLINEPAGE_COUNT_MASK ((1 << Z_EROFS_ONLINEPAGE_COUNT_BITS) - 1)
+#define Z_EROFS_ONLINEPAGE_COUNT_BITS   2
+#define Z_EROFS_ONLINEPAGE_COUNT_MASK   ((1 << Z_EROFS_ONLINEPAGE_COUNT_BITS) - 1)
 #define Z_EROFS_ONLINEPAGE_INDEX_SHIFT  (Z_EROFS_ONLINEPAGE_COUNT_BITS)
 
 /*
@@ -193,13 +190,12 @@ static inline void z_erofs_onlinepage_endio(struct page *page)
 			SetPageUptodate(page);
 		unlock_page(page);
 	}
-
 	debugln("%s, page %p value %x", __func__, page, atomic_read(u.o));
 }
 
-#define Z_EROFS_VLE_VMAP_ONSTACK_PAGES	\
+#define Z_EROFS_VMAP_ONSTACK_PAGES	\
 	min_t(unsigned int, THREAD_SIZE / 8 / sizeof(struct page *), 96U)
-#define Z_EROFS_VLE_VMAP_GLOBAL_PAGES	2048
+#define Z_EROFS_VMAP_GLOBAL_PAGES	2048
 
 #endif
 
-- 
2.17.1


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

* [PATCH 17/22] staging: erofs: remove clusterbits in sbi
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (15 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 16/22] staging: erofs: tidy up decompression frontend Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  9:12   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 18/22] staging: erofs: turn cache strategies into mount options Gao Xiang
                   ` (4 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

clustersize can now be set on per-file basis
rather than per-filesystem basis.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/internal.h | 5 -----
 drivers/staging/erofs/super.c    | 9 ---------
 drivers/staging/erofs/zmap.c     | 3 +--
 3 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index e35c7d8f75d2..be856c9facd1 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -77,8 +77,6 @@ struct erofs_sb_info {
 	struct list_head list;
 	struct mutex umount_mutex;
 
-	/* cluster size in bit shift */
-	unsigned char clusterbits;
 	/* the dedicated workstation for compression */
 	struct radix_tree_root workstn_tree;
 
@@ -267,9 +265,6 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
 /* hard limit of pages per compressed cluster */
 #define Z_EROFS_CLUSTER_MAX_PAGES       (CONFIG_EROFS_FS_CLUSTER_PAGE_LIMIT)
 
-/* page count of a compressed cluster */
-#define erofs_clusterpages(sbi)         ((1 << (sbi)->clusterbits) / PAGE_SIZE)
-
 #define EROFS_PCPUBUF_NR_PAGES          Z_EROFS_CLUSTER_MAX_PAGES
 #else
 #define EROFS_PCPUBUF_NR_PAGES          0
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index af5d87793e4d..dad5a3137988 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -124,15 +124,6 @@ static int superblock_read(struct super_block *sb)
 	sbi->xattr_blkaddr = le32_to_cpu(layout->xattr_blkaddr);
 #endif
 	sbi->islotbits = ffs(sizeof(struct erofs_inode_v1)) - 1;
-#ifdef CONFIG_EROFS_FS_ZIP
-	/* TODO: clusterbits should be related to inode */
-	sbi->clusterbits = blkszbits;
-
-	if (1 << (sbi->clusterbits - PAGE_SHIFT) > Z_EROFS_CLUSTER_MAX_PAGES)
-		errln("clusterbits %u is not supported on this kernel",
-		      sbi->clusterbits);
-#endif
-
 	sbi->root_nid = le16_to_cpu(layout->root_nid);
 	sbi->inos = le64_to_cpu(layout->inos);
 
diff --git a/drivers/staging/erofs/zmap.c b/drivers/staging/erofs/zmap.c
index 205e884ca4e0..aeed5c674d9e 100644
--- a/drivers/staging/erofs/zmap.c
+++ b/drivers/staging/erofs/zmap.c
@@ -13,13 +13,12 @@
 int z_erofs_fill_inode(struct inode *inode)
 {
 	struct erofs_vnode *const vi = EROFS_V(inode);
-	struct super_block *const sb = inode->i_sb;
 
 	if (vi->datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY) {
 		vi->z_advise = 0;
 		vi->z_algorithmtype[0] = 0;
 		vi->z_algorithmtype[1] = 0;
-		vi->z_logical_clusterbits = EROFS_SB(sb)->clusterbits;
+		vi->z_logical_clusterbits = LOG_BLOCK_SIZE;
 		vi->z_physical_clusterbits[0] = vi->z_logical_clusterbits;
 		vi->z_physical_clusterbits[1] = vi->z_logical_clusterbits;
 		set_bit(EROFS_V_Z_INITED_BIT, &vi->flags);
-- 
2.17.1


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

* [PATCH 18/22] staging: erofs: turn cache strategies into mount options
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (16 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 17/22] staging: erofs: remove clusterbits in sbi Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  9:23   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 19/22] staging: erofs: tidy up utils.c Gao Xiang
                   ` (3 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Kill all kconfig cache strategies and turn them into mount options
"cache_strategy={disable|readahead|readaround}".

As the first step, cached pages can still be usable after cache
is disabled by remounting, and these pages will be fallen out
over time, which can be refined in the later version if some
requirement is needed. Update related document as well.

Suggested-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 .../erofs/Documentation/filesystems/erofs.txt | 10 +++
 drivers/staging/erofs/Kconfig                 | 38 -----------
 drivers/staging/erofs/internal.h              | 25 +++-----
 drivers/staging/erofs/super.c                 | 64 +++++++++++++++++--
 drivers/staging/erofs/utils.c                 | 26 --------
 drivers/staging/erofs/zdata.c                 | 56 +++-------------
 drivers/staging/erofs/zdata.h                 |  6 --
 7 files changed, 85 insertions(+), 140 deletions(-)

diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
index 74cf84ac48a3..14a0e489345a 100644
--- a/drivers/staging/erofs/Documentation/filesystems/erofs.txt
+++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
@@ -65,6 +65,16 @@ fault_injection=%d     Enable fault injection in all supported types with
                        by default if CONFIG_EROFS_FS_XATTR is selected.
 (no)acl                Setup POSIX Access Control List. Note: acl is enabled
                        by default if CONFIG_EROFS_FS_POSIX_ACL is selected.
+cache_strategy=%s      Select a strategy for cached decompression from now on:
+                         disabled: In-place I/O decompression only;
+                        readahead: Cache the last incomplete compressed physical
+                                   cluster for further reading. It still does
+                                   in-place I/O decompression for the rest
+                                   compressed physical clusters;
+                       readaround: Cache the both ends of incomplete compressed
+                                   physical clusters for further reading.
+                                   It still does in-place I/O decompression
+                                   for the rest compressed physical clusters.
 
 On-disk details
 ===============
diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig
index 788beebf3f7d..1a8e48943e50 100644
--- a/drivers/staging/erofs/Kconfig
+++ b/drivers/staging/erofs/Kconfig
@@ -94,41 +94,3 @@ config EROFS_FS_CLUSTER_PAGE_LIMIT
 	  than 2. Otherwise, the image cannot be mounted
 	  correctly on this kernel.
 
-choice
-	prompt "EROFS VLE Data Decompression mode"
-	depends on EROFS_FS_ZIP
-	default EROFS_FS_ZIP_CACHE_BIPOLAR
-	help
-	  EROFS supports three options for VLE decompression.
-	  "In-place Decompression Only" consumes the minimum memory
-	  with lowest random read.
-
-	  "Bipolar Cached Decompression" consumes the maximum memory
-	  with highest random read.
-
-	  If unsure, select "Bipolar Cached Decompression"
-
-config EROFS_FS_ZIP_NO_CACHE
-	bool "In-place Decompression Only"
-	help
-	  Read compressed data into page cache and do in-place
-	  decompression directly.
-
-config EROFS_FS_ZIP_CACHE_UNIPOLAR
-	bool "Unipolar Cached Decompression"
-	help
-	  For each request, it caches the last compressed page
-	  for further reading.
-	  It still decompresses in place for the rest compressed pages.
-
-config EROFS_FS_ZIP_CACHE_BIPOLAR
-	bool "Bipolar Cached Decompression"
-	help
-	  For each request, it caches the both end compressed pages
-	  for further reading.
-	  It still decompresses in place for the rest compressed pages.
-
-	  Recommended for performance priority.
-
-endchoice
-
diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index be856c9facd1..43f9d90195bc 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -51,18 +51,6 @@ struct erofs_fault_info {
 };
 #endif
 
-#ifdef CONFIG_EROFS_FS_ZIP_CACHE_BIPOLAR
-#define EROFS_FS_ZIP_CACHE_LVL	(2)
-#elif defined(EROFS_FS_ZIP_CACHE_UNIPOLAR)
-#define EROFS_FS_ZIP_CACHE_LVL	(1)
-#else
-#define EROFS_FS_ZIP_CACHE_LVL	(0)
-#endif
-
-#if (!defined(EROFS_FS_HAS_MANAGED_CACHE) && (EROFS_FS_ZIP_CACHE_LVL > 0))
-#define EROFS_FS_HAS_MANAGED_CACHE
-#endif
-
 /* EROFS_SUPER_MAGIC_V1 to represent the whole file system */
 #define EROFS_SUPER_MAGIC   EROFS_SUPER_MAGIC_V1
 
@@ -85,10 +73,11 @@ struct erofs_sb_info {
 
 	unsigned int shrinker_run_no;
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-	struct inode *managed_cache;
-#endif
+	/* current strategy of how to use managed cache */
+	unsigned char cache_strategy;
 
+	/* pseudo inode to manage cached pages */
+	struct inode *managed_cache;
 #endif	/* CONFIG_EROFS_FS_ZIP */
 	u32 blocks;
 	u32 meta_blkaddr;
@@ -174,6 +163,12 @@ static inline void *erofs_kmalloc(struct erofs_sb_info *sbi,
 #define test_opt(sbi, option)	((sbi)->mount_opt & EROFS_MOUNT_##option)
 
 #ifdef CONFIG_EROFS_FS_ZIP
+enum {
+	EROFS_ZIP_CACHE_DISABLED,
+	EROFS_ZIP_CACHE_READAHEAD,
+	EROFS_ZIP_CACHE_READAROUND
+};
+
 #define EROFS_LOCKED_MAGIC     (INT_MIN | 0xE0F510CCL)
 
 /* basic unit of the workstation of a super_block */
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index dad5a3137988..a14fa5228bca 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -197,17 +197,50 @@ static unsigned int erofs_get_fault_rate(struct erofs_sb_info *sbi)
 }
 #endif
 
+#ifdef CONFIG_EROFS_FS_ZIP
+static int erofs_build_cache_strategy(struct erofs_sb_info *sbi,
+				      substring_t *args)
+{
+	const char *cs = match_strdup(args);
+	int err = 0;
+
+	if (!cs) {
+		errln("Not enough memory to store cache strategy");
+		return -ENOMEM;
+	}
+
+	if (!strcmp(cs, "disabled")) {
+		sbi->cache_strategy = EROFS_ZIP_CACHE_DISABLED;
+	} else if (!strcmp(cs, "readahead")) {
+		sbi->cache_strategy = EROFS_ZIP_CACHE_READAHEAD;
+	} else if (!strcmp(cs, "readaround")) {
+		sbi->cache_strategy = EROFS_ZIP_CACHE_READAROUND;
+	} else {
+		errln("Unrecognized cache strategy \"%s\"", cs);
+		err = -EINVAL;
+	}
+	kfree(cs);
+	return err;
+}
+#else
+static int erofs_build_cache_strategy(struct erofs_sb_info *sbi,
+				      substring_t *args)
+{
+	infoln("EROFS compression is disabled, so cache strategy is ignored");
+	return 0;
+}
+#endif
+
+/* set up default EROFS parameters */
 static void default_options(struct erofs_sb_info *sbi)
 {
-	/* set up some FS parameters */
 #ifdef CONFIG_EROFS_FS_ZIP
+	sbi->cache_strategy = EROFS_ZIP_CACHE_READAROUND;
 	sbi->max_sync_decompress_pages = 3;
 #endif
-
 #ifdef CONFIG_EROFS_FS_XATTR
 	set_opt(sbi, XATTR_USER);
 #endif
-
 #ifdef CONFIG_EROFS_FS_POSIX_ACL
 	set_opt(sbi, POSIX_ACL);
 #endif
@@ -219,6 +252,7 @@ enum {
 	Opt_acl,
 	Opt_noacl,
 	Opt_fault_injection,
+	Opt_cache_strategy,
 	Opt_err
 };
 
@@ -228,6 +262,7 @@ static match_table_t erofs_tokens = {
 	{Opt_acl, "acl"},
 	{Opt_noacl, "noacl"},
 	{Opt_fault_injection, "fault_injection=%u"},
+	{Opt_cache_strategy, "cache_strategy=%s"},
 	{Opt_err, NULL}
 };
 
@@ -285,7 +320,11 @@ static int parse_options(struct super_block *sb, char *options)
 			if (err)
 				return err;
 			break;
-
+		case Opt_cache_strategy:
+			err = erofs_build_cache_strategy(EROFS_SB(sb), args);
+			if (err)
+				return err;
+			break;
 		default:
 			errln("Unrecognized mount option \"%s\" "
 					"or missing value", p);
@@ -295,8 +334,7 @@ static int parse_options(struct super_block *sb, char *options)
 	return 0;
 }
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-
+#ifdef CONFIG_EROFS_FS_ZIP
 static const struct address_space_operations managed_cache_aops;
 
 static int managed_cache_releasepage(struct page *page, gfp_t gfp_mask)
@@ -469,7 +507,7 @@ static void erofs_put_super(struct super_block *sb)
 	DBG_BUGON(!sbi);
 
 	erofs_shrinker_unregister(sb);
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
+#ifdef CONFIG_EROFS_FS_ZIP
 	iput(sbi->managed_cache);
 	sbi->managed_cache = NULL;
 #endif
@@ -570,6 +608,18 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
 	if (test_opt(sbi, FAULT_INJECTION))
 		seq_printf(seq, ",fault_injection=%u",
 			   erofs_get_fault_rate(sbi));
+#ifdef CONFIG_EROFS_FS_ZIP
+	if (sbi->cache_strategy == EROFS_ZIP_CACHE_DISABLED) {
+		seq_puts(seq, ",cache_strategy=disabled");
+	} else if (sbi->cache_strategy == EROFS_ZIP_CACHE_READAHEAD) {
+		seq_puts(seq, ",cache_strategy=readahead");
+	} else if (sbi->cache_strategy == EROFS_ZIP_CACHE_READAROUND) {
+		seq_puts(seq, ",cache_strategy=readaround");
+	} else {
+		seq_puts(seq, ",cache_strategy=(unknown)");
+		DBG_BUGON(1);
+	}
+#endif
 	return 0;
 }
 
diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index 260ea2970b4b..0e6308b15717 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -145,8 +145,6 @@ int erofs_workgroup_put(struct erofs_workgroup *grp)
 	return count;
 }
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
-/* for cache-managed case, customized reclaim paths exist */
 static void erofs_workgroup_unfreeze_final(struct erofs_workgroup *grp)
 {
 	erofs_workgroup_unfreeze(grp, 0);
@@ -192,30 +190,6 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
 	return true;
 }
 
-#else
-/* for nocache case, no customized reclaim path at all */
-static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
-					   struct erofs_workgroup *grp,
-					   bool cleanup)
-{
-	int cnt = atomic_read(&grp->refcount);
-
-	DBG_BUGON(cnt <= 0);
-	DBG_BUGON(cleanup && cnt != 1);
-
-	if (cnt > 1)
-		return false;
-
-	DBG_BUGON(xa_untag_pointer(radix_tree_delete(&sbi->workstn_tree,
-						     grp->index)) != grp);
-
-	/* (rarely) could be grabbed again when freeing */
-	erofs_workgroup_put(grp);
-	return true;
-}
-
-#endif
-
 static unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi,
 					      unsigned long nr_shrink,
 					      bool cleanup)
diff --git a/drivers/staging/erofs/zdata.c b/drivers/staging/erofs/zdata.c
index 34ee19b4721d..709c7ba8e255 100644
--- a/drivers/staging/erofs/zdata.c
+++ b/drivers/staging/erofs/zdata.c
@@ -162,7 +162,6 @@ struct z_erofs_decompress_frontend {
 static struct page *z_pagemap_global[Z_EROFS_VMAP_GLOBAL_PAGES];
 static DEFINE_MUTEX(z_pagemap_global_lock);
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
 static void preload_compressed_pages(struct z_erofs_collector *clt,
 				     struct address_space *mc,
 				     enum z_erofs_cache_alloctype type,
@@ -273,15 +272,6 @@ int erofs_try_to_free_cached_page(struct address_space *mapping,
 	}
 	return ret;
 }
-#else
-static void preload_compressed_pages(struct z_erofs_collector *clt,
-				     struct address_space *mc,
-				     enum z_erofs_cache_alloctype type,
-				     struct list_head *pagepool)
-{
-	/* nowhere to load compressed pages from */
-}
-#endif
 
 /* page_type must be Z_EROFS_PAGE_TYPE_EXCLUSIVE */
 static inline bool try_inplace_io(struct z_erofs_collector *clt,
@@ -550,25 +540,19 @@ static inline struct page *__stagingpage_alloc(struct list_head *pagepool,
 	return page;
 }
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
 static bool should_alloc_managed_pages(struct z_erofs_decompress_frontend *fe,
+				       unsigned int cachestrategy,
 				       erofs_off_t la)
 {
+	if (cachestrategy <= EROFS_ZIP_CACHE_DISABLED)
+		return false;
+
 	if (fe->backmost)
 		return true;
 
-	if (EROFS_FS_ZIP_CACHE_LVL >= 2)
-		return la < fe->headoffset;
-
-	return false;
-}
-#else
-static bool should_alloc_managed_pages(struct z_erofs_decompress_frontend *fe,
-				       erofs_off_t la)
-{
-	return false;
+	return cachestrategy >= EROFS_ZIP_CACHE_READAROUND &&
+		la < fe->headoffset;
 }
-#endif
 
 static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
 				struct page *page,
@@ -624,7 +608,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
 		goto err_out;
 
 	/* preload all compressed pages (maybe downgrade role if necessary) */
-	if (should_alloc_managed_pages(fe, map->m_la))
+	if (should_alloc_managed_pages(fe, sbi->cache_strategy, map->m_la))
 		cache_strategy = DELAYEDALLOC;
 	else
 		cache_strategy = DONTALLOC;
@@ -1129,9 +1113,7 @@ static struct z_erofs_unzip_io *jobqueue_init(struct super_block *sb,
 
 /* define decompression jobqueue types */
 enum {
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
 	JQ_BYPASS,
-#endif
 	JQ_SUBMIT,
 	NR_JOBQUEUES,
 };
@@ -1142,14 +1124,12 @@ static void *jobqueueset_init(struct super_block *sb,
 			      struct z_erofs_unzip_io *fgq,
 			      bool forcefg)
 {
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
 	/*
 	 * if managed cache is enabled, bypass jobqueue is needed,
 	 * no need to read from device for all pclusters in this queue.
 	 */
 	q[JQ_BYPASS] = jobqueue_init(sb, fgq + JQ_BYPASS, true);
 	qtail[JQ_BYPASS] = &q[JQ_BYPASS]->head;
-#endif
 
 	q[JQ_SUBMIT] = jobqueue_init(sb, fgq + JQ_SUBMIT, forcefg);
 	qtail[JQ_SUBMIT] = &q[JQ_SUBMIT]->head;
@@ -1157,7 +1137,6 @@ static void *jobqueueset_init(struct super_block *sb,
 	return tagptr_cast_ptr(tagptr_fold(tagptr1_t, q[JQ_SUBMIT], !forcefg));
 }
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
 static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl,
 				    z_erofs_next_pcluster_t qtail[],
 				    z_erofs_next_pcluster_t owned_head)
@@ -1191,24 +1170,6 @@ static bool postsubmit_is_all_bypassed(struct z_erofs_unzip_io *q[],
 	kvfree(container_of(q[JQ_SUBMIT], struct z_erofs_unzip_io_sb, io));
 	return true;
 }
-#else
-static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl,
-				    z_erofs_next_pcluster_t qtail[],
-				    z_erofs_next_pcluster_t owned_head)
-{
-	/* impossible to bypass submission for managed cache disabled */
-	DBG_BUGON(1);
-}
-
-static bool postsubmit_is_all_bypassed(struct z_erofs_unzip_io *q[],
-				       unsigned int nr_bios,
-				       bool force_fg)
-{
-	/* bios should be >0 if managed cache is disabled */
-	DBG_BUGON(!nr_bios);
-	return false;
-}
-#endif
 
 static bool z_erofs_vle_submit_all(struct super_block *sb,
 				   z_erofs_next_pcluster_t owned_head,
@@ -1320,10 +1281,9 @@ static void z_erofs_submit_and_unzip(struct super_block *sb,
 				    pagepool, io, force_fg))
 		return;
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
 	/* decompress no I/O pclusters immediately */
 	z_erofs_vle_unzip_all(sb, &io[JQ_BYPASS], pagepool);
-#endif
+
 	if (!force_fg)
 		return;
 
diff --git a/drivers/staging/erofs/zdata.h b/drivers/staging/erofs/zdata.h
index 1f51d80fa89f..e11fe1959ca2 100644
--- a/drivers/staging/erofs/zdata.h
+++ b/drivers/staging/erofs/zdata.h
@@ -101,18 +101,12 @@ struct z_erofs_unzip_io_sb {
 	struct super_block *sb;
 };
 
-#ifdef EROFS_FS_HAS_MANAGED_CACHE
 #define MNGD_MAPPING(sbi)	((sbi)->managed_cache->i_mapping)
 static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
 					 struct page *page)
 {
 	return page->mapping == MNGD_MAPPING(sbi);
 }
-#else
-#define MNGD_MAPPING(sbi)	(NULL)
-static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
-					 struct page *page) { return false; }
-#endif	/* !EROFS_FS_HAS_MANAGED_CACHE */
 
 #define Z_EROFS_ONLINEPAGE_COUNT_BITS   2
 #define Z_EROFS_ONLINEPAGE_COUNT_MASK   ((1 << Z_EROFS_ONLINEPAGE_COUNT_BITS) - 1)
-- 
2.17.1


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

* [PATCH 19/22] staging: erofs: tidy up utils.c
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (17 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 18/22] staging: erofs: turn cache strategies into mount options Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  9:24   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 20/22] staging: erofs: tidy up internal.h Gao Xiang
                   ` (2 subsequent siblings)
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

keep in line with erofs-outofstaging patchset:
 - Update comments in erofs_try_to_release_workgroup;
 - code style cleanup.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/utils.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index 0e6308b15717..814c2ee037ae 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -114,8 +114,7 @@ int erofs_register_workgroup(struct super_block *sb,
 	 */
 	__erofs_workgroup_get(grp);
 
-	err = radix_tree_insert(&sbi->workstn_tree,
-				grp->index, grp);
+	err = radix_tree_insert(&sbi->workstn_tree, grp->index, grp);
 	if (unlikely(err))
 		/*
 		 * it's safe to decrease since the workgroup isn't visible
@@ -156,18 +155,18 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
 					   bool cleanup)
 {
 	/*
-	 * for managed cache enabled, the refcount of workgroups
-	 * themselves could be < 0 (freezed). So there is no guarantee
-	 * that all refcount > 0 if managed cache is enabled.
+	 * If managed cache is on, refcount of workgroups
+	 * themselves could be < 0 (freezed). In other words,
+	 * there is no guarantee that all refcounts > 0.
 	 */
 	if (!erofs_workgroup_try_to_freeze(grp, 1))
 		return false;
 
 	/*
-	 * note that all cached pages should be unlinked
-	 * before delete it from the radix tree.
-	 * Otherwise some cached pages of an orphan old workgroup
-	 * could be still linked after the new one is available.
+	 * Note that all cached pages should be unattached
+	 * before deleted from the radix tree. Otherwise some
+	 * cached pages could be still attached to the orphan
+	 * old workgroup when the new one is available in the tree.
 	 */
 	if (erofs_try_to_free_all_cached_pages(sbi, grp)) {
 		erofs_workgroup_unfreeze(grp, 1);
@@ -175,7 +174,7 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
 	}
 
 	/*
-	 * it is impossible to fail after the workgroup is freezed,
+	 * It's impossible to fail after the workgroup is freezed,
 	 * however in order to avoid some race conditions, add a
 	 * DBG_BUGON to observe this in advance.
 	 */
@@ -183,8 +182,8 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,
 						     grp->index)) != grp);
 
 	/*
-	 * if managed cache is enable, the last refcount
-	 * should indicate the related workstation.
+	 * If managed cache is on, last refcount should indicate
+	 * the related workstation.
 	 */
 	erofs_workgroup_unfreeze_final(grp);
 	return true;
@@ -273,9 +272,9 @@ static unsigned long erofs_shrink_scan(struct shrinker *shrink,
 	unsigned long freed = 0;
 
 	spin_lock(&erofs_sb_list_lock);
-	do
+	do {
 		run_no = ++shrinker_run_no;
-	while (run_no == 0);
+	} while (run_no == 0);
 
 	/* Iterate over all mounted superblocks and try to shrink them */
 	p = erofs_sb_list.next;
-- 
2.17.1


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

* [PATCH 20/22] staging: erofs: tidy up internal.h
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (18 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 19/22] staging: erofs: tidy up utils.c Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  9:25   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 21/22] staging: erofs: update super.c Gao Xiang
  2019-07-29  6:51 ` [PATCH 22/22] staging: erofs: update Kconfig Gao Xiang
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

keep in line with erofs-outofstaging patchset:
 - remove an extra #ifdef CONFIG_EROFS_FS_ZIP;
 - add tags at the end of #endif acrossing several lines.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/internal.h | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 43f9d90195bc..39d009554094 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -49,7 +49,7 @@ struct erofs_fault_info {
 	unsigned int inject_rate;
 	unsigned int inject_type;
 };
-#endif
+#endif	/* CONFIG_EROFS_FAULT_INJECTION */
 
 /* EROFS_SUPER_MAGIC_V1 to represent the whole file system */
 #define EROFS_SUPER_MAGIC   EROFS_SUPER_MAGIC_V1
@@ -138,7 +138,7 @@ static inline bool time_to_inject(struct erofs_sb_info *sbi, int type)
 static inline void erofs_show_injection_info(int type)
 {
 }
-#endif
+#endif	/* !CONFIG_EROFS_FAULT_INJECTION */
 
 static inline void *erofs_kmalloc(struct erofs_sb_info *sbi,
 					size_t size, gfp_t flags)
@@ -236,8 +236,14 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
 	DBG_BUGON(v == EROFS_LOCKED_MAGIC);
 	return v;
 }
-#endif
-#endif	/* CONFIG_EROFS_FS_ZIP */
+#endif	/* !CONFIG_SMP */
+
+/* hard limit of pages per compressed cluster */
+#define Z_EROFS_CLUSTER_MAX_PAGES       (CONFIG_EROFS_FS_CLUSTER_PAGE_LIMIT)
+#define EROFS_PCPUBUF_NR_PAGES          Z_EROFS_CLUSTER_MAX_PAGES
+#else
+#define EROFS_PCPUBUF_NR_PAGES          0
+#endif	/* !CONFIG_EROFS_FS_ZIP */
 
 /* we strictly follow PAGE_SIZE and no buffer head yet */
 #define LOG_BLOCK_SIZE		PAGE_SHIFT
@@ -256,15 +262,6 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)
 
 #define ROOT_NID(sb)		((sb)->root_nid)
 
-#ifdef CONFIG_EROFS_FS_ZIP
-/* hard limit of pages per compressed cluster */
-#define Z_EROFS_CLUSTER_MAX_PAGES       (CONFIG_EROFS_FS_CLUSTER_PAGE_LIMIT)
-
-#define EROFS_PCPUBUF_NR_PAGES          Z_EROFS_CLUSTER_MAX_PAGES
-#else
-#define EROFS_PCPUBUF_NR_PAGES          0
-#endif
-
 #define erofs_blknr(addr)       ((addr) / EROFS_BLKSIZ)
 #define erofs_blkoff(addr)      ((addr) % EROFS_BLKSIZ)
 #define blknr_to_addr(nr)       ((erofs_off_t)(nr) * EROFS_BLKSIZ)
@@ -304,7 +301,7 @@ struct erofs_vnode {
 			unsigned char  z_logical_clusterbits;
 			unsigned char  z_physical_clusterbits[2];
 		};
-#endif
+#endif	/* CONFIG_EROFS_FS_ZIP */
 	};
 	/* the corresponding vfs inode */
 	struct inode vfs_inode;
@@ -412,7 +409,7 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
 {
 	return -ENOTSUPP;
 }
-#endif
+#endif	/* !CONFIG_EROFS_FS_ZIP */
 
 /* data.c */
 static inline struct bio *erofs_grab_bio(struct super_block *sb,
@@ -548,7 +545,7 @@ static inline int erofs_init_shrinker(void) { return 0; }
 static inline void erofs_exit_shrinker(void) {}
 static inline int z_erofs_init_zip_subsystem(void) { return 0; }
 static inline void z_erofs_exit_zip_subsystem(void) {}
-#endif
+#endif	/* !CONFIG_EROFS_FS_ZIP */
 
 #endif	/* __EROFS_INTERNAL_H */
 
-- 
2.17.1


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

* [PATCH 21/22] staging: erofs: update super.c
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (19 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 20/22] staging: erofs: tidy up internal.h Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  9:40   ` Chao Yu
  2019-07-29  6:51 ` [PATCH 22/22] staging: erofs: update Kconfig Gao Xiang
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Keep in line with erofs-outofstaging patchset:
- "Chao Yu" is most commonly used in Linux community;
- quoted string split across lines.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/super.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index a14fa5228bca..f65a1ff9f42f 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -326,8 +326,7 @@ static int parse_options(struct super_block *sb, char *options)
 				return err;
 			break;
 		default:
-			errln("Unrecognized mount option \"%s\" "
-					"or missing value", p);
+			errln("Unrecognized mount option \"%s\" or missing value", p);
 			return -EINVAL;
 		}
 	}
@@ -662,6 +661,6 @@ module_init(erofs_module_init);
 module_exit(erofs_module_exit);
 
 MODULE_DESCRIPTION("Enhanced ROM File System");
-MODULE_AUTHOR("Gao Xiang, Yu Chao, Miao Xie, CONSUMER BG, HUAWEI Inc.");
+MODULE_AUTHOR("Gao Xiang, Chao Yu, Miao Xie, CONSUMER BG, HUAWEI Inc.");
 MODULE_LICENSE("GPL");
 
-- 
2.17.1


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

* [PATCH 22/22] staging: erofs: update Kconfig
  2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
                   ` (20 preceding siblings ...)
  2019-07-29  6:51 ` [PATCH 21/22] staging: erofs: update super.c Gao Xiang
@ 2019-07-29  6:51 ` Gao Xiang
  2019-07-31  9:44   ` Chao Yu
  21 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-29  6:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

Keep in line with erofs-outofstaging patchset:
 - turn on CONFIG_EROFS_FS_ZIP by default;
 - turn on CONFIG_EROFS_FS_SECURITY by default suggested by David;
 - update Kconfig description.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 drivers/staging/erofs/Kconfig | 54 ++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig
index 1a8e48943e50..16316d1adca3 100644
--- a/drivers/staging/erofs/Kconfig
+++ b/drivers/staging/erofs/Kconfig
@@ -4,16 +4,16 @@ config EROFS_FS
 	tristate "EROFS filesystem support"
 	depends on BLOCK
 	help
-	  EROFS(Enhanced Read-Only File System) is a lightweight
+	  EROFS (Enhanced Read-Only File System) is a lightweight
 	  read-only file system with modern designs (eg. page-sized
 	  blocks, inline xattrs/data, etc.) for scenarios which need
-	  high-performance read-only requirements, eg. firmwares in
-	  mobile phone or LIVECDs.
+	  high-performance read-only requirements, e.g. Android OS
+	  for mobile phones and LIVECDs.
 
-	  It also provides VLE compression support, focusing on
-	  random read improvements, keeping relatively lower
-	  compression ratios, which is useful for high-performance
-	  devices with limited memory and ROM space.
+	  It also provides fixed-sized output compression support,
+	  which improves storage density, keeps relatively higher
+	  compression ratios, which is more useful to achieve high
+	  performance for embedded devices with limited memory.
 
 	  If unsure, say N.
 
@@ -21,11 +21,19 @@ config EROFS_FS_DEBUG
 	bool "EROFS debugging feature"
 	depends on EROFS_FS
 	help
-	  Print EROFS debugging messages and enable more BUG_ONs
-	  which check the filesystem consistency aggressively.
+	  Print debugging messages and enable more BUG_ONs which check
+	  filesystem consistency and find potential issues aggressively,
+	  which can be used for Android eng build, for example.
 
 	  For daily use, say N.
 
+config EROFS_FAULT_INJECTION
+	bool "EROFS fault injection facility"
+	depends on EROFS_FS
+	help
+	  Test EROFS to inject faults such as ENOMEM, EIO, and so on.
+	  If unsure, say N.
+
 config EROFS_FS_XATTR
 	bool "EROFS extended attributes"
 	depends on EROFS_FS
@@ -54,6 +62,7 @@ config EROFS_FS_POSIX_ACL
 config EROFS_FS_SECURITY
 	bool "EROFS Security Labels"
 	depends on EROFS_FS_XATTR
+	default y
 	help
 	  Security labels provide an access control facility to support Linux
 	  Security Models (LSMs) accepted by AppArmor, SELinux, Smack and TOMOYO
@@ -63,22 +72,15 @@ config EROFS_FS_SECURITY
 
 	  If you are not using a security module, say N.
 
-config EROFS_FAULT_INJECTION
-	bool "EROFS fault injection facility"
-	depends on EROFS_FS
-	help
-	  Test EROFS to inject faults such as ENOMEM, EIO, and so on.
-	  If unsure, say N.
-
 config EROFS_FS_ZIP
-	bool "EROFS Data Compresssion Support"
+	bool "EROFS Data Compression Support"
 	depends on EROFS_FS
 	select LZ4_DECOMPRESS
+	default y
 	help
-	  Currently we support LZ4 VLE Compression only.
-	  Play at your own risk.
+	  Enable fixed-sized output compression for EROFS.
 
-	  If you don't want to use compression feature, say N.
+	  If you don't want to enable compression feature, say N.
 
 config EROFS_FS_CLUSTER_PAGE_LIMIT
 	int "EROFS Cluster Pages Hard Limit"
@@ -86,11 +88,11 @@ config EROFS_FS_CLUSTER_PAGE_LIMIT
 	range 1 256
 	default "1"
 	help
-	  Indicates VLE compressed pages hard limit of a
-	  compressed cluster.
+	  Indicates maximum # of pages of a compressed
+	  physical cluster.
 
-	  For example, if files of a image are compressed
-	  into 8k-unit, the hard limit should not be less
-	  than 2. Otherwise, the image cannot be mounted
-	  correctly on this kernel.
+	  For example, if files in a image were compressed
+	  into 8k-unit, hard limit should not be configured
+	  less than 2. Otherwise, the image will be refused
+	  to mount on this kernel.
 
-- 
2.17.1


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

* Re: [PATCH 01/22] staging: erofs: update source file headers
  2019-07-29  6:51 ` [PATCH 01/22] staging: erofs: update source file headers Gao Xiang
@ 2019-07-30  7:20   ` Greg Kroah-Hartman
  2019-07-30  7:26     ` Gao Xiang
  2019-07-31  6:36   ` Chao Yu
  1 sibling, 1 reply; 55+ messages in thread
From: Greg Kroah-Hartman @ 2019-07-30  7:20 UTC (permalink / raw)
  To: Gao Xiang; +Cc: devel, linux-erofs, Chao Yu, LKML, weidu.du, Fang Wei, Miao Xie

On Mon, Jul 29, 2019 at 02:51:38PM +0800, Gao Xiang wrote:
> - Use the correct style for all SPDX License Identifiers;
> - Get rid of the unnecessary license boilerplate;
> - Use "GPL-2.0-only" instead of "GPL-2.0" suggested-by Stephen.

Note, either tag works just fine, they are identical.  I'll take this,
but just be aware of this in the future please.

thanks,

greg k-h

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

* Re: [PATCH 01/22] staging: erofs: update source file headers
  2019-07-30  7:20   ` Greg Kroah-Hartman
@ 2019-07-30  7:26     ` Gao Xiang
  0 siblings, 0 replies; 55+ messages in thread
From: Gao Xiang @ 2019-07-30  7:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-erofs, Chao Yu, LKML, weidu.du, Fang Wei, Miao Xie

Hi Greg,

On 2019/7/30 15:20, Greg Kroah-Hartman wrote:
> On Mon, Jul 29, 2019 at 02:51:38PM +0800, Gao Xiang wrote:
>> - Use the correct style for all SPDX License Identifiers;
>> - Get rid of the unnecessary license boilerplate;
>> - Use "GPL-2.0-only" instead of "GPL-2.0" suggested-by Stephen.
> 
> Note, either tag works just fine, they are identical.  I'll take this,
> but just be aware of this in the future please.

Okay, got it. I will keep track of potential GPL3.0+ stuffes
if community has such license discussions again.

It seems fine for now. :)

Thanks,
Gao Xiang

> 
> thanks,
> 
> greg k-h
> 

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

* Re: [PATCH 01/22] staging: erofs: update source file headers
  2019-07-29  6:51 ` [PATCH 01/22] staging: erofs: update source file headers Gao Xiang
  2019-07-30  7:20   ` Greg Kroah-Hartman
@ 2019-07-31  6:36   ` Chao Yu
  1 sibling, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  6:36 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> - Use the correct style for all SPDX License Identifiers;
> - Get rid of the unnecessary license boilerplate;
> - Use "GPL-2.0-only" instead of "GPL-2.0" suggested-by Stephen.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 02/22] staging: erofs: rename source files for better understanding
  2019-07-29  6:51 ` [PATCH 02/22] staging: erofs: rename source files for better understanding Gao Xiang
@ 2019-07-31  6:43   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  6:43 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Keep in line with erofs-outofstaging patchset as well, see
> https://lore.kernel.org/linux-fsdevel/20190725095658.155779-1-gaoxiang25@huawei.com/
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 03/22] staging: erofs: fix dummy functions erofs_{get, list}xattr
  2019-07-29  6:51 ` [PATCH 03/22] staging: erofs: fix dummy functions erofs_{get,list}xattr Gao Xiang
@ 2019-07-31  6:44   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  6:44 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: Yue Hu, linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> dummy functions erofs_{get,list}xattr should be inlined
> without xattr enabled.
> 
> Signed-off-by: Yue Hu <zbestahu@gmail.com>
> [ Gao Xiang : this patch was "staging: erofs: remove needless
>               dummy functions of erofs_{get,list}xattr. "]
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 04/22] staging: erofs: keep up erofs_fs.h with erofs-outofstaging patchset
  2019-07-29  6:51 ` [PATCH 04/22] staging: erofs: keep up erofs_fs.h with erofs-outofstaging patchset Gao Xiang
@ 2019-07-31  6:46   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  6:46 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> The main change is to reserve all checksums except for superblock,
> since it's more useful to do block-based verity for read-only fs.
> 
> Some comments change as well, which is minor.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 05/22] staging: erofs: sunset erofs_workstn_{lock,unlock}
  2019-07-29  6:51 ` [PATCH 05/22] staging: erofs: sunset erofs_workstn_{lock,unlock} Gao Xiang
@ 2019-07-31  6:49   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  6:49 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> It was used for Linux backward compatibility, and no use
> for upstream kernel.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 06/22] staging: erofs: clean up internal.h
  2019-07-29  6:51 ` [PATCH 06/22] staging: erofs: clean up internal.h Gao Xiang
@ 2019-07-31  6:53   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  6:53 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Tidy up relative order of variables / declarations in internal.h,
> and moving some local static functions out to other files.
> 
> No logic change.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 07/22] staging: erofs: remove redundant #include "internal.h"
  2019-07-29  6:51 ` [PATCH 07/22] staging: erofs: remove redundant #include "internal.h" Gao Xiang
@ 2019-07-31  7:03   ` Chao Yu
  2019-07-31  7:08     ` Gao Xiang
  0 siblings, 1 reply; 55+ messages in thread
From: Chao Yu @ 2019-07-31  7:03 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Because #include "internal.h" is included in xattr.h

I think it would be better to remove "internal.h" in xattr.h, and include them
both in .c file in where we need xattr definition.

Thanks,


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

* Re: [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES
  2019-07-29  6:51 ` [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES Gao Xiang
@ 2019-07-31  7:05   ` Chao Yu
  2019-07-31  7:11     ` Gao Xiang
  0 siblings, 1 reply; 55+ messages in thread
From: Chao Yu @ 2019-07-31  7:05 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> CONFIG_EROFS_FS_IO_MAX_RETRIES seems a runtime setting
> and users have no idea about the change in behaviour.
> 
> Let's remove the setting currently and fold it into code,
> turn it into a module parameter if it's really needed.
> 
> Suggested-by: David Sterba <dsterba@suse.cz>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

It's fine to me, but I'd like to suggest to add this as a sys entry which can be
more flexible for user to change.

Thanks

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

* Re: [PATCH 07/22] staging: erofs: remove redundant #include "internal.h"
  2019-07-31  7:03   ` Chao Yu
@ 2019-07-31  7:08     ` Gao Xiang
  2019-07-31 12:07       ` Chao Yu
  0 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-31  7:08 UTC (permalink / raw)
  To: Chao Yu; +Cc: Greg Kroah-Hartman, devel, linux-erofs, LKML, weidu.du, Miao Xie

Hi Chao,

On 2019/7/31 15:03, Chao Yu wrote:
> On 2019/7/29 14:51, Gao Xiang wrote:
>> Because #include "internal.h" is included in xattr.h
> 
> I think it would be better to remove "internal.h" in xattr.h, and include them
> both in .c file in where we need xattr definition.

It seems that all xattr related source files needing internal.h,
and we need "EROFS_V(inode)", "struct erofs_sb_info", ... stuffs in xattr.h,
which is defined in internal.h...

Thanks,
Gao Xiang

> 
> Thanks,
> 

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

* Re: [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES
  2019-07-31  7:05   ` Chao Yu
@ 2019-07-31  7:11     ` Gao Xiang
  2019-07-31 12:10       ` Chao Yu
  0 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-31  7:11 UTC (permalink / raw)
  To: Chao Yu; +Cc: Greg Kroah-Hartman, devel, linux-erofs, LKML, weidu.du, Miao Xie

Hi Chao,

On 2019/7/31 15:05, Chao Yu wrote:
> On 2019/7/29 14:51, Gao Xiang wrote:
>> CONFIG_EROFS_FS_IO_MAX_RETRIES seems a runtime setting
>> and users have no idea about the change in behaviour.
>>
>> Let's remove the setting currently and fold it into code,
>> turn it into a module parameter if it's really needed.
>>
>> Suggested-by: David Sterba <dsterba@suse.cz>
>> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
> 
> It's fine to me, but I'd like to suggest to add this as a sys entry which can be
> more flexible for user to change.

I think it can be added in the later version, the original view
from David is that he had question how users using this option.

Maybe we can use the default value and leave it to users who
really need to modify this value (real requirement).

Thanks,
Gao Xiang

> 
> Thanks
> 

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

* Re: [PATCH 09/22] staging: erofs: clean up shrinker stuffs
  2019-07-29  6:51 ` [PATCH 09/22] staging: erofs: clean up shrinker stuffs Gao Xiang
@ 2019-07-31  7:41   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  7:41 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> - rename erofs_register_super / erofs_unregister_super
>   to erofs_shrinker_register / erofs_shrinker_unregister;
> - fold the only erofs_shrink_workstation external call
>   to erofs_shrinker_unregister;
> - localize erofs_shrink_workstation;
> - localize erofs_shrinker_info by introducing
>   erofs_init_shrinker and erofs_exit_shrinker.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 10/22] staging: erofs: kill sbi->dev_name
  2019-07-29  6:51 ` [PATCH 10/22] staging: erofs: kill sbi->dev_name Gao Xiang
@ 2019-07-31  7:46   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  7:46 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> As Al said, "the only use of sbi->dev_name is debugging
> printks and all of those have sb->s_id available, with
> device name stored in there.  Which makes the whole
> thing bloody weird".
> 
> sbi->dev_name was used for our debugging use and it's
> better to just use s_id in community and delete
> the whole erofs_mount_private stuff.
> 
> Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 11/22] staging: erofs: kill all failure handling in fill_super()
  2019-07-29  6:51 ` [PATCH 11/22] staging: erofs: kill all failure handling in fill_super() Gao Xiang
@ 2019-07-31  8:15   ` Chao Yu
  2019-07-31 12:52     ` Gao Xiang
  0 siblings, 1 reply; 55+ messages in thread
From: Chao Yu @ 2019-07-31  8:15 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> .kill_sb() will do that instead in order to remove duplicated code.
> 
> Note that the initialzation of managed_cache is now moved
> after s_root is assigned since it's more preferred to iput()
> in .put_super() and all inodes should be evicted before
> the end of generic_shutdown_super(sb).
> 
> Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
> ---
>  drivers/staging/erofs/super.c | 121 +++++++++++++++-------------------
>  1 file changed, 53 insertions(+), 68 deletions(-)
> 
> diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
> index bfb6e1e09781..af5d87793e4d 100644
> --- a/drivers/staging/erofs/super.c
> +++ b/drivers/staging/erofs/super.c
> @@ -343,51 +343,52 @@ static const struct address_space_operations managed_cache_aops = {
>  	.invalidatepage = managed_cache_invalidatepage,
>  };
>  
> -static struct inode *erofs_init_managed_cache(struct super_block *sb)
> +static int erofs_init_managed_cache(struct super_block *sb)
>  {
> -	struct inode *inode = new_inode(sb);
> +	struct erofs_sb_info *const sbi = EROFS_SB(sb);
> +	struct inode *const inode = new_inode(sb);
>  
>  	if (unlikely(!inode))
> -		return ERR_PTR(-ENOMEM);
> +		return -ENOMEM;
>  
>  	set_nlink(inode, 1);
>  	inode->i_size = OFFSET_MAX;
>  
>  	inode->i_mapping->a_ops = &managed_cache_aops;
>  	mapping_set_gfp_mask(inode->i_mapping,
> -			     GFP_NOFS | __GFP_HIGHMEM |
> -			     __GFP_MOVABLE |  __GFP_NOFAIL);
> -	return inode;
> +			     GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE);

It looks above change is not belong to this patch?

Otherwise, it looks good to me.

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> +	sbi->managed_cache = inode;
> +	return 0;
>  }
> -
> +#else
> +static int erofs_init_managed_cache(struct super_block *sb) { return 0; }
>  #endif
>  
>  static int erofs_fill_super(struct super_block *sb, void *data, int silent)
>  {
>  	struct inode *inode;
>  	struct erofs_sb_info *sbi;
> -	int err = -EINVAL;
> +	int err;
>  
>  	infoln("fill_super, device -> %s", sb->s_id);
>  	infoln("options -> %s", (char *)data);
>  
> +	sb->s_magic = EROFS_SUPER_MAGIC;
> +
>  	if (unlikely(!sb_set_blocksize(sb, EROFS_BLKSIZ))) {
>  		errln("failed to set erofs blksize");
> -		goto err;
> +		return -EINVAL;
>  	}
>  
>  	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
> -	if (unlikely(!sbi)) {
> -		err = -ENOMEM;
> -		goto err;
> -	}
> -	sb->s_fs_info = sbi;
> +	if (unlikely(!sbi))
> +		return -ENOMEM;
>  
> +	sb->s_fs_info = sbi;
>  	err = superblock_read(sb);
>  	if (err)
> -		goto err_sbread;
> +		return err;
>  
> -	sb->s_magic = EROFS_SUPER_MAGIC;
>  	sb->s_flags |= SB_RDONLY | SB_NOATIME;
>  	sb->s_maxbytes = MAX_LFS_FILESIZE;
>  	sb->s_time_gran = 1;
> @@ -397,13 +398,12 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
>  #ifdef CONFIG_EROFS_FS_XATTR
>  	sb->s_xattr = erofs_xattr_handlers;
>  #endif
> -
>  	/* set erofs default mount options */
>  	default_options(sbi);
>  
>  	err = parse_options(sb, data);
> -	if (err)
> -		goto err_parseopt;
> +	if (unlikely(err))
> +		return err;
>  
>  	if (!silent)
>  		infoln("root inode @ nid %llu", ROOT_NID(sbi));
> @@ -417,93 +417,78 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
>  	INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC);
>  #endif
>  
> -#ifdef EROFS_FS_HAS_MANAGED_CACHE
> -	sbi->managed_cache = erofs_init_managed_cache(sb);
> -	if (IS_ERR(sbi->managed_cache)) {
> -		err = PTR_ERR(sbi->managed_cache);
> -		goto err_init_managed_cache;
> -	}
> -#endif
> -
>  	/* get the root inode */
>  	inode = erofs_iget(sb, ROOT_NID(sbi), true);
> -	if (IS_ERR(inode)) {
> -		err = PTR_ERR(inode);
> -		goto err_iget;
> -	}
> +	if (IS_ERR(inode))
> +		return PTR_ERR(inode);
>  
> -	if (!S_ISDIR(inode->i_mode)) {
> +	if (unlikely(!S_ISDIR(inode->i_mode))) {
>  		errln("rootino(nid %llu) is not a directory(i_mode %o)",
>  		      ROOT_NID(sbi), inode->i_mode);
> -		err = -EINVAL;
>  		iput(inode);
> -		goto err_iget;
> +		return -EINVAL;
>  	}
>  
>  	sb->s_root = d_make_root(inode);
> -	if (!sb->s_root) {
> -		err = -ENOMEM;
> -		goto err_iget;
> -	}
> +	if (unlikely(!sb->s_root))
> +		return -ENOMEM;
>  
>  	erofs_shrinker_register(sb);
> +	/* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */
> +	err = erofs_init_managed_cache(sb);
> +	if (unlikely(err))
> +		return err;
>  
>  	if (!silent)
>  		infoln("mounted on %s with opts: %s.", sb->s_id, (char *)data);
>  	return 0;
> -	/*
> -	 * please add a label for each exit point and use
> -	 * the following name convention, thus new features
> -	 * can be integrated easily without renaming labels.
> -	 */
> -err_iget:
> -#ifdef EROFS_FS_HAS_MANAGED_CACHE
> -	iput(sbi->managed_cache);
> -err_init_managed_cache:
> -#endif
> -err_parseopt:
> -err_sbread:
> -	sb->s_fs_info = NULL;
> -	kfree(sbi);
> -err:
> -	return err;
> +}
> +
> +static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags,
> +				  const char *dev_name, void *data)
> +{
> +	return mount_bdev(fs_type, flags, dev_name, data, erofs_fill_super);
>  }
>  
>  /*
>   * could be triggered after deactivate_locked_super()
>   * is called, thus including umount and failed to initialize.
>   */
> -static void erofs_put_super(struct super_block *sb)
> +static void erofs_kill_sb(struct super_block *sb)
>  {
> -	struct erofs_sb_info *sbi = EROFS_SB(sb);
> +	struct erofs_sb_info *sbi;
> +
> +	WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
> +	infoln("unmounting for %s", sb->s_id);
>  
> -	/* for cases which are failed in "read_super" */
> +	kill_block_super(sb);
> +
> +	sbi = EROFS_SB(sb);
>  	if (!sbi)
>  		return;
> +	kfree(sbi);
> +	sb->s_fs_info = NULL;
> +}
>  
> -	WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
> +/* called when ->s_root is non-NULL */
> +static void erofs_put_super(struct super_block *sb)
> +{
> +	struct erofs_sb_info *const sbi = EROFS_SB(sb);
>  
> -	infoln("unmounted for %s", sb->s_id);
> +	DBG_BUGON(!sbi);
>  
>  	erofs_shrinker_unregister(sb);
>  #ifdef EROFS_FS_HAS_MANAGED_CACHE
>  	iput(sbi->managed_cache);
> +	sbi->managed_cache = NULL;
>  #endif
> -	kfree(sbi);
> -	sb->s_fs_info = NULL;
> -}
> -
> -static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags,
> -				  const char *dev_name, void *data)
> -{
> -	return mount_bdev(fs_type, flags, dev_name, data, erofs_fill_super);
>  }
>  
>  static struct file_system_type erofs_fs_type = {
>  	.owner          = THIS_MODULE,
>  	.name           = "erofs",
>  	.mount          = erofs_mount,
> -	.kill_sb        = kill_block_super,
> +	.kill_sb        = erofs_kill_sb,
>  	.fs_flags       = FS_REQUIRES_DEV,
>  };
>  MODULE_ALIAS_FS("erofs");
> 

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

* Re: [PATCH 12/22] staging: erofs: refine erofs_allocpage()
  2019-07-29  6:51 ` [PATCH 12/22] staging: erofs: refine erofs_allocpage() Gao Xiang
@ 2019-07-31  8:20   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  8:20 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> remove duplicated code in decompressor by introducing
> failable erofs_allocpage().
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
> ---
>  drivers/staging/erofs/decompressor.c | 12 +++---------
>  drivers/staging/erofs/internal.h     |  2 +-
>  drivers/staging/erofs/utils.c        |  5 +++--
>  drivers/staging/erofs/zdata.c        |  2 +-
>  4 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c
> index ee5762351f80..744c43a456e9 100644
> --- a/drivers/staging/erofs/decompressor.c
> +++ b/drivers/staging/erofs/decompressor.c
> @@ -74,15 +74,9 @@ static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
>  			victim = availables[--top];
>  			get_page(victim);
>  		} else {
> -			if (!list_empty(pagepool)) {
> -				victim = lru_to_page(pagepool);
> -				list_del(&victim->lru);
> -				DBG_BUGON(page_ref_count(victim) != 1);
> -			} else {
> -				victim = alloc_pages(GFP_KERNEL, 0);
> -				if (!victim)
> -					return -ENOMEM;
> -			}
> +			victim = erofs_allocpage(pagepool, GFP_KERNEL, false);
> +			if (unlikely(!victim))
> +				return -ENOMEM;
>  			victim->mapping = Z_EROFS_MAPPING_STAGING;
>  		}
>  		rq->out[i] = victim;
> diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
> index b206a85776b4..e35c7d8f75d2 100644
> --- a/drivers/staging/erofs/internal.h
> +++ b/drivers/staging/erofs/internal.h
> @@ -517,7 +517,7 @@ int erofs_namei(struct inode *dir, struct qstr *name,
>  extern const struct file_operations erofs_dir_fops;
>  
>  /* utils.c / zdata.c */
> -struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp);
> +struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp, bool nofail);
>  
>  #if (EROFS_PCPUBUF_NR_PAGES > 0)
>  void *erofs_get_pcpubuf(unsigned int pagenr);
> diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
> index 0e86e44d60d0..260ea2970b4b 100644
> --- a/drivers/staging/erofs/utils.c
> +++ b/drivers/staging/erofs/utils.c
> @@ -9,15 +9,16 @@
>  #include "internal.h"
>  #include <linux/pagevec.h>
>  
> -struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp)
> +struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp, bool nofail)
>  {
>  	struct page *page;
>  
>  	if (!list_empty(pool)) {
>  		page = lru_to_page(pool);
> +		DBG_BUGON(page_ref_count(page) != 1);
>  		list_del(&page->lru);
>  	} else {
> -		page = alloc_pages(gfp | __GFP_NOFAIL, 0);
> +		page = alloc_pages(gfp | (nofail ? __GFP_NOFAIL : 0), 0);
>  	}
>  	return page;
>  }
> diff --git a/drivers/staging/erofs/zdata.c b/drivers/staging/erofs/zdata.c
> index bc478eebf509..02560b940558 100644
> --- a/drivers/staging/erofs/zdata.c
> +++ b/drivers/staging/erofs/zdata.c
> @@ -634,7 +634,7 @@ z_erofs_vle_work_iter_end(struct z_erofs_vle_work_builder *builder)
>  static inline struct page *__stagingpage_alloc(struct list_head *pagepool,
>  					       gfp_t gfp)
>  {
> -	struct page *page = erofs_allocpage(pagepool, gfp);
> +	struct page *page = erofs_allocpage(pagepool, gfp, true);
>  
>  	if (unlikely(!page))
>  		return NULL;

Should remove it.

Otherwise, it looks good to me.

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> 

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

* Re: [PATCH 13/22] staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM
  2019-07-29  6:51 ` [PATCH 13/22] staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM Gao Xiang
@ 2019-07-31  8:27   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  8:27 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Turn into a module parameter ("use_vmap") as it
> can be set at runtime.
> 
> Suggested-by: David Sterba <dsterba@suse.cz>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
> ---
>  drivers/staging/erofs/Kconfig        |  8 ------
>  drivers/staging/erofs/decompressor.c | 37 +++++++++++++++-------------
>  2 files changed, 20 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig
> index 747e9eebfaa5..788beebf3f7d 100644
> --- a/drivers/staging/erofs/Kconfig
> +++ b/drivers/staging/erofs/Kconfig
> @@ -63,14 +63,6 @@ config EROFS_FS_SECURITY
>  
>  	  If you are not using a security module, say N.
>  
> -config EROFS_FS_USE_VM_MAP_RAM
> -	bool "EROFS VM_MAP_RAM Support"
> -	depends on EROFS_FS
> -	help
> -	  use vm_map_ram/vm_unmap_ram instead of vmap/vunmap.
> -
> -	  If you don't know what these are, say N.
> -
>  config EROFS_FAULT_INJECTION
>  	bool "EROFS fault injection facility"
>  	depends on EROFS_FS
> diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c
> index 744c43a456e9..5352a50981cb 100644
> --- a/drivers/staging/erofs/decompressor.c
> +++ b/drivers/staging/erofs/decompressor.c
> @@ -7,6 +7,7 @@
>   * Created by Gao Xiang <gaoxiang25@huawei.com>
>   */
>  #include "compress.h"
> +#include <linux/module.h>
>  #include <linux/lz4.h>
>  
>  #ifndef LZ4_DISTANCE_MAX	/* history window size */
> @@ -29,6 +30,10 @@ struct z_erofs_decompressor {
>  	char *name;
>  };
>  
> +static bool use_vmap;
> +module_param(use_vmap, bool, 0444);
> +MODULE_PARM_DESC(use_vmap, "Use vmap() instead of vm_map_ram() (default 0)");

This should be documented in erofs.txt simply.

> +
>  static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
>  				 struct list_head *pagepool)
>  {
> @@ -219,29 +224,27 @@ static void copy_from_pcpubuf(struct page **out, const char *dst,
>  
>  static void *erofs_vmap(struct page **pages, unsigned int count)
>  {
> -#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
> -	int i = 0;
> -
> -	while (1) {
> -		void *addr = vm_map_ram(pages, count, -1, PAGE_KERNEL);
> -		/* retry two more times (totally 3 times) */
> -		if (addr || ++i >= 3)
> -			return addr;
> -		vm_unmap_aliases();
> +	if (!use_vmap) {

Minor thing.

if (use_vmap)
	return vmap(pages, count, VM_MAP, PAGE_KERNEL);

while (1) {
}

return NULL;

Otherwise, it looks good to me.

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> +		int i = 0;
> +
> +		while (1) {
> +			void *addr = vm_map_ram(pages, count, -1, PAGE_KERNEL);
> +			/* retry two more times (totally 3 times) */
> +			if (addr || ++i >= 3)
> +				return addr;
> +			vm_unmap_aliases();
> +		}
> +		return NULL;
>  	}
> -	return NULL;
> -#else
>  	return vmap(pages, count, VM_MAP, PAGE_KERNEL);
> -#endif
>  }
>  
>  static void erofs_vunmap(const void *mem, unsigned int count)
>  {
> -#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
> -	vm_unmap_ram(mem, count);
> -#else
> -	vunmap(mem);
> -#endif
> +	if (!use_vmap)
> +		vm_unmap_ram(mem, count);
> +	else
> +		vunmap(mem);
>  }
>  
>  static int decompress_generic(struct z_erofs_decompress_req *rq,
> 

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

* Re: [PATCH 14/22] staging: erofs: tidy up zpvec.h
  2019-07-29  6:51 ` [PATCH 14/22] staging: erofs: tidy up zpvec.h Gao Xiang
@ 2019-07-31  8:28   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  8:28 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> - use shorter function names:
>   z_erofs_pagevec_enqueue and z_erofs_pagevec_dequeue;
> - minor code cleanup.
> 
> In order to keep in line with erofs-outofstaging patchset.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 15/22] staging: erofs: remove redundant braces in inode.c
  2019-07-29  6:51 ` [PATCH 15/22] staging: erofs: remove redundant braces in inode.c Gao Xiang
@ 2019-07-31  8:29   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  8:29 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Remove redundant braces in inode.c since
> these are all single statements.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 16/22] staging: erofs: tidy up decompression frontend
  2019-07-29  6:51 ` [PATCH 16/22] staging: erofs: tidy up decompression frontend Gao Xiang
@ 2019-07-31  9:07   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  9:07 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Although this patch has an amount of changes, it is hard to
> separate into smaller patches.
> 
> Most changes are due to structure renaming for better understand
> and straightforward,
>  z_erofs_vle_workgroup to z_erofs_pcluster
>              since it represents a physical cluster;
>  z_erofs_vle_work to z_erofs_collection
>              since it represents a collection of logical pages;
>  z_erofs_vle_work_builder to z_erofs_collector
>              since it's used to fill z_erofs_{pcluster,collection}.
> 
> struct z_erofs_vle_work_finder has no extra use compared with
> struct z_erofs_collector, delete it.
> 
> FULL_LENGTH bit is integrated into .length of pcluster so that it
> can be updated with the corresponding length change in atomic.
> 
> Minor, add comments for better description.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

I hope I don't miss anything, since this is so huge cleanup...

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 17/22] staging: erofs: remove clusterbits in sbi
  2019-07-29  6:51 ` [PATCH 17/22] staging: erofs: remove clusterbits in sbi Gao Xiang
@ 2019-07-31  9:12   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  9:12 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> clustersize can now be set on per-file basis
> rather than per-filesystem basis.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 18/22] staging: erofs: turn cache strategies into mount options
  2019-07-29  6:51 ` [PATCH 18/22] staging: erofs: turn cache strategies into mount options Gao Xiang
@ 2019-07-31  9:23   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  9:23 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Kill all kconfig cache strategies and turn them into mount options
> "cache_strategy={disable|readahead|readaround}".
> 
> As the first step, cached pages can still be usable after cache
> is disabled by remounting, and these pages will be fallen out
> over time, which can be refined in the later version if some
> requirement is needed. Update related document as well.
> 
> Suggested-by: Theodore Ts'o <tytso@mit.edu>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 19/22] staging: erofs: tidy up utils.c
  2019-07-29  6:51 ` [PATCH 19/22] staging: erofs: tidy up utils.c Gao Xiang
@ 2019-07-31  9:24   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  9:24 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> keep in line with erofs-outofstaging patchset:
>  - Update comments in erofs_try_to_release_workgroup;
>  - code style cleanup.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 20/22] staging: erofs: tidy up internal.h
  2019-07-29  6:51 ` [PATCH 20/22] staging: erofs: tidy up internal.h Gao Xiang
@ 2019-07-31  9:25   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  9:25 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> keep in line with erofs-outofstaging patchset:
>  - remove an extra #ifdef CONFIG_EROFS_FS_ZIP;
>  - add tags at the end of #endif acrossing several lines.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 21/22] staging: erofs: update super.c
  2019-07-29  6:51 ` [PATCH 21/22] staging: erofs: update super.c Gao Xiang
@ 2019-07-31  9:40   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  9:40 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Keep in line with erofs-outofstaging patchset:
> - "Chao Yu" is most commonly used in Linux community;

Either is okay to me, anyway, thanks for the correction. :)

BTW, I notice that .mailmap can map different email or name to single one on
git-shortlog or git-blame, so developer and user can find the correct people to
blame... I think we can change ours later.

> - quoted string split across lines.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 22/22] staging: erofs: update Kconfig
  2019-07-29  6:51 ` [PATCH 22/22] staging: erofs: update Kconfig Gao Xiang
@ 2019-07-31  9:44   ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-07-31  9:44 UTC (permalink / raw)
  To: Gao Xiang, Greg Kroah-Hartman, devel
  Cc: linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/29 14:51, Gao Xiang wrote:
> Keep in line with erofs-outofstaging patchset:
>  - turn on CONFIG_EROFS_FS_ZIP by default;
>  - turn on CONFIG_EROFS_FS_SECURITY by default suggested by David;
>  - update Kconfig description.
> 
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 07/22] staging: erofs: remove redundant #include "internal.h"
  2019-07-31  7:08     ` Gao Xiang
@ 2019-07-31 12:07       ` Chao Yu
  2019-07-31 12:54         ` Gao Xiang
  0 siblings, 1 reply; 55+ messages in thread
From: Chao Yu @ 2019-07-31 12:07 UTC (permalink / raw)
  To: Gao Xiang
  Cc: Greg Kroah-Hartman, devel, linux-erofs, LKML, weidu.du, Miao Xie

Hi Xiang,

On 2019/7/31 15:08, Gao Xiang wrote:
> Hi Chao,
> 
> On 2019/7/31 15:03, Chao Yu wrote:
>> On 2019/7/29 14:51, Gao Xiang wrote:
>>> Because #include "internal.h" is included in xattr.h
>>
>> I think it would be better to remove "internal.h" in xattr.h, and include them
>> both in .c file in where we need xattr definition.
> 
> It seems that all xattr related source files needing internal.h,
> and we need "EROFS_V(inode)", "struct erofs_sb_info", ... stuffs in xattr.h,
> which is defined in internal.h...

Since I checked f2fs', it looks it's okay to don't include internal.h for
xattr.h, if .c needs xattr.h, we can just include interanl.h and xattr.h in the
head of it, it's safe.

Thanks,

> 
> Thanks,
> Gao Xiang
> 
>>
>> Thanks,
>>
> .
> 

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

* Re: [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES
  2019-07-31  7:11     ` Gao Xiang
@ 2019-07-31 12:10       ` Chao Yu
  2019-07-31 12:55         ` Gao Xiang
  0 siblings, 1 reply; 55+ messages in thread
From: Chao Yu @ 2019-07-31 12:10 UTC (permalink / raw)
  To: Gao Xiang
  Cc: Greg Kroah-Hartman, devel, linux-erofs, LKML, weidu.du, Miao Xie

Hi Xiang,

On 2019/7/31 15:11, Gao Xiang wrote:
> Hi Chao,
> 
> On 2019/7/31 15:05, Chao Yu wrote:
>> On 2019/7/29 14:51, Gao Xiang wrote:
>>> CONFIG_EROFS_FS_IO_MAX_RETRIES seems a runtime setting
>>> and users have no idea about the change in behaviour.
>>>
>>> Let's remove the setting currently and fold it into code,
>>> turn it into a module parameter if it's really needed.
>>>
>>> Suggested-by: David Sterba <dsterba@suse.cz>
>>> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
>>
>> It's fine to me, but I'd like to suggest to add this as a sys entry which can be
>> more flexible for user to change.
> 
> I think it can be added in the later version, the original view
> from David is that he had question how users using this option.
> 
> Maybe we can use the default value and leave it to users who
> really need to modify this value (real requirement).

I think we need to decide it in this version, otherwise it may face backward
compatibility issue if we change module argument to sys entry later.

Maybe just leave it as an fixed macro is fine, since there is actually no
requirement on this.

Thanks,

> 
> Thanks,
> Gao Xiang
> 
>>
>> Thanks
>>
> .
> 

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

* Re: [PATCH 11/22] staging: erofs: kill all failure handling in fill_super()
  2019-07-31  8:15   ` Chao Yu
@ 2019-07-31 12:52     ` Gao Xiang
  0 siblings, 0 replies; 55+ messages in thread
From: Gao Xiang @ 2019-07-31 12:52 UTC (permalink / raw)
  To: Chao Yu; +Cc: Greg Kroah-Hartman, devel, linux-erofs, LKML, weidu.du, Miao Xie

Hi Chao,

On 2019/7/31 16:15, Chao Yu wrote:
> On 2019/7/29 14:51, Gao Xiang wrote:
>> .kill_sb() will do that instead in order to remove duplicated code.
>>
>> Note that the initialzation of managed_cache is now moved
>> after s_root is assigned since it's more preferred to iput()
>> in .put_super() and all inodes should be evicted before
>> the end of generic_shutdown_super(sb).
>>
>> Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
>> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
>> ---
>>  drivers/staging/erofs/super.c | 121 +++++++++++++++-------------------
>>  1 file changed, 53 insertions(+), 68 deletions(-)
>>
>> diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
>> index bfb6e1e09781..af5d87793e4d 100644
>> --- a/drivers/staging/erofs/super.c
>> +++ b/drivers/staging/erofs/super.c
>> @@ -343,51 +343,52 @@ static const struct address_space_operations managed_cache_aops = {
>>  	.invalidatepage = managed_cache_invalidatepage,
>>  };
>>  
>> -static struct inode *erofs_init_managed_cache(struct super_block *sb)
>> +static int erofs_init_managed_cache(struct super_block *sb)
>>  {
>> -	struct inode *inode = new_inode(sb);
>> +	struct erofs_sb_info *const sbi = EROFS_SB(sb);
>> +	struct inode *const inode = new_inode(sb);
>>  
>>  	if (unlikely(!inode))
>> -		return ERR_PTR(-ENOMEM);
>> +		return -ENOMEM;
>>  
>>  	set_nlink(inode, 1);
>>  	inode->i_size = OFFSET_MAX;
>>  
>>  	inode->i_mapping->a_ops = &managed_cache_aops;
>>  	mapping_set_gfp_mask(inode->i_mapping,
>> -			     GFP_NOFS | __GFP_HIGHMEM |
>> -			     __GFP_MOVABLE |  __GFP_NOFAIL);
>> -	return inode;
>> +			     GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE);

Seems so, I will add a new patch addressing on it if needed.

Thanks,
Gao Xiang

> 
> It looks above change is not belong to this patch?
> 
> Otherwise, it looks good to me.
> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> 
> Thanks,
> 
>> +	sbi->managed_cache = inode;
>> +	return 0;
>>  }
>> -
>> +#else
>> +static int erofs_init_managed_cache(struct super_block *sb) { return 0; }
>>  #endif
>>  
>>  static int erofs_fill_super(struct super_block *sb, void *data, int silent)
>>  {
>>  	struct inode *inode;
>>  	struct erofs_sb_info *sbi;
>> -	int err = -EINVAL;
>> +	int err;
>>  
>>  	infoln("fill_super, device -> %s", sb->s_id);
>>  	infoln("options -> %s", (char *)data);
>>  
>> +	sb->s_magic = EROFS_SUPER_MAGIC;
>> +
>>  	if (unlikely(!sb_set_blocksize(sb, EROFS_BLKSIZ))) {
>>  		errln("failed to set erofs blksize");
>> -		goto err;
>> +		return -EINVAL;
>>  	}
>>  
>>  	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
>> -	if (unlikely(!sbi)) {
>> -		err = -ENOMEM;
>> -		goto err;
>> -	}
>> -	sb->s_fs_info = sbi;
>> +	if (unlikely(!sbi))
>> +		return -ENOMEM;
>>  
>> +	sb->s_fs_info = sbi;
>>  	err = superblock_read(sb);
>>  	if (err)
>> -		goto err_sbread;
>> +		return err;
>>  
>> -	sb->s_magic = EROFS_SUPER_MAGIC;
>>  	sb->s_flags |= SB_RDONLY | SB_NOATIME;
>>  	sb->s_maxbytes = MAX_LFS_FILESIZE;
>>  	sb->s_time_gran = 1;
>> @@ -397,13 +398,12 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
>>  #ifdef CONFIG_EROFS_FS_XATTR
>>  	sb->s_xattr = erofs_xattr_handlers;
>>  #endif
>> -
>>  	/* set erofs default mount options */
>>  	default_options(sbi);
>>  
>>  	err = parse_options(sb, data);
>> -	if (err)
>> -		goto err_parseopt;
>> +	if (unlikely(err))
>> +		return err;
>>  
>>  	if (!silent)
>>  		infoln("root inode @ nid %llu", ROOT_NID(sbi));
>> @@ -417,93 +417,78 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent)
>>  	INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC);
>>  #endif
>>  
>> -#ifdef EROFS_FS_HAS_MANAGED_CACHE
>> -	sbi->managed_cache = erofs_init_managed_cache(sb);
>> -	if (IS_ERR(sbi->managed_cache)) {
>> -		err = PTR_ERR(sbi->managed_cache);
>> -		goto err_init_managed_cache;
>> -	}
>> -#endif
>> -
>>  	/* get the root inode */
>>  	inode = erofs_iget(sb, ROOT_NID(sbi), true);
>> -	if (IS_ERR(inode)) {
>> -		err = PTR_ERR(inode);
>> -		goto err_iget;
>> -	}
>> +	if (IS_ERR(inode))
>> +		return PTR_ERR(inode);
>>  
>> -	if (!S_ISDIR(inode->i_mode)) {
>> +	if (unlikely(!S_ISDIR(inode->i_mode))) {
>>  		errln("rootino(nid %llu) is not a directory(i_mode %o)",
>>  		      ROOT_NID(sbi), inode->i_mode);
>> -		err = -EINVAL;
>>  		iput(inode);
>> -		goto err_iget;
>> +		return -EINVAL;
>>  	}
>>  
>>  	sb->s_root = d_make_root(inode);
>> -	if (!sb->s_root) {
>> -		err = -ENOMEM;
>> -		goto err_iget;
>> -	}
>> +	if (unlikely(!sb->s_root))
>> +		return -ENOMEM;
>>  
>>  	erofs_shrinker_register(sb);
>> +	/* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */
>> +	err = erofs_init_managed_cache(sb);
>> +	if (unlikely(err))
>> +		return err;
>>  
>>  	if (!silent)
>>  		infoln("mounted on %s with opts: %s.", sb->s_id, (char *)data);
>>  	return 0;
>> -	/*
>> -	 * please add a label for each exit point and use
>> -	 * the following name convention, thus new features
>> -	 * can be integrated easily without renaming labels.
>> -	 */
>> -err_iget:
>> -#ifdef EROFS_FS_HAS_MANAGED_CACHE
>> -	iput(sbi->managed_cache);
>> -err_init_managed_cache:
>> -#endif
>> -err_parseopt:
>> -err_sbread:
>> -	sb->s_fs_info = NULL;
>> -	kfree(sbi);
>> -err:
>> -	return err;
>> +}
>> +
>> +static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags,
>> +				  const char *dev_name, void *data)
>> +{
>> +	return mount_bdev(fs_type, flags, dev_name, data, erofs_fill_super);
>>  }
>>  
>>  /*
>>   * could be triggered after deactivate_locked_super()
>>   * is called, thus including umount and failed to initialize.
>>   */
>> -static void erofs_put_super(struct super_block *sb)
>> +static void erofs_kill_sb(struct super_block *sb)
>>  {
>> -	struct erofs_sb_info *sbi = EROFS_SB(sb);
>> +	struct erofs_sb_info *sbi;
>> +
>> +	WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
>> +	infoln("unmounting for %s", sb->s_id);
>>  
>> -	/* for cases which are failed in "read_super" */
>> +	kill_block_super(sb);
>> +
>> +	sbi = EROFS_SB(sb);
>>  	if (!sbi)
>>  		return;
>> +	kfree(sbi);
>> +	sb->s_fs_info = NULL;
>> +}
>>  
>> -	WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC);
>> +/* called when ->s_root is non-NULL */
>> +static void erofs_put_super(struct super_block *sb)
>> +{
>> +	struct erofs_sb_info *const sbi = EROFS_SB(sb);
>>  
>> -	infoln("unmounted for %s", sb->s_id);
>> +	DBG_BUGON(!sbi);
>>  
>>  	erofs_shrinker_unregister(sb);
>>  #ifdef EROFS_FS_HAS_MANAGED_CACHE
>>  	iput(sbi->managed_cache);
>> +	sbi->managed_cache = NULL;
>>  #endif
>> -	kfree(sbi);
>> -	sb->s_fs_info = NULL;
>> -}
>> -
>> -static struct dentry *erofs_mount(struct file_system_type *fs_type, int flags,
>> -				  const char *dev_name, void *data)
>> -{
>> -	return mount_bdev(fs_type, flags, dev_name, data, erofs_fill_super);
>>  }
>>  
>>  static struct file_system_type erofs_fs_type = {
>>  	.owner          = THIS_MODULE,
>>  	.name           = "erofs",
>>  	.mount          = erofs_mount,
>> -	.kill_sb        = kill_block_super,
>> +	.kill_sb        = erofs_kill_sb,
>>  	.fs_flags       = FS_REQUIRES_DEV,
>>  };
>>  MODULE_ALIAS_FS("erofs");
>>

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

* Re: [PATCH 07/22] staging: erofs: remove redundant #include "internal.h"
  2019-07-31 12:07       ` Chao Yu
@ 2019-07-31 12:54         ` Gao Xiang
  2019-08-01  1:31           ` Chao Yu
  0 siblings, 1 reply; 55+ messages in thread
From: Gao Xiang @ 2019-07-31 12:54 UTC (permalink / raw)
  To: Chao Yu; +Cc: Greg Kroah-Hartman, devel, linux-erofs, LKML, weidu.du, Miao Xie



On 2019/7/31 20:07, Chao Yu wrote:
> Hi Xiang,
> 
> On 2019/7/31 15:08, Gao Xiang wrote:
>> Hi Chao,
>>
>> On 2019/7/31 15:03, Chao Yu wrote:
>>> On 2019/7/29 14:51, Gao Xiang wrote:
>>>> Because #include "internal.h" is included in xattr.h
>>>
>>> I think it would be better to remove "internal.h" in xattr.h, and include them
>>> both in .c file in where we need xattr definition.
>>
>> It seems that all xattr related source files needing internal.h,
>> and we need "EROFS_V(inode)", "struct erofs_sb_info", ... stuffs in xattr.h,
>> which is defined in internal.h...
> 
> Since I checked f2fs', it looks it's okay to don't include internal.h for
> xattr.h, if .c needs xattr.h, we can just include interanl.h and xattr.h in the
> head of it, it's safe.

I think xattr.h should be used independently (all dependencies of xattr.h should
be included in xattr.h, most of include files behave like that)... Maybe it is
not a good way to follow f2fs...

Thanks,
Gao Xiang

> 
> Thanks,
> 
>>
>> Thanks,
>> Gao Xiang
>>
>>>
>>> Thanks,
>>>
>> .
>>

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

* Re: [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES
  2019-07-31 12:10       ` Chao Yu
@ 2019-07-31 12:55         ` Gao Xiang
  0 siblings, 0 replies; 55+ messages in thread
From: Gao Xiang @ 2019-07-31 12:55 UTC (permalink / raw)
  To: Chao Yu; +Cc: Greg Kroah-Hartman, devel, linux-erofs, LKML, weidu.du, Miao Xie



On 2019/7/31 20:10, Chao Yu wrote:
> Hi Xiang,
> 
> On 2019/7/31 15:11, Gao Xiang wrote:
>> Hi Chao,
>>
>> On 2019/7/31 15:05, Chao Yu wrote:
>>> On 2019/7/29 14:51, Gao Xiang wrote:
>>>> CONFIG_EROFS_FS_IO_MAX_RETRIES seems a runtime setting
>>>> and users have no idea about the change in behaviour.
>>>>
>>>> Let's remove the setting currently and fold it into code,
>>>> turn it into a module parameter if it's really needed.
>>>>
>>>> Suggested-by: David Sterba <dsterba@suse.cz>
>>>> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
>>>
>>> It's fine to me, but I'd like to suggest to add this as a sys entry which can be
>>> more flexible for user to change.
>>
>> I think it can be added in the later version, the original view
>> from David is that he had question how users using this option.
>>
>> Maybe we can use the default value and leave it to users who
>> really need to modify this value (real requirement).
> 
> I think we need to decide it in this version, otherwise it may face backward
> compatibility issue if we change module argument to sys entry later.
> 
> Maybe just leave it as an fixed macro is fine, since there is actually no
> requirement on this.

OK, will fix it --- leave the fixed macro.

Thanks,
Gao Xiang

> 
> Thanks,
> 
>>
>> Thanks,
>> Gao Xiang
>>
>>>
>>> Thanks
>>>
>> .
>>

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

* Re: [PATCH 07/22] staging: erofs: remove redundant #include "internal.h"
  2019-07-31 12:54         ` Gao Xiang
@ 2019-08-01  1:31           ` Chao Yu
  0 siblings, 0 replies; 55+ messages in thread
From: Chao Yu @ 2019-08-01  1:31 UTC (permalink / raw)
  To: Gao Xiang
  Cc: Greg Kroah-Hartman, devel, linux-erofs, LKML, weidu.du, Miao Xie

On 2019/7/31 20:54, Gao Xiang wrote:
> 
> 
> On 2019/7/31 20:07, Chao Yu wrote:
>> Hi Xiang,
>>
>> On 2019/7/31 15:08, Gao Xiang wrote:
>>> Hi Chao,
>>>
>>> On 2019/7/31 15:03, Chao Yu wrote:
>>>> On 2019/7/29 14:51, Gao Xiang wrote:
>>>>> Because #include "internal.h" is included in xattr.h
>>>>
>>>> I think it would be better to remove "internal.h" in xattr.h, and include them
>>>> both in .c file in where we need xattr definition.
>>>
>>> It seems that all xattr related source files needing internal.h,
>>> and we need "EROFS_V(inode)", "struct erofs_sb_info", ... stuffs in xattr.h,
>>> which is defined in internal.h...
>>
>> Since I checked f2fs', it looks it's okay to don't include internal.h for
>> xattr.h, if .c needs xattr.h, we can just include interanl.h and xattr.h in the
>> head of it, it's safe.
> 
> I think xattr.h should be used independently (all dependencies of xattr.h should
> be included in xattr.h, most of include files behave like that)... Maybe it is
> not a good way to follow f2fs...

Yes, I've confirmed it's fine to do this, let's go ahead. :)

Thanks,

> 
> Thanks,
> Gao Xiang
> 
>>
>> Thanks,
>>
>>>
>>> Thanks,
>>> Gao Xiang
>>>
>>>>
>>>> Thanks,
>>>>
>>> .
>>>
> .
> 

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

end of thread, other threads:[~2019-08-01  1:31 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29  6:51 [PATCH 00/22] staging: erofs: updates according to erofs-outofstaging v4 Gao Xiang
2019-07-29  6:51 ` [PATCH 01/22] staging: erofs: update source file headers Gao Xiang
2019-07-30  7:20   ` Greg Kroah-Hartman
2019-07-30  7:26     ` Gao Xiang
2019-07-31  6:36   ` Chao Yu
2019-07-29  6:51 ` [PATCH 02/22] staging: erofs: rename source files for better understanding Gao Xiang
2019-07-31  6:43   ` Chao Yu
2019-07-29  6:51 ` [PATCH 03/22] staging: erofs: fix dummy functions erofs_{get,list}xattr Gao Xiang
2019-07-31  6:44   ` [PATCH 03/22] staging: erofs: fix dummy functions erofs_{get, list}xattr Chao Yu
2019-07-29  6:51 ` [PATCH 04/22] staging: erofs: keep up erofs_fs.h with erofs-outofstaging patchset Gao Xiang
2019-07-31  6:46   ` Chao Yu
2019-07-29  6:51 ` [PATCH 05/22] staging: erofs: sunset erofs_workstn_{lock,unlock} Gao Xiang
2019-07-31  6:49   ` Chao Yu
2019-07-29  6:51 ` [PATCH 06/22] staging: erofs: clean up internal.h Gao Xiang
2019-07-31  6:53   ` Chao Yu
2019-07-29  6:51 ` [PATCH 07/22] staging: erofs: remove redundant #include "internal.h" Gao Xiang
2019-07-31  7:03   ` Chao Yu
2019-07-31  7:08     ` Gao Xiang
2019-07-31 12:07       ` Chao Yu
2019-07-31 12:54         ` Gao Xiang
2019-08-01  1:31           ` Chao Yu
2019-07-29  6:51 ` [PATCH 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES Gao Xiang
2019-07-31  7:05   ` Chao Yu
2019-07-31  7:11     ` Gao Xiang
2019-07-31 12:10       ` Chao Yu
2019-07-31 12:55         ` Gao Xiang
2019-07-29  6:51 ` [PATCH 09/22] staging: erofs: clean up shrinker stuffs Gao Xiang
2019-07-31  7:41   ` Chao Yu
2019-07-29  6:51 ` [PATCH 10/22] staging: erofs: kill sbi->dev_name Gao Xiang
2019-07-31  7:46   ` Chao Yu
2019-07-29  6:51 ` [PATCH 11/22] staging: erofs: kill all failure handling in fill_super() Gao Xiang
2019-07-31  8:15   ` Chao Yu
2019-07-31 12:52     ` Gao Xiang
2019-07-29  6:51 ` [PATCH 12/22] staging: erofs: refine erofs_allocpage() Gao Xiang
2019-07-31  8:20   ` Chao Yu
2019-07-29  6:51 ` [PATCH 13/22] staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM Gao Xiang
2019-07-31  8:27   ` Chao Yu
2019-07-29  6:51 ` [PATCH 14/22] staging: erofs: tidy up zpvec.h Gao Xiang
2019-07-31  8:28   ` Chao Yu
2019-07-29  6:51 ` [PATCH 15/22] staging: erofs: remove redundant braces in inode.c Gao Xiang
2019-07-31  8:29   ` Chao Yu
2019-07-29  6:51 ` [PATCH 16/22] staging: erofs: tidy up decompression frontend Gao Xiang
2019-07-31  9:07   ` Chao Yu
2019-07-29  6:51 ` [PATCH 17/22] staging: erofs: remove clusterbits in sbi Gao Xiang
2019-07-31  9:12   ` Chao Yu
2019-07-29  6:51 ` [PATCH 18/22] staging: erofs: turn cache strategies into mount options Gao Xiang
2019-07-31  9:23   ` Chao Yu
2019-07-29  6:51 ` [PATCH 19/22] staging: erofs: tidy up utils.c Gao Xiang
2019-07-31  9:24   ` Chao Yu
2019-07-29  6:51 ` [PATCH 20/22] staging: erofs: tidy up internal.h Gao Xiang
2019-07-31  9:25   ` Chao Yu
2019-07-29  6:51 ` [PATCH 21/22] staging: erofs: update super.c Gao Xiang
2019-07-31  9:40   ` Chao Yu
2019-07-29  6:51 ` [PATCH 22/22] staging: erofs: update Kconfig Gao Xiang
2019-07-31  9:44   ` Chao Yu

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).