From 1f0e9d8ebcb6cd257c3b7a7f7d9a1948d67e0b24 Mon Sep 17 00:00:00 2001 From: y30045862 Date: Sat, 7 Sep 2024 11:45:31 +0800 Subject: [PATCH] fix hmdfs issue to match new logic in 6.6 version Signed-off-by: yangjingbo10 --- fs/hmdfs/comm/socket_adapter.c | 2 +- fs/hmdfs/file_merge.c | 35 +++++++++++++++++++--------------- fs/hmdfs/hmdfs_dentryfile.c | 10 +++++----- fs/hmdfs/hmdfs_server.c | 4 ++-- fs/hmdfs/inode_local.c | 4 ++-- fs/hmdfs/stash.c | 10 +++++----- 6 files changed, 35 insertions(+), 30 deletions(-) diff --git a/fs/hmdfs/comm/socket_adapter.c b/fs/hmdfs/comm/socket_adapter.c index 6ed430268d84..b9f35b9e1626 100644 --- a/fs/hmdfs/comm/socket_adapter.c +++ b/fs/hmdfs/comm/socket_adapter.c @@ -281,7 +281,7 @@ static struct hmdfs_msg_parasite *mp_alloc(struct hmdfs_peer *peer, return ERR_PTR(-ENOMEM); ret = hmdfs_alloc_msg_idr(peer, MSG_IDR_MESSAGE_ASYNC, mp, - mp->head.send_cmd_operations); + req->operations); if (unlikely(ret)) { kfree(mp); return ERR_PTR(ret); diff --git a/fs/hmdfs/file_merge.c b/fs/hmdfs/file_merge.c index 8fb439d3b286..2a2998e32e9e 100644 --- a/fs/hmdfs/file_merge.c +++ b/fs/hmdfs/file_merge.c @@ -19,12 +19,12 @@ struct hmdfs_iterate_callback_merge { /* * Record the return value of 'caller->actor': * - * -EINVAL, buffer is exhausted - * -EINTR, current task is pending - * -EFAULT, something is wrong - * 0, success and can do more + * false, buffer is exhausted + * false, current task is pending + * false, something is wrong + * true, success and can do more */ - int result; + bool result ; struct rb_root *root; uint64_t dev_id; }; @@ -210,7 +210,7 @@ static bool hmdfs_actor_merge(struct dir_context *ctx, const char *name, int namelen, long long offset, unsigned long long ino, unsigned int d_type) { - int ret = 0; + bool ret = true; int insert_res = 0; int max_devid_len = 2; char *dentry_name = NULL; @@ -219,14 +219,20 @@ static bool hmdfs_actor_merge(struct dir_context *ctx, const char *name, struct hmdfs_iterate_callback_merge *iterate_callback_merge = NULL; struct dir_context *org_ctx = NULL; - if (hmdfs_file_type(name) != HMDFS_TYPE_COMMON) - return 0; + if (hmdfs_file_type(name) != HMDFS_TYPE_COMMON) { + /* + * return true here, so that the caller can continue to next + * dentry even if failed on this dentry somehow. + */ + return true; + } + if (namelen > NAME_MAX) - return -EINVAL; + return false; dentry_name = kzalloc(NAME_MAX + 1, GFP_KERNEL); if (!dentry_name) - return -ENOMEM; + return false; strncpy(dentry_name, name, dentry_len); @@ -245,7 +251,7 @@ static bool hmdfs_actor_merge(struct dir_context *ctx, const char *name, } else if (d_type == DT_DIR && (insert_res == DT_REG || insert_res == DT_LNK)) { if (strlen(CONFLICTING_DIR_SUFFIX) > NAME_MAX - dentry_len) { - ret = -ENAMETOOLONG; + ret = false; goto delete; } rename_conflicting_directory(dentry_name, &dentry_len); @@ -253,7 +259,7 @@ static bool hmdfs_actor_merge(struct dir_context *ctx, const char *name, } else if ((d_type == DT_REG || d_type == DT_LNK) && insert_res > 0) { if (strlen(CONFLICTING_FILE_SUFFIX) + max_devid_len > NAME_MAX - dentry_len) { - ret = -ENAMETOOLONG; + ret = false; goto delete; } rename_conflicting_file(dentry_name, &dentry_len, @@ -268,13 +274,12 @@ static bool hmdfs_actor_merge(struct dir_context *ctx, const char *name, * different situations. */ iterate_callback_merge->result = ret; - ret = ret == 0 ? 0 : 1; - if (ret && d_type == DT_DIR && cache_entry->file_type == DT_DIR && + if (!ret && d_type == DT_DIR && cache_entry->file_type == DT_DIR && (insert_res == DT_REG || insert_res == DT_LNK)) cache_entry->file_type = DT_REG; delete: - if (ret && !insert_res) + if (!ret && !insert_res) delete_filename(iterate_callback_merge->root, cache_entry); done: kfree(dentry_name); diff --git a/fs/hmdfs/hmdfs_dentryfile.c b/fs/hmdfs/hmdfs_dentryfile.c index 2da6bd8ad8cb..46e0deae7240 100644 --- a/fs/hmdfs/hmdfs_dentryfile.c +++ b/fs/hmdfs/hmdfs_dentryfile.c @@ -1827,25 +1827,25 @@ static bool cache_file_iterate(struct dir_context *ctx, const char *name, if (name_len > NAME_MAX) { hmdfs_err("name_len:%d NAME_MAX:%u", name_len, NAME_MAX); - return 0; + return true; } if (d_type != DT_REG) - return 0; + return true; cfi = kmalloc(sizeof(*cfi), GFP_KERNEL); if (!cfi) - return -ENOMEM; + return false; cfi->name = kstrndup(name, name_len, GFP_KERNEL); if (!cfi->name) { kfree(cfi); - return -ENOMEM; + return false; } list_add_tail(&cfi->list, &cb->list); - return 0; + return true; } void hmdfs_do_load(struct hmdfs_sb_info *sbi, const char *fullname, bool server) diff --git a/fs/hmdfs/hmdfs_server.c b/fs/hmdfs/hmdfs_server.c index d7c4d98cf672..b1217f476e00 100644 --- a/fs/hmdfs/hmdfs_server.c +++ b/fs/hmdfs/hmdfs_server.c @@ -1463,10 +1463,10 @@ static bool hmdfs_filldir_real(struct dir_context *ctx, const char *name, out: /* - * we always return 0 here, so that the caller can continue to next + * we always return true here, so that the caller can continue to next * dentry even if failed on this dentry somehow. */ - return 0; + return true; } static void hmdfs_server_set_header(struct hmdfs_dcache_header *header, diff --git a/fs/hmdfs/inode_local.c b/fs/hmdfs/inode_local.c index 4fd799a21645..10c589b3b147 100644 --- a/fs/hmdfs/inode_local.c +++ b/fs/hmdfs/inode_local.c @@ -183,9 +183,9 @@ static bool hmdfs_name_match(struct dir_context *ctx, const char *name, memcpy(buf->name, name, namelen); buf->name[namelen] = 0; buf->found = true; - return 1; + return false; } - return 0; + return true; } static int __lookup_nosensitive(struct path *lower_parent_path, diff --git a/fs/hmdfs/stash.c b/fs/hmdfs/stash.c index c6c88b026792..21c5fac34c9e 100644 --- a/fs/hmdfs/stash.c +++ b/fs/hmdfs/stash.c @@ -1022,10 +1022,10 @@ static bool hmdfs_has_stash_file(struct dir_context *dctx, const char *name, err = hmdfs_parse_stash_file_name(dctx, name, namelen, d_type, &stash_inum); if (!err) - return 0; + return true; ctx->tbl->cnt++; - return 1; + return false; } static bool hmdfs_fill_stash_file(struct dir_context *dctx, const char *name, @@ -1040,13 +1040,13 @@ static bool hmdfs_fill_stash_file(struct dir_context *dctx, const char *name, err = hmdfs_parse_stash_file_name(dctx, name, namelen, d_type, &stash_inum); if (!err) - return 0; + return true; if (ctx->tbl->cnt >= ctx->tbl->max) - return 1; + return false; ctx->tbl->inodes[ctx->tbl->cnt++] = stash_inum; - return 0; + return true; } static int hmdfs_del_stash_file(struct dentry *parent, struct dentry *child) -- Gitee