Skip to content

Commit 2f0805d

Browse files
Liang Jieidryomov
authored andcommitted
ceph: streamline request head structures in MDS client
The existence of the ceph_mds_request_head_old structure in the MDS client code is no longer required due to improvements in handling different MDS request header versions. This patch removes the now redundant ceph_mds_request_head_old structure and replaces its usage with the flexible and extensible ceph_mds_request_head structure. Changes include: - Modification of find_legacy_request_head to directly cast the pointer to ceph_mds_request_head_legacy without going through the old structure. - Update sizeof calculations in create_request_message to use offsetofend for consistency and future-proofing, rather than referencing the old structure. - Use of the structured ceph_mds_request_head directly instead of the old one. Additionally, this consolidation normalizes the handling of request_head_version v1 to align with versions v2 and v3, leading to a more consistent and maintainable codebase. These changes simplify the codebase and reduce potential confusion stemming from the existence of an obsolete structure. Signed-off-by: Liang Jie <liangjie@lixiang.com> Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 3b7d93d commit 2f0805d

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

fs/ceph/mds_client.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,12 +2945,12 @@ static struct ceph_mds_request_head_legacy *
29452945
find_legacy_request_head(void *p, u64 features)
29462946
{
29472947
bool legacy = !(features & CEPH_FEATURE_FS_BTIME);
2948-
struct ceph_mds_request_head_old *ohead;
2948+
struct ceph_mds_request_head *head;
29492949

29502950
if (legacy)
29512951
return (struct ceph_mds_request_head_legacy *)p;
2952-
ohead = (struct ceph_mds_request_head_old *)p;
2953-
return (struct ceph_mds_request_head_legacy *)&ohead->oldest_client_tid;
2952+
head = (struct ceph_mds_request_head *)p;
2953+
return (struct ceph_mds_request_head_legacy *)&head->oldest_client_tid;
29542954
}
29552955

29562956
/*
@@ -3020,7 +3020,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
30203020
if (legacy)
30213021
len = sizeof(struct ceph_mds_request_head_legacy);
30223022
else if (request_head_version == 1)
3023-
len = sizeof(struct ceph_mds_request_head_old);
3023+
len = offsetofend(struct ceph_mds_request_head, args);
30243024
else if (request_head_version == 2)
30253025
len = offsetofend(struct ceph_mds_request_head, ext_num_fwd);
30263026
else
@@ -3104,11 +3104,11 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
31043104
msg->hdr.version = cpu_to_le16(3);
31053105
p = msg->front.iov_base + sizeof(*lhead);
31063106
} else if (request_head_version == 1) {
3107-
struct ceph_mds_request_head_old *ohead = msg->front.iov_base;
3107+
struct ceph_mds_request_head *nhead = msg->front.iov_base;
31083108

31093109
msg->hdr.version = cpu_to_le16(4);
3110-
ohead->version = cpu_to_le16(1);
3111-
p = msg->front.iov_base + sizeof(*ohead);
3110+
nhead->version = cpu_to_le16(1);
3111+
p = msg->front.iov_base + offsetofend(struct ceph_mds_request_head, args);
31123112
} else if (request_head_version == 2) {
31133113
struct ceph_mds_request_head *nhead = msg->front.iov_base;
31143114

@@ -3265,7 +3265,7 @@ static int __prepare_send_request(struct ceph_mds_session *session,
32653265
* so we limit to retry at most 256 times.
32663266
*/
32673267
if (req->r_attempts) {
3268-
old_max_retry = sizeof_field(struct ceph_mds_request_head_old,
3268+
old_max_retry = sizeof_field(struct ceph_mds_request_head,
32693269
num_retry);
32703270
old_max_retry = 1 << (old_max_retry * BITS_PER_BYTE);
32713271
if ((old_version && req->r_attempts >= old_max_retry) ||

include/linux/ceph/ceph_fs.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -504,20 +504,6 @@ struct ceph_mds_request_head_legacy {
504504

505505
#define CEPH_MDS_REQUEST_HEAD_VERSION 3
506506

507-
struct ceph_mds_request_head_old {
508-
__le16 version; /* struct version */
509-
__le64 oldest_client_tid;
510-
__le32 mdsmap_epoch; /* on client */
511-
__le32 flags; /* CEPH_MDS_FLAG_* */
512-
__u8 num_retry, num_fwd; /* count retry, fwd attempts */
513-
__le16 num_releases; /* # include cap/lease release records */
514-
__le32 op; /* mds op code */
515-
__le32 caller_uid, caller_gid;
516-
__le64 ino; /* use this ino for openc, mkdir, mknod,
517-
etc. (if replaying) */
518-
union ceph_mds_request_args_ext args;
519-
} __attribute__ ((packed));
520-
521507
struct ceph_mds_request_head {
522508
__le16 version; /* struct version */
523509
__le64 oldest_client_tid;

0 commit comments

Comments
 (0)