History

libceph: factor out logic from ceph_osdc_start_request()

Factor out logic from ceph_osdc_start_request() into a new helper, __ceph_osdc_start_request(). ceph_osdc_start_request() now amounts to taking locks and calling __ceph_osdc_start_request().

Ilya Dryomov committed 12 years ago

Commit 0bbfdfe1 parent c172ec51 file · +39 −23Browse files

Unified · Split

net/ceph/osd_client.c+39−23
@@ -1426,6 +1426,40 @@ static void __send_queued(struct ceph_osd_client *osdc) · 1425 unmodified lines
1426 __send_request(osdc, req);1426 __send_request(osdc, req);
1427}1427}
1428 1428
1429/*
1430 * Caller should hold map_sem for read and request_mutex.
1431 */
1432static int __ceph_osdc_start_request(struct ceph_osd_client *osdc,
1433 struct ceph_osd_request *req,
1434 bool nofail)
1435{
1436 int rc;
1437
1438 __register_request(osdc, req);
1439 req->r_sent = 0;
1440 req->r_got_reply = 0;
1441 rc = __map_request(osdc, req, 0);
1442 if (rc < 0) {
1443 if (nofail) {
1444 dout("osdc_start_request failed map, "
1445 " will retry %lld\n", req->r_tid);
1446 rc = 0;
1447 } else {
1448 __unregister_request(osdc, req);
1449 }
1450 return rc;
1451 }
1452
1453 if (req->r_osd == NULL) {
1454 dout("send_request %p no up osds in pg\n", req);
1455 ceph_monc_request_next_osdmap(&osdc->client->monc);
1456 } else {
1457 __send_queued(osdc);
1458 }
1459
1460 return 0;
1461}
1462
1429/*1463/*
1430 * Timeout callback, called every N seconds when 1 or more osd1464 * Timeout callback, called every N seconds when 1 or more osd
1431 * requests has been active for more than N seconds. When this1465 * requests has been active for more than N seconds. When this
@@ -2351,34 +2385,16 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc, · 919 unmodified lines
2351 struct ceph_osd_request *req,2385 struct ceph_osd_request *req,
2352 bool nofail)2386 bool nofail)
2353{2387{
2354 int rc = 0;2388 int rc;
2355 2389
2356 down_read(&osdc->map_sem);2390 down_read(&osdc->map_sem);
2357 mutex_lock(&osdc->request_mutex);2391 mutex_lock(&osdc->request_mutex);
2358 __register_request(osdc, req);2392
2359 req->r_sent = 0;2393 rc = __ceph_osdc_start_request(osdc, req, nofail);
2360 req->r_got_reply = 0;2394
2361 rc = __map_request(osdc, req, 0);
2362 if (rc < 0) {
2363 if (nofail) {
2364 dout("osdc_start_request failed map, "
2365 " will retry %lld\n", req->r_tid);
2366 rc = 0;
2367 } else {
2368 __unregister_request(osdc, req);
2369 }
2370 goto out_unlock;
2371 }
2372 if (req->r_osd == NULL) {
2373 dout("send_request %p no up osds in pg\n", req);
2374 ceph_monc_request_next_osdmap(&osdc->client->monc);
2375 } else {
2376 __send_queued(osdc);
2377 }
2378 rc = 0;
2379out_unlock:
2380 mutex_unlock(&osdc->request_mutex);2395 mutex_unlock(&osdc->request_mutex);
2381 up_read(&osdc->map_sem);2396 up_read(&osdc->map_sem);
2397
2382 return rc;2398 return rc;
2383}2399}
2384EXPORT_SYMBOL(ceph_osdc_start_request);2400EXPORT_SYMBOL(ceph_osdc_start_request);