Re: How to notify an object watched by client via ceph class API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 5, 2015 at 4:51 PM, Sage Weil <sage@xxxxxxxxxxxx> wrote:
> On Thu, 5 Feb 2015, Dennis Chen wrote:
>> Hello,
>>
>> Just as the subject indicated, how can I notify an object watcher
>> within a class '.so' loaded into osd deamon. I checked the code and
>> found the below op code defined already:CEPH_OSD_OP_NOTIFY, but this
>> op code is not used by existing ceph class api, I guest there must be
>> a simple solution to resolve this if I don't want to make the osd to
>> play client role the same time.
>>
>> Anyone can help me out this?
>>
>
> The watch/notify does not rely on rados classes, e.g.:
>
> rados -p rbd create foo
> rados -p rbd watch foo &
> rados -p rbd notify foo hello
>
> The notify is just a normal librados operation, and most of those can be
> called from classes, but it normally blocks for some period until the
> others acknowledge.  If it were wired up in objclass.h you could probably
> initiate the async notify but there would be no way to check whether it
> ever arrived, so I'm not sure it would be useful.
>
> What are you trying to accomplish?
>
> sage

What I am trying is to design a signaling control mechanism based on
ceph, so the notify will not be in heavy load(just some event state
needed to report to the client async). Below is the investigation for
this question, initialy the result is good as expected except that the
argement transfering between the client watcher callback function and
the osd class function, the code snippet:

Client side--

void notify_test(uint8_t opcode, uint64_t ver, void *arg)
{
    char *str = (char *)arg;
    printf("get notify:%s\n", str);
}

int main(...)
{
   ...
   strcpy(arg, "notify: from client");
   err = rados_watch(io, objname, 0, &handle, notify_test, arg);
   err = rados_exec(io, objname, "devctl", "devctl_op", in,
strlen(in), out, 128);
   ...
}

OSD side (in the ceph class)--
int test_class_ext(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
{
    int ret;

    CLS_LOG(0, "+test_class_ext");
    in->append("input data");
    out->append("output data");
    ReplicatedPG::OpContext **pctx = (ReplicatedPG::OpContext **)hctx;
    vector<OSDOp> ops(1);
    ops[0].op.op = CEPH_OSD_OP_NOTIFY;
    ops[0].indata = *in;
    ops[0].outdata = *out;
    ret = (*pctx)->pg->do_osd_ops(*pctx, ops);
    in->claim(ops[0].indata);
    out->claim(ops[0].outdata);
    CLS_LOG(0, "ret = %d", ret);

    return 0;
}

static int devctl_op(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
{
   ...
   test_class_ext(hctx, in, out);
   return 0;
}


The output in the client:
get notify:notify: from client


I can't pass the parameters to the client watcher currently :( , any hints?

-- 
Den
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux