diff options
author | Sage Weil <sage@newdream.net> | 2010-06-10 15:57:11 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-08-01 23:11:39 -0400 |
commit | 38e8883ee31667d901feb9106f4863af35948c91 (patch) | |
tree | 2b36df7cde625b72a43adf9d6ad998a46b8c5b04 /fs/ceph/mds_client.c | |
parent | ee6b272b9c3447a78fa831e37b925aefd5587ec9 (diff) |
ceph: simplify add_cap_releases
No functional change, aside from more useful debug output.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/mds_client.c')
-rw-r--r-- | fs/ceph/mds_client.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 26a5368e91f2..774407f96ff1 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -1069,11 +1069,14 @@ static int trim_caps(struct ceph_mds_client *mdsc, | |||
1069 | int ceph_add_cap_releases(struct ceph_mds_client *mdsc, | 1069 | int ceph_add_cap_releases(struct ceph_mds_client *mdsc, |
1070 | struct ceph_mds_session *session) | 1070 | struct ceph_mds_session *session) |
1071 | { | 1071 | { |
1072 | struct ceph_msg *msg; | 1072 | struct ceph_msg *msg, *partial = NULL; |
1073 | struct ceph_mds_cap_release *head; | 1073 | struct ceph_mds_cap_release *head; |
1074 | int err = -ENOMEM; | 1074 | int err = -ENOMEM; |
1075 | int extra = mdsc->client->mount_args->cap_release_safety; | 1075 | int extra = mdsc->client->mount_args->cap_release_safety; |
1076 | int num; | ||
1076 | 1077 | ||
1078 | dout("add_cap_releases %p mds%d extra %d\n", session, session->s_mds, | ||
1079 | extra); | ||
1077 | 1080 | ||
1078 | spin_lock(&session->s_cap_lock); | 1081 | spin_lock(&session->s_cap_lock); |
1079 | 1082 | ||
@@ -1082,9 +1085,14 @@ int ceph_add_cap_releases(struct ceph_mds_client *mdsc, | |||
1082 | struct ceph_msg, | 1085 | struct ceph_msg, |
1083 | list_head); | 1086 | list_head); |
1084 | head = msg->front.iov_base; | 1087 | head = msg->front.iov_base; |
1085 | extra += CEPH_CAPS_PER_RELEASE - le32_to_cpu(head->num); | 1088 | num = le32_to_cpu(head->num); |
1089 | if (num) { | ||
1090 | dout(" partial %p with (%d/%d)\n", msg, num, | ||
1091 | (int)CEPH_CAPS_PER_RELEASE); | ||
1092 | extra += CEPH_CAPS_PER_RELEASE - num; | ||
1093 | partial = msg; | ||
1094 | } | ||
1086 | } | 1095 | } |
1087 | |||
1088 | while (session->s_num_cap_releases < session->s_nr_caps + extra) { | 1096 | while (session->s_num_cap_releases < session->s_nr_caps + extra) { |
1089 | spin_unlock(&session->s_cap_lock); | 1097 | spin_unlock(&session->s_cap_lock); |
1090 | msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE, | 1098 | msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE, |
@@ -1101,19 +1109,14 @@ int ceph_add_cap_releases(struct ceph_mds_client *mdsc, | |||
1101 | session->s_num_cap_releases += CEPH_CAPS_PER_RELEASE; | 1109 | session->s_num_cap_releases += CEPH_CAPS_PER_RELEASE; |
1102 | } | 1110 | } |
1103 | 1111 | ||
1104 | if (!list_empty(&session->s_cap_releases)) { | 1112 | if (partial) { |
1105 | msg = list_first_entry(&session->s_cap_releases, | 1113 | head = partial->front.iov_base; |
1106 | struct ceph_msg, | 1114 | num = le32_to_cpu(head->num); |
1107 | list_head); | 1115 | dout(" queueing partial %p with %d/%d\n", partial, num, |
1108 | head = msg->front.iov_base; | 1116 | (int)CEPH_CAPS_PER_RELEASE); |
1109 | if (head->num) { | 1117 | list_move_tail(&partial->list_head, |
1110 | dout(" queueing non-full %p (%d)\n", msg, | 1118 | &session->s_cap_releases_done); |
1111 | le32_to_cpu(head->num)); | 1119 | session->s_num_cap_releases -= CEPH_CAPS_PER_RELEASE - num; |
1112 | list_move_tail(&msg->list_head, | ||
1113 | &session->s_cap_releases_done); | ||
1114 | session->s_num_cap_releases -= | ||
1115 | CEPH_CAPS_PER_RELEASE - le32_to_cpu(head->num); | ||
1116 | } | ||
1117 | } | 1120 | } |
1118 | err = 0; | 1121 | err = 0; |
1119 | spin_unlock(&session->s_cap_lock); | 1122 | spin_unlock(&session->s_cap_lock); |