diff options
author | Sage Weil <sage@newdream.net> | 2010-05-10 19:31:25 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-05-17 18:25:35 -0400 |
commit | 34b6c855fafc54ef130649809cd580f98e3f8416 (patch) | |
tree | e66408bc69b59a8a096feeadda16984c3da563e4 /fs/ceph/mds_client.c | |
parent | 29790f26ab3e63b2a083f0811b80e2f086e4fcb2 (diff) |
ceph: clean up send_mds_reconnect interface
Pass a ceph_mds_session, since the caller has it.
Remove the dead code for sending empty reconnects. It used to be used
when the MDS contacted _us_ to solicit a reconnect, and we could reply
saying "go away, I have no session." Now we only send reconnects based
on the mds map, and only when we do in fact have an open session.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/mds_client.c')
-rw-r--r-- | fs/ceph/mds_client.c | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 972ec5ae2ac4..e310b4be5588 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -2177,50 +2177,38 @@ out: | |||
2177 | * | 2177 | * |
2178 | * called with mdsc->mutex held. | 2178 | * called with mdsc->mutex held. |
2179 | */ | 2179 | */ |
2180 | static void send_mds_reconnect(struct ceph_mds_client *mdsc, int mds) | 2180 | static void send_mds_reconnect(struct ceph_mds_client *mdsc, |
2181 | struct ceph_mds_session *session) | ||
2181 | { | 2182 | { |
2182 | struct ceph_mds_session *session = NULL; | ||
2183 | struct ceph_msg *reply; | 2183 | struct ceph_msg *reply; |
2184 | struct rb_node *p; | 2184 | struct rb_node *p; |
2185 | int mds = session->s_mds; | ||
2185 | int err = -ENOMEM; | 2186 | int err = -ENOMEM; |
2186 | struct ceph_pagelist *pagelist; | 2187 | struct ceph_pagelist *pagelist; |
2187 | 2188 | ||
2188 | pr_info("reconnect to recovering mds%d\n", mds); | 2189 | pr_info("mds%d reconnect start\n", mds); |
2189 | 2190 | ||
2190 | pagelist = kmalloc(sizeof(*pagelist), GFP_NOFS); | 2191 | pagelist = kmalloc(sizeof(*pagelist), GFP_NOFS); |
2191 | if (!pagelist) | 2192 | if (!pagelist) |
2192 | goto fail_nopagelist; | 2193 | goto fail_nopagelist; |
2193 | ceph_pagelist_init(pagelist); | 2194 | ceph_pagelist_init(pagelist); |
2194 | 2195 | ||
2195 | err = -ENOMEM; | ||
2196 | reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0); | 2196 | reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0); |
2197 | if (!reply) | 2197 | if (!reply) |
2198 | goto fail_nomsg; | 2198 | goto fail_nomsg; |
2199 | 2199 | ||
2200 | /* find session */ | 2200 | mutex_lock(&session->s_mutex); |
2201 | session = __ceph_lookup_mds_session(mdsc, mds); | 2201 | session->s_state = CEPH_MDS_SESSION_RECONNECTING; |
2202 | mutex_unlock(&mdsc->mutex); /* drop lock for duration */ | 2202 | session->s_seq = 0; |
2203 | |||
2204 | if (session) { | ||
2205 | mutex_lock(&session->s_mutex); | ||
2206 | |||
2207 | session->s_state = CEPH_MDS_SESSION_RECONNECTING; | ||
2208 | session->s_seq = 0; | ||
2209 | 2203 | ||
2210 | ceph_con_open(&session->s_con, | 2204 | ceph_con_open(&session->s_con, |
2211 | ceph_mdsmap_get_addr(mdsc->mdsmap, mds)); | 2205 | ceph_mdsmap_get_addr(mdsc->mdsmap, mds)); |
2212 | 2206 | ||
2213 | /* replay unsafe requests */ | 2207 | /* replay unsafe requests */ |
2214 | replay_unsafe_requests(mdsc, session); | 2208 | replay_unsafe_requests(mdsc, session); |
2215 | } else { | ||
2216 | dout("no session for mds%d, will send short reconnect\n", | ||
2217 | mds); | ||
2218 | } | ||
2219 | 2209 | ||
2220 | down_read(&mdsc->snap_rwsem); | 2210 | down_read(&mdsc->snap_rwsem); |
2221 | 2211 | ||
2222 | if (!session) | ||
2223 | goto send; | ||
2224 | dout("session %p state %s\n", session, | 2212 | dout("session %p state %s\n", session, |
2225 | session_state_name(session->s_state)); | 2213 | session_state_name(session->s_state)); |
2226 | 2214 | ||
@@ -2255,7 +2243,6 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc, int mds) | |||
2255 | goto fail; | 2243 | goto fail; |
2256 | } | 2244 | } |
2257 | 2245 | ||
2258 | send: | ||
2259 | reply->pagelist = pagelist; | 2246 | reply->pagelist = pagelist; |
2260 | reply->hdr.data_len = cpu_to_le32(pagelist->length); | 2247 | reply->hdr.data_len = cpu_to_le32(pagelist->length); |
2261 | reply->nr_pages = calc_pages_for(0, pagelist->length); | 2248 | reply->nr_pages = calc_pages_for(0, pagelist->length); |
@@ -2267,23 +2254,18 @@ send: | |||
2267 | __wake_requests(mdsc, &session->s_waiting); | 2254 | __wake_requests(mdsc, &session->s_waiting); |
2268 | mutex_unlock(&mdsc->mutex); | 2255 | mutex_unlock(&mdsc->mutex); |
2269 | 2256 | ||
2270 | ceph_put_mds_session(session); | ||
2271 | |||
2272 | up_read(&mdsc->snap_rwsem); | 2257 | up_read(&mdsc->snap_rwsem); |
2273 | mutex_lock(&mdsc->mutex); | ||
2274 | return; | 2258 | return; |
2275 | 2259 | ||
2276 | fail: | 2260 | fail: |
2277 | ceph_msg_put(reply); | 2261 | ceph_msg_put(reply); |
2278 | up_read(&mdsc->snap_rwsem); | 2262 | up_read(&mdsc->snap_rwsem); |
2279 | mutex_unlock(&session->s_mutex); | 2263 | mutex_unlock(&session->s_mutex); |
2280 | ceph_put_mds_session(session); | ||
2281 | fail_nomsg: | 2264 | fail_nomsg: |
2282 | ceph_pagelist_release(pagelist); | 2265 | ceph_pagelist_release(pagelist); |
2283 | kfree(pagelist); | 2266 | kfree(pagelist); |
2284 | fail_nopagelist: | 2267 | fail_nopagelist: |
2285 | pr_err("error %d preparing reconnect for mds%d\n", err, mds); | 2268 | pr_err("error %d preparing reconnect for mds%d\n", err, mds); |
2286 | mutex_lock(&mdsc->mutex); | ||
2287 | return; | 2269 | return; |
2288 | } | 2270 | } |
2289 | 2271 | ||
@@ -2345,8 +2327,11 @@ static void check_new_map(struct ceph_mds_client *mdsc, | |||
2345 | * send reconnect? | 2327 | * send reconnect? |
2346 | */ | 2328 | */ |
2347 | if (s->s_state == CEPH_MDS_SESSION_RESTARTING && | 2329 | if (s->s_state == CEPH_MDS_SESSION_RESTARTING && |
2348 | newstate >= CEPH_MDS_STATE_RECONNECT) | 2330 | newstate >= CEPH_MDS_STATE_RECONNECT) { |
2349 | send_mds_reconnect(mdsc, i); | 2331 | mutex_unlock(&mdsc->mutex); |
2332 | send_mds_reconnect(mdsc, s); | ||
2333 | mutex_lock(&mdsc->mutex); | ||
2334 | } | ||
2350 | 2335 | ||
2351 | /* | 2336 | /* |
2352 | * kick request on any mds that has gone active. | 2337 | * kick request on any mds that has gone active. |