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
14261426 __send_request(osdc, req);
14271427 }
14281428
1429+/*
1430+ * Caller should hold map_sem for read and request_mutex.
1431+ */
1432+static 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+
14291463 /*
14301464 * Timeout callback, called every N seconds when 1 or more osd
14311465 * 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
23512385 struct ceph_osd_request *req,
23522386 bool nofail)
23532387 {
2354− int rc = 0;
2388+ int rc;
23552389
23562390 down_read(&osdc->map_sem);
23572391 mutex_lock(&osdc->request_mutex);
2358− __register_request(osdc, req);
2359− req->r_sent = 0;
2360− req->r_got_reply = 0;
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;
2379−out_unlock:
2392+
2393+ rc = __ceph_osdc_start_request(osdc, req, nofail);
2394+
23802395 mutex_unlock(&osdc->request_mutex);
23812396 up_read(&osdc->map_sem);
2397+
23822398 return rc;
23832399 }
23842400 EXPORT_SYMBOL(ceph_osdc_start_request);