<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi David,</p>
    <p>As I said earlier the inode is not linked with itable, so similar
      to inode_path, inode_parent also won't work. We need to remember
      the parent inode during the worm_create. May be we can store it in
      the frame-&gt;local by creating a struct(if we have more than 2
      elements to remember), or simply store it in the frame-&gt;local =
      inode_ref(loc-&gt;parent). Please make sure to unref/free the
      local.</p>
    <p><br>
    </p>
    <p>Regards</p>
    <p>Rafi KC<br>
    </p>
    <div class="moz-cite-prefix">On 2/5/20 7:18 PM, David Spisla wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAJyj9j_r6pgTvQUpuy_vjWgc_qPJHbbMuTHtif25OobX2wQmhw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Hello Rafi,</div>
        <div>I understand. I first tried the way with the parent inode.
          I did it this way:</div>
        <div><br>
        </div>
        <div>inode_t *parent_inode = NULL;<br>
          char *filepath = NULL;<br>
          parent_inode = inode_parent(inode, NULL, NULL); // also with
          fd-&gt;inode it didn't work<br>
          if (!parent_inode) {<br>
            gf_log(this-&gt;name, GF_LOG_ERROR, "Can't get parent
          inode!");<br>
          }<br>
          inode_path(parent_inode, NULL, &amp;filepath);<br>
          if (!filepath) {<br>
             gf_log(this-&gt;name, GF_LOG_ERROR, "Can't get filepath!");</div>
        <div>}</div>
        <div><br>
        </div>
        <div>But it didn't work. See brick log:</div>
        <div>[2020-02-05 13:39:56.408915] E [worm.c:489:worm_create_cbk]
          0-repo2-worm: Can't get parent inode!<br>
          [2020-02-05 13:39:56.408941] E [worm.c:495:worm_create_cbk]
          0-repo2-worm: Can't get filepath!<br>
        </div>
        <div><br>
        </div>
        <div>What could be wrong? If this way promise no succeed I will
          try out the other approach you suggested.</div>
        <div><br>
        </div>
        <div>Regards</div>
        <div>David Spisla<br>
        </div>
        <div><br>
        </div>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">Am Mi., 5. Feb. 2020 um
            12:00 Uhr schrieb RAFI KC &lt;<a
              href="mailto:rkavunga@redhat.com" moz-do-not-send="true">rkavunga@redhat.com</a>&gt;:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            <div bgcolor="#FFFFFF">
              <p><br>
              </p>
              <div>On 2/5/20 4:15 PM, David Spisla wrote:<br>
              </div>
              <blockquote type="cite">
                <div dir="ltr">
                  <div>Hello Amar,</div>
                  <div>I do the following in worm_create_cbk:</div>
                  <div><br>
                  </div>
                  <div>char *filepath = NULL;<br>
                    inode_path(inode, NULL, &amp;filepath);<br>
                    if (!filepath) {<br>
                        gf_log(this-&gt;name, GF_LOG_ERROR, "Can't get
                    filepath!");</div>
                  <div>}</div>
                  <div><br>
                  </div>
                  <div>Unfortunately I got this in the brick log:</div>
                  <div>[2020-02-05 10:09:41.880522] E
                    [inode.c:1498:__inode_path]
(--&gt;/usr/lib64/glusterfs/5.11/xlator/features/worm.so(+0xb129)
                    [0x7f4657df7129]
                    --&gt;/usr/lib64/libglusterfs.so.0(inode_path+0x31)
                    [0x7f4664e44961] --&gt;/us<br>
                    r/lib64/libglusterfs.so.0(__inode_path+0x38b)
                    [0x7f4664e448bb] ) 0-: Assertion failed: 0<br>
                    [2020-02-05 10:09:41.880580] W
                    [inode.c:1500:__inode_path]
                    (--&gt;/usr/lib64/glusterfs/5.11/xlator/features/worm.so(+0xb129)
                    [0x7f4657df7129]
                    --&gt;/usr/lib64/libglusterfs.so.0(inode_path+0x31)
                    [0x7f4664e44961] --&gt;/us<br>
                    r/lib64/libglusterfs.so.0(__inode_path+0x3d3)
                    [0x7f4664e44903] ) 0-repo2-worm: invalid inode
                    [Invalid argument]<br>
                    [2020-02-05 10:09:41.880594] E
                    [worm.c:488:worm_create_cbk] 0-repo2-worm: Can't get
                    filepath!</div>
                  <div><br>
                  </div>
                  <div>The inode I use seems to be not valid because
                    inode_path() returns with error. The same with
                    fd-&gt;inode. Is there a way to validate the inode
                    before passing it to the function?</div>
                </div>
              </blockquote>
              <p>This inode hasn't linked yet to the inode
                table(creation is still in progress), that will only
                happens at server4_post_create from the server xlator
                which is the last xlator in the cbk path. That is why
                the inode_path creation is failed. Why don't you use
                parent inode to create the path, I believe parent inode
                will work for you.</p>
              <p><br>
              </p>
              <p>If all the files and folders in the special directory
                follows the same property, An alternative approach is to
                use an inode type to distinguish this special directory
                and dentries on it. Something similar to snapview-client
                which uses virtual inode to distinguish the .snap
                folder.</p>
              <p><br>
              </p>
              <p>Regards</p>
              <p>Rafi KC<br>
              </p>
              <p><br>
              </p>
              <p><br>
              </p>
              <blockquote type="cite">
                <div dir="ltr">
                  <div><br>
                  </div>
                  <div>Regards</div>
                  <div>David<br>
                  </div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                </div>
                <br>
                <div class="gmail_quote">
                  <div dir="ltr" class="gmail_attr">Am Di., 4. Feb. 2020
                    um 17:57 Uhr schrieb Amar Tumballi &lt;<a
                      href="mailto:amar@kadalu.io" target="_blank"
                      moz-do-not-send="true">amar@kadalu.io</a>&gt;:<br>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0px 0px
                    0px 0.8ex;border-left:1px solid
                    rgb(204,204,204);padding-left:1ex">
                    <div dir="ltr">
                      <div dir="ltr"><br>
                      </div>
                      <br>
                      <div class="gmail_quote">
                        <div dir="ltr" class="gmail_attr">On Tue, Feb 4,
                          2020 at 7:16 PM David Spisla &lt;<a
                            href="mailto:spisla80@gmail.com"
                            target="_blank" moz-do-not-send="true">spisla80@gmail.com</a>&gt;
                          wrote:<br>
                        </div>
                        <blockquote class="gmail_quote"
                          style="margin:0px 0px 0px
                          0.8ex;border-left:1px solid
                          rgb(204,204,204);padding-left:1ex">
                          <div dir="ltr">
                            <div>Dear Gluster Community,</div>
                            <div>in worm_create_cbk a file gets the
                              xattr "trusted.worm_file" and
                              "trusted.start_time" if worm-file-level is
                              enabled. Now I want to exclude some files
                              in a special folder from the WORM
                              function. Therefore I want to check in
                              worm_create_cbk if the file is in this
                              folder or not. But I don't find a
                              parameter where the filepath is stored. So
                              my alternative solution was, to check it
                              in worm_create (via loc-&gt;path) and
                              store a boolean value in frame-&gt;local.
                              This boolean value will be used in
                              worm_create_cbk later. But its not my
                              favourite solution.</div>
                            <div> <br>
                            </div>
                          </div>
                        </blockquote>
                        <blockquote class="gmail_quote"
                          style="margin:0px 0px 0px
                          0.8ex;border-left:1px solid
                          rgb(204,204,204);padding-left:1ex">
                          <div dir="ltr">
                            <div>Do you know how to get the filepath in
                              the cbk function?</div>
                            <div><br>
                            </div>
                          </div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>As per FS guidelines, inside the
                          filesystem, we need to handle inodes or
                          parent-inode + basename. If you are looking at
                          building a 'path' info in create_cbk, then i
                          recommend using 'inode_path()' to build the
                          path as per the latest inode table
                          information.  </div>
                        <div><br>
                        </div>
                        <div>-Amar</div>
                      </div>
                      <br clear="all">
                      <div><br>
                      </div>
                      -- 
                      <div dir="ltr">
                        <div dir="ltr">
                          <div><a href="https://kadalu.io"
                              target="_blank" moz-do-not-send="true">https://kadalu.io</a></div>
                          <div>Container Storage made easy!</div>
                          <div><br>
                          </div>
                        </div>
                      </div>
                    </div>
                  </blockquote>
                </div>
              </blockquote>
            </div>
          </blockquote>
        </div>
      </div>
    </blockquote>
  </body>
</html>