Skip to contentSkip to conversation

erofs: convert workstn to XArray

RFC PATCH Superseded Gao Xiang 1 participant 1 message Jan 21, 2020 EROFS file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

RFC PATCH 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 root convert.

Cc Chao Yu <[email protected]>
Cc Matthew Wilcox <[email protected]>

---

(This patch is still under testing...)

 fs/erofs/internal.h |  8 ++---
 fs/erofs/super.c    |  2 +-
 fs/erofs/utils.c    | 85 ++++++++++++++++-----------------------------
 fs/erofs/zdata.c    | 65 ++++++++++++++++------------------
 4 files changed, 64 insertions(+), 96 deletions(-)
fs/erofs/internal.h +4 -4
index c4c6dcdc89ad..b70f52c80852 100644
@@ -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 array 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
index 057e6d7b5b7f..b514c67e5fc2 100644
@@ -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 +30 -55

135 lines not on this page · raw message

fs/erofs/zdata.c +29 -36

146 lines not on this page · raw message

Signature · 1 line
2.17.1