diff options
author | Sage Weil <sage@newdream.net> | 2010-04-01 19:06:19 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-05-17 18:25:18 -0400 |
commit | a79832f26be370ee26ea81eecdfd42d10e49d66a (patch) | |
tree | 59d55f3c928558505a420830eddfb01b3186d467 /fs/ceph/mds_client.c | |
parent | d52f847a841bfeba0ea87a7842732d388a1ca2e8 (diff) |
ceph: make ceph_msg_new return NULL on failure; clean up, fix callers
Returning ERR_PTR(-ENOMEM) is useless extra work. Return NULL on failure
instead, and fix up the callers (about half of which were wrong anyway).
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/mds_client.c')
-rw-r--r-- | fs/ceph/mds_client.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index d549ab3adfda..7e89c185d38d 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -666,9 +666,9 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq) | |||
666 | struct ceph_mds_session_head *h; | 666 | struct ceph_mds_session_head *h; |
667 | 667 | ||
668 | msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), 0, 0, NULL); | 668 | msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), 0, 0, NULL); |
669 | if (IS_ERR(msg)) { | 669 | if (!msg) { |
670 | pr_err("create_session_msg ENOMEM creating msg\n"); | 670 | pr_err("create_session_msg ENOMEM creating msg\n"); |
671 | return ERR_PTR(PTR_ERR(msg)); | 671 | return NULL; |
672 | } | 672 | } |
673 | h = msg->front.iov_base; | 673 | h = msg->front.iov_base; |
674 | h->op = cpu_to_le32(op); | 674 | h->op = cpu_to_le32(op); |
@@ -687,7 +687,6 @@ static int __open_session(struct ceph_mds_client *mdsc, | |||
687 | struct ceph_msg *msg; | 687 | struct ceph_msg *msg; |
688 | int mstate; | 688 | int mstate; |
689 | int mds = session->s_mds; | 689 | int mds = session->s_mds; |
690 | int err = 0; | ||
691 | 690 | ||
692 | /* wait for mds to go active? */ | 691 | /* wait for mds to go active? */ |
693 | mstate = ceph_mdsmap_get_state(mdsc->mdsmap, mds); | 692 | mstate = ceph_mdsmap_get_state(mdsc->mdsmap, mds); |
@@ -698,13 +697,9 @@ static int __open_session(struct ceph_mds_client *mdsc, | |||
698 | 697 | ||
699 | /* send connect message */ | 698 | /* send connect message */ |
700 | msg = create_session_msg(CEPH_SESSION_REQUEST_OPEN, session->s_seq); | 699 | msg = create_session_msg(CEPH_SESSION_REQUEST_OPEN, session->s_seq); |
701 | if (IS_ERR(msg)) { | 700 | if (!msg) |
702 | err = PTR_ERR(msg); | 701 | return -ENOMEM; |
703 | goto out; | ||
704 | } | ||
705 | ceph_con_send(&session->s_con, msg); | 702 | ceph_con_send(&session->s_con, msg); |
706 | |||
707 | out: | ||
708 | return 0; | 703 | return 0; |
709 | } | 704 | } |
710 | 705 | ||
@@ -883,8 +878,8 @@ static int send_renew_caps(struct ceph_mds_client *mdsc, | |||
883 | ceph_mds_state_name(state)); | 878 | ceph_mds_state_name(state)); |
884 | msg = create_session_msg(CEPH_SESSION_REQUEST_RENEWCAPS, | 879 | msg = create_session_msg(CEPH_SESSION_REQUEST_RENEWCAPS, |
885 | ++session->s_renew_seq); | 880 | ++session->s_renew_seq); |
886 | if (IS_ERR(msg)) | 881 | if (!msg) |
887 | return PTR_ERR(msg); | 882 | return -ENOMEM; |
888 | ceph_con_send(&session->s_con, msg); | 883 | ceph_con_send(&session->s_con, msg); |
889 | return 0; | 884 | return 0; |
890 | } | 885 | } |
@@ -931,17 +926,15 @@ static int request_close_session(struct ceph_mds_client *mdsc, | |||
931 | struct ceph_mds_session *session) | 926 | struct ceph_mds_session *session) |
932 | { | 927 | { |
933 | struct ceph_msg *msg; | 928 | struct ceph_msg *msg; |
934 | int err = 0; | ||
935 | 929 | ||
936 | dout("request_close_session mds%d state %s seq %lld\n", | 930 | dout("request_close_session mds%d state %s seq %lld\n", |
937 | session->s_mds, session_state_name(session->s_state), | 931 | session->s_mds, session_state_name(session->s_state), |
938 | session->s_seq); | 932 | session->s_seq); |
939 | msg = create_session_msg(CEPH_SESSION_REQUEST_CLOSE, session->s_seq); | 933 | msg = create_session_msg(CEPH_SESSION_REQUEST_CLOSE, session->s_seq); |
940 | if (IS_ERR(msg)) | 934 | if (!msg) |
941 | err = PTR_ERR(msg); | 935 | return -ENOMEM; |
942 | else | 936 | ceph_con_send(&session->s_con, msg); |
943 | ceph_con_send(&session->s_con, msg); | 937 | return 0; |
944 | return err; | ||
945 | } | 938 | } |
946 | 939 | ||
947 | /* | 940 | /* |
@@ -1426,8 +1419,10 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc, | |||
1426 | len += req->r_old_dentry->d_name.len; | 1419 | len += req->r_old_dentry->d_name.len; |
1427 | 1420 | ||
1428 | msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, 0, 0, NULL); | 1421 | msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, 0, 0, NULL); |
1429 | if (IS_ERR(msg)) | 1422 | if (!msg) { |
1423 | msg = ERR_PTR(-ENOMEM); | ||
1430 | goto out_free2; | 1424 | goto out_free2; |
1425 | } | ||
1431 | 1426 | ||
1432 | msg->hdr.tid = cpu_to_le64(req->r_tid); | 1427 | msg->hdr.tid = cpu_to_le64(req->r_tid); |
1433 | 1428 | ||
@@ -1518,7 +1513,7 @@ static int __prepare_send_request(struct ceph_mds_client *mdsc, | |||
1518 | if (IS_ERR(msg)) { | 1513 | if (IS_ERR(msg)) { |
1519 | req->r_err = PTR_ERR(msg); | 1514 | req->r_err = PTR_ERR(msg); |
1520 | complete_request(mdsc, req); | 1515 | complete_request(mdsc, req); |
1521 | return -PTR_ERR(msg); | 1516 | return PTR_ERR(msg); |
1522 | } | 1517 | } |
1523 | req->r_request = msg; | 1518 | req->r_request = msg; |
1524 | 1519 | ||
@@ -2158,11 +2153,10 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc, int mds) | |||
2158 | goto fail_nopagelist; | 2153 | goto fail_nopagelist; |
2159 | ceph_pagelist_init(pagelist); | 2154 | ceph_pagelist_init(pagelist); |
2160 | 2155 | ||
2156 | err = -ENOMEM; | ||
2161 | reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, 0, 0, NULL); | 2157 | reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, 0, 0, NULL); |
2162 | if (IS_ERR(reply)) { | 2158 | if (!reply) |
2163 | err = PTR_ERR(reply); | ||
2164 | goto fail_nomsg; | 2159 | goto fail_nomsg; |
2165 | } | ||
2166 | 2160 | ||
2167 | /* find session */ | 2161 | /* find session */ |
2168 | session = __ceph_lookup_mds_session(mdsc, mds); | 2162 | session = __ceph_lookup_mds_session(mdsc, mds); |
@@ -2469,7 +2463,7 @@ void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session, | |||
2469 | len += dnamelen; | 2463 | len += dnamelen; |
2470 | 2464 | ||
2471 | msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, 0, 0, NULL); | 2465 | msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, 0, 0, NULL); |
2472 | if (IS_ERR(msg)) | 2466 | if (!msg) |
2473 | return; | 2467 | return; |
2474 | lease = msg->front.iov_base; | 2468 | lease = msg->front.iov_base; |
2475 | lease->action = action; | 2469 | lease->action = action; |