staging: erofs: document, bugfix and cleanups
Subsystems (3)
cover staging: erofs: document, bugfix and cleanups
Hi,
This is the first EROFS patchset for this new round.
An initial document describing the details of EROFS is added in this patchset and it was previewed in
https://lists.ozlabs.org/pipermail/linux-erofs/2019-January/001227.html
In addition, Li Guifu found an unexpected crash related to fast symlink in our internal test, this patchset also addresses this issue:
https://lists.ozlabs.org/pipermail/linux-erofs/2019-January/001190.html
and the rest patches are all cleanups, nothing special.
Thanks,
Gao Xiang
Chao Yu (1):
staging: erofs: clean up erofs_map_blocks_iter
Gao Xiang (4):
staging: erofs: add document
staging: erofs: fix fast symlink w/o xattr when fs xattr is on
staging: erofs: remove unneeded inode_operations
staging: erofs: move erofs_xattr_handlers to xattr.h
.../erofs/Documentation/filesystems/erofs.txt | 195 +++++++++++++++++++++ drivers/staging/erofs/data.c | 31 +--- drivers/staging/erofs/inode.c | 38 ++-- drivers/staging/erofs/internal.h | 67 +++---- drivers/staging/erofs/namei.c | 4 - drivers/staging/erofs/super.c | 1 + drivers/staging/erofs/unzip_vle.c | 30 ++-- drivers/staging/erofs/xattr.c | 25 ++- drivers/staging/erofs/xattr.h | 4 +- 9 files changed, 278 insertions(+), 117 deletions(-) create mode 100644 drivers/staging/erofs/Documentation/filesystems/erofs.txt
Signature · 1 line
2.14.4
PATCH 1/5 staging: erofs: add document
This documents key feature, usage, and on-disk design of erofs.
--- .../erofs/Documentation/filesystems/erofs.txt | 195 +++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 drivers/staging/erofs/Documentation/filesystems/erofs.txt
drivers/staging/erofs/Documentation/filesystems/erofs.txt new file +195 -0
@@ -0,0 +1,195 @@ +Overview +======== + +EROFS file-system stands for Enhanced Read-Only File System. Different +from other read-only file systems, it aims to be designed for flexibility, +scalability, but be kept simple and high performance. + +Here is the main features of EROFS: + - Little endian on-disk design; + + - Currently 4KB block size (nobh) and therefore maximum 16TB address space; + + - Metadata & data could be mixed by design; + + - 2 inode versions for different requirements: + v1 v2 + Inode metadata size: 32 bytes 64 bytes + Max file size: 4 GB 16 EB (also limited by max. vol size) + Max uids/gids: 65536 4294967296 + File creation time: no yes (64 + 32-bit timestamp) + Max hardlinks: 65536 4294967296 + Metadata reserved: 4 bytes 14 bytes + + - Support extended attributes (xattrs) + + - Support xattr inline and tail-end data inline for all files; + + - Support transparent file compression as an option: + LZ4 algorithm with 4 KB fixed-output compression for high performance; + +The following git tree provides the file system user-space tools under +development (ex, formatting tool mkfs.erofs): +>> git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git + +Bugs and patches are welcome, please kindly help us and send to the following +linux-erofs mailing list: +>> linux-erofs mailing list <linux-erofs at lists.ozlabs.org> + +Note that EROFS is still working in progress as a Linux staging driver, +Cc the staging mailing list as well is highly recommended: +>> Linux Driver Project Developer List <devel at driverdev.osuosl.org> + +Mount options +============= + +fault_injection=%d Enable fault injection in all supported types with + specified injection rate. Supported injection type: + Type_Name Type_Value + FAULT_KMALLOC 0x000000001 +(no)user_xattr Setup Extended User Attributes. Note: xattr is enabled + 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. + +On-disk details +=============== + +Summary +------- +Different from other read-only file systems, an EROFS volume is designed +to be as simple as possible: + + |-> aligned with the block size + ____________________________________________________________ + | |SB| | ... | Metadata | ... | Data | Metadata | ... | Data | + |_|__|_|_____|__________|_____|______|__________|_____|______| + 0 +1K + +All data areas should be aligned with the block size, but metadata areas +may not. All metadatas can be now observed in two different spaces (views): + 1. Inode metadata space + Each valid inode should be aligned with an inode slot, which is a fixed + value (32 bytes) and designed to be kept in line with v1 inode size. + + Each inode can be directly found with the following formula: + inode offset = meta_blkaddr * block_size + 32 * nid + + |-> aligned with 8B + |-> followed closely + + meta_blkaddr blocks |-> another slot + _____________________________________________________________________ + | ... | inode | xattrs | extents | data inline | ... | inode ... + |________|_______|(optional)|(optional)|__(optional)_|_____|__________ + |-> aligned with the inode slot size + . . + . . + . . + . . + . . + . . + .____________________________________________________|-> aligned with 4B + | xattr_ibody_header | shared xattrs | inline xattrs | + |____________________|_______________|_______________| + |-> 12 bytes <-|->x * 4 bytes<-| . + . . . + . . . + . . . + ._______________________________.______________________. + | id | id | id | id | ... | id | ent | ... | ent| ... | + |____|____|____|____|______|____|_____|_____|____|_____| + |-> aligned with 4B + |-> aligned with 4B + + Inode could be 32 or 64 bytes, which can be distinguished from a common + field which all inode versions have -- i_advise: + + __________________ __________________ + | i_advise | | i_advise | + |__________________| |__________________| + | ... | | ... | + | | | | + |__________________| 32 bytes | | + | | + |__________________| 64 bytes + + Xattrs, extents, data inline are followed by the corresponding inode with + proper alignes, and they could be optional for different data mappings, + _currently_ there are totally 3 valid data mappings supported: + + 1) flat file data without data inline (no extent); + 2) fixed-output size data compression (must have extents); + 3) flat file data with tail-end data inline (no extent); + + The size of the optional xattrs is indicated by i_xattr_count in inode + header. Large xattrs or xattrs shared by many different files can be + stored in shared xattrs metadata rather than inlined right after inode. + + 2. Shared xattrs metadata space + Shared xattrs space is similar to the above inode space, started with + a specific block indicated by xattr_blkaddr, organized one by one with + proper align. + + Each share xattr can also be directly found by the following formula: + xattr offset = xattr_blkaddr * block_size + 4 * xattr_id + + |-> aligned by 4 bytes + + xattr_blkaddr blocks |-> aligned with 4 bytes + _________________________________________________________________________ + | ... | xattr_entry | xattr data | ... | xattr_entry | xattr data ... + |________|_____________|_____________|_____|______________|_______________ + +Directories +----------- +All directories are now organized in a compact on-disk format. Note that +each directory block is divided into index and name areas in order to support +random file lookup, and all directory entries are _strictly_ recorded in +alphabetical order in order to support improved prefix binary search +algorithm (could refer to the related source code). + + ___________________________ + / | + / ______________|________________ + / / | namelen1 | namelenN-1 + ____________.______________._______________v________________v__________ +| dirent | dirent | ... | dirent | filename | filename | ... | filename | +|___.0___|____1___|_____|___N-1__|____0_____|____1_____|_____|___N-1____| + \ ^ + \ | * could have + \ | trailing '\0' + \________________________| namelen0 + + Directory block + +Note that apart from the offset of the first filename, namelen0 also indicates +the total number of directory entries in this block since it is no need to +introduce another on-disk field at all. + +Compression +----------- +Currently, EROFS supports 4KB fixed-output clustersize transparent file +compression, as illustrated below: + + |---- Variant-Length Extent ----|-------- VLE --------|----- VLE ----- + clusterofs clusterofs clusterofs + | | | logical data +_________v_______________________________v_____________________v_______________ +... | . | | . | | . | ... +____|____.________|_____________|________.____|_____________|__.__________|____ + |-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-| + size size size size size + . . . . + . . . . + . . . . + _______._____________._____________._____________._____________________ + ... | | | | ... physical data + _______|_____________|_____________|_____________|_____________________ + |-> cluster <-|-> cluster <-|-> cluster <-| + size size size + +Currently each on-disk physical cluster can contain 4KB (un)compressed data +at most. For each logical cluster, there is a corresponding on-disk index to +describe its cluster type, physical cluster address, el. + +See "struct z_erofs_vle_decompressed_index" in erofs_fs.h for more details. +
Signature · 1 line
2.14.4
PATCH v2 1/1 staging: erofs: add document
From: Gao Xiang <[email protected]>
This documents key feature, usage, and on-disk design of erofs.
---
change log v2:
- fix some incorrect descriptions, such as namelen -> nameoff;
- add description about target EROFS users.
Thanks,
Gao Xiang
.../erofs/Documentation/filesystems/erofs.txt | 206 +++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 drivers/staging/erofs/Documentation/filesystems/erofs.txt
drivers/staging/erofs/Documentation/filesystems/erofs.txt new file +206 -0
@@ -0,0 +1,206 @@ +Overview +======== + +EROFS file-system stands for Enhanced Read-Only File System. Different +from other read-only file systems, it aims to be designed for flexibility, +scalability, but be kept simple and high performance. + +It is designed as a better filesystem solution for the following scenarios: + - read-only storage media or + + - part of a fully trusted read-only solution, which means it needs to be + immutable and bit-for-bit identical to the official golden image for + their releases due to security and other considerations and + + - hope to save some extra storage space with guaranteed end-to-end performance + by using reduced metadata and transparent file compression, especially + for those embedded devices with limited memory (ex, smartphone); + +Here is the main features of EROFS: + - Little endian on-disk design; + + - Currently 4KB block size (nobh) and therefore maximum 16TB address space; + + - Metadata & data could be mixed by design; + + - 2 inode versions for different requirements: + v1 v2 + Inode metadata size: 32 bytes 64 bytes + Max file size: 4 GB 16 EB (also limited by max. vol size) + Max uids/gids: 65536 4294967296 + File creation time: no yes (64 + 32-bit timestamp) + Max hardlinks: 65536 4294967296 + Metadata reserved: 4 bytes 14 bytes + + - Support extended attributes (xattrs) as an option; + + - Support xattr inline and tail-end data inline for all files; + + - Support transparent file compression as an option: + LZ4 algorithm with 4 KB fixed-output compression for high performance; + +The following git tree provides the file system user-space tools under +development (ex, formatting tool mkfs.erofs): +>> git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git + +Bugs and patches are welcome, please kindly help us and send to the following +linux-erofs mailing list: +>> linux-erofs mailing list <linux-erofs at lists.ozlabs.org> + +Note that EROFS is still working in progress as a Linux staging driver, +Cc the staging mailing list as well is highly recommended: +>> Linux Driver Project Developer List <devel at driverdev.osuosl.org> + +Mount options +============= + +fault_injection=%d Enable fault injection in all supported types with + specified injection rate. Supported injection type: + Type_Name Type_Value + FAULT_KMALLOC 0x000000001 +(no)user_xattr Setup Extended User Attributes. Note: xattr is enabled + 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. + +On-disk details +=============== + +Summary +------- +Different from other read-only file systems, an EROFS volume is designed +to be as simple as possible: + + |-> aligned with the block size + ____________________________________________________________ + | |SB| | ... | Metadata | ... | Data | Metadata | ... | Data | + |_|__|_|_____|__________|_____|______|__________|_____|______| + 0 +1K + +All data areas should be aligned with the block size, but metadata areas +may not. All metadatas can be now observed in two different spaces (views): + 1. Inode metadata space + Each valid inode should be aligned with an inode slot, which is a fixed + value (32 bytes) and designed to be kept in line with v1 inode size. + + Each inode can be directly found with the following formula: + inode offset = meta_blkaddr * block_size + 32 * nid + + |-> aligned with 8B + |-> followed closely + + meta_blkaddr blocks |-> another slot + _____________________________________________________________________ + | ... | inode | xattrs | extents | data inline | ... | inode ... + |________|_______|(optional)|(optional)|__(optional)_|_____|__________ + |-> aligned with the inode slot size + . . + . . + . . + . . + . . + . . + .____________________________________________________|-> aligned with 4B + | xattr_ibody_header | shared xattrs | inline xattrs | + |____________________|_______________|_______________| + |-> 12 bytes <-|->x * 4 bytes<-| . + . . . + . . . + . . . + ._______________________________.______________________. + | id | id | id | id | ... | id | ent | ... | ent| ... | + |____|____|____|____|______|____|_____|_____|____|_____| + |-> aligned with 4B + |-> aligned with 4B + + Inode could be 32 or 64 bytes, which can be distinguished from a common + field which all inode versions have -- i_advise: + + __________________ __________________ + | i_advise | | i_advise | + |__________________| |__________________| + | ... | | ... | + | | | | + |__________________| 32 bytes | | + | | + |__________________| 64 bytes + + Xattrs, extents, data inline are followed by the corresponding inode with + proper alignes, and they could be optional for different data mappings, + _currently_ there are totally 3 valid data mappings supported: + + 1) flat file data without data inline (no extent); + 2) fixed-output size data compression (must have extents); + 3) flat file data with tail-end data inline (no extent); + + The size of the optional xattrs is indicated by i_xattr_count in inode + header. Large xattrs or xattrs shared by many different files can be + stored in shared xattrs metadata rather than inlined right after inode. + + 2. Shared xattrs metadata space + Shared xattrs space is similar to the above inode space, started with + a specific block indicated by xattr_blkaddr, organized one by one with + proper align. + + Each share xattr can also be directly found by the following formula: + xattr offset = xattr_blkaddr * block_size + 4 * xattr_id + + |-> aligned by 4 bytes + + xattr_blkaddr blocks |-> aligned with 4 bytes + _________________________________________________________________________ + | ... | xattr_entry | xattr data | ... | xattr_entry | xattr data ... + |________|_____________|_____________|_____|______________|_______________ + +Directories +----------- +All directories are now organized in a compact on-disk format. Note that +each directory block is divided into index and name areas in order to support +random file lookup, and all directory entries are _strictly_ recorded in +alphabetical order in order to support improved prefix binary search +algorithm (could refer to the related source code). + + ___________________________ + / | + / ______________|________________ + / / | nameoff1 | nameoffN-1 + ____________.______________._______________v________________v__________ +| dirent | dirent | ... | dirent | filename | filename | ... | filename | +|___.0___|____1___|_____|___N-1__|____0_____|____1_____|_____|___N-1____| + \ ^ + \ | * could have + \ | trailing '\0' + \________________________| nameoff0 + + Directory block + +Note that apart from the offset of the first filename, nameoff0 also indicates +the total number of directory entries in this block since it is no need to +introduce another on-disk field at all. + +Compression +----------- +Currently, EROFS supports 4KB fixed-output clustersize transparent file +compression, as illustrated below: + + |---- Variant-Length Extent ----|-------- VLE --------|----- VLE ----- + clusterofs clusterofs clusterofs + | | | logical data +_________v_______________________________v_____________________v_______________ +... | . | | . | | . | ... +____|____.________|_____________|________.____|_____________|__.__________|____ + |-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-| + size size size size size + . . . . + . . . . + . . . . + _______._____________._____________._____________._____________________ + ... | | | | ... physical data + _______|_____________|_____________|_____________|_____________________ + |-> cluster <-|-> cluster <-|-> cluster <-| + size size size + +Currently each on-disk physical cluster can contain 4KB (un)compressed data +at most. For each logical cluster, there is a corresponding on-disk index to +describe its cluster type, physical cluster address, etc. + +See "struct z_erofs_vle_decompressed_index" in erofs_fs.h for more details. +
Signature · 1 line
2.11.0
PATCH 2/5 staging: erofs: fix fast symlink w/o xattr when fs xattr is on
In reply to Gao XiangCurrently, this will hit a BUG_ON for these symlinks as follows:
- kernel message
------------[ cut here ]------------ kernel BUG at drivers/staging/erofs/xattr.c:59! SMP PTI CPU: 1 PID: 1170 Comm: getllxattr Not tainted 4.20.0-rc6+ #92 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-2.fc27 04/01/2014 RIP: 0010:init_inode_xattrs+0x22b/0x270 Code: 48 0f 45 ea f0 ff 4d 34 74 0d 41 83 4c 24 e0 01 31 c0 e9 00 fe ff ff 48 89 ef e8 e0 31 9e ff eb e9 89 e8 e9 ef fd ff ff 0f 0$ <0f> 0b 48 89 ef e8 fb f6 9c ff 48 8b 45 08 a8 01 75 24 f0 ff 4d 34 RSP: 0018:ffffa03ac026bdf8 EFLAGS: 00010246 ------------[ cut here ]------------ ... Call Trace: erofs_listxattr+0x30/0x2c0 ? selinux_inode_listxattr+0x5a/0x80 ? kmem_cache_alloc+0x33/0x170 ? security_inode_listxattr+0x27/0x40 listxattr+0xaf/0xc0 path_listxattr+0x5a/0xa0 do_syscall_64+0x43/0xf0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 ... ---[ end trace 3c24b49408dc0c72 ]---
Fix it by checking ->xattr_isize in init_inode_xattrs(), and it also fixes improper return value -ENOTSUPP (it should be -ENODATA if xattr is enabled) for those inodes.
--- drivers/staging/erofs/inode.c | 8 ++++---- drivers/staging/erofs/xattr.c | 25 ++++++++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-)
drivers/staging/erofs/inode.c +4 -4
@@ -185,16 +185,16 @@ static int fill_inode(struct inode *inode, int isdir)/* setup the new inode */ if (S_ISREG (inode->i_mode)) {#ifdef CONFIG_EROFS_FS_XATTR -if (vi->xattr_isize) - inode->i_op = &erofs_generic_xattr_iops; + inode->i_op = &erofs_generic_xattr_iops;#endif inode->i_fop = &generic_ro_fops; }else if (S_ISDIR (inode->i_mode)) { inode->i_op = #ifdef CONFIG_EROFS_FS_XATTR - vi->xattr_isize ? &erofs_dir_xattr_iops : -#endif + &erofs_dir_xattr_iops; +#else &erofs_dir_iops; +#endif inode->i_fop = &erofs_dir_fops; }else if (S_ISLNK (inode->i_mode)) {/* by default, page_get_link is used for symlink */
drivers/staging/erofs/xattr.c +20 -5
@@ -56,7 +56,26 @@ static int init_inode_xattrs(struct inode *inode)return 0 ; vi =EROFS_V (inode); -BUG_ON (!vi->xattr_isize); + +/* +* bypass all xattr operations if ->xattr_isize is not greater than +* sizeof(struct erofs_xattr_ibody_header), in detail: +* 1) it is not enough to contain erofs_xattr_ibody_header then +* ->xattr_isize should be 0 (it means no xattr); +* 2) it is just to contain erofs_xattr_ibody_header, which is on-disk +* undefined right now (maybe use later with some new sb feature). +*/ +if (vi->xattr_isize ==sizeof (struct erofs_xattr_ibody_header )) { +errln ("xattr_isize %d of nid %llu is not supported yet" , + vi->xattr_isize, vi->nid); +return -ENOTSUPP ; + }else if (vi->xattr_isize <sizeof (struct erofs_xattr_ibody_header )) { +if (unlikely (vi->xattr_isize)) { +DBG_BUGON (1 ); +return -EIO ;/* xattr ondisk layout error */ + } +return -ENOATTR ; + } sb = inode->i_sb; sbi =EROFS_SB (sb);
@@ -422,7 +441,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *buffer, size_t size) { - struct erofs_vnode *const vi = EROFS_V(inode); struct erofs_sb_info *const sbi = EROFS_I_SB(inode);switch (handler->flags) {
@@ -440,9 +458,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,return -EINVAL ; } -if (!vi->xattr_isize) -return -ENOATTR ; -return erofs_getxattr (inode, handler->flags, name, buffer, size); }
Signature · 1 line
2.14.4
PATCH 3/5 staging: erofs: remove unneeded inode_operations
In reply to Gao XiangCurrently, EROFS uses generic iops when xattr is off, it seems unnecessary and a lot of extra code is there. Let's follow what other filesystems do instead.
--- drivers/staging/erofs/inode.c | 38 ++++++++++++------------------------ drivers/staging/erofs/internal.h | 42 +++++++++++++++++----------------------- drivers/staging/erofs/namei.c | 4 ---- drivers/staging/erofs/xattr.h | 4 ---- 4 files changed, 30 insertions(+), 58 deletions(-)
drivers/staging/erofs/inode.c +12 -26
@@ -184,32 +184,18 @@ static int fill_inode(struct inode *inode, int isdir)if (!err) {/* setup the new inode */ if (S_ISREG (inode->i_mode)) { -#ifdef CONFIG_EROFS_FS_XATTR - inode->i_op = &erofs_generic_xattr_iops; -#endif + inode->i_op = &erofs_generic_iops; inode->i_fop = &generic_ro_fops; }else if (S_ISDIR (inode->i_mode)) { - inode->i_op = -#ifdef CONFIG_EROFS_FS_XATTR - &erofs_dir_xattr_iops; -#else - &erofs_dir_iops; -#endif + inode->i_op = &erofs_dir_iops; inode->i_fop = &erofs_dir_fops; }else if (S_ISLNK (inode->i_mode)) {/* by default, page_get_link is used for symlink */ - inode->i_op = -#ifdef CONFIG_EROFS_FS_XATTR - &erofs_symlink_xattr_iops, -#else - &page_symlink_inode_operations; -#endif + inode->i_op = &erofs_symlink_iops;inode_nohighmem (inode); }else if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode) ||S_ISFIFO (inode->i_mode) ||S_ISSOCK (inode->i_mode)) { -#ifdef CONFIG_EROFS_FS_XATTR - inode->i_op = &erofs_special_inode_operations; -#endif + inode->i_op = &erofs_generic_iops;init_special_inode (inode, inode->i_mode, inode->i_rdev); }else { err = -EIO ;
@@ -297,23 +283,23 @@ struct inode *erofs_iget(struct super_block *sb,return inode; } +const struct inode_operations erofs_generic_iops = { #ifdef CONFIG_EROFS_FS_XATTR -const struct inode_operations erofs_generic_xattr_iops = { .listxattr = erofs_listxattr, +#endif }; -const struct inode_operations erofs_symlink_xattr_iops = { +const struct inode_operations erofs_symlink_iops = { .get_link = page_get_link, +#ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, +#endif }; -const struct inode_operations erofs_special_inode_operations = { - .listxattr = erofs_listxattr, -}; - -const struct inode_operations erofs_fast_symlink_xattr_iops = { +const struct inode_operations erofs_fast_symlink_iops = { .get_link = simple_get_link, +#ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, -}; #endif +};
drivers/staging/erofs/internal.h +18 -24
63 lines not on this page · raw message
drivers/staging/erofs/namei.c +0 -4
@@ -235,10 +235,6 @@ static struct dentry *erofs_lookup(struct inode *dir,const struct inode_operations erofs_dir_iops = { .lookup = erofs_lookup, -}; - -const struct inode_operations erofs_dir_xattr_iops = { - .lookup = erofs_lookup, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif
drivers/staging/erofs/xattr.h +0 -4
@@ -68,10 +68,6 @@ static const struct xattr_handler *xattr_handler_map[] = { }#ifdef CONFIG_EROFS_FS_XATTR - -extern const struct inode_operations erofs_generic_xattr_iops; -extern const struct inode_operations erofs_dir_xattr_iops; -int erofs_getxattr (struct inode *,int ,const char *,void *,size_t );ssize_t erofs_listxattr (struct dentry *,char *,size_t );#else
Signature · 1 line
2.14.4
PATCH 4/5 staging: erofs: move erofs_xattr_handlers to xattr.h
In reply to Gao XiangLet's move independent xattr-related stuffs to xattr.h. No logic changes.
--- drivers/staging/erofs/internal.h | 5 ----- drivers/staging/erofs/super.c | 1 + drivers/staging/erofs/xattr.h | 2 ++ 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/staging/erofs/internal.h +0 -5
@@ -580,11 +580,6 @@ int erofs_namei(struct inode *dir, struct qstr *name,/* dir.c */ extern const struct file_operations erofs_dir_fops; -#ifdef CONFIG_EROFS_FS_XATTR -/* xattr.c */ -extern const struct xattr_handler *erofs_xattr_handlers[]; -#endif -static inline void *erofs_vmap (struct page **pages,unsigned int count) {#ifdef CONFIG_EROFS_FS_USE_VM_MAP_RAM
drivers/staging/erofs/super.c +1 -0
@@ -16,6 +16,7 @@#include <linux/parser.h> #include <linux/seq_file.h> #include "internal.h" +#include "xattr.h" #define CREATE_TRACE_POINTS #include <trace/events/erofs.h>
drivers/staging/erofs/xattr.h +2 -0
@@ -68,6 +68,8 @@ static const struct xattr_handler *xattr_handler_map[] = { }#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
Signature · 1 line
2.14.4
PATCH 5/5 staging: erofs: clean up erofs_map_blocks_iter
In reply to Gao XiangFrom: Chao Yu <[email protected]>
This patch cleans up erofs_map_blocks* function and structure family, just simply the code, no logic change.
--- drivers/staging/erofs/data.c | 31 +++++-------------------------- drivers/staging/erofs/internal.h | 28 +++++++++++++++------------- drivers/staging/erofs/unzip_vle.c | 30 +++++++++++++++--------------- 3 files changed, 35 insertions(+), 54 deletions(-)
drivers/staging/erofs/data.c +5 -26
@@ -165,37 +165,16 @@ static int erofs_map_blocks_flatmode(struct inode *inode,return err; } -int erofs_map_blocks_iter (struct inode *inode, -struct erofs_map_blocks *map, -struct page **mpage_ret,int flags) -{ -/* by default, reading raw data never use erofs_map_blocks_iter */ -if (unlikely (!is_inode_layout_compression (inode))) { -if (*mpage_ret) -put_page (*mpage_ret); - *mpage_ret =NULL ; - -return erofs_map_blocks (inode, map, flags); - } - -#ifdef CONFIG_EROFS_FS_ZIP -return z_erofs_map_blocks_iter (inode, map, mpage_ret, flags); -#else -/* data compression is not available */ -return -ENOTSUPP ; -#endif -} -int erofs_map_blocks (struct inode *inode,struct erofs_map_blocks *map,int flags) {if (unlikely (is_inode_layout_compression (inode))) { -struct page *mpage =NULL ; -int err; +int err =z_erofs_map_blocks_iter (inode, map, flags); - err =erofs_map_blocks_iter (inode, map, &mpage, flags); -if (mpage) -put_page (mpage); +if (map->mpage) { +put_page (map->mpage); + map->mpage =NULL ; + }return err; }return erofs_map_blocks_flatmode (inode, map, flags);
drivers/staging/erofs/internal.h +15 -13
@@ -461,11 +461,26 @@ struct erofs_map_blocks {u64 m_plen, m_llen;unsigned int m_flags; + +struct page *mpage; };/* Flags used by erofs_map_blocks() */ #define EROFS_GET_BLOCKS_RAW 0x0001 +#ifdef CONFIG_EROFS_FS_ZIP +int z_erofs_map_blocks_iter (struct inode *inode, +struct erofs_map_blocks *map, +int flags); +#else +static inline int z_erofs_map_blocks_iter (struct inode *inode, +struct erofs_map_blocks *map, +int flags); +{ +return -ENOTSUPP ; +} +#endif +/* data.c */ static inline struct bio * erofs_grab_bio(struct super_block *sb,
@@ -522,19 +537,6 @@ static inline struct page *erofs_get_meta_page_nofail(struct super_block *sb, }extern int erofs_map_blocks (struct inode *,struct erofs_map_blocks *,int ); -extern int erofs_map_blocks_iter (struct inode *,struct erofs_map_blocks *, -struct page **,int ); - -struct erofs_map_blocks_iter { -struct erofs_map_blocks map; -struct page *mpage; -}; - -#ifdef CONFIG_EROFS_FS_ZIP -extern int z_erofs_map_blocks_iter (struct inode *, -struct erofs_map_blocks *, -struct page **,int ); -#endif static inline struct page * erofs_get_inline_page(struct inode *inode,
drivers/staging/erofs/unzip_vle.c +15 -15
@@ -636,7 +636,7 @@ struct z_erofs_vle_frontend {struct inode *const inode;struct z_erofs_vle_work_builder builder; -struct erofs_map_blocks_iter m_iter; +struct erofs_map_blocks map;z_erofs_vle_owned_workgrp_t owned_head;
@@ -647,8 +647,9 @@ struct z_erofs_vle_frontend {#define VLE_FRONTEND_INIT (__i) { \ .inode = __i, \ - .m_iter = { \ - { .m_llen = 0, .m_plen = 0 }, \ + .map = { \ + .m_llen = 0, \ + .m_plen = 0, \ .mpage = NULL \ }, \ .builder = VLE_WORK_BUILDER_INIT(), \
@@ -681,8 +682,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, {struct super_block *const sb = fe->inode->i_sb;struct erofs_sb_info *const sbi__maybe_unused =EROFS_SB (sb); -struct erofs_map_blocks_iter *const m = &fe->m_iter; -struct erofs_map_blocks *const map = &m->map; +struct erofs_map_blocks *const map = &fe->map;struct z_erofs_vle_work_builder *const builder = &fe->builder;const loff_t offset =page_offset (page);
@@ -715,7 +715,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, map->m_la = offset + cur; map->m_llen =0 ; - err =erofs_map_blocks_iter (fe->inode, map, &m->mpage,0 ); + err =z_erofs_map_blocks_iter (fe->inode, map,0 );if (unlikely (err)) goto err_out;
@@ -1484,8 +1484,8 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file,z_erofs_submit_and_unzip (&f, &pagepool, true); out: -if (f.m_iter.mpage) -put_page (f.m_iter.mpage); +if (f.map.mpage) +put_page (f.map.mpage);/* clean up the remaining free pages */ put_pages_list (&pagepool);
@@ -1555,8 +1555,8 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp,z_erofs_submit_and_unzip (&f, &pagepool, sync); -if (f.m_iter.mpage) -put_page (f.m_iter.mpage); +if (f.map.mpage) +put_page (f.map.mpage);/* clean up the remaining free pages */ put_pages_list (&pagepool);
@@ -1701,14 +1701,14 @@ vle_get_logical_extent_head(const struct vle_map_blocks_iter_ctx *ctx,int z_erofs_map_blocks_iter (struct inode *inode,struct erofs_map_blocks *map, -struct page **mpage_ret,int flags) +int flags) {void *kaddr;const struct vle_map_blocks_iter_ctx ctx = { .inode = inode, .sb = inode->i_sb, .clusterbits =EROFS_I_SB (inode)->clusterbits, - .mpage_ret = mpage_ret, + .mpage_ret = &map->mpage, .kaddr_ret = &kaddr };const unsigned int clustersize =1 << ctx.clusterbits;
@@ -1722,7 +1722,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,/* initialize `pblk' to keep gcc from printing foolish warnings */ erofs_blk_t mblk, pblk =0 ; -struct page *mpage = *mpage_ret; +struct page *mpage = map->mpage;struct z_erofs_vle_decompressed_index *di;unsigned int cluster_type, logical_cluster_ofs;int err =0 ;
@@ -1758,7 +1758,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, err =PTR_ERR (mpage); goto out; } - *mpage_ret = mpage; + map->mpage = mpage; }else {lock_page (mpage);DBG_BUGON (!PageUptodate (mpage));
@@ -1818,7 +1818,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,/* get the correspoinding first chunk */ err =vle_get_logical_extent_head (&ctx, lcn, &ofs, &pblk, &map->m_flags); - mpage = *mpage_ret; + mpage = map->mpage;if (unlikely (err)) {if (mpage)
Signature · 1 line
2.14.4
PATCH v2 5/5 staging: erofs: clean up erofs_map_blocks_iter
This patch cleans up erofs_map_blocks* function and structure family, just simply the code, no logic change.
---
v2:
- remove unneed semicolon in definition of z_erofs_map_blocks_iter
drivers/staging/erofs/data.c | 31 +++++-------------------------- drivers/staging/erofs/internal.h | 28 +++++++++++++++------------- drivers/staging/erofs/unzip_vle.c | 30 +++++++++++++++--------------- 3 files changed, 35 insertions(+), 54 deletions(-)
drivers/staging/erofs/data.c +5 -26
@@ -165,37 +165,16 @@ static int erofs_map_blocks_flatmode(struct inode *inode,return err; } -int erofs_map_blocks_iter (struct inode *inode, -struct erofs_map_blocks *map, -struct page **mpage_ret,int flags) -{ -/* by default, reading raw data never use erofs_map_blocks_iter */ -if (unlikely (!is_inode_layout_compression (inode))) { -if (*mpage_ret) -put_page (*mpage_ret); - *mpage_ret =NULL ; - -return erofs_map_blocks (inode, map, flags); - } - -#ifdef CONFIG_EROFS_FS_ZIP -return z_erofs_map_blocks_iter (inode, map, mpage_ret, flags); -#else -/* data compression is not available */ -return -ENOTSUPP ; -#endif -} -int erofs_map_blocks (struct inode *inode,struct erofs_map_blocks *map,int flags) {if (unlikely (is_inode_layout_compression (inode))) { -struct page *mpage =NULL ; -int err; +int err =z_erofs_map_blocks_iter (inode, map, flags); - err =erofs_map_blocks_iter (inode, map, &mpage, flags); -if (mpage) -put_page (mpage); +if (map->mpage) { +put_page (map->mpage); + map->mpage =NULL ; + }return err; }return erofs_map_blocks_flatmode (inode, map, flags);
drivers/staging/erofs/internal.h +15 -13
@@ -461,11 +461,26 @@ struct erofs_map_blocks {u64 m_plen, m_llen;unsigned int m_flags; + +struct page *mpage; };/* Flags used by erofs_map_blocks() */ #define EROFS_GET_BLOCKS_RAW 0x0001 +#ifdef CONFIG_EROFS_FS_ZIP +int z_erofs_map_blocks_iter (struct inode *inode, +struct erofs_map_blocks *map, +int flags); +#else +static inline int z_erofs_map_blocks_iter (struct inode *inode, +struct erofs_map_blocks *map, +int flags) +{ +return -ENOTSUPP ; +} +#endif +/* data.c */ static inline struct bio * erofs_grab_bio(struct super_block *sb,
@@ -522,19 +537,6 @@ static inline struct page *erofs_get_meta_page_nofail(struct super_block *sb, }extern int erofs_map_blocks (struct inode *,struct erofs_map_blocks *,int ); -extern int erofs_map_blocks_iter (struct inode *,struct erofs_map_blocks *, -struct page **,int ); - -struct erofs_map_blocks_iter { -struct erofs_map_blocks map; -struct page *mpage; -}; - -#ifdef CONFIG_EROFS_FS_ZIP -extern int z_erofs_map_blocks_iter (struct inode *, -struct erofs_map_blocks *, -struct page **,int ); -#endif static inline struct page * erofs_get_inline_page(struct inode *inode,
drivers/staging/erofs/unzip_vle.c +15 -15
@@ -636,7 +636,7 @@ struct z_erofs_vle_frontend {struct inode *const inode;struct z_erofs_vle_work_builder builder; -struct erofs_map_blocks_iter m_iter; +struct erofs_map_blocks map;z_erofs_vle_owned_workgrp_t owned_head;
@@ -647,8 +647,9 @@ struct z_erofs_vle_frontend {#define VLE_FRONTEND_INIT (__i) { \ .inode = __i, \ - .m_iter = { \ - { .m_llen = 0, .m_plen = 0 }, \ + .map = { \ + .m_llen = 0, \ + .m_plen = 0, \ .mpage = NULL \ }, \ .builder = VLE_WORK_BUILDER_INIT(), \
@@ -681,8 +682,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, {struct super_block *const sb = fe->inode->i_sb;struct erofs_sb_info *const sbi__maybe_unused =EROFS_SB (sb); -struct erofs_map_blocks_iter *const m = &fe->m_iter; -struct erofs_map_blocks *const map = &m->map; +struct erofs_map_blocks *const map = &fe->map;struct z_erofs_vle_work_builder *const builder = &fe->builder;const loff_t offset =page_offset (page);
@@ -715,7 +715,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, map->m_la = offset + cur; map->m_llen =0 ; - err =erofs_map_blocks_iter (fe->inode, map, &m->mpage,0 ); + err =z_erofs_map_blocks_iter (fe->inode, map,0 );if (unlikely (err)) goto err_out;
@@ -1484,8 +1484,8 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file,z_erofs_submit_and_unzip (&f, &pagepool, true); out: -if (f.m_iter.mpage) -put_page (f.m_iter.mpage); +if (f.map.mpage) +put_page (f.map.mpage);/* clean up the remaining free pages */ put_pages_list (&pagepool);
@@ -1555,8 +1555,8 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp,z_erofs_submit_and_unzip (&f, &pagepool, sync); -if (f.m_iter.mpage) -put_page (f.m_iter.mpage); +if (f.map.mpage) +put_page (f.map.mpage);/* clean up the remaining free pages */ put_pages_list (&pagepool);
@@ -1701,14 +1701,14 @@ vle_get_logical_extent_head(const struct vle_map_blocks_iter_ctx *ctx,int z_erofs_map_blocks_iter (struct inode *inode,struct erofs_map_blocks *map, -struct page **mpage_ret,int flags) +int flags) {void *kaddr;const struct vle_map_blocks_iter_ctx ctx = { .inode = inode, .sb = inode->i_sb, .clusterbits =EROFS_I_SB (inode)->clusterbits, - .mpage_ret = mpage_ret, + .mpage_ret = &map->mpage, .kaddr_ret = &kaddr };const unsigned int clustersize =1 << ctx.clusterbits;
@@ -1722,7 +1722,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,/* initialize `pblk' to keep gcc from printing foolish warnings */ erofs_blk_t mblk, pblk =0 ; -struct page *mpage = *mpage_ret; +struct page *mpage = map->mpage;struct z_erofs_vle_decompressed_index *di;unsigned int cluster_type, logical_cluster_ofs;int err =0 ;
@@ -1758,7 +1758,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, err =PTR_ERR (mpage); goto out; } - *mpage_ret = mpage; + map->mpage = mpage; }else {lock_page (mpage);DBG_BUGON (!PageUptodate (mpage));
@@ -1818,7 +1818,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,/* get the correspoinding first chunk */ err =vle_get_logical_extent_head (&ctx, lcn, &ofs, &pblk, &map->m_flags); - mpage = *mpage_ret; + mpage = map->mpage;if (unlikely (err)) {if (mpage)
Signature · 1 line
2.18.0.rc1