Skip to content

Commit

Permalink
Merge pull request ceph#8550 from xiexingguo/xxg-wip-cls
Browse files Browse the repository at this point in the history
objclass: honour do_osd_ops() results before going any further

Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed May 4, 2016
2 parents e1dd16f + 8647cd9 commit 83f6e12
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/objclass/class_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ int cls_call(cls_method_context_t hctx, const char *cls, const char *method,
op.indata.append(method, op.op.cls.method_len);
op.indata.append(indata, datalen);
r = (*pctx)->pg->do_osd_ops(*pctx, nops);
if (r < 0)
return r;

*outdata = (char *)malloc(op.outdata.length());
if (!*outdata)
Expand All @@ -143,6 +145,8 @@ int cls_getxattr(cls_method_context_t hctx, const char *name,
op.indata.append(name);
op.op.xattr.name_len = strlen(name);
r = (*pctx)->pg->do_osd_ops(*pctx, nops);
if (r < 0)
return r;

*outdata = (char *)malloc(op.outdata.length());
if (!*outdata)
Expand Down Expand Up @@ -181,16 +185,15 @@ int cls_read(cls_method_context_t hctx, int ofs, int len,
ops[0].op.extent.offset = ofs;
ops[0].op.extent.length = len;
int r = (*pctx)->pg->do_osd_ops(*pctx, ops);
if (r < 0)
return r;

*outdata = (char *)malloc(ops[0].outdata.length());
if (!*outdata)
return -ENOMEM;
memcpy(*outdata, ops[0].outdata.c_str(), ops[0].outdata.length());
*outdatalen = ops[0].outdata.length();

if (r < 0)
return r;

return *outdatalen;
}

Expand Down

0 comments on commit 83f6e12

Please sign in to comment.