Skip to contentSkip to conversation

ceph: update the oldest_client_tid via the renew caps

PATCH Superseded [email protected] 2 participants 5 messages Nov 16, 2023 – Nov 17, 2023 Ceph client

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ceph: update the oldest_client_tid via the renew caps

From: Xiubo Li <[email protected]>

This is the kclient fixes after https://tracker.ceph.com/issues/63364.

Xiubo Li (2):
ceph: rename create_session_open_msg() to create_session_full_msg()
ceph: update the oldest_client_tid via the renew caps

 fs/ceph/mds_client.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/2 ceph: rename create_session_open_msg() to create_session_full_msg()

From: Xiubo Li <[email protected]>

Makes the create session msg helper to be more general and could be used by other OPs.

URL: https://tracker.ceph.com/issues/63364

---
 fs/ceph/mds_client.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ceph/mds_client.c +5 -3
index 81040052eb4d..fdfea11d9568 100644
@@ -1534,7 +1534,8 @@ static int encode_metric_spec(void **p, void *end)
  * session message, specialization for CEPH_SESSION_REQUEST_OPEN
  * to include additional client metadata fields.
  */
-static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u64 seq)
+static struct ceph_msg *
+create_session_full_msg(struct ceph_mds_client *mdsc, int op, u64 seq)
 {
 	struct ceph_msg *msg;
 	struct ceph_mds_session_head *h;
@@ -1589,7 +1590,7 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6
 	end = p + msg->front.iov_len;
 
 	h = p;
-	h->op = cpu_to_le32(CEPH_SESSION_REQUEST_OPEN);
+	h->op = cpu_to_le32(op);
 	h->seq = cpu_to_le64(seq);
 
 	/*
@@ -1663,7 +1664,8 @@ static int __open_session(struct ceph_mds_client *mdsc,
 	session->s_renew_requested = jiffies;
 
 	/* send connect message */
-	msg = create_session_open_msg(mdsc, session->s_seq);
+	msg = create_session_full_msg(mdsc, CEPH_SESSION_REQUEST_OPEN,
+				      session->s_seq);
 	if (IS_ERR(msg))
 		return PTR_ERR(msg);
 	ceph_con_send(&session->s_con, msg);
Signature · 1 line
2.41.0
#2 lore raw

PATCH 2/2 ceph: update the oldest_client_tid via the renew caps

In reply to [email protected]

From: Xiubo Li <[email protected]>

Update the oldest_client_tid via the session renew caps msg to make sure that the MDSs won't pile up the completed request list in a very large size.

URL: https://tracker.ceph.com/issues/63364

---
 fs/ceph/mds_client.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
fs/ceph/mds_client.c +19 -5
index fdfea11d9568..7d38b988273c 100644
@@ -1579,6 +1579,9 @@ create_session_full_msg(struct ceph_mds_client *mdsc, int op, u64 seq)
 		size = METRIC_BYTES(count);
 	extra_bytes += 2 + 4 + 4 + size;
 
+	/* flags, mds auth caps and oldest_client_tid */
+	extra_bytes += 4 + 4 + 8;
+
 	/* Allocate the message */
 	msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h) + extra_bytes,
 			   GFP_NOFS, false);
@@ -1597,9 +1600,9 @@ create_session_full_msg(struct ceph_mds_client *mdsc, int op, u64 seq)
 	 * Serialize client metadata into waiting buffer space, using
 	 * the format that userspace expects for map<string, string>
 	 *
-	 * ClientSession messages with metadata are v4
+	 * ClientSession messages with metadata are v7
 	 */
-	msg->hdr.version = cpu_to_le16(4);
+	msg->hdr.version = cpu_to_le16(7);
 	msg->hdr.compat_version = cpu_to_le16(1);
 
 	/* The write pointer, following the session_head structure */
@@ -1635,6 +1638,15 @@ create_session_full_msg(struct ceph_mds_client *mdsc, int op, u64 seq)
 		return ERR_PTR(ret);
 	}
 
+	/* version == 5, flags */
+	ceph_encode_32(&p, 0);
+
+	/* version == 6, mds auth caps */
+	ceph_encode_32(&p, 0);
+
+	/* version == 7, oldest_client_tid */
+	ceph_encode_64(&p, cpu_to_le64(mdsc->oldest_tid));
+
 	msg->front.iov_len = p - msg->front.iov_base;
 	msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
 
@@ -2030,10 +2042,12 @@ static int send_renew_caps(struct ceph_mds_client *mdsc,
 
 	doutc(cl, "to mds%d (%s)\n", session->s_mds,
 	      ceph_mds_state_name(state));
-	msg = ceph_create_session_msg(CEPH_SESSION_REQUEST_RENEWCAPS,
+
+	/* send connect message */
+	msg = create_session_full_msg(mdsc, CEPH_SESSION_REQUEST_RENEWCAPS,
 				      ++session->s_renew_seq);
-	if (!msg)
-		return -ENOMEM;
+	if (IS_ERR(msg))
+		return PTR_ERR(msg);
 	ceph_con_send(&session->s_con, msg);
 	return 0;
 }
Signature · 1 line
2.41.0
#3 lore raw
kernel test robot noticed the following build warnings:

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on ceph-client/for-linus]
[also build test WARNING on linus/master v6.7-rc1 next-20231117] [cannot apply to ceph-client/testing]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/xiubli-redhat-com/ceph-rename-create_session_open_msg-to-create_session_full_msg/20231116-151746
base:   https://github.com/ceph/ceph-client.git for-linus
patch link:    https://lore.kernel.org/r/20231116071338.678918-3-xiubli%40redhat.com
patch subject: [PATCH 2/2] ceph: update the oldest_client_tid via the renew caps
config: i386-randconfig-063-20231117 (https://download.01.org/0day-ci/archive/20231117/[email protected]/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231117/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> fs/ceph/mds_client.c:1648:28: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned long long [usertype] v @@     got restricted __le64 [usertype] @@

fs/ceph/mds_client.c:1648:28: sparse: expected unsigned long long [usertype] v
fs/ceph/mds_client.c:1648:28: sparse: got restricted __le64 [usertype]
fs/ceph/mds_client.c: note: in included file (through include/linux/wait.h, include/linux/wait_bit.h, include/linux/fs.h):
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true

vim +1648 fs/ceph/mds_client.c

1532
1533 /*
1534 * session message, specialization for CEPH_SESSION_REQUEST_OPEN
1535 * to include additional client metadata fields.
1536 */
1537 static struct ceph_msg *
1538 create_session_full_msg(struct ceph_mds_client *mdsc, int op, u64 seq)
1539 {
1540 struct ceph_msg *msg;
1541 struct ceph_mds_session_head *h;
1542 int i;
1543 int extra_bytes = 0;
1544 int metadata_key_count = 0;
1545 struct ceph_options *opt = mdsc->fsc->client->options;
1546 struct ceph_mount_options *fsopt = mdsc->fsc->mount_options;
1547 struct ceph_client *cl = mdsc->fsc->client;
1548 size_t size, count;
1549 void *p, *end;
1550 int ret;
1551
1552 const char* metadata[][2] = {
1553 {"hostname", mdsc->nodename},
1554 {"kernel_version", init_utsname()->release},
1555 {"entity_id", opt->name ? : ""},
1556 {"root", fsopt->server_path ? : "/"},
1557 {NULL, NULL}
1558 };
1559
1560 /* Calculate serialized length of metadata */
1561 extra_bytes = 4; /* map length */
1562 for (i = 0; metadata[i][0]; ++i) {
1563 extra_bytes += 8 + strlen(metadata[i][0]) +
1564 strlen(metadata[i][1]);
1565 metadata_key_count++;
1566 }
1567
1568 /* supported feature */
1569 size = 0;
1570 count = ARRAY_SIZE(feature_bits);
1571 if (count > 0)
1572 size = FEATURE_BYTES(count);
1573 extra_bytes += 4 + size;
1574
1575 /* metric spec */
1576 size = 0;
1577 count = ARRAY_SIZE(metric_bits);
1578 if (count > 0)
1579 size = METRIC_BYTES(count);
1580 extra_bytes += 2 + 4 + 4 + size;
1581
1582 /* flags, mds auth caps and oldest_client_tid */
1583 extra_bytes += 4 + 4 + 8;
1584
1585 /* Allocate the message */
1586 msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h) + extra_bytes,
1587 GFP_NOFS, false);
1588 if (!msg) {
1589 pr_err_client(cl, "ENOMEM creating session open msg\n");
1590 return ERR_PTR(-ENOMEM);
1591 }
1592 p = msg->front.iov_base;
1593 end = p + msg->front.iov_len;
1594
1595 h = p;
1596 h->op = cpu_to_le32(op);
1597 h->seq = cpu_to_le64(seq);
1598
1599 /*
1600 * Serialize client metadata into waiting buffer space, using
1601 * the format that userspace expects for map<string, string>
1602 *
1603 * ClientSession messages with metadata are v7
1604 */
1605 msg->hdr.version = cpu_to_le16(7);
1606 msg->hdr.compat_version = cpu_to_le16(1);
1607
1608 /* The write pointer, following the session_head structure */
1609 p += sizeof(*h);
1610
1611 /* Number of entries in the map */
1612 ceph_encode_32(&p, metadata_key_count);
1613
1614 /* Two length-prefixed strings for each entry in the map */
1615 for (i = 0; metadata[i][0]; ++i) {
1616 size_t const key_len = strlen(metadata[i][0]);
1617 size_t const val_len = strlen(metadata[i][1]);
1618
1619 ceph_encode_32(&p, key_len);
1620 memcpy(p, metadata[i][0], key_len);
1621 p += key_len;
1622 ceph_encode_32(&p, val_len);
1623 memcpy(p, metadata[i][1], val_len);
1624 p += val_len;
1625 }
1626
1627 ret = encode_supported_features(&p, end);
1628 if (ret) {
1629 pr_err_client(cl, "encode_supported_features failed!\n");
1630 ceph_msg_put(msg);
1631 return ERR_PTR(ret);
1632 }
1633
1634 ret = encode_metric_spec(&p, end);
1635 if (ret) {
1636 pr_err_client(cl, "encode_metric_spec failed!\n");
1637 ceph_msg_put(msg);
1638 return ERR_PTR(ret);
1639 }
1640
1641 /* version == 5, flags */
1642 ceph_encode_32(&p, 0);
1643
1644 /* version == 6, mds auth caps */
1645 ceph_encode_32(&p, 0);
1646
1647 /* version == 7, oldest_client_tid */

> 1648		ceph_encode_64(&p, cpu_to_le64(mdsc->oldest_tid));

1649
1650 msg->front.iov_len = p - msg->front.iov_base;
1651 msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
1652
1653 return msg;
1654 }
1655

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author
#4 lore raw

Fixed it.

Thanks for reporting this.

- Xiubo

Quoted 166 lines · kernel test robot

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on ceph-client/for-linus]
[also build test WARNING on linus/master v6.7-rc1 next-20231117] [cannot apply to ceph-client/testing]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/xiubli-redhat-com/ceph-rename-create_session_open_msg-to-create_session_full_msg/20231116-151746
base:   https://github.com/ceph/ceph-client.git for-linus
patch link:    https://lore.kernel.org/r/20231116071338.678918-3-xiubli%40redhat.com
patch subject: [PATCH 2/2] ceph: update the oldest_client_tid via the renew caps
config: i386-randconfig-063-20231117 (https://download.01.org/0day-ci/archive/20231117/[email protected]/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231117/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

fs/ceph/mds_client.c:1648:28: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned long long [usertype] v @@ got restricted __le64 [usertype] @@

fs/ceph/mds_client.c:1648:28: sparse: expected unsigned long long [usertype] v
fs/ceph/mds_client.c:1648:28: sparse: got restricted __le64 [usertype]
fs/ceph/mds_client.c: note: in included file (through include/linux/wait.h, include/linux/wait_bit.h, include/linux/fs.h):
include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true

vim +1648 fs/ceph/mds_client.c

   1532	
   1533	/*
   1534	 * session message, specialization for CEPH_SESSION_REQUEST_OPEN
   1535	 * to include additional client metadata fields.
   1536	 */
   1537	static struct ceph_msg *
   1538	create_session_full_msg(struct ceph_mds_client *mdsc, int op, u64 seq)
   1539	{
   1540		struct ceph_msg *msg;
   1541		struct ceph_mds_session_head *h;
   1542		int i;
   1543		int extra_bytes = 0;
   1544		int metadata_key_count = 0;
   1545		struct ceph_options *opt = mdsc->fsc->client->options;
   1546		struct ceph_mount_options *fsopt = mdsc->fsc->mount_options;
   1547		struct ceph_client *cl = mdsc->fsc->client;
   1548		size_t size, count;
   1549		void *p, *end;
   1550		int ret;
   1551	
   1552		const char* metadata[][2] = {
   1553			{"hostname", mdsc->nodename},
   1554			{"kernel_version", init_utsname()->release},
   1555			{"entity_id", opt->name ? : ""},
   1556			{"root", fsopt->server_path ? : "/"},
   1557			{NULL, NULL}
   1558		};
   1559	
   1560		/* Calculate serialized length of metadata */
   1561		extra_bytes = 4;  /* map length */
   1562		for (i = 0; metadata[i][0]; ++i) {
   1563			extra_bytes += 8 + strlen(metadata[i][0]) +
   1564				strlen(metadata[i][1]);
   1565			metadata_key_count++;
   1566		}
   1567	
   1568		/* supported feature */
   1569		size = 0;
   1570		count = ARRAY_SIZE(feature_bits);
   1571		if (count > 0)
   1572			size = FEATURE_BYTES(count);
   1573		extra_bytes += 4 + size;
   1574	
   1575		/* metric spec */
   1576		size = 0;
   1577		count = ARRAY_SIZE(metric_bits);
   1578		if (count > 0)
   1579			size = METRIC_BYTES(count);
   1580		extra_bytes += 2 + 4 + 4 + size;
   1581	
   1582		/* flags, mds auth caps and oldest_client_tid */
   1583		extra_bytes += 4 + 4 + 8;
   1584	
   1585		/* Allocate the message */
   1586		msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h) + extra_bytes,
   1587				   GFP_NOFS, false);
   1588		if (!msg) {
   1589			pr_err_client(cl, "ENOMEM creating session open msg\n");
   1590			return ERR_PTR(-ENOMEM);
   1591		}
   1592		p = msg->front.iov_base;
   1593		end = p + msg->front.iov_len;
   1594	
   1595		h = p;
   1596		h->op = cpu_to_le32(op);
   1597		h->seq = cpu_to_le64(seq);
   1598	
   1599		/*
   1600		 * Serialize client metadata into waiting buffer space, using
   1601		 * the format that userspace expects for map<string, string>
   1602		 *
   1603		 * ClientSession messages with metadata are v7
   1604		 */
   1605		msg->hdr.version = cpu_to_le16(7);
   1606		msg->hdr.compat_version = cpu_to_le16(1);
   1607	
   1608		/* The write pointer, following the session_head structure */
   1609		p += sizeof(*h);
   1610	
   1611		/* Number of entries in the map */
   1612		ceph_encode_32(&p, metadata_key_count);
   1613	
   1614		/* Two length-prefixed strings for each entry in the map */
   1615		for (i = 0; metadata[i][0]; ++i) {
   1616			size_t const key_len = strlen(metadata[i][0]);
   1617			size_t const val_len = strlen(metadata[i][1]);
   1618	
   1619			ceph_encode_32(&p, key_len);
   1620			memcpy(p, metadata[i][0], key_len);
   1621			p += key_len;
   1622			ceph_encode_32(&p, val_len);
   1623			memcpy(p, metadata[i][1], val_len);
   1624			p += val_len;
   1625		}
   1626	
   1627		ret = encode_supported_features(&p, end);
   1628		if (ret) {
   1629			pr_err_client(cl, "encode_supported_features failed!\n");
   1630			ceph_msg_put(msg);
   1631			return ERR_PTR(ret);
   1632		}
   1633	
   1634		ret = encode_metric_spec(&p, end);
   1635		if (ret) {
   1636			pr_err_client(cl, "encode_metric_spec failed!\n");
   1637			ceph_msg_put(msg);
   1638			return ERR_PTR(ret);
   1639		}
   1640	
   1641		/* version == 5, flags */
   1642		ceph_encode_32(&p, 0);
   1643	
   1644		/* version == 6, mds auth caps */
   1645		ceph_encode_32(&p, 0);
   1646	
   1647		/* version == 7, oldest_client_tid */
Quoted 1 line

1648 ceph_encode_64(&p, cpu_to_le64(mdsc->oldest_tid));

1649

   1650		msg->front.iov_len = p - msg->front.iov_base;
   1651		msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
   1652	
   1653		return msg;
   1654	}
   1655