erofs: convert workstn to XArray
PATCH v3 1/1 erofs: convert workstn to XArray
XArray has friendly APIs and it will replace the old radix tree in the near future.
This convert makes use of __xa_cmpxchg when inserting on a just inserted item by other thread. In detail, instead of totally looking up again as what we did for the old radix tree, it will try to legitimize the current in-tree item in the XArray therefore more effective.
In addition, naming is rather a challenge for non-English speaker like me. The basic idea of workstn is to provide a runtime sparse array with items arranged in the physical block number order. Such items (was called workgroup) can be used to record compress clusters or for later new features.
However, both workgroup and workstn seem not good names from whatever point of view, so I'd like to rename them as pslot and managed_pslots to stand for physical slots. This patch handles the second as a part of the radix tree convert.
---
Changes since v2:
- add path to bail out all potential __xa_cmpxchg() errors pointed out by Chao.
fs/erofs/internal.h | 8 ++--- fs/erofs/super.c | 2 +- fs/erofs/utils.c | 88 +++++++++++++++++---------------------------- fs/erofs/zdata.c | 76 ++++++++++++++++++++------------------- 4 files changed, 76 insertions(+), 98 deletions(-)
fs/erofs/internal.h +4 -4
@@ -52,8 +52,8 @@ struct erofs_sb_info {struct list_head list;struct mutex umount_mutex; -/* the dedicated workstation for compression */ -struct radix_tree_root workstn_tree; +/* managed XArray arranged in physical block number */ +struct xarray managed_pslots;/* threshold for decompression synchronously */ unsigned int max_sync_decompress_pages;
@@ -402,8 +402,8 @@ static inline void *erofs_get_pcpubuf(unsigned int pagenr)int erofs_workgroup_put (struct erofs_workgroup *grp);struct erofs_workgroup *erofs_find_workgroup (struct super_block *sb,pgoff_t index); -int erofs_register_workgroup (struct super_block *sb, -struct erofs_workgroup *grp); +struct erofs_workgroup *erofs_insert_workgroup (struct super_block *sb, +struct erofs_workgroup *grp);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);
fs/erofs/super.c +1 -1
@@ -425,7 +425,7 @@ static int erofs_fill_super(struct super_block *sb, void *data, int silent) sb->s_flags &= ~SB_POSIXACL ;#ifdef CONFIG_EROFS_FS_ZIP -INIT_RADIX_TREE (&sbi->workstn_tree,GFP_ATOMIC ); +xa_init (&sbi->managed_pslots);#endif /* get the root inode */
fs/erofs/utils.c +32 -56
137 lines not on this page · raw message
fs/erofs/zdata.c +39 -37
160 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 15 lines · Gao Xiang
XArray has friendly APIs and it will replace the old radix tree in the near future.
This convert makes use of
__xa_cmpxchgwhen inserting on a just inserted item by other thread. In detail, instead of totally looking up again as what we did for the old radix tree, it will try to legitimize the current in-tree item in the XArray therefore more effective.In addition, naming is rather a challenge for non-English speaker like me. The basic idea of workstn is to provide a runtime sparse array with items arranged in the physical block number order. Such items (was called workgroup) can be used to record compress clusters or for later new features.
Quoted 8 lines
However, both workgroup and workstn seem not good names from whatever point of view, so I'd like to rename them as pslot and
managed_pslotsto stand for physical slots. This patch handles the second as a part of the radix tree convert.Cc Chao Yu <[email protected]>Cc Matthew Wilcox <[email protected]>Signed-off-by Gao Xiang <[email protected]>
Looks good to me.
Thanks,