aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGao Xiang <hsiangkao@linux.alibaba.com>2023-09-15 16:26:19 +0800
committerGao Xiang <hsiangkao@linux.alibaba.com>2023-09-20 19:34:47 +0800
commitb097208781ecda1e382c8e0f47c5c07413c51676 (patch)
tree4b4e9d490909a871fbce927b7017ddded766f9be
parent376fb2dbe66da82687c287b06ea04553d026644a (diff)
downloaderofs-utils-b097208781ecda1e382c8e0f47c5c07413c51676.tar.gz
erofs-utils: mkfs: pop up most recently used dentries for tarerofs
Each tar header keeps the full file path. It's useful to move most recently used intermediate dirs to list heads. User time of tarerofs index mode can be reduced by 19%. Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20230915082619.3533530-1-hsiangkao@linux.alibaba.com
-rw-r--r--include/erofs/rebuild.h2
-rw-r--r--lib/rebuild.c9
-rw-r--r--lib/tar.c5
3 files changed, 11 insertions, 5 deletions
diff --git a/include/erofs/rebuild.h b/include/erofs/rebuild.h
index 3ac074c..e99ce74 100644
--- a/include/erofs/rebuild.h
+++ b/include/erofs/rebuild.h
@@ -10,7 +10,7 @@ extern "C"
#include "internal.h"
struct erofs_dentry *erofs_rebuild_get_dentry(struct erofs_inode *pwd,
- char *path, bool aufs, bool *whout, bool *opq);
+ char *path, bool aufs, bool *whout, bool *opq, bool to_head);
int erofs_rebuild_load_tree(struct erofs_inode *root, struct erofs_sb_info *sbi);
diff --git a/lib/rebuild.c b/lib/rebuild.c
index 27a1df4..9751f0e 100644
--- a/lib/rebuild.c
+++ b/lib/rebuild.c
@@ -52,7 +52,7 @@ static struct erofs_dentry *erofs_rebuild_mkdir(struct erofs_inode *dir,
}
struct erofs_dentry *erofs_rebuild_get_dentry(struct erofs_inode *pwd,
- char *path, bool aufs, bool *whout, bool *opq)
+ char *path, bool aufs, bool *whout, bool *opq, bool to_head)
{
struct erofs_dentry *d = NULL;
unsigned int len = strlen(path);
@@ -100,6 +100,10 @@ struct erofs_dentry *erofs_rebuild_get_dentry(struct erofs_inode *pwd,
}
if (inode) {
+ if (to_head) {
+ list_del(&d->d_child);
+ list_add(&d->d_child, &pwd->i_subdirs);
+ }
pwd = inode;
} else if (!slash) {
d = erofs_d_alloc(pwd, s);
@@ -262,7 +266,8 @@ static int erofs_rebuild_dirent_iter(struct erofs_dir_context *ctx)
erofs_dbg("parsing %s", path);
dname = path + strlen(parent->i_srcpath) + 1;
- d = erofs_rebuild_get_dentry(parent, dname, false, &dumb, &dumb);
+ d = erofs_rebuild_get_dentry(parent, dname, false,
+ &dumb, &dumb, false);
if (IS_ERR(d)) {
ret = PTR_ERR(d);
goto out;
diff --git a/lib/tar.c b/lib/tar.c
index 08a140d..f6320b0 100644
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -671,7 +671,7 @@ restart:
erofs_dbg("parsing %s (mode %05o)", eh.path, st.st_mode);
- d = erofs_rebuild_get_dentry(root, eh.path, tar->aufs, &whout, &opq);
+ d = erofs_rebuild_get_dentry(root, eh.path, tar->aufs, &whout, &opq, true);
if (IS_ERR(d)) {
ret = PTR_ERR(d);
goto out;
@@ -704,7 +704,8 @@ restart:
}
d->inode = NULL;
- d2 = erofs_rebuild_get_dentry(root, eh.link, tar->aufs, &dumb, &dumb);
+ d2 = erofs_rebuild_get_dentry(root, eh.link, tar->aufs,
+ &dumb, &dumb, false);
if (IS_ERR(d2)) {
ret = PTR_ERR(d2);
goto out;