Skip to contentSkip to conversation

ceph: show max caps in debugfs caps file

PATCH In review Yanhu Cao 2 participants 2 messages May 25, 2020 – May 26, 2020 Ceph client

lore
Share & tools
lore

Yanhu Cao

author
#0 lore raw

PATCH v2 1/1 ceph: show max caps in debugfs caps file

before
------
total 1286
avail 1005
used 281
reserved 0
min 1024

after
-----
total 1286
avail 1005
used 281
limit 261
reserved 0
min 1024

---
 fs/ceph/caps.c       | 6 ++++--
 fs/ceph/debugfs.c    | 8 +++++---
 fs/ceph/mds_client.c | 1 +
 fs/ceph/mds_client.h | 4 +++-
 fs/ceph/super.h      | 2 +-
 5 files changed, 14 insertions(+), 7 deletions(-)
fs/ceph/caps.c +4 -2
index 5f3aa4d607de..17191d6cd3b5 100644
@@ -404,8 +404,8 @@ void ceph_put_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap)
 }
 
 void ceph_reservation_status(struct ceph_fs_client *fsc,
-			     int *total, int *avail, int *used, int *reserved,
-			     int *min)
+			     int *total, int *avail, int *used, int *limit,
+			     int *reserved, int *min)
 {
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 
@@ -417,6 +417,8 @@ void ceph_reservation_status(struct ceph_fs_client *fsc,
 		*avail = mdsc->caps_avail_count;
 	if (used)
 		*used = mdsc->caps_use_count;
+	if (limit)
+		*limit = mdsc->caps_limit;
 	if (reserved)
 		*reserved = mdsc->caps_reserve_count;
 	if (min)
fs/ceph/debugfs.c +5 -3
index 481ac97b4d25..617020261902 100644
@@ -138,16 +138,18 @@ static int caps_show(struct seq_file *s, void *p)
 {
 	struct ceph_fs_client *fsc = s->private;
 	struct ceph_mds_client *mdsc = fsc->mdsc;
-	int total, avail, used, reserved, min, i;
+	int total, avail, used, limit, reserved, min, i;
 	struct cap_wait	*cw;
 
-	ceph_reservation_status(fsc, &total, &avail, &used, &reserved, &min);
+	ceph_reservation_status(fsc, &total, &avail, &used,
+				&limit, &reserved, &min);
 	seq_printf(s, "total\t\t%d\n"
 		   "avail\t\t%d\n"
 		   "used\t\t%d\n"
+		   "limit\t\t%d\n"
 		   "reserved\t%d\n"
 		   "min\t\t%d\n\n",
-		   total, avail, used, reserved, min);
+		   total, avail, used, limit, reserved, min);
 	seq_printf(s, "ino                issued           implemented\n");
 	seq_printf(s, "-----------------------------------------------\n");
 
fs/ceph/mds_client.c +1 -0
index 7c63abf5bea9..d26bc065f5f5 100644
@@ -1920,6 +1920,7 @@ int ceph_trim_caps(struct ceph_mds_client *mdsc,
 		   int max_caps)
 {
 	int trim_caps = session->s_nr_caps - max_caps;
+	mdsc->caps_limit = max_caps;
 
 	dout("trim_caps mds%d start: %d / %d, trim %d\n",
 	     session->s_mds, session->s_nr_caps, max_caps, trim_caps);
fs/ceph/mds_client.h +3 -1
index 903d9edfd4bf..840d47976dbb 100644
@@ -445,7 +445,9 @@ struct ceph_mds_client {
 	struct		list_head cap_wait_list;
 	int		caps_total_count;    /* total caps allocated */
 	int		caps_use_count;      /* in use */
-	int		caps_use_max;	     /* max used caps */
+	int		caps_use_max;	     /* max used caps,
+						limited by client */
+	int		caps_limit;          /* limited by mds */
 	int		caps_reserve_count;  /* unused, reserved */
 	int		caps_avail_count;    /* unused, unreserved */
 	int		caps_min_count;      /* keep at least this many
fs/ceph/super.h +1 -1
index 60aac3aee055..052d7725761d 100644
@@ -700,7 +700,7 @@ extern void ceph_unreserve_caps(struct ceph_mds_client *mdsc,
 			       struct ceph_cap_reservation *ctx);
 extern void ceph_reservation_status(struct ceph_fs_client *client,
 				    int *total, int *avail, int *used,
-				    int *reserved, int *min);
+				    int *limit, int *reserved, int *min);
 
 
 
Signature · 1 line
2.24.3 (Apple Git-128)
#1 lore raw
Quoted 8 lines · Yanhu Cao

before
------
total 1286
avail 1005
used 281
reserved 0
min 1024

Quoted 9 lines

after
-----
total 1286
avail 1005
used 281
limit 261
reserved 0
min 1024

The description should explain what this new field actually _means_.

Quoted 66 lines
---
 fs/ceph/caps.c       | 6 ++++--
 fs/ceph/debugfs.c    | 8 +++++---
 fs/ceph/mds_client.c | 1 +
 fs/ceph/mds_client.h | 4 +++-
 fs/ceph/super.h      | 2 +-
 5 files changed, 14 insertions(+), 7 deletions(-)
fs/ceph/caps.c +4 -2
index 5f3aa4d607de..17191d6cd3b5 100644
@@ -404,8 +404,8 @@ void ceph_put_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap)
 }
 
 void ceph_reservation_status(struct ceph_fs_client *fsc,
-			     int *total, int *avail, int *used, int *reserved,
-			     int *min)
+			     int *total, int *avail, int *used, int *limit,
+			     int *reserved, int *min)
 {
 	struct ceph_mds_client *mdsc = fsc->mdsc;
 
@@ -417,6 +417,8 @@ void ceph_reservation_status(struct ceph_fs_client *fsc,
 		*avail = mdsc->caps_avail_count;
 	if (used)
 		*used = mdsc->caps_use_count;
+	if (limit)
+		*limit = mdsc->caps_limit;
 	if (reserved)
 		*reserved = mdsc->caps_reserve_count;
 	if (min)
fs/ceph/debugfs.c +5 -3
index 481ac97b4d25..617020261902 100644
@@ -138,16 +138,18 @@ static int caps_show(struct seq_file *s, void *p)
 {
 	struct ceph_fs_client *fsc = s->private;
 	struct ceph_mds_client *mdsc = fsc->mdsc;
-	int total, avail, used, reserved, min, i;
+	int total, avail, used, limit, reserved, min, i;
 	struct cap_wait	*cw;
 
-	ceph_reservation_status(fsc, &total, &avail, &used, &reserved, &min);
+	ceph_reservation_status(fsc, &total, &avail, &used,
+				&limit, &reserved, &min);
 	seq_printf(s, "total\t\t%d\n"
 		   "avail\t\t%d\n"
 		   "used\t\t%d\n"
+		   "limit\t\t%d\n"
 		   "reserved\t%d\n"
 		   "min\t\t%d\n\n",
-		   total, avail, used, reserved, min);
+		   total, avail, used, limit, reserved, min);
 	seq_printf(s, "ino                issued           implemented\n");
 	seq_printf(s, "-----------------------------------------------\n");
 
fs/ceph/mds_client.c +0 -0
index 7c63abf5bea9..d26bc065f5f5 100644

fs/ceph/mds_client.c int ceph_trim_caps(struct ceph_mds_client *mdsc, · line 1924

Quoted 5 lines
fs/ceph/mds_client.c +1 -0
@@ -1920,6 +1920,7 @@ int ceph_trim_caps(struct ceph_mds_client *mdsc,
 		   int max_caps)
 {
 	int trim_caps = session->s_nr_caps - max_caps;
+	mdsc->caps_limit = max_caps;
 

I was thinking that you'd track this in handle_session. Note that ceph_trim_caps is called from ceph_reserve_caps as well. There's also some delay between calling ceph_trim_caps and actually releasing them, so it's not clear to me how one should interpret mdsc->caps_limit.

What does that value actually _mean_? I think it would be a lot more straightforward to have this be the limit sent by the MDS (if any). If there is value in tracking it this way then we need to carefully document what it means and how it should be interpreted.

Quoted 30 lines
fs/ceph/mds_client.c +0 -0
 	dout("trim_caps mds%d start: %d / %d, trim %d\n",
 	     session->s_mds, session->s_nr_caps, max_caps, trim_caps);
fs/ceph/mds_client.h +3 -1
index 903d9edfd4bf..840d47976dbb 100644
@@ -445,7 +445,9 @@ struct ceph_mds_client {
 	struct		list_head cap_wait_list;
 	int		caps_total_count;    /* total caps allocated */
 	int		caps_use_count;      /* in use */
-	int		caps_use_max;	     /* max used caps */
+	int		caps_use_max;	     /* max used caps,
+						limited by client */
+	int		caps_limit;          /* limited by mds */
 	int		caps_reserve_count;  /* unused, reserved */
 	int		caps_avail_count;    /* unused, unreserved */
 	int		caps_min_count;      /* keep at least this many
fs/ceph/super.h +1 -1
index 60aac3aee055..052d7725761d 100644
@@ -700,7 +700,7 @@ extern void ceph_unreserve_caps(struct ceph_mds_client *mdsc,
 			       struct ceph_cap_reservation *ctx);
 extern void ceph_reservation_status(struct ceph_fs_client *client,
 				    int *total, int *avail, int *used,
-				    int *reserved, int *min);
+				    int *limit, int *reserved, int *min);
 
 
 
Signature · 1 line
Jeff Layton <[email protected]>