<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Fog,<br>
      <br>
      On 04/29/2013 01:57 PM, fog - wrote:<br>
    </div>
    <blockquote cite="mid:BAY171-W930585B6245B591348F89EF7B20@phx.gbl"
      type="cite">
      <style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
      <div dir="ltr">Hello Avati,<br>
        <br>
        I am wrapping the syncop call in a synctask_new (otherwise
        glusterFS will run into a null pointer @ synctask_get in the
        SYNCOP macro &amp; crash). Below is some code to show how I do
        it currently to test the syncops. <br>
        <br>
        typedef struct{<br>
        &nbsp;&nbsp;&nbsp; xlator_t *this;&nbsp;&nbsp;&nbsp; loc_t *loc;&nbsp;&nbsp;&nbsp; dict_t *dic;<br>
        }syncstore_args;<br>
        <br>
        int32_t __xattr_store_sync(void* data)<br>
        {<br>
        &nbsp;&nbsp;&nbsp; syncstore_args *args = (syncstore_args*)data;<br>
        &nbsp;&nbsp;&nbsp; return syncop_setxattr(FIRST_CHILD(args-&gt;this),
        args-&gt;loc, args-&gt;dic, 0);<br>
        }<br>
        <br>
        int32_t xattr_store_sync(xlator_t *this, call_frame_t *frame,
        loc_t *loc, dict_t *dic)<br>
        {<br>
        &nbsp;&nbsp;&nbsp; syncstore_args args = {this, loc, dic};<br>
        &nbsp;&nbsp;&nbsp; return synctask_new(this-&gt;ctx-&gt;env,
        __xattr_store_sync, NULL, NULL, &amp;args);<br>
      </div>
    </blockquote>
    If you don't provide a synctask_cbk_t to synctask_new, you are using
    synctask in a 'blocking' mode.<br>
    That is, the thread calling synctask_new would block until the
    synctask_fn_t function (ie, __xattr_store_sync) returns.<br>
    An alternative way to do this would be,<br>
    <br>
    int32_t xattr_store_sync(xlator_t *this, call_frame_t *frame, loc_t
    *loc, dict_t *dic)<br>
    {<br>
    &nbsp;&nbsp;&nbsp; syncstore_args args = {this, loc, dic};<br>
    &nbsp;&nbsp;&nbsp; return synctask_new(this-&gt;ctx-&gt;env, __xattr_store_sync,
    __xattr_store_sync_cbk, NULL, &amp;args);<br>
    }<br>
    <br>
    int32_t __xattr_store_sync_cbk (int ret, /*and the other args*/) <br>
    {<br>
    &nbsp;&nbsp;&nbsp; // Your code goes here<br>
    &nbsp;&nbsp;&nbsp; return ret;<br>
    }<br>
    <br>
    Now, all file operations performed using syncop_* inside
    __xattr_store_sync would have the synchronous flavour, while leaving
    the calling thread (thread calling xattr_store_sync fn) 'free'. This
    should avoid the hang issue.<br>
    <br>
    HTH,<br>
    krish<br>
    <br>
    <br>
    <blockquote cite="mid:BAY171-W930585B6245B591348F89EF7B20@phx.gbl"
      type="cite">
      <div dir="ltr">}<br>
        <br>
        <div>
          <hr id="stopSpelling">Date: Mon, 29 Apr 2013 00:19:11 -0700<br>
          Subject: Re: [Gluster-devel] rpc problems when using syncops
          in callbacks<br>
          From: <a class="moz-txt-link-abbreviated" href="mailto:anand.avati@gmail.com">anand.avati@gmail.com</a><br>
          To: <a class="moz-txt-link-abbreviated" href="mailto:fog_is_my_name@hotmail.com">fog_is_my_name@hotmail.com</a><br>
          CC: <a class="moz-txt-link-abbreviated" href="mailto:gluster-devel@nongnu.org">gluster-devel@nongnu.org</a><br>
          <br>
          <div dir="ltr">Note that you need to place your syncop code in
            a synctask function strictly within a syncenv (by calling
            synctask_new(). You're probably calling syncop_XXX()
            directly in your xlator code?
            <div><br>
            </div>
            <div>Avati</div>
          </div>
          <div class="ecxgmail_extra"><br>
            <br>
            <div class="ecxgmail_quote">On Fri, Apr 26, 2013 at 2:40 AM,
              fog - <span dir="ltr">&lt;<a moz-do-not-send="true"
                  href="mailto:fog_is_my_name@hotmail.com"
                  target="_blank">fog_is_my_name@hotmail.com</a>&gt;</span>
              wrote:<br>
              <blockquote class="ecxgmail_quote" style="border-left:1px
                #ccc solid;padding-left:1ex;">
                <div>
                  <div dir="ltr">Hello everyone,<br>
                    <div>
                      <div dir="ltr">
                        <div>
                          <div><br>
                          </div>
                          I am trying to use syncops in a custom
                          translator to keep my code at least borderline
                          readable, but I am having limited success. <br>
                          <br>
                          Problem Symptoms: <br>
                          Using a syncop in a regular fop is fine.
                          However, in a callback it causes a 'freeze'
                          (synctask_yield called by the SYNCOP macro
                          doesn't return). <br>
                          <br>
                        </div>
                        <div>What seems to be the Problem: <br>
                        </div>
                        <div>Looking at the traces, there is no
                          corresponding trace from rpc_clnt_reply_init
                          on the client to the trace from
                          rpcsvc_submit_generic on the server. In other
                          words, the rpc reply gets sent but isn't
                          correctly received. Obviously this is not
                          really a networking problem but something
                          else... I'd guess it's a deadlock somewhere on
                          the client?<br>
                        </div>
                        <div>From the point of the syncop call onwards
                          the client doesn't 'get' any rpc replies any
                          more (the next GlusterFS Handshake sent by the
                          client, which is received by the server and
                          replied to, leads to a disconnection
                          accordingly).<br>
                        </div>
                        <div><br>
                        </div>
                        <div>Again: This problem is only occurring when
                          calling a syncop from a callback function
                          inside my translator, if I call the same
                          syncop in a fop call it completes fine.<br>
                          <br>
                          I hope you can make sense out of the above
                          problem description. <br>
                        </div>
                        <div>Thanks for your time ~<br>
                        </div>
                        <br>
                      </div>
                    </div>
                  </div>
                </div>
                <br>
                _______________________________________________<br>
                Gluster-devel mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:Gluster-devel@nongnu.org">Gluster-devel@nongnu.org</a><br>
                <a moz-do-not-send="true"
                  href="https://lists.nongnu.org/mailman/listinfo/gluster-devel"
                  target="_blank">https://lists.nongnu.org/mailman/listinfo/gluster-devel</a><br>
                <br>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Gluster-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Gluster-devel@nongnu.org">Gluster-devel@nongnu.org</a>
<a class="moz-txt-link-freetext" href="https://lists.nongnu.org/mailman/listinfo/gluster-devel">https://lists.nongnu.org/mailman/listinfo/gluster-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>