From mboxrd@z Thu Jan 1 00:00:00 1970 From: xiubli@redhat.com Subject: [PATCH resend v5 11/11] ceph: send client provided metric flags in client metadata Date: Wed, 29 Jan 2020 03:27:15 -0500 Message-ID: <20200129082715.5285-12-xiubli@redhat.com> References: <20200129082715.5285-1-xiubli@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44796 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726314AbgA2I2b (ORCPT ); Wed, 29 Jan 2020 03:28:31 -0500 In-Reply-To: <20200129082715.5285-1-xiubli@redhat.com> Sender: ceph-devel-owner@vger.kernel.org List-ID: To: jlayton@kernel.org, idryomov@gmail.com, zyan@redhat.com Cc: sage@redhat.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li From: Xiubo Li Will send the metric flags to MDS, currently it supports the cap, dentry lease, read latency, write latency and metadata latency. URL: https://tracker.ceph.com/issues/43435 Signed-off-by: Xiubo Li --- fs/ceph/mds_client.c | 47 ++++++++++++++++++++++++++++++++++++++++++-- fs/ceph/metric.h | 14 +++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index d765804dc855..f9d3acd36656 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -1096,6 +1096,41 @@ static void encode_supported_features(void **p, vo= id *end) } } =20 +static const unsigned char metric_bits[] =3D CEPHFS_METRIC_SPEC_CLIENT_S= UPPORTED; +#define METRIC_BYTES(cnt) (DIV_ROUND_UP((size_t)metric_bits[cnt - 1] + 1= , 64) * 8) +static void encode_metric_spec(void **p, void *end) +{ + static const size_t count =3D ARRAY_SIZE(metric_bits); + + /* header */ + BUG_ON(*p + 2 > end); + ceph_encode_8(p, 1); /* version */ + ceph_encode_8(p, 1); /* compat */ + + if (count > 0) { + size_t i; + size_t size =3D METRIC_BYTES(count); + + BUG_ON(*p + 4 + 4 + size > end); + + /* metric spec info length */ + ceph_encode_32(p, 4 + size); + + /* metric spec */ + ceph_encode_32(p, size); + memset(*p, 0, size); + for (i =3D 0; i < count; i++) + ((unsigned char*)(*p))[i / 8] |=3D BIT(metric_bits[i] % 8); + *p +=3D size; + } else { + BUG_ON(*p + 4 + 4 > end); + /* metric spec info length */ + ceph_encode_32(p, 4); + /* metric spec */ + ceph_encode_32(p, 0); + } +} + /* * session message, specialization for CEPH_SESSION_REQUEST_OPEN * to include additional client metadata fields. @@ -1135,6 +1170,13 @@ static struct ceph_msg *create_session_open_msg(st= ruct ceph_mds_client *mdsc, u6 size =3D FEATURE_BYTES(count); extra_bytes +=3D 4 + size; =20 + /* metric spec */ + size =3D 0; + count =3D ARRAY_SIZE(metric_bits); + if (count > 0) + size =3D METRIC_BYTES(count); + extra_bytes +=3D 2 + 4 + 4 + size; + /* Allocate the message */ msg =3D ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h) + extra_bytes, GFP_NOFS, false); @@ -1153,9 +1195,9 @@ static struct ceph_msg *create_session_open_msg(str= uct ceph_mds_client *mdsc, u6 * Serialize client metadata into waiting buffer space, using * the format that userspace expects for map * - * ClientSession messages with metadata are v3 + * ClientSession messages with metadata are v4 */ - msg->hdr.version =3D cpu_to_le16(3); + msg->hdr.version =3D cpu_to_le16(4); msg->hdr.compat_version =3D cpu_to_le16(1); =20 /* The write pointer, following the session_head structure */ @@ -1178,6 +1220,7 @@ static struct ceph_msg *create_session_open_msg(str= uct ceph_mds_client *mdsc, u6 } =20 encode_supported_features(&p, end); + encode_metric_spec(&p, end); msg->front.iov_len =3D p - msg->front.iov_base; msg->hdr.front_len =3D cpu_to_le32(msg->front.iov_len); =20 diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index 352eb753ce25..70e0b586b687 100644 --- a/fs/ceph/metric.h +++ b/fs/ceph/metric.h @@ -14,6 +14,20 @@ enum ceph_metric_type { CLIENT_METRIC_TYPE_MAX =3D CLIENT_METRIC_TYPE_DENTRY_LEASE, }; =20 +/* + * This will always have the highest metric bit value + * as the last element of the array. + */ +#define CEPHFS_METRIC_SPEC_CLIENT_SUPPORTED { \ + CLIENT_METRIC_TYPE_CAP_INFO, \ + CLIENT_METRIC_TYPE_READ_LATENCY, \ + CLIENT_METRIC_TYPE_WRITE_LATENCY, \ + CLIENT_METRIC_TYPE_METADATA_LATENCY, \ + CLIENT_METRIC_TYPE_DENTRY_LEASE, \ + \ + CLIENT_METRIC_TYPE_MAX, \ +} + /* metric caps header */ struct ceph_metric_cap { __le32 type; /* ceph metric type */ --=20 2.21.0