[PATCH 5/6] ceph: let ceph_trim_caps() return trimmed cap number

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When we failed allocating new cap in ceph_reserve_caps(),
then try to trim existing caps from every session and try to
reserve caps again. However, if we do not return trimmed cap
number from ceph_trim_caps(), we cannot know how many caps
released by one session, so we have to wait until trimming
finish on all sessions. Sometimes, maybe a few of sessions
(not all) can release enough caps so that we can do reservation
more effectively.

This patch let ceph_trim_caps() return trimmed cap number,
so ceph_reserve_caps() can use this for optimization.

Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx>
---
 fs/ceph/mds_client.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index d01a262ba691..edccf2353912 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1611,20 +1611,22 @@ int ceph_trim_caps(struct ceph_mds_client *mdsc,
 		   int max_caps)
 {
 	int trim_caps = session->s_nr_caps - max_caps;
+	int trimmed_caps = 0;
 
 	dout("trim_caps mds%d start: %d / %d, trim %d\n",
 	     session->s_mds, session->s_nr_caps, max_caps, trim_caps);
 	if (trim_caps > 0) {
 		session->s_trim_caps = trim_caps;
 		iterate_session_caps(session, trim_caps_cb, session);
+		trimmed_caps = trim_caps - session->s_trim_caps;
 		dout("trim_caps mds%d done: %d / %d, trimmed %d\n",
 		     session->s_mds, session->s_nr_caps, max_caps,
-			trim_caps - session->s_trim_caps);
+			trimmed_caps);
 		session->s_trim_caps = 0;
 	}
 
 	ceph_send_cap_releases(mdsc, session);
-	return 0;
+	return trimmed_caps;
 }
 
 static int check_caps_flush(struct ceph_mds_client *mdsc,
-- 
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux