From 4f0522bae4fdd4a18468626dec478122690b2bf6 Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 14:09:05 +0800 Subject: [PATCH 1/9] testmodify Signed-off-by: fuletian --- fs/hmdfs/inode.c | 26 +++++++++++++ fs/hmdfs/inode.h | 4 ++ fs/hmdfs/inode_cloud_merge.c | 75 +++++++++++++++++++++++++++++++++++- fs/hmdfs/inode_merge.c | 28 ++++++++++++++ 4 files changed, 132 insertions(+), 1 deletion(-) diff --git a/fs/hmdfs/inode.c b/fs/hmdfs/inode.c index 33cc8c7419d5..a26a2187a19c 100644 --- a/fs/hmdfs/inode.c +++ b/fs/hmdfs/inode.c @@ -354,4 +354,30 @@ void hmdfs_update_upper_file(struct file *upper_file, struct file *lower_file) i_size_write(upper_file->f_inode, lower_size); truncate_inode_pages(upper_file->f_inode->i_mapping, 0); } +} + +struct dentry *lookup_multi_dir(struct dentry *root_dentry, + const char *name, + unsigned int flags) +{ + struct dentry *current_dentry = root_dentry; + struct dentry *ret_dentry = NULL; + const char *start = name; + const char *end = NULL; + + while (*start) { + end = strchr(start, '/'); + if (!end) { + end = start + strlen(start); + } + ret_dentry = lookup_one_len(start, current_dentry, end - start); + if (IS_ERR(ret_dentry)) { + dput(current_dentry); + return ret_dentry; + } + dput(current_dentry); + current_dentry = ret_dentry; + start = end; + } + return ret_dentry; } \ No newline at end of file diff --git a/fs/hmdfs/inode.h b/fs/hmdfs/inode.h index fb9bd2929d58..c09dbae8af8a 100644 --- a/fs/hmdfs/inode.h +++ b/fs/hmdfs/inode.h @@ -261,4 +261,8 @@ struct inode *hmdfs_iget5_locked_cloud(struct super_block *sb, void hmdfs_update_upper_file(struct file *upper_file, struct file *lower_file); uint32_t make_ino_raw_cloud(uint8_t *cloud_id); + +struct dentry *lookup_multi_dir(struct dentry *root_dentry, + const char *name, + unsigned int flags) #endif // INODE_H diff --git a/fs/hmdfs/inode_cloud_merge.c b/fs/hmdfs/inode_cloud_merge.c index a6f0b150fcfc..61db38071d7c 100644 --- a/fs/hmdfs/inode_cloud_merge.c +++ b/fs/hmdfs/inode_cloud_merge.c @@ -97,6 +97,9 @@ cloud_merge_lookup_comrade(struct hmdfs_sb_info *sbi, int err; struct path root, path; struct hmdfs_dentry_comrade *comrade = NULL; + struct dentry *tmp_dentry = NULL; + struct dentry *p_dentry = NULL; + struct dentry *dentry = NULL; err = kern_path(sbi->real_dst, LOOKUP_DIRECTORY, &root); if (err) { @@ -109,7 +112,23 @@ cloud_merge_lookup_comrade(struct hmdfs_sb_info *sbi, comrade = ERR_PTR(err); goto root_put; } - + tmp_dentry = path.dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in cloud_merge_lookup_comrade BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + + dentry = lookup_multi_dir(sbi->sb->s_root, name, flags); + if (IS_ERR(dentry)) { + hmdfs_err("flt :: in cloud_merge_lookup_comrade lookup_multi_dir FAILED!"); + } else { + tmp_dentry = dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in cloud_merge_lookup_comrade AFTER dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + dput(dentry); + } comrade = alloc_comrade(path.dentry, devid); path_put(&path); @@ -251,6 +270,9 @@ static int lookup_cloud_merge_root(struct inode *root_inode, int buf_len; char *buf = NULL; bool locked, down; + struct dentry *dentry = NULL; + struct dentry *p_dentry = NULL; + struct dentry *tmp_dentry = NULL; // consider additional one slash and one '\0' buf_len = strlen(sbi->real_dst) + 1 + sizeof(DEVICE_VIEW_ROOT); @@ -268,6 +290,24 @@ static int lookup_cloud_merge_root(struct inode *root_inode, if (ret) goto free_buf; + tmp_dentry = path_dev.dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in lookup_cloud_merge_root BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + + dentry = lookup_multi_dir(sbi->sb->s_root, name, flags); + if (IS_ERR(dentry)) { + hmdfs_err("flt :: in lookup_cloud_merge_root lookup_multi_dir FAILED!"); + } else { + tmp_dentry = dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in lookup_cloud_merge_root AFTER dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + dput(dentry); + } + ret = do_lookup_cloud_merge_root(path_dev, child_dentry, flags); path_put(&path_dev); @@ -458,6 +498,10 @@ int hmdfs_create_lower_cloud_dentry(struct inode *i_parent, struct dentry *d_chi char *path_name = NULL; struct path path = { .mnt = NULL, .dentry = NULL }; int ret = 0; + char *absolute_path_buf_tmp = kmalloc(PATH_MAX, GFP_KERNEL); + struct dentry *dentry = NULL; + struct dentry *p_dentry = NULL; + struct dentry *tmp_dentry = NULL; if (unlikely(!path_buf || !absolute_path_buf)) { ret = -ENOMEM; @@ -478,6 +522,9 @@ int hmdfs_create_lower_cloud_dentry(struct inode *i_parent, struct dentry *d_chi sprintf(absolute_path_buf, "%s%s/%s", sbi->real_dst, path_name, d_child->d_name.name); + sprintf(absolute_path_buf_tmp, "%s/%s", path_name, + d_child->d_name.name); + if (is_dir) lo_d_child = kern_path_create(AT_FDCWD, absolute_path_buf, &path, LOOKUP_DIRECTORY); @@ -488,6 +535,32 @@ int hmdfs_create_lower_cloud_dentry(struct inode *i_parent, struct dentry *d_chi ret = PTR_ERR(lo_d_child); goto out; } + tmp_dentry = lo_d_child; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in hmdfs_create_lower_cloud_dentry BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + + if (is_dir) + dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, LOOKUP_DIRECTORY); + else + dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, 0); + if (IS_ERR(dentry)) { + hmdfs_err("flt :: in hmdfs_create_lower_cloud_dentry lookup_multi_dir FAILED!"); + } else if (d_is_positive(dentry)) { + hmdfs_err("flt :: in hmdfs_create_lower_cloud_dentry EXIST!"); + dput(dentry); + kfree(absolute_path_buf_tmp); + } else { + tmp_dentry = dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in hmdfs_create_lower_cloud_dentry AFTER dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + dput(dentry); + kfree(absolute_path_buf_tmp); + } + // to ensure link_comrade after vfs_mkdir succeed ret = hmdfs_do_ops_cloud_merge(i_parent, d_child, lo_d_child, path, rec_op_para); diff --git a/fs/hmdfs/inode_merge.c b/fs/hmdfs/inode_merge.c index 7c1e1e4f8539..b902cdc4e317 100644 --- a/fs/hmdfs/inode_merge.c +++ b/fs/hmdfs/inode_merge.c @@ -350,6 +350,9 @@ static struct hmdfs_dentry_comrade *merge_lookup_comrade( struct path root, path; struct hmdfs_dentry_comrade *comrade = NULL; const struct cred *old_cred = hmdfs_override_creds(sbi->cred); + struct dentry *tmp_dentry = NULL; + struct dentry *p_dentry = NULL; + struct dentry *dentry = NULL; err = kern_path(sbi->real_dst, LOOKUP_DIRECTORY, &root); if (err) { @@ -362,6 +365,23 @@ static struct hmdfs_dentry_comrade *merge_lookup_comrade( comrade = ERR_PTR(err); goto root_put; } + tmp_dentry = path.dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in merge_lookup_comrade BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + + dentry = lookup_multi_dir(sbi->sb->s_root, name, flags); + if (IS_ERR(dentry)) { + hmdfs_err("flt :: in merge_lookup_comrade lookup_multi_dir FAILED!"); + } else { + tmp_dentry = dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in merge_lookup_comrade AFTER dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + dput(dentry); + } comrade = alloc_comrade(path.dentry, devid); @@ -663,6 +683,14 @@ static int lookup_merge_root(struct inode *root_inode, if (ret) goto free_buf; + // tmp_dentry = path_dev.dentry; + // p_dentry = tmp_dentry->d_parent; + // hmdfs_err("flt :: in lookup_cloud_merge_root BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + // tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + // p_dentry, p_dentry->d_name.name); + + + ret = do_lookup_merge_root(path_dev, child_dentry, flags); path_put(&path_dev); -- Gitee From bcb4253478ec5e76ea6aa72397949cebec093329 Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 14:13:12 +0800 Subject: [PATCH 2/9] testmodify Signed-off-by: fuletian --- fs/hmdfs/inode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hmdfs/inode.h b/fs/hmdfs/inode.h index c09dbae8af8a..43c6ba027285 100644 --- a/fs/hmdfs/inode.h +++ b/fs/hmdfs/inode.h @@ -264,5 +264,5 @@ uint32_t make_ino_raw_cloud(uint8_t *cloud_id); struct dentry *lookup_multi_dir(struct dentry *root_dentry, const char *name, - unsigned int flags) + unsigned int flags); #endif // INODE_H -- Gitee From 16533bef3eda73d28fc32e5515f6fa77eb29733b Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 14:31:36 +0800 Subject: [PATCH 3/9] testmodify Signed-off-by: fuletian --- fs/hmdfs/inode.c | 3 +++ fs/hmdfs/inode_cloud_merge.c | 6 +++--- fs/hmdfs/inode_merge.c | 24 +++++++++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/fs/hmdfs/inode.c b/fs/hmdfs/inode.c index a26a2187a19c..ffa3abbca931 100644 --- a/fs/hmdfs/inode.c +++ b/fs/hmdfs/inode.c @@ -364,6 +364,9 @@ struct dentry *lookup_multi_dir(struct dentry *root_dentry, struct dentry *ret_dentry = NULL; const char *start = name; const char *end = NULL; + if (*start) { + dget(root_dentry); + } while (*start) { end = strchr(start, '/'); diff --git a/fs/hmdfs/inode_cloud_merge.c b/fs/hmdfs/inode_cloud_merge.c index 61db38071d7c..1472b21f2873 100644 --- a/fs/hmdfs/inode_cloud_merge.c +++ b/fs/hmdfs/inode_cloud_merge.c @@ -119,7 +119,7 @@ cloud_merge_lookup_comrade(struct hmdfs_sb_info *sbi, p_dentry, p_dentry->d_name.name); dentry = lookup_multi_dir(sbi->sb->s_root, name, flags); - if (IS_ERR(dentry)) { + if (dentry == NULL || IS_ERR(dentry)) { hmdfs_err("flt :: in cloud_merge_lookup_comrade lookup_multi_dir FAILED!"); } else { tmp_dentry = dentry; @@ -297,7 +297,7 @@ static int lookup_cloud_merge_root(struct inode *root_inode, p_dentry, p_dentry->d_name.name); dentry = lookup_multi_dir(sbi->sb->s_root, name, flags); - if (IS_ERR(dentry)) { + if (dentry == NULL || IS_ERR(dentry)) { hmdfs_err("flt :: in lookup_cloud_merge_root lookup_multi_dir FAILED!"); } else { tmp_dentry = dentry; @@ -545,7 +545,7 @@ int hmdfs_create_lower_cloud_dentry(struct inode *i_parent, struct dentry *d_chi dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, LOOKUP_DIRECTORY); else dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, 0); - if (IS_ERR(dentry)) { + if (dentry == NULL || IS_ERR(dentry)) { hmdfs_err("flt :: in hmdfs_create_lower_cloud_dentry lookup_multi_dir FAILED!"); } else if (d_is_positive(dentry)) { hmdfs_err("flt :: in hmdfs_create_lower_cloud_dentry EXIST!"); diff --git a/fs/hmdfs/inode_merge.c b/fs/hmdfs/inode_merge.c index b902cdc4e317..39c4ff8225b9 100644 --- a/fs/hmdfs/inode_merge.c +++ b/fs/hmdfs/inode_merge.c @@ -372,7 +372,7 @@ static struct hmdfs_dentry_comrade *merge_lookup_comrade( p_dentry, p_dentry->d_name.name); dentry = lookup_multi_dir(sbi->sb->s_root, name, flags); - if (IS_ERR(dentry)) { + if (dentry == NULL || IS_ERR(dentry)) { hmdfs_err("flt :: in merge_lookup_comrade lookup_multi_dir FAILED!"); } else { tmp_dentry = dentry; @@ -683,13 +683,23 @@ static int lookup_merge_root(struct inode *root_inode, if (ret) goto free_buf; - // tmp_dentry = path_dev.dentry; - // p_dentry = tmp_dentry->d_parent; - // hmdfs_err("flt :: in lookup_cloud_merge_root BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", - // tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, - // p_dentry, p_dentry->d_name.name); - + tmp_dentry = path_dev.dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in lookup_merge_root BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + dentry = lookup_multi_dir(sbi->sb->s_root, DEVICE_VIEW_ROOT, flags); + if (dentry == NULL || IS_ERR(dentry)) { + hmdfs_err("flt :: in lookup_merge_root lookup_multi_dir FAILED!"); + } else { + tmp_dentry = dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in lookup_merge_root AFTER dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + dput(dentry); + } ret = do_lookup_merge_root(path_dev, child_dentry, flags); path_put(&path_dev); -- Gitee From f118507aa123ded67fecdaeab3656a84bef5d134 Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 15:18:37 +0800 Subject: [PATCH 4/9] updata Signed-off-by: fuletian --- fs/hmdfs/inode_cloud_merge.c | 4 +- fs/hmdfs/inode_merge.c | 83 ++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 3 deletions(-) diff --git a/fs/hmdfs/inode_cloud_merge.c b/fs/hmdfs/inode_cloud_merge.c index 1472b21f2873..7538413bd8a9 100644 --- a/fs/hmdfs/inode_cloud_merge.c +++ b/fs/hmdfs/inode_cloud_merge.c @@ -550,7 +550,6 @@ int hmdfs_create_lower_cloud_dentry(struct inode *i_parent, struct dentry *d_chi } else if (d_is_positive(dentry)) { hmdfs_err("flt :: in hmdfs_create_lower_cloud_dentry EXIST!"); dput(dentry); - kfree(absolute_path_buf_tmp); } else { tmp_dentry = dentry; p_dentry = tmp_dentry->d_parent; @@ -558,9 +557,8 @@ int hmdfs_create_lower_cloud_dentry(struct inode *i_parent, struct dentry *d_chi tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, p_dentry, p_dentry->d_name.name); dput(dentry); - kfree(absolute_path_buf_tmp); } - + kfree(absolute_path_buf_tmp); // to ensure link_comrade after vfs_mkdir succeed ret = hmdfs_do_ops_cloud_merge(i_parent, d_child, lo_d_child, path, rec_op_para); diff --git a/fs/hmdfs/inode_merge.c b/fs/hmdfs/inode_merge.c index 39c4ff8225b9..e2708b4979a4 100644 --- a/fs/hmdfs/inode_merge.c +++ b/fs/hmdfs/inode_merge.c @@ -666,6 +666,9 @@ static int lookup_merge_root(struct inode *root_inode, int buf_len; char *buf = NULL; bool locked, down; + struct dentry *tmp_dentry = NULL; + struct dentry *p_dentry = NULL; + struct dentry *dentry = NULL; // consider additional one slash and one '\0' buf_len = strlen(sbi->real_dst) + 1 + sizeof(DEVICE_VIEW_ROOT); @@ -975,6 +978,10 @@ int hmdfs_create_lower_dentry(struct inode *i_parent, struct dentry *d_child, char *path_name = NULL; struct path path = { .mnt = NULL, .dentry = NULL }; int ret = 0; + struct dentry *tmp_dentry = NULL; + struct dentry *p_dentry = NULL; + struct dentry *dentry = NULL; + char *absolute_path_buf_tmp = kmalloc(PATH_MAX, GFP_KERNEL); if (unlikely(!path_buf || !absolute_path_buf)) { ret = -ENOMEM; @@ -994,6 +1001,8 @@ int hmdfs_create_lower_dentry(struct inode *i_parent, struct dentry *d_child, sprintf(absolute_path_buf, "%s%s/%s", sbi->real_dst, path_name, d_child->d_name.name); + sprintf(absolute_path_buf_tmp, "%s/%s", path_name, + d_child->d_name.name); if (is_dir) lo_d_child = kern_path_create(AT_FDCWD, absolute_path_buf, @@ -1005,7 +1014,42 @@ int hmdfs_create_lower_dentry(struct inode *i_parent, struct dentry *d_child, ret = PTR_ERR(lo_d_child); goto out; } + tmp_dentry = lo_d_child; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in hmdfs_create_lower_dentry BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + + if (is_dir) + dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, LOOKUP_DIRECTORY); + else + dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, 0); + if (dentry == NULL || IS_ERR(dentry)) { + hmdfs_err("flt :: in hmdfs_create_lower_dentry lookup_multi_dir FAILED!"); + } else if (d_is_positive(dentry)) { + hmdfs_err("flt :: in hmdfs_create_lower_dentry EXIST!"); + dput(dentry); + } else { + tmp_dentry = dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in hmdfs_create_lower_dentry AFTER dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + dput(dentry); + } + kfree(absolute_path_buf_tmp); // to ensure link_comrade after vfs_mkdir succeed + tmp_dentry = path.dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in hmdfs_create_lower_dentry goto next 11111 dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + tmp_dentry = lo_d_parent; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in hmdfs_create_lower_dentry goto next 11111 dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + ret = hmdfs_do_ops_merge(i_parent, d_child, lo_d_child, path, rec_op_para); if (ret) @@ -1290,6 +1334,10 @@ int do_rename_merge(struct inode *old_dir, struct dentry *old_dentry, char *path_name = NULL; struct hmdfs_dentry_info_merge *pmdi = NULL; struct renamedata rename_data; + struct dentry *tmp_dentry = NULL; + struct dentry *p_dentry = NULL; + struct dentry *dentry = NULL; + char *absolute_path_buf_tmp = kmalloc(PATH_MAX, GFP_KERNEL); if (flags & ~RENAME_NOREPLACE) { ret = -EINVAL; @@ -1328,6 +1376,8 @@ int do_rename_merge(struct inode *old_dir, struct dentry *old_dentry, snprintf(abs_path_buf, PATH_MAX, "%s%s/%s", sbi->real_dst, path_name, new_dentry->d_name.name); + sprintf(absolute_path_buf_tmp, "%s/%s", path_name, + new_dentry->d_name.name); if (S_ISDIR(d_inode(old_dentry)->i_mode)) lo_d_new = kern_path_create(AT_FDCWD, abs_path_buf, &lo_p_new, @@ -1339,6 +1389,29 @@ int do_rename_merge(struct inode *old_dir, struct dentry *old_dentry, ret = PTR_ERR(lo_d_new); goto out; } + tmp_dentry = lo_d_new; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in do_rename_merge BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + if (is_dir) + dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, LOOKUP_DIRECTORY); + else + dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, 0); + if (dentry == NULL || IS_ERR(dentry)) { + hmdfs_err("flt :: in do_rename_merge lookup_multi_dir FAILED!"); + } else if (d_is_positive(dentry)) { + hmdfs_err("flt :: in do_rename_merge EXIST!"); + dput(dentry); + } else { + tmp_dentry = dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in do_rename_merge AFTER dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + dput(dentry); + } + kfree(absolute_path_buf_tmp); lo_d_new_dir = dget_parent(lo_d_new); lo_i_new_dir = d_inode(lo_d_new_dir); @@ -1354,6 +1427,16 @@ int do_rename_merge(struct inode *old_dir, struct dentry *old_dentry, rename_data.flags = flags; ret = vfs_rename(&rename_data); + tmp_dentry = lo_p_new.dentry; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in rename goto alloc 111111 dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); + tmp_dentry = lo_d_new_dir; + p_dentry = tmp_dentry->d_parent; + hmdfs_err("flt :: in rename goto alloc 222222 dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", + tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, + p_dentry, p_dentry->d_name.name); new_comrade = alloc_comrade(lo_p_new.dentry, comrade->dev_id); if (IS_ERR(new_comrade)) { ret = PTR_ERR(new_comrade); -- Gitee From f5fbe876148b2f2e8a76ab34fcfba65a6a0e1717 Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 16:05:47 +0800 Subject: [PATCH 5/9] 1605 Signed-off-by: fuletian --- fs/hmdfs/inode.c | 1 + fs/hmdfs/inode_cloud_merge.c | 2 +- fs/hmdfs/inode_merge.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/hmdfs/inode.c b/fs/hmdfs/inode.c index ffa3abbca931..6536440177c4 100644 --- a/fs/hmdfs/inode.c +++ b/fs/hmdfs/inode.c @@ -369,6 +369,7 @@ struct dentry *lookup_multi_dir(struct dentry *root_dentry, } while (*start) { + hmdfs_err("flt :: lookup_multi_dir work == %s\n", start); end = strchr(start, '/'); if (!end) { end = start + strlen(start); diff --git a/fs/hmdfs/inode_cloud_merge.c b/fs/hmdfs/inode_cloud_merge.c index 7538413bd8a9..e509bcd2a3d2 100644 --- a/fs/hmdfs/inode_cloud_merge.c +++ b/fs/hmdfs/inode_cloud_merge.c @@ -296,7 +296,7 @@ static int lookup_cloud_merge_root(struct inode *root_inode, tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, p_dentry, p_dentry->d_name.name); - dentry = lookup_multi_dir(sbi->sb->s_root, name, flags); + dentry = lookup_multi_dir(sbi->sb->s_root, DEVICE_VIEW_ROOT, flags); if (dentry == NULL || IS_ERR(dentry)) { hmdfs_err("flt :: in lookup_cloud_merge_root lookup_multi_dir FAILED!"); } else { diff --git a/fs/hmdfs/inode_merge.c b/fs/hmdfs/inode_merge.c index e2708b4979a4..2782245b2834 100644 --- a/fs/hmdfs/inode_merge.c +++ b/fs/hmdfs/inode_merge.c @@ -354,6 +354,8 @@ static struct hmdfs_dentry_comrade *merge_lookup_comrade( struct dentry *p_dentry = NULL; struct dentry *dentry = NULL; + hmdfs_err("flt :: init merge_lookup_comrade, name = %s\n", name); + err = kern_path(sbi->real_dst, LOOKUP_DIRECTORY, &root); if (err) { comrade = ERR_PTR(err); -- Gitee From 104b763471ff896c91f091db598af65f0de4a020 Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 16:54:34 +0800 Subject: [PATCH 6/9] updata Signed-off-by: fuletian --- fs/hmdfs/inode_merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hmdfs/inode_merge.c b/fs/hmdfs/inode_merge.c index 2782245b2834..022005043c71 100644 --- a/fs/hmdfs/inode_merge.c +++ b/fs/hmdfs/inode_merge.c @@ -1396,7 +1396,7 @@ int do_rename_merge(struct inode *old_dir, struct dentry *old_dentry, hmdfs_err("flt :: in do_rename_merge BEFORE dentry_name = %s, node = %lu, d_parent = %x, parent_name = %s", tmp_dentry->d_name.name, tmp_dentry->d_inode->i_ino, p_dentry, p_dentry->d_name.name); - if (is_dir) + if (S_ISDIR(d_inode(old_dentry)->i_mode)) dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, LOOKUP_DIRECTORY); else dentry = lookup_multi_dir(sbi->sb->s_root, absolute_path_buf_tmp, 0); -- Gitee From 549bda8aec557283e181a6739a0c448f3d925af5 Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 17:00:35 +0800 Subject: [PATCH 7/9] updata Signed-off-by: fuletian --- fs/hmdfs/inode.c | 3 ++- fs/hmdfs/inode_merge.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/hmdfs/inode.c b/fs/hmdfs/inode.c index 6536440177c4..76940a7e2131 100644 --- a/fs/hmdfs/inode.c +++ b/fs/hmdfs/inode.c @@ -369,13 +369,14 @@ struct dentry *lookup_multi_dir(struct dentry *root_dentry, } while (*start) { - hmdfs_err("flt :: lookup_multi_dir work == %s\n", start); end = strchr(start, '/'); if (!end) { end = start + strlen(start); } + hmdfs_err("flt :: goto lookup_one_len name = %s, len = %d\n", start, end - start); ret_dentry = lookup_one_len(start, current_dentry, end - start); if (IS_ERR(ret_dentry)) { + hmdfs_err("flt :: lookup_one_len failed!"); dput(current_dentry); return ret_dentry; } diff --git a/fs/hmdfs/inode_merge.c b/fs/hmdfs/inode_merge.c index 022005043c71..fccc90b0d5e7 100644 --- a/fs/hmdfs/inode_merge.c +++ b/fs/hmdfs/inode_merge.c @@ -376,6 +376,11 @@ static struct hmdfs_dentry_comrade *merge_lookup_comrade( dentry = lookup_multi_dir(sbi->sb->s_root, name, flags); if (dentry == NULL || IS_ERR(dentry)) { hmdfs_err("flt :: in merge_lookup_comrade lookup_multi_dir FAILED!"); + if (dentry == NULL) { + hmdfs_err("flt :: dentry == NULL"); + } else { + hmdfs_err("flt :: IS_ERR(dentry)"); + } } else { tmp_dentry = dentry; p_dentry = tmp_dentry->d_parent; -- Gitee From 3ff22e6cd983de32e9460fe5d32dd853c3630066 Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 17:48:54 +0800 Subject: [PATCH 8/9] updata Signed-off-by: fuletian --- fs/hmdfs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/hmdfs/inode.c b/fs/hmdfs/inode.c index 76940a7e2131..9acf1426f7c8 100644 --- a/fs/hmdfs/inode.c +++ b/fs/hmdfs/inode.c @@ -382,7 +382,11 @@ struct dentry *lookup_multi_dir(struct dentry *root_dentry, } dput(current_dentry); current_dentry = ret_dentry; - start = end; + if (*end == '/') { + start = end + 1; + } else { + start = end; + } } return ret_dentry; } \ No newline at end of file -- Gitee From 4c6e30f13d6879b59ebaad0ea97352ab0548f715 Mon Sep 17 00:00:00 2001 From: fuletian Date: Fri, 11 Jul 2025 18:02:28 +0800 Subject: [PATCH 9/9] updata Signed-off-by: fuletian --- fs/hmdfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hmdfs/inode.c b/fs/hmdfs/inode.c index 9acf1426f7c8..c11fba903f25 100644 --- a/fs/hmdfs/inode.c +++ b/fs/hmdfs/inode.c @@ -385,7 +385,7 @@ struct dentry *lookup_multi_dir(struct dentry *root_dentry, if (*end == '/') { start = end + 1; } else { - start = end; + break; } } return ret_dentry; -- Gitee