From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: Xiubo Li <xiubli@redhat.com>, "buaajxlj@163.com" <buaajxlj@163.com>
Cc: "fanggeng@lixiang.com" <fanggeng@lixiang.com>,
"yangchen11@lixiang.com" <yangchen11@lixiang.com>,
"idryomov@gmail.com" <idryomov@gmail.com>,
"ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"liangjie@lixiang.com" <liangjie@lixiang.com>
Subject: Re: [PATCH] ceph: streamline request head structures in MDS client
Date: Fri, 10 Jan 2025 19:25:35 +0000 [thread overview]
Message-ID: <c5276b40b56a092ea1ec8d161eaa42926018bf5f.camel@ibm.com> (raw)
In-Reply-To: <20250110100524.1891669-1-buaajxlj@163.com>
On Fri, 2025-01-10 at 18:05 +0800, Liang Jie wrote:
> From: Liang Jie <liangjie@lixiang.com>
>
> 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>
> ---
> fs/ceph/mds_client.c | 16 ++++++++--------
> include/linux/ceph/ceph_fs.h | 14 --------------
> 2 files changed, 8 insertions(+), 22 deletions(-)
>
Looks good to me. Nice cleanup.
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Thanks,
Slava.
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index 785fe489ef4b..2196e404318c 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -2945,12 +2945,12 @@ static struct ceph_mds_request_head_legacy *
> find_legacy_request_head(void *p, u64 features)
> {
> bool legacy = !(features & CEPH_FEATURE_FS_BTIME);
> - struct ceph_mds_request_head_old *ohead;
> + struct ceph_mds_request_head *head;
>
> if (legacy)
> return (struct ceph_mds_request_head_legacy *)p;
> - ohead = (struct ceph_mds_request_head_old *)p;
> - return (struct ceph_mds_request_head_legacy *)&ohead-
> >oldest_client_tid;
> + head = (struct ceph_mds_request_head *)p;
> + return (struct ceph_mds_request_head_legacy *)&head-
> >oldest_client_tid;
> }
>
> /*
> @@ -3020,7 +3020,7 @@ static struct ceph_msg
> *create_request_message(struct ceph_mds_session *session,
> if (legacy)
> len = sizeof(struct ceph_mds_request_head_legacy);
> else if (request_head_version == 1)
> - len = sizeof(struct ceph_mds_request_head_old);
> + len = offsetofend(struct ceph_mds_request_head,
> args);
> else if (request_head_version == 2)
> len = offsetofend(struct ceph_mds_request_head,
> ext_num_fwd);
> else
> @@ -3104,11 +3104,11 @@ static struct ceph_msg
> *create_request_message(struct ceph_mds_session *session,
> msg->hdr.version = cpu_to_le16(3);
> p = msg->front.iov_base + sizeof(*lhead);
> } else if (request_head_version == 1) {
> - struct ceph_mds_request_head_old *ohead = msg-
> >front.iov_base;
> + struct ceph_mds_request_head *nhead = msg-
> >front.iov_base;
>
> msg->hdr.version = cpu_to_le16(4);
> - ohead->version = cpu_to_le16(1);
> - p = msg->front.iov_base + sizeof(*ohead);
> + nhead->version = cpu_to_le16(1);
> + p = msg->front.iov_base + offsetofend(struct
> ceph_mds_request_head, args);
> } else if (request_head_version == 2) {
> struct ceph_mds_request_head *nhead = msg-
> >front.iov_base;
>
> @@ -3265,7 +3265,7 @@ static int __prepare_send_request(struct
> ceph_mds_session *session,
> * so we limit to retry at most 256 times.
> */
> if (req->r_attempts) {
> - old_max_retry = sizeof_field(struct
> ceph_mds_request_head_old,
> + old_max_retry = sizeof_field(struct
> ceph_mds_request_head,
> num_retry);
> old_max_retry = 1 << (old_max_retry * BITS_PER_BYTE);
> if ((old_version && req->r_attempts >= old_max_retry)
> ||
> diff --git a/include/linux/ceph/ceph_fs.h
> b/include/linux/ceph/ceph_fs.h
> index 2d7d86f0290d..c7f2c63b3bc3 100644
> --- a/include/linux/ceph/ceph_fs.h
> +++ b/include/linux/ceph/ceph_fs.h
> @@ -504,20 +504,6 @@ struct ceph_mds_request_head_legacy {
>
> #define CEPH_MDS_REQUEST_HEAD_VERSION 3
>
> -struct ceph_mds_request_head_old {
> - __le16 version; /* struct version */
> - __le64 oldest_client_tid;
> - __le32 mdsmap_epoch; /* on client */
> - __le32 flags; /* CEPH_MDS_FLAG_* */
> - __u8 num_retry, num_fwd; /* count retry, fwd attempts
> */
> - __le16 num_releases; /* # include cap/lease
> release records */
> - __le32 op; /* mds op code */
> - __le32 caller_uid, caller_gid;
> - __le64 ino; /* use this ino for openc,
> mkdir, mknod,
> - etc. (if replaying) */
> - union ceph_mds_request_args_ext args;
> -} __attribute__ ((packed));
> -
> struct ceph_mds_request_head {
> __le16 version; /* struct version */
> __le64 oldest_client_tid;
next prev parent reply other threads:[~2025-01-10 19:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 10:05 Liang Jie
2025-01-10 19:25 ` Viacheslav Dubeyko [this message]
2025-01-15 20:15 ` Ilya Dryomov
2025-01-18 13:52 ` Liang Jie
2025-01-18 19:33 ` Ilya Dryomov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c5276b40b56a092ea1ec8d161eaa42926018bf5f.camel@ibm.com \
--to=slava.dubeyko@ibm.com \
--cc=buaajxlj@163.com \
--cc=ceph-devel@vger.kernel.org \
--cc=fanggeng@lixiang.com \
--cc=idryomov@gmail.com \
--cc=liangjie@lixiang.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xiubli@redhat.com \
--cc=yangchen11@lixiang.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®