diff --git a/fs/hmdfs/comm/connection.c b/fs/hmdfs/comm/connection.c index aec9cabf69311e20792ee517459efb708fe2b302..046688747d83784d57501ceb6aeef512c2c6ae2f 100644 --- a/fs/hmdfs/comm/connection.c +++ b/fs/hmdfs/comm/connection.c @@ -1241,21 +1241,24 @@ void head_put(struct hmdfs_msg_idr_head *head) kref_put_lock(&head->ref, head_release, &head->peer->idr_lock); } -struct hmdfs_msg_idr_head *hmdfs_find_msg_head(struct hmdfs_peer *peer, int id) +struct hmdfs_msg_idr_head *hmdfs_find_msg_head(struct hmdfs_peer *peer, + int id, struct hmdfs_cmd operations) { struct hmdfs_msg_idr_head *head = NULL; spin_lock(&peer->idr_lock); head = idr_find(&peer->msg_idr, id); - if (head) + if (head && head->send_cmd_operations.command == operations.command) kref_get(&head->ref); + else + head = NULL; spin_unlock(&peer->idr_lock); return head; } int hmdfs_alloc_msg_idr(struct hmdfs_peer *peer, enum MSG_IDR_TYPE type, - void *ptr) + void *ptr, struct hmdfs_cmd operations) { int ret = -EAGAIN; struct hmdfs_msg_idr_head *head = ptr; @@ -1270,6 +1273,7 @@ int hmdfs_alloc_msg_idr(struct hmdfs_peer *peer, enum MSG_IDR_TYPE type, head->msg_id = ret; head->type = type; head->peer = peer; + head->send_cmd_operations = operations; peer->msg_idr_process++; ret = 0; } diff --git a/fs/hmdfs/comm/connection.h b/fs/hmdfs/comm/connection.h index 8178590d4e3d1aefe54423bfe406c03214d15763..1988e99f78089aba55f67925786bce73e4b749f1 100644 --- a/fs/hmdfs/comm/connection.h +++ b/fs/hmdfs/comm/connection.h @@ -331,8 +331,9 @@ void hmdfs_disconnect_node(struct hmdfs_peer *node); void connection_to_working(struct hmdfs_peer *node); int hmdfs_alloc_msg_idr(struct hmdfs_peer *peer, enum MSG_IDR_TYPE type, - void *ptr); -struct hmdfs_msg_idr_head *hmdfs_find_msg_head(struct hmdfs_peer *peer, int id); + void *ptr, struct hmdfs_cmd operations); +struct hmdfs_msg_idr_head *hmdfs_find_msg_head(struct hmdfs_peer *peer, int id, + struct hmdfs_cmd operations); static inline void hmdfs_start_process_offline(struct hmdfs_peer *peer) { diff --git a/fs/hmdfs/comm/protocol.h b/fs/hmdfs/comm/protocol.h index e140963989de9a4ff9da15c3dbc3d387413ae5fb..beaa5adf4ba13782fc2c86afa4349d51c222f9a7 100644 --- a/fs/hmdfs/comm/protocol.h +++ b/fs/hmdfs/comm/protocol.h @@ -60,6 +60,7 @@ enum MSG_IDR_TYPE { struct hmdfs_msg_idr_head { __u32 type; __u32 msg_id; + struct hmdfs_cmd send_cmd_operations; struct kref ref; struct hmdfs_peer *peer; }; diff --git a/fs/hmdfs/comm/socket_adapter.c b/fs/hmdfs/comm/socket_adapter.c index e6b340b4ee72ac35592f8a67e323696218b8b312..794409933a194c8b23128828f3285c149da7a3f3 100644 --- a/fs/hmdfs/comm/socket_adapter.c +++ b/fs/hmdfs/comm/socket_adapter.c @@ -96,12 +96,13 @@ static void recv_info_init(struct file_recv_info *recv_info) atomic_set(&recv_info->state, FILE_RECV_PROCESS); } -static int msg_init(struct hmdfs_peer *con, struct sendmsg_wait_queue *msg_wq) +static int msg_init(struct hmdfs_peer *con, struct sendmsg_wait_queue *msg_wq, + struct hmdfs_cmd operations) { int ret = 0; struct file_recv_info *recv_info = &msg_wq->recv_info; - ret = hmdfs_alloc_msg_idr(con, MSG_IDR_MESSAGE_SYNC, msg_wq); + ret = hmdfs_alloc_msg_idr(con, MSG_IDR_MESSAGE_SYNC, msg_wq, operations); if (unlikely(ret)) return ret; @@ -279,7 +280,8 @@ static struct hmdfs_msg_parasite *mp_alloc(struct hmdfs_peer *peer, if (unlikely(!mp)) return ERR_PTR(-ENOMEM); - ret = hmdfs_alloc_msg_idr(peer, MSG_IDR_MESSAGE_ASYNC, mp); + ret = hmdfs_alloc_msg_idr(peer, MSG_IDR_MESSAGE_ASYNC, mp, + mp->head.send_cmd_operations); if (unlikely(ret)) { kfree(mp); return ERR_PTR(ret); @@ -437,7 +439,7 @@ int hmdfs_sendmessage_request(struct hmdfs_peer *con, ret = -ENOMEM; goto free_filp; } - ret = msg_init(con, msg_wq); + ret = msg_init(con, msg_wq, sm->operations); if (ret) { kfree(msg_wq); msg_wq = NULL; @@ -674,7 +676,7 @@ int hmdfs_sendpage_request(struct hmdfs_peer *con, goto unlock; } async_work->start = start; - ret = hmdfs_alloc_msg_idr(con, MSG_IDR_PAGE, async_work); + ret = hmdfs_alloc_msg_idr(con, MSG_IDR_PAGE, async_work, sm->operations); if (ret) { hmdfs_err("alloc msg_id failed, err %d", ret); goto unlock; @@ -911,7 +913,7 @@ static void hmdfs_file_response_work_fn(struct work_struct *ptr) hmdfs_override_creds(desp->peer->sbi->cred); msg_info = (struct sendmsg_wait_queue *)hmdfs_find_msg_head(desp->peer, - le32_to_cpu(desp->head->msg_id)); + le32_to_cpu(desp->head->msg_id), desp->head->operations); if (!msg_info || atomic_read(&msg_info->valid) != MSG_Q_SEND) { hmdfs_client_resp_statis(desp->peer->sbi, cmd, HMDFS_RESP_DELAY, 0, 0); @@ -963,7 +965,7 @@ int hmdfs_response_handle_sync(struct hmdfs_peer *con, bool woke = false; u8 cmd = head->operations.command; - msg_head = hmdfs_find_msg_head(con, msg_id); + msg_head = hmdfs_find_msg_head(con, msg_id, head->operations); if (!msg_head) goto out; diff --git a/fs/hmdfs/comm/transport.c b/fs/hmdfs/comm/transport.c index 1b52f46b69b8e0151f1bd8f940d5ab8f7d342027..bb6bc0e3e7ad5a2174bcfd7dd06e292370a6a9b6 100644 --- a/fs/hmdfs/comm/transport.c +++ b/fs/hmdfs/comm/transport.c @@ -235,7 +235,7 @@ static int tcp_recvpage_tls(struct connection *connect, node->device_id, rd_err); async_work = (struct hmdfs_async_work *)hmdfs_find_msg_head(node, - le32_to_cpu(recv->msg_id)); + le32_to_cpu(recv->msg_id), recv->operations); if (!async_work || !cancel_delayed_work(&async_work->d_work)) goto out; diff --git a/fs/hmdfs/hmdfs_client.c b/fs/hmdfs/hmdfs_client.c index fa8e7435c1efe38d6de68695b3b16c75f6ef023e..b251bb25f2fe1c38e134f3fd9c162b989a04f23e 100644 --- a/fs/hmdfs/hmdfs_client.c +++ b/fs/hmdfs/hmdfs_client.c @@ -40,6 +40,7 @@ int hmdfs_send_open(struct hmdfs_peer *con, const char *send_buf, struct hmdfs_send_command sm = { .data = open_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_OPEN); @@ -80,6 +81,7 @@ void hmdfs_send_close(struct hmdfs_peer *con, const struct hmdfs_fid *fid) struct hmdfs_send_command sm = { .data = release_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_RELEASE); @@ -102,6 +104,7 @@ int hmdfs_send_fsync(struct hmdfs_peer *con, const struct hmdfs_fid *fid, struct hmdfs_send_command sm = { .data = fsync_req, .len = sizeof(struct fsync_request), + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_FSYNC); @@ -130,6 +133,7 @@ int hmdfs_client_readpage(struct hmdfs_peer *con, const struct hmdfs_fid *fid, struct hmdfs_send_command sm = { .data = read_data, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_READPAGE); @@ -464,6 +468,7 @@ int hmdfs_client_start_mkdir(struct hmdfs_peer *con, struct hmdfs_send_command sm = { .data = mkdir_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_MKDIR); @@ -511,6 +516,7 @@ int hmdfs_client_start_create(struct hmdfs_peer *con, struct hmdfs_send_command sm = { .data = create_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_CREATE); @@ -556,6 +562,7 @@ int hmdfs_client_start_rmdir(struct hmdfs_peer *con, const char *path, struct hmdfs_send_command sm = { .data = rmdir_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_RMDIR); @@ -585,6 +592,7 @@ int hmdfs_client_start_unlink(struct hmdfs_peer *con, const char *path, struct hmdfs_send_command sm = { .data = unlink_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_UNLINK); @@ -619,6 +627,7 @@ int hmdfs_client_start_rename(struct hmdfs_peer *con, const char *old_path, struct hmdfs_send_command sm = { .data = rename_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_RENAME); @@ -656,6 +665,7 @@ int hmdfs_send_setattr(struct hmdfs_peer *con, const char *send_buf, struct hmdfs_send_command sm = { .data = setattr_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_SETATTR); @@ -714,6 +724,7 @@ int hmdfs_send_getattr(struct hmdfs_peer *con, const char *send_buf, struct hmdfs_send_command sm = { .data = req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_GETATTR); @@ -768,6 +779,7 @@ int hmdfs_send_statfs(struct hmdfs_peer *con, const char *path, struct hmdfs_send_command sm = { .data = req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_STATFS); @@ -850,6 +862,7 @@ int hmdfs_send_getxattr(struct hmdfs_peer *con, const char *send_buf, struct hmdfs_send_command sm = { .data = req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_GETXATTR); @@ -888,6 +901,7 @@ int hmdfs_send_setxattr(struct hmdfs_peer *con, const char *send_buf, struct hmdfs_send_command sm = { .data = req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_SETXATTR); @@ -937,6 +951,7 @@ ssize_t hmdfs_send_listxattr(struct hmdfs_peer *con, const char *send_buf, struct hmdfs_send_command sm = { .data = req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_LISTXATTR); @@ -1008,6 +1023,7 @@ void hmdfs_send_drop_push(struct hmdfs_peer *con, const char *path) struct hmdfs_send_command sm = { .data = dp_req, .len = send_len, + .local_filp = NULL, }; hmdfs_init_cmd(&sm.operations, F_DROP_PUSH);