erofs: remove tags of pointers stored in a radix tree
Subsystems (2)
cover erofs: remove tags of pointers stored in a radix tree
The changeset simplifies a couple of internal interfaces and removes excessive tagging and untagging of workgroup pointers stored in a radix tree.
All the changes in the series are non-functional.
Vladimir Zapolskiy (3):
erofs: remove unused tag argument while finding a workgroup
erofs: remove unused tag argument while registering a workgroup
erofs: remove void tagging/untagging of workgroup pointers
fs/erofs/internal.h | 4 ++-- fs/erofs/utils.c | 15 ++++----------- fs/erofs/zdata.c | 5 ++--- 3 files changed, 8 insertions(+), 16 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/3 erofs: remove unused tag argument while finding a workgroup
It is feasible to simplify erofs_find_workgroup() interface by removing an unused function argument. While formally the argument is used in the function itself, its assigned value is ignored on the caller side.
--- fs/erofs/internal.h | 2 +- fs/erofs/utils.c | 3 +-- fs/erofs/zdata.c | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-)
fs/erofs/internal.h +1 -1
@@ -401,7 +401,7 @@ static inline void *erofs_get_pcpubuf(unsigned int pagenr)#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); +pgoff_t index);int erofs_register_workgroup (struct super_block *sb,struct erofs_workgroup *grp,bool tag);void erofs_workgroup_free_rcu (struct erofs_workgroup *grp);
fs/erofs/utils.c +1 -2
@@ -59,7 +59,7 @@ static int erofs_workgroup_get(struct erofs_workgroup *grp) }struct erofs_workgroup *erofs_find_workgroup (struct super_block *sb, -pgoff_t index,bool *tag) +pgoff_t index) {struct erofs_sb_info *sbi =EROFS_SB (sb);struct erofs_workgroup *grp;
@@ -68,7 +68,6 @@ struct erofs_workgroup *erofs_find_workgroup(struct super_block *sb,rcu_read_lock (); grp =radix_tree_lookup (&sbi->workstn_tree, index);if (grp) { - *tag =xa_pointer_tag (grp); grp =xa_untag_pointer (grp);if (erofs_workgroup_get (grp)) {
fs/erofs/zdata.c +1 -2
@@ -345,9 +345,8 @@ static int z_erofs_lookup_collection(struct z_erofs_collector *clt,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); + grp =erofs_find_workgroup (inode->i_sb, map->m_pa >>PAGE_SHIFT );if (!grp)return -ENOENT ;
Signature · 1 line
2.20.1
PATCH 2/3 erofs: remove unused tag argument while registering a workgroup
In reply to Vladimir ZapolskiyAll workgroups are registered with tag value set to 0, to simplify erofs_register_workgroup() interface the tag argument can be removed, if its only value is sent down to the function body.
--- fs/erofs/internal.h | 2 +- fs/erofs/utils.c | 5 ++--- fs/erofs/zdata.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
fs/erofs/internal.h +1 -1
@@ -403,7 +403,7 @@ 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,bool tag); +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/utils.c +2 -3
@@ -83,8 +83,7 @@ struct erofs_workgroup *erofs_find_workgroup(struct super_block *sb, }int erofs_register_workgroup (struct super_block *sb, -struct erofs_workgroup *grp, -bool tag) +struct erofs_workgroup *grp) {struct erofs_sb_info *sbi;int err;
@@ -102,7 +101,7 @@ int erofs_register_workgroup(struct super_block *sb, sbi =EROFS_SB (sb);xa_lock (&sbi->workstn_tree); - grp =xa_tag_pointer (grp, tag); + grp =xa_tag_pointer (grp,0 );/* * Bump up reference count before making this workgroup
fs/erofs/zdata.c +1 -1
@@ -437,7 +437,7 @@ static int z_erofs_register_collection(struct z_erofs_collector *clt,*/ mutex_trylock (&cl->lock); - err =erofs_register_workgroup (inode->i_sb, &pcl->obj,0 ); + err =erofs_register_workgroup (inode->i_sb, &pcl->obj);if (err) {mutex_unlock (&cl->lock);kmem_cache_free (pcluster_cachep, pcl);
Signature · 1 line
2.20.1
PATCH 3/3 erofs: remove void tagging/untagging of workgroup pointers
In reply to Vladimir ZapolskiyBecause workgroup pointers inserted to a radix tree are always tagged with a single value of 0, it is possible to remove tagging and untagging of the pointers completely.
--- fs/erofs/utils.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/erofs/utils.c +2 -7
@@ -68,8 +68,6 @@ struct erofs_workgroup *erofs_find_workgroup(struct super_block *sb,rcu_read_lock (); grp =radix_tree_lookup (&sbi->workstn_tree, index);if (grp) { - grp =xa_untag_pointer (grp); -if (erofs_workgroup_get (grp)) {/* prefer to relax rcu read side */ rcu_read_unlock ();
@@ -101,8 +99,6 @@ int erofs_register_workgroup(struct super_block *sb, sbi =EROFS_SB (sb);xa_lock (&sbi->workstn_tree); - grp =xa_tag_pointer (grp,0 ); -/* * Bump up reference count before making this workgroup * visible to other users in order to avoid potential UAF
@@ -173,8 +169,7 @@ static bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi,* however in order to avoid some race conditions, add a * DBG_BUGON to observe this in advance. */ -DBG_BUGON (xa_untag_pointer (radix_tree_delete (&sbi->workstn_tree, - grp->index)) != grp); +DBG_BUGON (radix_tree_delete (&sbi->workstn_tree, grp->index) != grp);/* * If managed cache is on, last refcount should indicate
@@ -199,7 +194,7 @@ static unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi, batch, first_index, PAGEVEC_SIZE);for (i =0 ; i < found; ++i) { -struct erofs_workgroup *grp =xa_untag_pointer (batch[i]); +struct erofs_workgroup *grp = batch[i]; first_index = grp->index +1 ;
Signature · 1 line
2.20.1
Hi Vladimir,
Quoted 5 lines · Vladimir Zapolskiy
The changeset simplifies a couple of internal interfaces and removes excessive tagging and untagging of workgroup pointers stored in a radix tree.
All the changes in the series are non-functional.
This radix tree tag was planned to be reserved for other use in order to differ it from the current fixed-sized output compression management structure. I agree that it can be simplified for now, so I will test this series and apply. However, I think such XArray tagged pointer usage is useful.
p.s. I'm converting this radix tree to XArray and cleaning up related functions for the next cycle as well.
Thanks,
Gao Xiang
Quoted 14 lines
Vladimir Zapolskiy (3):
erofs: remove unused tag argument while finding a workgroup
erofs: remove unused tag argument while registering a workgroup
erofs: remove void tagging/untagging of workgroup pointersfs/erofs/internal.h | 4 ++-- fs/erofs/utils.c | 15 ++++----------- fs/erofs/zdata.c | 5 ++--- 3 files changed, 8 insertions(+), 16 deletions(-)Signature · 1 line
2.20.1
Quoted 11 lines · Vladimir Zapolskiy
The changeset simplifies a couple of internal interfaces and removes excessive tagging and untagging of workgroup pointers stored in a radix tree.
All the changes in the series are non-functional.
Vladimir Zapolskiy (3):
erofs: remove unused tag argument while finding a workgroup
erofs: remove unused tag argument while registering a workgroup
erofs: remove void tagging/untagging of workgroup pointers
Quoted 5 lines
fs/erofs/internal.h | 4 ++-- fs/erofs/utils.c | 15 ++++----------- fs/erofs/zdata.c | 5 ++--- 3 files changed, 8 insertions(+), 16 deletions(-)
Thanks,