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/messenger.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/messenger.c')
-rw-r--r-- | fs/ceph/messenger.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index af3b143fbf02..fe7d0c52ae3c 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -1402,19 +1402,17 @@ static int read_partial_message(struct ceph_connection *con) | |||
1402 | con->in_msg = ceph_alloc_msg(con, &con->in_hdr, &skip); | 1402 | con->in_msg = ceph_alloc_msg(con, &con->in_hdr, &skip); |
1403 | if (skip) { | 1403 | if (skip) { |
1404 | /* skip this message */ | 1404 | /* skip this message */ |
1405 | dout("alloc_msg returned NULL, skipping message\n"); | 1405 | dout("alloc_msg said skip message\n"); |
1406 | con->in_base_pos = -front_len - middle_len - data_len - | 1406 | con->in_base_pos = -front_len - middle_len - data_len - |
1407 | sizeof(m->footer); | 1407 | sizeof(m->footer); |
1408 | con->in_tag = CEPH_MSGR_TAG_READY; | 1408 | con->in_tag = CEPH_MSGR_TAG_READY; |
1409 | con->in_seq++; | 1409 | con->in_seq++; |
1410 | return 0; | 1410 | return 0; |
1411 | } | 1411 | } |
1412 | if (IS_ERR(con->in_msg)) { | 1412 | if (!con->in_msg) { |
1413 | ret = PTR_ERR(con->in_msg); | ||
1414 | con->in_msg = NULL; | ||
1415 | con->error_msg = | 1413 | con->error_msg = |
1416 | "error allocating memory for incoming message"; | 1414 | "error allocating memory for incoming message"; |
1417 | return ret; | 1415 | return -ENOMEM; |
1418 | } | 1416 | } |
1419 | m = con->in_msg; | 1417 | m = con->in_msg; |
1420 | m->front.iov_len = 0; /* haven't read it yet */ | 1418 | m->front.iov_len = 0; /* haven't read it yet */ |
@@ -2147,7 +2145,7 @@ out2: | |||
2147 | ceph_msg_put(m); | 2145 | ceph_msg_put(m); |
2148 | out: | 2146 | out: |
2149 | pr_err("msg_new can't create type %d len %d\n", type, front_len); | 2147 | pr_err("msg_new can't create type %d len %d\n", type, front_len); |
2150 | return ERR_PTR(-ENOMEM); | 2148 | return NULL; |
2151 | } | 2149 | } |
2152 | 2150 | ||
2153 | /* | 2151 | /* |
@@ -2190,10 +2188,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con, | |||
2190 | mutex_unlock(&con->mutex); | 2188 | mutex_unlock(&con->mutex); |
2191 | msg = con->ops->alloc_msg(con, hdr, skip); | 2189 | msg = con->ops->alloc_msg(con, hdr, skip); |
2192 | mutex_lock(&con->mutex); | 2190 | mutex_lock(&con->mutex); |
2193 | if (IS_ERR(msg)) | 2191 | if (!msg || *skip) |
2194 | return msg; | ||
2195 | |||
2196 | if (*skip) | ||
2197 | return NULL; | 2192 | return NULL; |
2198 | } | 2193 | } |
2199 | if (!msg) { | 2194 | if (!msg) { |
@@ -2202,17 +2197,16 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con, | |||
2202 | if (!msg) { | 2197 | if (!msg) { |
2203 | pr_err("unable to allocate msg type %d len %d\n", | 2198 | pr_err("unable to allocate msg type %d len %d\n", |
2204 | type, front_len); | 2199 | type, front_len); |
2205 | return ERR_PTR(-ENOMEM); | 2200 | return NULL; |
2206 | } | 2201 | } |
2207 | } | 2202 | } |
2208 | memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr)); | 2203 | memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr)); |
2209 | 2204 | ||
2210 | if (middle_len) { | 2205 | if (middle_len) { |
2211 | ret = ceph_alloc_middle(con, msg); | 2206 | ret = ceph_alloc_middle(con, msg); |
2212 | |||
2213 | if (ret < 0) { | 2207 | if (ret < 0) { |
2214 | ceph_msg_put(msg); | 2208 | ceph_msg_put(msg); |
2215 | return msg; | 2209 | return NULL; |
2216 | } | 2210 | } |
2217 | } | 2211 | } |
2218 | 2212 | ||