From: Yehuda Sadeh Date: Fri, 24 Jan 2014 01:04:06 +0000 (-0800) Subject: rgw, cls_user: handle error cases related to response decoding X-Git-Tag: v0.78~270^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5dc8d6583d5fe107a26fec9d3ca354c6ee6e588;p=ceph.git rgw, cls_user: handle error cases related to response decoding Certain operations weren't handling errors in decode, add some missing logic. Signed-off-by: Yehuda Sadeh --- diff --git a/src/cls/user/cls_user_client.cc b/src/cls/user/cls_user_client.cc index d2f4b366fd74..d86c5bfc3ced 100644 --- a/src/cls/user/cls_user_client.cc +++ b/src/cls/user/cls_user_client.cc @@ -45,9 +45,10 @@ class ClsUserListCtx : public ObjectOperationCompletion { list *entries; string *marker; bool *truncated; + int *pret; public: - ClsUserListCtx(list *_entries, string *_marker, bool *_truncated) : - entries(_entries), marker(_marker), truncated(_truncated) {} + ClsUserListCtx(list *_entries, string *_marker, bool *_truncated, int *_pret) : + entries(_entries), marker(_marker), truncated(_truncated), pret(_pret) {} void handle_completion(int r, bufferlist& outbl) { if (r >= 0) { cls_user_list_buckets_ret ret; @@ -61,15 +62,18 @@ public: if (marker) *marker = ret.marker; } catch (buffer::error& err) { - // nothing we can do about it atm + r = -EIO; } } + if (pret) { + *pret = r; + } } }; void cls_user_bucket_list(librados::ObjectReadOperation& op, const string& in_marker, int max_entries, list& entries, - string *out_marker, bool *truncated) + string *out_marker, bool *truncated, int *pret) { bufferlist inbl; cls_user_list_buckets_op call; @@ -78,14 +82,15 @@ void cls_user_bucket_list(librados::ObjectReadOperation& op, ::encode(call, inbl); - op.exec("user", "list_buckets", inbl, new ClsUserListCtx(&entries, out_marker, truncated)); + op.exec("user", "list_buckets", inbl, new ClsUserListCtx(&entries, out_marker, truncated, pret)); } class ClsUserGetHeaderCtx : public ObjectOperationCompletion { cls_user_header *header; RGWGetUserHeader_CB *ret_ctx; + int *pret; public: - ClsUserGetHeaderCtx(cls_user_header *_h, RGWGetUserHeader_CB *_ctx) : header(_h), ret_ctx(_ctx) {} + ClsUserGetHeaderCtx(cls_user_header *_h, RGWGetUserHeader_CB *_ctx, int *_pret) : header(_h), ret_ctx(_ctx), pret(_pret) {} ~ClsUserGetHeaderCtx() { if (ret_ctx) { ret_ctx->put(); @@ -100,24 +105,27 @@ public: if (header) *header = ret.header; } catch (buffer::error& err) { - // nothing we can do about it atm + r = -EIO; } if (ret_ctx) { ret_ctx->handle_response(r, ret.header); } } + if (pret) { + *pret = r; + } } }; void cls_user_get_header(librados::ObjectReadOperation& op, - cls_user_header *header) + cls_user_header *header, int *pret) { bufferlist inbl; cls_user_get_header_op call; ::encode(call, inbl); - op.exec("user", "get_header", inbl, new ClsUserGetHeaderCtx(header, NULL)); + op.exec("user", "get_header", inbl, new ClsUserGetHeaderCtx(header, NULL, pret)); } int cls_user_get_header_async(IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *ctx) @@ -126,7 +134,7 @@ int cls_user_get_header_async(IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *c cls_user_get_header_op call; ::encode(call, in); ObjectReadOperation op; - op.exec("user", "get_header", in, new ClsUserGetHeaderCtx(NULL, ctx)); + op.exec("user", "get_header", in, new ClsUserGetHeaderCtx(NULL, ctx, NULL)); /* no need to pass pret, as we'll call ctx->handle_response() with correct error */ AioCompletion *c = librados::Rados::aio_create_completion(NULL, NULL, NULL); int r = io_ctx.aio_operate(oid, c, &op, NULL); c->release(); diff --git a/src/cls/user/cls_user_client.h b/src/cls/user/cls_user_client.h index 62e96294997c..dcfdab6f6c4f 100644 --- a/src/cls/user/cls_user_client.h +++ b/src/cls/user/cls_user_client.h @@ -25,8 +25,9 @@ void cls_user_remove_bucket(librados::ObjectWriteOperation& op, const cls_user_ void cls_user_bucket_list(librados::ObjectReadOperation& op, const string& in_marker, int max_entries, list& entries, - string *out_marker, bool *truncated); -void cls_user_get_header(librados::ObjectReadOperation& op, cls_user_header *header); + string *out_marker, bool *truncated, + int *pret); +void cls_user_get_header(librados::ObjectReadOperation& op, cls_user_header *header, int *pret); int cls_user_get_header_async(librados::IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *ctx); #endif diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 2dbcd52595d1..af3afe51a92c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5675,11 +5675,14 @@ int RGWRados::cls_user_get_header(const string& user_id, cls_user_header *header return r; librados::ObjectReadOperation op; - ::cls_user_get_header(op, header); + int rc; + ::cls_user_get_header(op, header, &rc); bufferlist ibl; r = io_ctx.operate(oid, &op, &ibl); if (r < 0) return r; + if (rc < 0) + return rc; return 0; } @@ -5776,11 +5779,15 @@ int RGWRados::cls_user_list_buckets(rgw_obj& obj, return r; librados::ObjectReadOperation op; - cls_user_bucket_list(op, in_marker, max_entries, entries, out_marker, truncated); + int rc; + + cls_user_bucket_list(op, in_marker, max_entries, entries, out_marker, truncated, &rc); bufferlist ibl; r = io_ctx.operate(oid, &op, &ibl); if (r < 0) return r; + if (rc < 0) + return rc; return 0; }