Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Liang Jie and committed by
Ilya Dryomov
2f0805d7 3b7d93db

+8 -22
+8 -8
fs/ceph/mds_client.c
··· 2945 2945 find_legacy_request_head(void *p, u64 features) 2946 2946 { 2947 2947 bool legacy = !(features & CEPH_FEATURE_FS_BTIME); 2948 - struct ceph_mds_request_head_old *ohead; 2948 + struct ceph_mds_request_head *head; 2949 2949 2950 2950 if (legacy) 2951 2951 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; 2954 2954 } 2955 2955 2956 2956 /* ··· 3020 3020 if (legacy) 3021 3021 len = sizeof(struct ceph_mds_request_head_legacy); 3022 3022 else if (request_head_version == 1) 3023 - len = sizeof(struct ceph_mds_request_head_old); 3023 + len = offsetofend(struct ceph_mds_request_head, args); 3024 3024 else if (request_head_version == 2) 3025 3025 len = offsetofend(struct ceph_mds_request_head, ext_num_fwd); 3026 3026 else ··· 3104 3104 msg->hdr.version = cpu_to_le16(3); 3105 3105 p = msg->front.iov_base + sizeof(*lhead); 3106 3106 } 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; 3108 3108 3109 3109 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); 3112 3112 } else if (request_head_version == 2) { 3113 3113 struct ceph_mds_request_head *nhead = msg->front.iov_base; 3114 3114 ··· 3265 3265 * so we limit to retry at most 256 times. 3266 3266 */ 3267 3267 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, 3269 3269 num_retry); 3270 3270 old_max_retry = 1 << (old_max_retry * BITS_PER_BYTE); 3271 3271 if ((old_version && req->r_attempts >= old_max_retry) ||
-14
include/linux/ceph/ceph_fs.h
··· 504 504 505 505 #define CEPH_MDS_REQUEST_HEAD_VERSION 3 506 506 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 - 521 507 struct ceph_mds_request_head { 522 508 __le16 version; /* struct version */ 523 509 __le64 oldest_client_tid;