<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Andeas and others,<br>
    </p>
    <p>Thanks again for all the info.  I guess its about time for me to
      attempt to contribute to the Lustre code base.  A question about
      llapi_layout_dom_size().  I have code that is building up a multi
      component layout.  After switching to the second component with
      llapi_layout_comp_use( layout, LLAPI_COMP_USE_NEXT ) I call
      llapi_layout_dom_size() so I know where to set the extent start
      for second component.  Internal to ...dom_size() the current
      component gets set back to the first component, see below.  I then
      make calls thinking I am modifying the second component, but I am
      actually modifying the first.  Is this behavior documented
      somewhere, that calls to llapi_layout_... functions can change the
      current component without notice?</p>
    <p>Is there a llapi function that returns the lustre file system's
      max dom size?  I mistakenly thought this was the purpose of
      llapi_layout_dom_size(), but found out I made a bad assumption. 
      Trying to  find the max dom_size is what sent me down this path.<br>
    </p>
    <p>John<br>
    </p>
    <pre><font color="#4E9A06">int</font> llapi_layout_dom_size(<font color="#4E9A06">struct</font> llapi_layout *layout, <font color="#4E9A06">uint64_t</font> *size)
{
        <font color="#4E9A06">uint64_t</font> pattern, start;
        <font color="#4E9A06">int</font> rc;

        <font color="#AF5F00">if</font> (!layout || !llapi_layout_is_composite(layout)) {
                *size = <font color="#CC0000">0</font>;
                <font color="#AF5F00">return</font> <font color="#CC0000">0</font>;
        }

        <font color="#ff0054">rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_FIRST)</font>;
        <font color="#AF5F00">if</font> (rc)
                <font color="#AF5F00">return</font> -errno;

        rc = llapi_layout_pattern_get(layout, &pattern);
        <font color="#AF5F00">if</font> (rc)
                <font color="#AF5F00">return</font> -errno;

        <font color="#AF5F00">if</font> (pattern != LOV_PATTERN_MDT && pattern != LLAPI_LAYOUT_MDT) {
                *size = <font color="#CC0000">0</font>;
                <font color="#AF5F00">return</font> <font color="#CC0000">0</font>;
        }

        rc = llapi_layout_comp_extent_get(layout, &start, size);
        <font color="#AF5F00">if</font> (rc)
                <font color="#AF5F00">return</font> -errno;
        <font color="#AF5F00">if</font> (start)
                <font color="#AF5F00">return</font> -<font color="#CC0000">ERANGE</font>;
        <font color="#AF5F00">return</font> <font color="#CC0000">0</font>;
}</pre>
    <div class="moz-cite-prefix">On 7/28/22 19:42, Andreas Dilger wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:5AD10FEB-825C-40AC-B157-694069ADACE4@whamcloud.com">
      John, you are probably right that allowing a passed fd would also
      be useful, but nobody has done it this way before because of the
      need to use O_LOV_DELAY_CREATE within the application code...  and
      to be honest very few applications tune their IO to this extent,
      especially with PFL layouts being available to handle 99% of the
      usage.
      <div class=""><br class="">
      </div>
      <div class="">Please feel free to submit a patch that splits
        llapi_layout_file_open() into two functions:</div>
      <div class="">- llapi_layout_open_fd() (or ...fd_open()? not sure)
        that only opens the file with O_LOV_DELAY_CREATE and returns the
        fd</div>
      <div class="">- llapi_layout_set_by_fd() that sets the layout on
        the provided fd (whatever the source)
        <div class=""><br class="">
        </div>
        <div class="">Then llapi_layout_file_open() would just call
          those two functions internally, and you could use only
          the llapi_layout_set_by_fd() function, if available (you could
          add:</div>
        <div class=""><br class="">
        </div>
        <div class="">#defeine HAVE_LLAPI_LAYOUT_SET_BY_FD</div>
        <div class=""><br class="">
        </div>
        <div class="">in the lustreapi.h header to avoid the need for a
          separate configure check.   Otherwise, your code would call
          your own internal wrapper of the same name that calls
          llapi_layout_file_open() and immediately closes the returned
          fd.  That would be slightly less efficient than the new API
          (two opens and closes), but would allow you to migrate to the
          new (more efficient) implementation easily in the future.</div>
        <div class=""><br class="">
        </div>
        <div class="">Cheers, Andreas</div>
        <div class="">
          <div><br class="">
            <blockquote type="cite" class="">
              <div class="">On Jul 28, 2022, at 14:03, John Bauer <<a
                  href="mailto:bauerj@iodoctors.com"
                  class="moz-txt-link-freetext" moz-do-not-send="true">bauerj@iodoctors.com</a>>
                wrote:</div>
              <br class="Apple-interchange-newline">
              <div class="">
                <div class="">
                  <p class="">Andreas,</p>
                  <p class="">Thanks for the info.  A related question: 
                    I am using the O_LOV_DELAY_CREATE open flag
                    mechanism to open a file and then set the composite
                    layout with llapi_layout_file_open().  I was kind of
                    surprised this worked.  This ends up opening the
                    file twice and I simply close the fd returned from
                    llapi_layout_file_open().  It would seem there
                    should be an llapi function such as
                    llapi_layout_set_by_fd() to match the
                    llapi_layout_get_by_fd().  I need to use this
                    mechanism to set striping for files where the
                    pathname is not necessarily known before the open,
                    such as the mkstemps() family of opens.  It also
                    makes it easier to handle setting striping for files
                    opened with openat().  It seems it would be more
                    straight forward for llapi to work with an fd than a
                    pathname if a valid fd already exists. Am I missing
                    an easier way to do this?</p>
                  <p class="">Thanks,</p>
                  <p class="">John<br class="">
                  </p>
                  <div class="moz-cite-prefix">On 7/27/22 16:25, Andreas
                    Dilger wrote:<br class="">
                  </div>
                  <blockquote type="cite"
                    cite="mid:D58CA859-926E-4B94-96AE-DA40C023DF8B@ddn.com"
                    class="">
                    The HLD document was written before the feature was
                    implemented, and is outdated.  The lustreapi.h and
                    llapi_layout_file_comp_del.3 man page are correct.
                     Feel free to update the wiki to use the correct
                    argument list.
                    <div class=""><br class="">
                    </div>
                    <div class="">I believe that it is possible to
                      delete multiple components that match the
                      <flags> argument (e.g.
                      LCME_FL_NEG|LCME_FL_INIT), but I haven't tested
                      that. <br class="">
                      <div class=""><br class="">
                        <blockquote type="cite" class="">
                          <div class="">On Jul 26, 2022, at 14:35, John
                            Bauer <<a
                              href="mailto:bauerj@iodoctors.com"
                              class="moz-txt-link-freetext"
                              moz-do-not-send="true">bauerj@iodoctors.com</a>>
                            wrote:</div>
                          <br class="Apple-interchange-newline">
                          <div class="">
                            <div class="">Hi all,<br class="">
                              <br class="">
                              I would like to use the
                              llapi_layout_file_comp_del() function.  I
                              have found 2 prototypes in different
                              places.  One has the 3rd argument,
                              uint32_t flags, and the other doesn't.  I
                              suspect the High Level Design document is
                              incorrect.  The one line of documentation
                              in lustreapi.h indicates I could delete
                              multiple components with one call.  How
                              does one do that? What are the applicable
                              flags?<br class="">
                              <br class="">
                              From version 2.12.8 lustreapi.h<br
                                class="">
                              <br class="">
                              /**<br class="">
                              * Delete component(s) by the specified
                              component id or flags.<br class="">
                              */<br class="">
                              int  llapi_layout_file_comp_del(const
                               char  *path, uint32_t  id, uint32_t
                               flags);<br class="">
                              <br class="">
                              <br class="">
                              From <a
                                href="https://wiki.lustre.org/PFL2_High_Level_Design"
                                class="moz-txt-link-freetext"
                                moz-do-not-send="true">
https://wiki.lustre.org/PFL2_High_Level_Design</a><br class="">
                              <br class="">
                              A new interface
                              llapi_layout_file_comp_del(3) to delete
                              component(s) by the specified component id
                              (accepting LCME_ID_* wildcards also) from
                              an existing file:<br class="">
                              <br class="">
                              int llapi_layout_file_comp_del(const char
                              *path, uint32_t id);<br class="">
                              <br class="">
                              John<br class="">
                              <br class="">
_______________________________________________<br class="">
                              lustre-discuss mailing list<br class="">
                              <a
                                href="mailto:lustre-discuss@lists.lustre.org"
                                class="moz-txt-link-freetext"
                                moz-do-not-send="true">lustre-discuss@lists.lustre.org</a><br
                                class="">
                              <a class="moz-txt-link-freetext"
                                href="http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org"
                                moz-do-not-send="true">http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org</a><br
                                class="">
                            </div>
                          </div>
                        </blockquote>
                      </div>
                      <br class="">
                      <div class="">
                        <div dir="auto" class="">
                          <div dir="auto" class="">
                            <div dir="auto" class="">
                              <div dir="auto" class="">
                                <div dir="auto" class="">
                                  <div dir="auto" class="">
                                    <div class="">Cheers, Andreas</div>
                                    <div class="">--</div>
                                    <div class="">Andreas Dilger</div>
                                    <div class="">Lustre Principal
                                      Architect</div>
                                    <div class="">Whamcloud</div>
                                    <div class=""><br class="">
                                    </div>
                                    <div class=""><br class="">
                                    </div>
                                    <div class=""><br class="">
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                          <br class="Apple-interchange-newline">
                        </div>
                        <br class="Apple-interchange-newline">
                        <br class="Apple-interchange-newline">
                      </div>
                      <br class="">
                    </div>
                  </blockquote>
                </div>
              </div>
            </blockquote>
          </div>
          <br class="">
          <div class="">
            <div dir="auto" class="">
              <div dir="auto" class="">
                <div dir="auto" class="">
                  <div dir="auto" class="">
                    <div dir="auto" class="">
                      <div dir="auto" class="">
                        <div>Cheers, Andreas</div>
                        <div>--</div>
                        <div>Andreas Dilger</div>
                        <div>Lustre Principal Architect</div>
                        <div>Whamcloud</div>
                        <div><br class="">
                        </div>
                        <div><br class="">
                        </div>
                        <div><br class="">
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <br class="Apple-interchange-newline">
            </div>
            <br class="Apple-interchange-newline">
            <br class="Apple-interchange-newline">
          </div>
          <br class="">
        </div>
      </div>
    </blockquote>
  </body>
</html>