staging: erofs: updates according to erofs-outofstaging v4
v2 cover staging: erofs: updates according to erofs-outofstaging v4
changes from v1:
(mainly address comments from Chao:)
- keep EROFS_IO_MAX_RETRIES_NOFAIL;
- add a new patch "drop __GFP_NOFAIL for managed inode";
- kill a redundant NULL check in "__stagingpage_alloc";
- add some description in document about "use_vmap";
- rearrange erofs_vmap of "staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM";
- combine two similar patches about "cleaning up internal.h"
since they rearrange the same file...
----8<----
This patchset includes all meaningful modifications till now according
to erofs-outofstaging v4:
https://lore.kernel.org/linux-fsdevel/20190725095658.155779-1-gaoxiang25 at 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: drop __GFP_NOFAIL for managed inode
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: update super.c
staging: erofs: update Kconfig
.../erofs/Documentation/filesystems/erofs.txt | 14 +
drivers/staging/erofs/Kconfig | 111 +-
drivers/staging/erofs/Makefile | 4 +-
drivers/staging/erofs/compress.h | 2 +-
drivers/staging/erofs/data.c | 6 +-
drivers/staging/erofs/decompressor.c | 45 +-
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 | 246 +--
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 | 1405 +++++++++++++++
.../staging/erofs/{unzip_vle.h => zdata.h} | 119 +-
drivers/staging/erofs/zmap.c | 5 +-
.../erofs/{unzip_pagevec.h => zpvec.h} | 41 +-
22 files changed, 1856 insertions(+), 2239 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%)Signature · 1 line
2.17.1
PATCH v2 1/22 staging: erofs: update source file headers
- 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.
--- 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(-)
drivers/staging/erofs/Kconfig +1 -1
@@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: GPL-2.0-only config EROFS_FS tristate "EROFS filesystem support"
drivers/staging/erofs/Makefile +1 -1
@@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: GPL-2.0-only EROFS_VERSION = "1.0pre1"
drivers/staging/erofs/compress.h +1 -1
@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * linux/drivers/staging/erofs/compress.h *
drivers/staging/erofs/data.c +1 -5
@@ -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 at 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>
drivers/staging/erofs/decompressor.c +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0-only /* * linux/drivers/staging/erofs/decompressor.c *
drivers/staging/erofs/dir.c +1 -5
@@ -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 at 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"
drivers/staging/erofs/erofs_fs.h +2 -6
@@ -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 at 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
drivers/staging/erofs/include/linux/tagptr.h +3 -3
@@ -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 at huawei.com> */
drivers/staging/erofs/include/trace/events/erofs.h +1 -1
@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +/* SPDX-License-Identifier: GPL-2.0-only */ #undef TRACE_SYSTEM#define TRACE_SYSTEM erofs
drivers/staging/erofs/inode.c +1 -5
@@ -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 at 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"
drivers/staging/erofs/internal.h +2 -6
@@ -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 at 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
drivers/staging/erofs/namei.c +1 -5
@@ -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 at 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"
drivers/staging/erofs/super.c +1 -5
@@ -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 at 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>
drivers/staging/erofs/unzip_pagevec.h +2 -6
@@ -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 at 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
drivers/staging/erofs/unzip_vle.c +1 -5
@@ -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 at 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"
drivers/staging/erofs/unzip_vle.h +2 -6
@@ -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 at 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
drivers/staging/erofs/utils.c +1 -6
@@ -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 at 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>
drivers/staging/erofs/xattr.c +1 -5
@@ -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 at 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"
drivers/staging/erofs/xattr.h +2 -6
@@ -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 at 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
drivers/staging/erofs/zmap.c +1 -1
@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0-only /* * linux/drivers/staging/erofs/zmap.c *
Signature · 1 line
2.17.1
PATCH v2 2/22 staging: erofs: rename source files for better understanding
In reply to Gao XiangKeep in line with erofs-outofstaging patchset as well, see
https://lore.kernel.org/linux-fsdevel/20190725095658.155779-1-gaoxiang25 at 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%)drivers/staging/erofs/Makefile +1 -1
@@ -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
drivers/staging/erofs/tagptr.h renamed from drivers/staging/erofs/include/linux/tagptr.h +3 -3
@@ -4,8 +4,8 @@* * Copyright (C) 2018 Gao Xiang <gaoxiang25 at 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 */
drivers/staging/erofs/zdata.c renamed from drivers/staging/erofs/unzip_vle.c +2 -2
@@ -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 at huawei.com> */ -#include "unzip_vle.h" +#include "zdata.h" #include "compress.h" #include <linux/prefetch.h>
drivers/staging/erofs/zdata.h renamed from drivers/staging/erofs/unzip_vle.h +4 -4
@@ -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 at 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
drivers/staging/erofs/zpvec.h renamed from drivers/staging/erofs/unzip_pagevec.h +4 -4
@@ -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 at 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 {
Signature · 1 line
2.17.1
PATCH v2 3/22 staging: erofs: fix dummy functions erofs_{get,list}xattr
In reply to Gao Xiangdummy functions erofs_{get,list}xattr should be inlined without xattr enabled.
Signed-off-by: Yue Hu <zbestahu at gmail.com>
[ Gao Xiang : this patch was "staging: erofs: remove needless
dummy functions of erofs_{get,list}xattr. "]
Reviewed-by: Chao Yu <yuchao0 at huawei.com>
Signed-off-by: Gao Xiang <gaoxiang25 at huawei.com>
--- drivers/staging/erofs/xattr.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/erofs/xattr.h +7 -7
@@ -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);
Signature · 1 line
2.17.1
PATCH v2 4/22 staging: erofs: keep up erofs_fs.h with erofs-outofstaging patchset
In reply to Gao XiangThe 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.
--- drivers/staging/erofs/erofs_fs.h | 39 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/staging/erofs/erofs_fs.h +19 -20
@@ -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 1struct 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;
Signature · 1 line
2.17.1
PATCH v2 5/22 staging: erofs: sunset erofs_workstn_{lock,unlock}
In reply to Gao XiangIt was used for Linux backward compatibility, and
no use for upstream kernel.
--- drivers/staging/erofs/internal.h | 3 --- drivers/staging/erofs/utils.c | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/staging/erofs/internal.h +0 -3
@@ -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 */
drivers/staging/erofs/utils.c +5 -5
@@ -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;
Signature · 1 line
2.17.1
PATCH v2 6/22 staging: erofs: clean up internal.h
In reply to Gao XiangTidy up relative order of variables / declarations in internal.h, move some local static functions out into other files and add tags at the end of #endif acrossing several lines.
No logic change.
--- drivers/staging/erofs/decompressor.c | 27 +++++ drivers/staging/erofs/internal.h | 157 ++++++++------------------- drivers/staging/erofs/super.c | 2 +- drivers/staging/erofs/zdata.c | 8 +- drivers/staging/erofs/zdata.h | 13 +++ 5 files changed, 92 insertions(+), 115 deletions(-)
drivers/staging/erofs/decompressor.c +27 -0
@@ -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) {
drivers/staging/erofs/internal.h +44 -113
260 lines not on this page · raw message
drivers/staging/erofs/super.c +1 -1
@@ -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
drivers/staging/erofs/zdata.c +7 -1
@@ -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 ;
drivers/staging/erofs/zdata.h +13 -0
@@ -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)
Signature · 1 line
2.17.1
PATCH v2 7/22 staging: erofs: remove redundant #include "internal.h"
In reply to Gao XiangBecause #include "internal.h" is included in xattr.h
--- drivers/staging/erofs/namei.c | 1 - drivers/staging/erofs/super.c | 1 - 2 files changed, 2 deletions(-)
drivers/staging/erofs/namei.c +0 -1
@@ -6,7 +6,6 @@* http://www.huawei.com/ * Created by Gao Xiang <gaoxiang25 at huawei.com> */ -#include "internal.h" #include "xattr.h" #include <trace/events/erofs.h>
drivers/staging/erofs/super.c +0 -1
@@ -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
Signature · 1 line
2.17.1
Re: [PATCH v2 07/22] staging: erofs: remove redundant #include "internal.h"
Quoted 3 lines · Gao Xiang
Because #include "
internal.h" is included inxattr.hSigned-off-by Gao Xiang <gaoxiang25 at huawei.com>
Thanks,
PATCH v2 8/22 staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES
In reply to Gao XiangCONFIG_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 could turn it into a module parameter if it's really needed.
--- drivers/staging/erofs/Kconfig | 9 --------- drivers/staging/erofs/internal.h | 8 ++------ 2 files changed, 2 insertions(+), 15 deletions(-)
drivers/staging/erofs/Kconfig +0 -9
@@ -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
drivers/staging/erofs/internal.h +2 -6
@@ -279,6 +279,8 @@ static inline void z_erofs_exit_zip_subsystem(void) {}#error erofs cannot be used in this platform#endif +#define EROFS_IO_MAX_RETRIES_NOFAIL 5 +#define ROOT_NID (sb) ((sb)->root_nid)#define erofs_blknr (addr) ((addr) / EROFS_BLKSIZ)
@@ -467,12 +469,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);
Signature · 1 line
2.17.1
Re: [PATCH v2 08/22] staging: erofs: kill CONFIG_EROFS_FS_IO_MAX_RETRIES
Quoted 8 lines · Gao Xiang
CONFIG_EROFS_FS_IO_MAX_RETRIESseems a runtime setting and users have no idea about the change in behaviour.Let's remove the setting currently and could turn it into a module parameter if it's really needed.
Suggested-by David Sterba <dsterba at suse.cz>Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
Thanks,
PATCH v2 9/22 staging: erofs: clean up shrinker stuffs
In reply to 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.
--- 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(-)
drivers/staging/erofs/internal.h +26 -24
@@ -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 */
@@ -253,15 +253,8 @@ static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp)/* page count of a compressed cluster */ #define erofs_clusterpages (sbi) ((1 << (sbi)->clusterbits) / PAGE_SIZE) - -int __init z_erofs_init_zip_subsystem (void ); -void z_erofs_exit_zip_subsystem (void );#else #define EROFS_PCPUBUF_NR_PAGES 0 - -/* 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 */
@@ -525,8 +518,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 )
@@ -544,20 +535,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 /* !CONFIG_EROFS_FS_ZIP */ #endif /* __EROFS_INTERNAL_H */
drivers/staging/erofs/super.c +5 -15
@@ -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" ); }
drivers/staging/erofs/utils.c +25 -12
@@ -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 */ +
Signature · 1 line
2.17.1
PATCH v2 10/22 staging: erofs: kill sbi->dev_name
In reply to Gao XiangAs 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.
--- drivers/staging/erofs/internal.h | 2 -- drivers/staging/erofs/super.c | 54 +++++--------------------------- 2 files changed, 7 insertions(+), 49 deletions(-)
drivers/staging/erofs/internal.h +0 -2
@@ -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
drivers/staging/erofs/super.c +7 -47
93 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 11/22 staging: erofs: kill all failure handling in fill_super()
In reply to 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).
--- drivers/staging/erofs/super.c | 118 +++++++++++++++------------------- 1 file changed, 52 insertions(+), 66 deletions(-)
drivers/staging/erofs/super.c +52 -66
@@ -343,12 +343,13 @@ 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 ;
@@ -357,37 +358,38 @@ static struct inode *erofs_init_managed_cache(struct super_block *sb)mapping_set_gfp_mask (inode->i_mapping,GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE | __GFP_NOFAIL); -return inode; + 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 +399,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 +418,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" );
Signature · 1 line
2.17.1
PATCH v2 12/22 staging: erofs: drop __GFP_NOFAIL for managed inode
In reply to Gao XiangFor historical reasons, __GFP_NOFAIL was set for managed inode. It's no need using that since EROFS can handle it properly.
--- drivers/staging/erofs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/erofs/super.c +1 -2
@@ -356,8 +356,7 @@ static int erofs_init_managed_cache(struct super_block *sb) inode->i_mapping->a_ops = &managed_cache_aops;mapping_set_gfp_mask (inode->i_mapping, -GFP_NOFS | __GFP_HIGHMEM | - __GFP_MOVABLE | __GFP_NOFAIL); +GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE); sbi->managed_cache = inode;return 0 ; }
Signature · 1 line
2.17.1
Re: [PATCH v2 12/22] staging: erofs: drop __GFP_NOFAIL for managed inode
Quoted 4 lines · Gao Xiang
For historical reasons,
__GFP_NOFAILwas set for managed inode. It's no need using that since EROFS can handle it properly.Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
Thanks,
PATCH v2 13/22 staging: erofs: refine erofs_allocpage()
In reply to Gao Xiangremove duplicated code in decompressor by introducing failable erofs_allocpage().
--- drivers/staging/erofs/decompressor.c | 12 +++--------- drivers/staging/erofs/internal.h | 2 +- drivers/staging/erofs/utils.c | 5 +++-- drivers/staging/erofs/zdata.c | 5 +---- 4 files changed, 8 insertions(+), 16 deletions(-)
drivers/staging/erofs/decompressor.c +3 -9
@@ -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;
drivers/staging/erofs/internal.h +1 -1
@@ -516,7 +516,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);
drivers/staging/erofs/utils.c +3 -2
@@ -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; }
drivers/staging/erofs/zdata.c +1 -4
@@ -634,10 +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); - -if (unlikely (!page)) -return NULL ; +struct page *page =erofs_allocpage (pagepool, gfp, true); page->mapping =Z_EROFS_MAPPING_STAGING ;return page;
Signature · 1 line
2.17.1
PATCH v2 14/22 staging: erofs: kill CONFIG_EROFS_FS_USE_VM_MAP_RAM
In reply to Gao XiangTurn into a module parameter ("use_vmap") as it can be set at runtime.
--- .../erofs/Documentation/filesystems/erofs.txt | 4 ++++ drivers/staging/erofs/Kconfig | 8 ------- drivers/staging/erofs/decompressor.c | 22 +++++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-)
drivers/staging/erofs/Documentation/filesystems/erofs.txt +4 -0
@@ -66,6 +66,10 @@ fault_injection=%d Enable fault injection in all supported types with (no)acl Setup POSIX Access Control List. Note: acl is enabled by default if CONFIG_EROFS_FS_POSIX_ACL is selected. +Module parameters +================= +use_vmap=[0|1] Use vmap() instead of vm_map_ram() (default 0). + On-disk details ===============
drivers/staging/erofs/Kconfig +0 -8
@@ -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
drivers/staging/erofs/decompressor.c +13 -9
@@ -7,6 +7,7 @@* Created by Gao Xiang <gaoxiang25 at 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,28 @@ 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 ; +if (use_vmap) +return vmap (pages, count,VM_MAP ,PAGE_KERNEL ); +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 +if (!use_vmap) +vm_unmap_ram (mem, count); +else +vunmap (mem); } static int decompress_generic(struct z_erofs_decompress_req *rq,
Signature · 1 line
2.17.1
PATCH v2 15/22 staging: erofs: tidy up zpvec.h
In reply to 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.
--- drivers/staging/erofs/zdata.c | 6 +++--- drivers/staging/erofs/zpvec.h | 25 +++++++++---------------- 2 files changed, 12 insertions(+), 19 deletions(-)
drivers/staging/erofs/zdata.c +3 -3
@@ -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 ;
@@ -938,7 +938,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);
drivers/staging/erofs/zpvec.h +9 -16
@@ -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
Signature · 1 line
2.17.1
PATCH v2 16/22 staging: erofs: remove redundant braces in inode.c
In reply to Gao XiangRemove redundant braces in inode.c
since these are all single statements.
--- drivers/staging/erofs/inode.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/staging/erofs/inode.c +8 -10
@@ -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));
Signature · 1 line
2.17.1
PATCH v2 17/22 staging: erofs: tidy up decompression frontend
In reply to Gao XiangAlthough 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.
--- drivers/staging/erofs/zdata.c | 983 +++++++++++++++------------------- drivers/staging/erofs/zdata.h | 96 ++-- 2 files changed, 465 insertions(+), 614 deletions(-)
drivers/staging/erofs/zdata.c +419 -564
@@ -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; }
@@ -640,33 +547,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;
@@ -677,25 +560,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;
@@ -713,8 +594,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; }
@@ -722,12 +603,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;
@@ -735,10 +616,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;
@@ -748,13 +626,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 ))) {
@@ -769,17 +644,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; }
@@ -787,15 +662,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;
@@ -805,7 +679,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",
@@ -821,7 +694,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) {
@@ -878,45 +751,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 *),
@@ -933,9 +799,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);
@@ -944,7 +810,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 )
@@ -957,12 +823,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) {
@@ -989,7 +853,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;
@@ -1005,30 +868,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 */
@@ -1039,7 +898,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 ); }
@@ -1052,7 +911,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 ))
@@ -1066,65 +925,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;
@@ -1134,7 +991,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)
@@ -1186,7 +1043,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)) {
@@ -1198,7 +1055,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); }
@@ -1222,7 +1079,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;
@@ -1234,18 +1091,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 */
@@ -1264,11 +1120,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 ,
@@ -1278,15 +1134,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;
@@ -1299,26 +1155,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) {
@@ -1329,21 +1185,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) {
@@ -1354,17 +1208,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 */
@@ -1372,7 +1223,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;
@@ -1384,29 +1235,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;
@@ -1437,10 +1291,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 );
@@ -1452,17 +1306,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)
@@ -1480,7 +1336,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);
@@ -1489,14 +1345,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);
@@ -1521,7 +1377,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);
@@ -1567,13 +1423,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);
drivers/staging/erofs/zdata.h +46 -50
155 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 18/22 staging: erofs: remove clusterbits in sbi
In reply to Gao Xiangclustersize can now be set on per-file basis
rather than per-filesystem basis.
--- 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(-)
drivers/staging/erofs/internal.h +0 -5
@@ -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;
@@ -248,9 +246,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)#define EROFS_PCPUBUF_NR_PAGES Z_EROFS_CLUSTER_MAX_PAGES - -/* page count of a compressed cluster */ -#define erofs_clusterpages (sbi) ((1 << (sbi)->clusterbits) / PAGE_SIZE)#else #define EROFS_PCPUBUF_NR_PAGES 0#endif /* !CONFIG_EROFS_FS_ZIP */
drivers/staging/erofs/super.c +0 -9
@@ -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);
drivers/staging/erofs/zmap.c +1 -2
@@ -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);
Signature · 1 line
2.17.1
PATCH v2 19/22 staging: erofs: turn cache strategies into mount options
In reply to Gao XiangKill 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.
--- .../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(-)
drivers/staging/erofs/Documentation/filesystems/erofs.txt +10 -0
@@ -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. Module parameters =================
drivers/staging/erofs/Kconfig +0 -38
@@ -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 -
drivers/staging/erofs/internal.h +10 -15
@@ -51,18 +51,6 @@ struct erofs_fault_info { };#endif /* CONFIG_EROFS_FAULT_INJECTION */ -#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 */
drivers/staging/erofs/super.c +57 -7
114 lines not on this page · raw message
drivers/staging/erofs/utils.c +0 -26
@@ -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)
drivers/staging/erofs/zdata.c +8 -48
126 lines not on this page · raw message
drivers/staging/erofs/zdata.h +0 -6
@@ -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)
Signature · 1 line
2.17.1
PATCH v2 20/22 staging: erofs: tidy up utils.c
In reply to Gao XiangKeep in line with erofs-outofstaging patchset:
- Update comments in erofs_try_to_release_workgroup;
- code style cleanup.
--- drivers/staging/erofs/utils.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/staging/erofs/utils.c +13 -14
@@ -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;
Signature · 1 line
2.17.1
PATCH v2 21/22 staging: erofs: update super.c
In reply to Gao XiangKeep in line with erofs-outofstaging patchset:
- "Chao Yu" is most commonly used in Linux community;
- quoted string split across lines.
--- drivers/staging/erofs/super.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/erofs/super.c +2 -3
@@ -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" );
Signature · 1 line
2.17.1
PATCH v2 22/22 staging: erofs: update Kconfig
In reply to Gao XiangKeep 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.
--- drivers/staging/erofs/Kconfig | 54 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 26 deletions(-)
drivers/staging/erofs/Kconfig +28 -26
@@ -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.
Signature · 1 line
2.17.1