-<?xml version="1.0" encoding="UTF-8"?>
-<chapter version="5.0" xml:lang="en-US" xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink">
- <info>
- <title>Setting Lustre Properties in a C Program (llapi)</title>
- </info>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297638" xreflabel=""/>This chapter describes the llapi library of commands used for setting Lustre file properties within a C program running in a cluster environment, such as a data processing or MPI application. The commands described in this chapter are:</para>
- <itemizedlist><listitem>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296814" xreflabel=""/><link xl:href="SettingLustreProperties_HTML.html#50438215_30970">llapi_file_create</link></para>
+<?xml version='1.0' encoding='UTF-8'?><chapter xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en-US" xml:id="settinglustreproperties">
+ <title xml:id="settinglustreproperties.title">Setting Lustre Properties in a C Program (<literal>llapi</literal>)</title>
+ <para>This chapter describes the <literal>llapi</literal> library of commands used for setting Lustre file properties within a C program running in a cluster environment, such as a data processing or MPI application. The commands described in this chapter are:</para>
+ <itemizedlist>
+ <listitem>
+ <para><xref linkend="dbdoclet.50438215_30970"/></para>
</listitem>
-<listitem>
- <para> </para>
+ <listitem>
+ <para><xref linkend="dbdoclet.50438215_50149"/></para>
</listitem>
-<listitem>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297652" xreflabel=""/><link xl:href="SettingLustreProperties_HTML.html#50438215_50149">llapi_file_get_stripe</link></para>
+ <listitem>
+ <para><xref linkend="dbdoclet.50438215_86607"/></para>
</listitem>
-<listitem>
- <para> </para>
+ <listitem>
+ <para><xref linkend="dbdoclet.50438215_12433"/></para>
</listitem>
-<listitem>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297658" xreflabel=""/><link xl:href="SettingLustreProperties_HTML.html#50438215_86607">llapi_file_open</link></para>
+ <listitem>
+ <para><xref linkend="dbdoclet.50438215_15718"/></para>
</listitem>
-<listitem>
- <para> </para>
- </listitem>
-<listitem>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298853" xreflabel=""/><link xl:href="SettingLustreProperties_HTML.html#50438215_12433">llapi_quotactl</link></para>
- </listitem>
-<listitem>
- <para> </para>
- </listitem>
-<listitem>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298974" xreflabel=""/><link xl:href="SettingLustreProperties_HTML.html#50438215_15718">llapi_path2fid</link></para>
- </listitem>
-<listitem>
- <para> </para>
- </listitem>
-</itemizedlist>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298854" xreflabel=""/> </para>
- <informaltable frame="none">
- <tgroup cols="1">
- <colspec colname="c1" colwidth="100*"/>
- <tbody>
- <row>
- <entry><para><emphasis role="bold">Note -</emphasis><anchor xml:id="dbdoclet.50438215_pgfId-1298855" xreflabel=""/>Lustre programming interface man pages are found in the lustre/doc folder.</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <section remap="h2">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1296828" xreflabel=""/></title>
- <section remap="h2">
- <title>34.1 <anchor xml:id="dbdoclet.50438215_30970" xreflabel=""/>llapi_file_create</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296829" xreflabel=""/>Use llapi_file_create to set Lustre properties for a new file.</para>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1296830" xreflabel=""/>Synopsis</title>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296831" xreflabel=""/>#include <lustre/liblustreapi.h>#include <lustre/lustre_user.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296832" xreflabel=""/>int llapi_file_create(char *name, long stripe_size, int stripe_offset, int \
-stripe_count, int stripe_pattern);
-</screen>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1296833" xreflabel=""/>Description</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296834" xreflabel=""/>The llapi_file_create() function sets a file descriptor’s Lustre striping information. The file descriptor is then accessed with open ().</para>
- <informaltable frame="all">
- <tgroup cols="2">
- <colspec colname="c1" colwidth="50*"/>
- <colspec colname="c2" colwidth="50*"/>
- <thead>
- <row>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1296837" xreflabel=""/>Option</emphasis></para></entry>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1296839" xreflabel=""/>Description</emphasis></para></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296841" xreflabel=""/><emphasis role="bold">llapi_file_create()</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296843" xreflabel=""/>If the file already exists, this parameter returns to ‘EEXIST’. If the stripe parameters are invalid, this parameter returns to ‘EINVAL’.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296845" xreflabel=""/><emphasis role="bold">stripe_size</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296847" xreflabel=""/>This value must be an even multiple of system page size, as shown by getpagesize (). The default Lustre stripe size is 4MB.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296849" xreflabel=""/><emphasis role="bold">stripe_offset</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296851" xreflabel=""/>Indicates the starting OST for this file.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296853" xreflabel=""/><emphasis role="bold">stripe_count</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296855" xreflabel=""/>Indicates the number of OSTs that this file will be striped across.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296857" xreflabel=""/><emphasis role="bold">stripe_pattern</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1296859" xreflabel=""/> Indicates the RAID pattern.</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <informaltable frame="none">
- <tgroup cols="1">
- <colspec colname="c1" colwidth="100*"/>
- <tbody>
- <row>
- <entry><para><emphasis role="bold">Note -</emphasis><anchor xml:id="dbdoclet.50438215_pgfId-1296860" xreflabel=""/>Currently, only RAID 0 is supported. To use the system defaults, set these values: stripe_size = 0, stripe_offset = -1, stripe_count = 0, stripe_pattern = 0</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1296861" xreflabel=""/>Examples</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296862" xreflabel=""/>System default size is 4 MB.</para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296863" xreflabel=""/>char *tfile = TESTFILE;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296864" xreflabel=""/>int stripe_size = 65536
-</screen>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296865" xreflabel=""/>To start at default, run:</para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296866" xreflabel=""/>int stripe_offset = -1
-</screen>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296867" xreflabel=""/>To start at the default, run:</para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296868" xreflabel=""/>int stripe_count = 1
-</screen>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296869" xreflabel=""/>To set a single stripe for this example, run:</para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296870" xreflabel=""/>int stripe_pattern = 0
+ </itemizedlist>
+ <note>
+ <para>Lustre programming interface man pages are found in the <literal>lustre/doc</literal> folder.</para>
+ </note>
+ <section xml:id="dbdoclet.50438215_30970">
+ <title>
+ <literal>llapi_file_create</literal>
+ </title>
+ <para>Use <literal>llapi_file_create</literal> to set Lustre properties for a new file.</para>
+ <section remap="h5">
+ <title>Synopsis</title>
+ <screen>#include <lustre/lustreapi.h>
+
+int llapi_file_create(char *name, long stripe_size, int stripe_offset, int stripe_count, int stripe_pattern);
</screen>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296871" xreflabel=""/>Currently, only RAID 0 is supported.</para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296872" xreflabel=""/>int stripe_pattern = 0;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296873" xreflabel=""/>int rc, fd;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296874" xreflabel=""/>rc = llapi_file_create(tfile, stripe_size,stripe_offset, stripe_count,strip\
-e_pattern);
-</screen>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296875" xreflabel=""/>Result code is inverted, you may return with ’EINVAL’ or an ioctl error.</para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296876" xreflabel=""/>if (rc) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1296877" xreflabel=""/>fprintf(stderr,"llapi_file_create failed: %d (%s) 0, rc, strerror(-rc));retu\
-rn -1; }
-</screen>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296878" xreflabel=""/>llapi_file_create closes the file descriptor. You must re-open the descriptor. To do this, run:</para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296879" xreflabel=""/>fd = open(tfile, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644); if (fd < 0) \\
- { fprintf(stderr, "Can’t open %s file: %s0, tfile,
-<anchor xml:id="dbdoclet.50438215_pgfId-1296880" xreflabel=""/>str-
-<anchor xml:id="dbdoclet.50438215_pgfId-1296881" xreflabel=""/>error(errno));
-<anchor xml:id="dbdoclet.50438215_pgfId-1296882" xreflabel=""/>return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296883" xreflabel=""/>}
-</screen>
- </section>
</section>
- <section remap="h2">
- <title>34.2 <anchor xml:id="dbdoclet.50438215_50149" xreflabel=""/>llapi_file_get_stripe</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296886" xreflabel=""/>Use llapi_file_get_stripe to get striping information for a file or directory on a Lustre file system.</para>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1296887" xreflabel=""/>Synopsis</title>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296888" xreflabel=""/>#include <sys/types.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296889" xreflabel=""/>#include <sys/stat.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296890" xreflabel=""/>#include <fcntl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296891" xreflabel=""/>#include <liblustre.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296892" xreflabel=""/>#include <lustre/lustre_idl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296893" xreflabel=""/>#include <lustre/liblustreapi.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296894" xreflabel=""/>#include <lustre/lustre_user.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296895" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1296896" xreflabel=""/>int llapi_file_get_stripe(const char *<emphasis>path</emphasis>, void *<emphasis>lum</emphasis>);
-</screen>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1296897" xreflabel=""/>Description</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1296898" xreflabel=""/>The llapi_file_get_stripe() function returns striping information for a file or directory <emphasis>path</emphasis> in <emphasis>lum</emphasis> (which should point to a large enough memory region) in one of the following formats:</para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1296899" xreflabel=""/>struct lov_user_md_v1 {
-<anchor xml:id="dbdoclet.50438215_pgfId-1296900" xreflabel=""/>__u32 lmm_magic;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296901" xreflabel=""/>__u32 lmm_pattern;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296902" xreflabel=""/>__u64 lmm_object_id;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296903" xreflabel=""/>__u64 lmm_object_seq;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296904" xreflabel=""/>__u32 lmm_stripe_size;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296905" xreflabel=""/>__u16 lmm_stripe_count;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296906" xreflabel=""/>__u16 lmm_stripe_offset;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296907" xreflabel=""/>struct lov_user_ost_data_v1 lmm_objects[0];
-<anchor xml:id="dbdoclet.50438215_pgfId-1296908" xreflabel=""/>} __attribute__((packed));
-<anchor xml:id="dbdoclet.50438215_pgfId-1296909" xreflabel=""/>struct lov_user_md_v3 {
-<anchor xml:id="dbdoclet.50438215_pgfId-1296910" xreflabel=""/>__u32 lmm_magic;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296911" xreflabel=""/>__u32 lmm_pattern;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296912" xreflabel=""/>__u64 lmm_object_id;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296913" xreflabel=""/>__u64 lmm_object_seq;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296914" xreflabel=""/>__u32 lmm_stripe_size;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296915" xreflabel=""/>__u16 lmm_stripe_count;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296916" xreflabel=""/>__u16 lmm_stripe_offset;
-<anchor xml:id="dbdoclet.50438215_pgfId-1296917" xreflabel=""/>char lmm_pool_name[LOV_MAXPOOLNAME];
-<anchor xml:id="dbdoclet.50438215_pgfId-1296918" xreflabel=""/>struct lov_user_ost_data_v1 lmm_objects[0];
-<anchor xml:id="dbdoclet.50438215_pgfId-1297038" xreflabel=""/>} __attribute__((packed));
-</screen>
- <informaltable frame="all">
- <tgroup cols="2">
- <colspec colname="c1" colwidth="50*"/>
- <colspec colname="c2" colwidth="50*"/>
- <thead>
- <row>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1298282" xreflabel=""/>Option</emphasis></para></entry>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1298284" xreflabel=""/>Description</emphasis></para></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298286" xreflabel=""/><emphasis role="bold">lmm_magic</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298288" xreflabel=""/>Specifies the format of the returned striping information. <emphasis role="bold">LOV_MAGIC_V1</emphasis> isused for lov_user_md_v1. <emphasis role="bold">LOV_MAGIC_V3</emphasis> is used for lov_user_md_v3.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298290" xreflabel=""/><emphasis role="bold">lmm_pattern</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298292" xreflabel=""/>Holds the striping pattern. Only <emphasis role="bold">LOV_PATTERN_RAID0</emphasis> is possible in this Lustre version.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298294" xreflabel=""/><emphasis role="bold">lmm_object_id</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298296" xreflabel=""/>Holds the MDS object ID.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298298" xreflabel=""/><emphasis role="bold">lmm_object_gr</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298300" xreflabel=""/>Holds the MDS object group.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298302" xreflabel=""/><emphasis role="bold">lmm_stripe_size</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298304" xreflabel=""/>Holds the stripe size in bytes.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298306" xreflabel=""/><emphasis role="bold">lmm_stripe_count</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298308" xreflabel=""/>Holds the number of OSTs over which the file is striped.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298310" xreflabel=""/><emphasis role="bold">lmm_stripe_offset</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298359" xreflabel=""/>Holds the OST index from which the file starts.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298314" xreflabel=""/><emphasis role="bold">lmm_pool_name</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298374" xreflabel=""/>Holds the OST pool name to which the file belongs.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298318" xreflabel=""/><emphasis role="bold">lmm_objects</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298390" xreflabel=""/>An array of lmm_stripe_count members containing per OST file information in</para><para><anchor xml:id="dbdoclet.50438215_pgfId-1298391" xreflabel=""/>the following format:</para><para><anchor xml:id="dbdoclet.50438215_pgfId-1298392" xreflabel=""/>struct lov_user_ost_data_v1 {</para><para><anchor xml:id="dbdoclet.50438215_pgfId-1298393" xreflabel=""/>__u64 l_object_id;</para><para><anchor xml:id="dbdoclet.50438215_pgfId-1298394" xreflabel=""/>__u64 l_object_seq;</para><para><anchor xml:id="dbdoclet.50438215_pgfId-1298395" xreflabel=""/>__u32 l_ost_gen;</para><para><anchor xml:id="dbdoclet.50438215_pgfId-1298396" xreflabel=""/>__u32 l_ost_idx;</para><para><anchor xml:id="dbdoclet.50438215_pgfId-1298397" xreflabel=""/>} __attribute__((packed));</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298322" xreflabel=""/><emphasis role="bold">l_object_id</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298412" xreflabel=""/>Holds the OST’s object ID.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298326" xreflabel=""/><emphasis role="bold">l_object_seq</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298427" xreflabel=""/>Holds the OST’s object group.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298330" xreflabel=""/><emphasis role="bold">l_ost_gen</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298442" xreflabel=""/>Holds the OST’s index generation.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298334" xreflabel=""/><emphasis role="bold">l_ost_idx</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298461" xreflabel=""/>Holds the OST’s index in LOV.</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297039" xreflabel=""/>Return Values</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297040" xreflabel=""/>llapi_file_get_stripe() returns:</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297041" xreflabel=""/><emphasis role="bold">0</emphasis> On success</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297042" xreflabel=""/><emphasis role="bold">!= 0</emphasis> On failure, <emphasis>errno</emphasis> is set appropriately</para>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297043" xreflabel=""/>Errors</title>
- <informaltable frame="all">
- <tgroup cols="2">
- <colspec colname="c1" colwidth="50*"/>
- <colspec colname="c2" colwidth="50*"/>
- <thead>
- <row>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1298797" xreflabel=""/>Errors</emphasis></para></entry>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1298799" xreflabel=""/>Description</emphasis></para></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298801" xreflabel=""/><emphasis role="bold">ENOMEM</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298803" xreflabel=""/><emphasis role="bold">Failed to allocate memory</emphasis></para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298805" xreflabel=""/><emphasis role="bold">ENAMETOOLONG</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298868" xreflabel=""/>Path was too long</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298809" xreflabel=""/><emphasis role="bold">ENOENT</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298870" xreflabel=""/>Path does not point to a file or directory</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298813" xreflabel=""/><emphasis role="bold">ENOTTY</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298872" xreflabel=""/>Path does not point to a Lustre file system</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298817" xreflabel=""/><emphasis role="bold">EFAULT</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298819" xreflabel=""/>Memory region pointed by lum is not properly mapped</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1298829" xreflabel=""/>Examples</title>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1297050" xreflabel=""/>#include <sys/vfs.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297051" xreflabel=""/>#include <liblustre.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297052" xreflabel=""/>#include <lnet/lnetctl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297053" xreflabel=""/>#include <obd.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297054" xreflabel=""/>#include <lustre_lib.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297055" xreflabel=""/>#include <lustre/liblustreapi.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297056" xreflabel=""/>#include <obd_lov.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297057" xreflabel=""/>static inline int maxint(int a, int b)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297058" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297059" xreflabel=""/>return a > b ? a : b;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297060" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297061" xreflabel=""/>static void *alloc_lum()
-<anchor xml:id="dbdoclet.50438215_pgfId-1297062" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297063" xreflabel=""/>int v1, v3, join;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297064" xreflabel=""/>v1 = sizeof(struct lov_user_md_v1) +
-<anchor xml:id="dbdoclet.50438215_pgfId-1297065" xreflabel=""/>LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297066" xreflabel=""/>v3 = sizeof(struct lov_user_md_v3) +
-<anchor xml:id="dbdoclet.50438215_pgfId-1297067" xreflabel=""/>LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297068" xreflabel=""/>return malloc(maxint(v1, v3));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297069" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297070" xreflabel=""/>int main(int argc, char** argv)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297071" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297072" xreflabel=""/>struct lov_user_md *lum_file = NULL;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297073" xreflabel=""/>int rc;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297074" xreflabel=""/>int lum_size;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297075" xreflabel=""/>if (argc != 2) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297076" xreflabel=""/>fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297077" xreflabel=""/>return 1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297078" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297079" xreflabel=""/>lum_file = alloc_lum();
-<anchor xml:id="dbdoclet.50438215_pgfId-1297080" xreflabel=""/>if (lum_file == NULL) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297081" xreflabel=""/>rc = ENOMEM;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297082" xreflabel=""/>goto cleanup;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297083" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297084" xreflabel=""/>rc = llapi_file_get_stripe(argv[1], lum_file);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297085" xreflabel=""/>if (rc) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297086" xreflabel=""/>rc = errno;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297087" xreflabel=""/>goto cleanup;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297088" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297089" xreflabel=""/>/* stripe_size stripe_count */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297090" xreflabel=""/>printf("%d %d\n",
-<anchor xml:id="dbdoclet.50438215_pgfId-1297091" xreflabel=""/>lum_file->lmm_stripe_size,
-<anchor xml:id="dbdoclet.50438215_pgfId-1297092" xreflabel=""/>lum_file->lmm_stripe_count);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297093" xreflabel=""/>cleanup:
-<anchor xml:id="dbdoclet.50438215_pgfId-1297094" xreflabel=""/>if (lum_file != NULL)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297095" xreflabel=""/>free(lum_file);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297096" xreflabel=""/>return rc;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297097" xreflabel=""/>}
-</screen>
- </section>
+ <section remap="h5">
+ <title>Description</title>
+ <para>The <literal>llapi_file_create()</literal> function sets a file descriptor's Lustre
+ file system striping information. The file descriptor is then accessed with
+ <literal>open()</literal>.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Option</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para> <literal>llapi_file_create()</literal></para>
+ </entry>
+ <entry>
+ <para>If the file already exists, this parameter returns to '<literal>EEXIST</literal>'. If the stripe parameters are invalid, this parameter returns to '<literal>EINVAL</literal>'.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>stripe_size</literal></para>
+ </entry>
+ <entry>
+ <para>This value must be an even multiple of system page size, as shown by <literal>getpagesize()</literal>. The default Lustre stripe size is 4MB.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>stripe_offset</literal></para>
+ </entry>
+ <entry>
+ <para>Indicates the starting OST for this file.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>stripe_count</literal></para>
+ </entry>
+ <entry>
+ <para>Indicates the number of OSTs that this file will be striped across.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>stripe_pattern</literal></para>
+ </entry>
+ <entry>
+ <para>Indicates the RAID pattern.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <note>
+ <para>Currently, only RAID 0 is supported. To use the system defaults, set these values: <literal>stripe_size</literal> = 0, <literal>stripe_offset</literal> = -1, <literal>stripe_count</literal> = 0, <literal>stripe_pattern</literal> = 0</para>
+ </note>
</section>
- <section remap="h2">
- <title>34.3 <anchor xml:id="dbdoclet.50438215_86607" xreflabel=""/>llapi_file_open</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298469" xreflabel=""/>The llapi_file_open command opens (or creates) a file or device on a Lustre filesystem.</para>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297361" xreflabel=""/>Synopsis</title>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1297362" xreflabel=""/>#include <sys/types.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297363" xreflabel=""/>#include <sys/stat.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297364" xreflabel=""/>#include <fcntl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297365" xreflabel=""/>#include <liblustre.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297366" xreflabel=""/>#include <lustre/lustre_idl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297367" xreflabel=""/>#include <lustre/liblustreapi.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297368" xreflabel=""/>#include <lustre/lustre_user.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297369" xreflabel=""/>int llapi_file_open(const char *<emphasis>name</emphasis>, int <emphasis>flags</emphasis>, int <emphasis>mode</emphasis>,
-<anchor xml:id="dbdoclet.50438215_pgfId-1297370" xreflabel=""/> unsigned long long <emphasis>stripe_size</emphasis>, int <emphasis>stripe_offset</emphasis>,
-<anchor xml:id="dbdoclet.50438215_pgfId-1297371" xreflabel=""/> int <emphasis>stripe_count</emphasis>, int <emphasis>stripe_pattern</emphasis>);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297372" xreflabel=""/>int llapi_file_create(const char *<emphasis>name</emphasis>, unsigned long long <emphasis>stripe_size</emphasis>,
-<anchor xml:id="dbdoclet.50438215_pgfId-1297373" xreflabel=""/> int <emphasis>stripe_offset</emphasis>, int <emphasis>stripe_count</emphasis>,
-<anchor xml:id="dbdoclet.50438215_pgfId-1297374" xreflabel=""/> int <emphasis>stripe_pattern</emphasis>);
-</screen>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1298000" xreflabel=""/>Description</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298001" xreflabel=""/>The llapi_file_create() call is equivalent to the llapi_file_open call with <emphasis>flags</emphasis> equal to O_CREAT|O_WRONLY and <emphasis>mode</emphasis> equal to 0644, followed by file close.</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298510" xreflabel=""/>llapi_file_open() opens a file with a given name on a Lustre filesystem.</para>
- <informaltable frame="all">
- <tgroup cols="2">
- <colspec colname="c1" colwidth="50*"/>
- <colspec colname="c2" colwidth="50*"/>
- <thead>
- <row>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1298598" xreflabel=""/>Option</emphasis></para></entry>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1298600" xreflabel=""/>Description</emphasis></para></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298602" xreflabel=""/><emphasis role="bold">flags</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298636" xreflabel=""/>Can be a combination of O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, O_NONBLOCK, O_SYNC, FASYNC, O_DIRECT, O_LARGEFILE, O_DIRECTORY, O_NOFOLLOW, O_NOATIME.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298606" xreflabel=""/><emphasis role="bold">mode</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298656" xreflabel=""/>Specifies the permission bits to be used for a new file when O_CREAT is used.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298610" xreflabel=""/><emphasis role="bold">stripe_size</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298669" xreflabel=""/>Specifies stripe size (in bytes). Should be multiple of 64 KB, not exceeding 4 GB.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298614" xreflabel=""/><emphasis role="bold">stripe_offset</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298678" xreflabel=""/>Specifies an OST index from which the file should start. The default value is -1.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298618" xreflabel=""/><emphasis role="bold">stripe_count</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298687" xreflabel=""/>Specifies the number of OSTs to stripe the file across. The default value is -1.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298693" xreflabel=""/><emphasis role="bold">stripe_pattern</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298705" xreflabel=""/>Specifies the striping pattern. In this version of Lustre, only LOV_PATTERN_RAID0 is available. The default value is 0.</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1298592" xreflabel=""/>Return Values</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297430" xreflabel=""/>llapi_file_open() and llapi_file_create() return:</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297431" xreflabel=""/><emphasis role="bold">>=0</emphasis> On success, for llapi_file_open the return value is a file descriptor</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297432" xreflabel=""/><emphasis role="bold"><0</emphasis> On failure, the absolute value is an error code</para>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1298750" xreflabel=""/>Errors</title>
- <informaltable frame="all">
- <tgroup cols="2">
- <colspec colname="c1" colwidth="50*"/>
- <colspec colname="c2" colwidth="50*"/>
- <thead>
- <row>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1297435" xreflabel=""/>Errors</emphasis></para></entry>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1297437" xreflabel=""/>Description</emphasis></para></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297439" xreflabel=""/><emphasis role="bold">EINVAL</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297441" xreflabel=""/><emphasis role="bold">stripe_size</emphasis> or <emphasis role="bold">stripe_offset</emphasis> or <emphasis role="bold">stripe_count</emphasis> or <emphasis role="bold">stripe_pattern</emphasis> is invalid.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297443" xreflabel=""/><emphasis role="bold">EEXIST</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298878" xreflabel=""/>Striping information has already been set and cannot be altered; <emphasis role="bold">name</emphasis> already exists.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297447" xreflabel=""/><emphasis role="bold">EALREADY</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297449" xreflabel=""/>Striping information has already been set and cannot be altered</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297451" xreflabel=""/><emphasis role="bold">ENOTTY</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297453" xreflabel=""/><emphasis role="bold">name</emphasis> may not point to a Lustre filesystem.</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297462" xreflabel=""/>Example</title>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1297463" xreflabel=""/>#include <sys/types.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297464" xreflabel=""/>#include <sys/stat.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297465" xreflabel=""/>#include <fcntl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297466" xreflabel=""/>#include <errno.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297467" xreflabel=""/>#include <stdio.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297468" xreflabel=""/>#include <liblustre.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297469" xreflabel=""/>#include <lustre/lustre_idl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297470" xreflabel=""/>#include <lustre/liblustreapi.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297471" xreflabel=""/>#include <lustre/lustre_user.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297472" xreflabel=""/>int main(int argc, char *argv[])
-<anchor xml:id="dbdoclet.50438215_pgfId-1297473" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297474" xreflabel=""/> int rc;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297475" xreflabel=""/> if (argc != 2)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297476" xreflabel=""/> return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297477" xreflabel=""/> rc = llapi_file_create(argv[1], 1048576, 0, 2, LOV_PATTERN_RAID0);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297478" xreflabel=""/> if (rc < 0) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297479" xreflabel=""/> fprintf(stderr, "file creation has failed, %s\n", strerror\
-(-rc));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297480" xreflabel=""/> return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297481" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297482" xreflabel=""/> printf("%s with stripe size 1048576, striped across 2 OSTs,"
-<anchor xml:id="dbdoclet.50438215_pgfId-1297483" xreflabel=""/> " has been created!\n", argv[1]);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297484" xreflabel=""/> return 0;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297485" xreflabel=""/>}
-</screen>
- </section>
+ <section remap="h5">
+ <title>Examples</title>
+ <para>System default size is 4 MB.</para>
+ <screen>char *tfile = TESTFILE;
+int stripe_size = 65536</screen>
+ <para>To start at default, run:</para>
+ <screen>int stripe_offset = -1</screen>
+ <para>To start at the default, run:</para>
+ <screen>int stripe_count = 1</screen>
+ <para>To set a single stripe for this example, run:</para>
+ <screen>int stripe_pattern = 0</screen>
+ <para>Currently, only RAID 0 is supported.</para>
+ <screen>int stripe_pattern = 0;
+int rc, fd;
+rc = llapi_file_create(tfile, stripe_size,stripe_offset, stripe_count,stripe_pattern);</screen>
+ <para>Result code is inverted, you may return with '<literal>EINVAL</literal>' or an ioctl error.</para>
+ <screen>if (rc) {
+fprintf(stderr,"llapi_file_create failed: %d (%s) 0, rc, strerror(-rc));return -1; }</screen>
+ <para><literal>llapi_file_create</literal> closes the file descriptor. You must re-open the descriptor. To do this, run:</para>
+ <screen>fd = open(tfile, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644); if (fd < 0) \ {
+fprintf(stderr, "Can't open %s file: %s0, tfile,
+str-
+error(errno));
+return -1;
+}</screen>
</section>
- <section remap="h2">
- <title>34.4 <anchor xml:id="dbdoclet.50438215_12433" xreflabel=""/>llapi_quotactl</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297144" xreflabel=""/>Use llapi_quotactl to manipulate disk quotas on a Lustre file system.</para>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297145" xreflabel=""/>Synopsis</title>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1297146" xreflabel=""/>#include <liblustre.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297147" xreflabel=""/>#include <lustre/lustre_idl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297148" xreflabel=""/>#include <lustre/liblustreapi.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297149" xreflabel=""/>#include <lustre/lustre_user.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297150" xreflabel=""/>int llapi_quotactl(char" " *mnt," " struct if_quotactl" " *qctl)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297151" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297152" xreflabel=""/>struct if_quotactl {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297153" xreflabel=""/> __u32 qc_cmd;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297154" xreflabel=""/> __u32 qc_type;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297155" xreflabel=""/> __u32 qc_id;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297156" xreflabel=""/> __u32 qc_stat;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297157" xreflabel=""/> struct obd_dqinfo qc_dqinfo;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297158" xreflabel=""/> struct obd_dqblk qc_dqblk;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297159" xreflabel=""/> char obd_type[16];
-<anchor xml:id="dbdoclet.50438215_pgfId-1297160" xreflabel=""/> struct obd_uuid obd_uuid;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297161" xreflabel=""/>};
-<anchor xml:id="dbdoclet.50438215_pgfId-1297162" xreflabel=""/>struct obd_dqblk {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297163" xreflabel=""/> __u64 dqb_bhardlimit;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297164" xreflabel=""/> __u64 dqb_bsoftlimit;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297165" xreflabel=""/> __u64 dqb_curspace;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297166" xreflabel=""/> __u64 dqb_ihardlimit;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297167" xreflabel=""/> __u64 dqb_isoftlimit;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297168" xreflabel=""/> __u64 dqb_curinodes;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297169" xreflabel=""/> __u64 dqb_btime;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297170" xreflabel=""/> __u64 dqb_itime;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297171" xreflabel=""/> __u32 dqb_valid;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297172" xreflabel=""/> __u32 padding;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297173" xreflabel=""/>};
-<anchor xml:id="dbdoclet.50438215_pgfId-1297174" xreflabel=""/>struct obd_dqinfo {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297175" xreflabel=""/> __u64 dqi_bgrace;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297176" xreflabel=""/> __u64 dqi_igrace;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297177" xreflabel=""/> __u32 dqi_flags;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297178" xreflabel=""/> __u32 dqi_valid;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297179" xreflabel=""/>};
-<anchor xml:id="dbdoclet.50438215_pgfId-1297180" xreflabel=""/>struct obd_uuid {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297181" xreflabel=""/> char uuid[40];
-<anchor xml:id="dbdoclet.50438215_pgfId-1297182" xreflabel=""/>};
+ </section>
+ <section xml:id="dbdoclet.50438215_50149">
+ <title>llapi_file_get_stripe</title>
+ <para>Use <literal>llapi_file_get_stripe</literal> to get striping information for a file or directory on a Lustre file system.</para>
+ <section remap="h5">
+ <title>Synopsis</title>
+ <screen>
+#include <lustre/lustreapi.h>
+
+int llapi_file_get_stripe(const char *<emphasis>path</emphasis>, void *<emphasis>lum</emphasis>);</screen>
+ </section>
+ <section remap="h5">
+ <title>Description</title>
+ <para>The <literal>llapi_file_get_stripe()</literal> function returns striping information for a file or directory <emphasis>path</emphasis> in <emphasis>lum</emphasis> (which should point to a large enough memory region) in one of the following formats:</para>
+ <screen>struct lov_user_md_v1 {
+__u32 lmm_magic;
+__u32 lmm_pattern;
+__u64 lmm_object_id;
+__u64 lmm_object_seq;
+__u32 lmm_stripe_size;
+__u16 lmm_stripe_count;
+__u16 lmm_stripe_offset;
+struct lov_user_ost_data_v1 lmm_objects[0];
+} __attribute__((packed));
+struct lov_user_md_v3 {
+__u32 lmm_magic;
+__u32 lmm_pattern;
+__u64 lmm_object_id;
+__u64 lmm_object_seq;
+__u32 lmm_stripe_size;
+__u16 lmm_stripe_count;
+__u16 lmm_stripe_offset;
+char lmm_pool_name[LOV_MAXPOOLNAME];
+struct lov_user_ost_data_v1 lmm_objects[0];
+} __attribute__((packed));</screen>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Option</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para> <literal>lmm_magic</literal></para>
+ </entry>
+ <entry>
+ <para>Specifies the format of the returned striping information. <literal>LOV_MAGIC_V1</literal> is used for lov_user_md_v1. LOV_MAGIC_V3 is used for <literal>lov_user_md_v3</literal>.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>lmm_pattern</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the striping pattern. Only <literal>LOV_PATTERN_RAID0</literal> is
+ possible in this Lustre software release.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>lmm_object_id</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the MDS object ID.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>lmm_object_gr</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the MDS object group.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>lmm_stripe_size</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the stripe size in bytes.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>lmm_stripe_count</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the number of OSTs over which the file is striped.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>lmm_stripe_offset</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the OST index from which the file starts.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>lmm_pool_name</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the OST pool name to which the file belongs.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>lmm_objects</literal></para>
+ </entry>
+ <entry>
+ <para>An array of <literal>lmm_stripe_count</literal> members containing per OST file information in</para>
+ <para>the following format:</para>
+ <screen>struct lov_user_ost_data_v1 {
+ __u64 l_object_id;
+ __u64 l_object_seq;
+ __u32 l_ost_gen;
+ __u32 l_ost_idx;
+ } __attribute__((packed));</screen>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>l_object_id</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the OST's object ID.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>l_object_seq</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the OST's object group.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>l_ost_gen</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the OST's index generation.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>l_ost_idx</literal></para>
+ </entry>
+ <entry>
+ <para>Holds the OST's index in LOV.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section remap="h5">
+ <title>Return Values</title>
+ <para><literal>llapi_file_get_stripe()</literal> returns:</para>
+ <para><literal>0</literal> On success</para>
+ <para><literal>!= 0</literal> On failure, <literal>errno</literal> is set appropriately</para>
+ </section>
+ <section remap="h5">
+ <title>Errors</title>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Errors</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para> <literal>ENOMEM</literal></para>
+ </entry>
+ <entry>
+ <para>Failed to allocate memory</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENAMETOOLONG</literal></para>
+ </entry>
+ <entry>
+ <para>Path was too long</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENOENT</literal></para>
+ </entry>
+ <entry>
+ <para>Path does not point to a file or directory</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENOTTY</literal></para>
+ </entry>
+ <entry>
+ <para>Path does not point to a Lustre file system</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>EFAULT</literal></para>
+ </entry>
+ <entry>
+ <para>Memory region pointed by lum is not properly mapped</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section remap="h5">
+ <title>Examples</title>
+ <programlisting>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <lustre/lustreapi.h>
+
+static inline int maxint(int a, int b)
+{
+ return a > b ? a : b;
+}
+static void *alloc_lum()
+{
+ int v1, v3, join;
+ v1 = sizeof(struct lov_user_md_v1) +
+ LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
+ v3 = sizeof(struct lov_user_md_v3) +
+ LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
+ return malloc(maxint(v1, v3));
+}
+int main(int argc, char** argv)
+{
+ struct lov_user_md *lum_file = NULL;
+ int rc;
+ int lum_size;
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
+ return 1;
+ }
+ lum_file = alloc_lum();
+ if (lum_file == NULL) {
+ rc = ENOMEM;
+ goto cleanup;
+ }
+ rc = llapi_file_get_stripe(argv[1], lum_file);
+ if (rc) {
+ rc = errno;
+ goto cleanup;
+ }
+ /* stripe_size stripe_count */
+ printf("%d %d\n",
+ lum_file->lmm_stripe_size,
+ lum_file->lmm_stripe_count);
+cleanup:
+ if (lum_file != NULL)
+ free(lum_file);
+ return rc;
+}
+</programlisting>
+ </section>
+ </section>
+ <section xml:id="dbdoclet.50438215_86607">
+ <title>
+ <literal>llapi_file_open</literal>
+ </title>
+ <para>The <literal>llapi_file_open</literal> command opens (or creates) a file or device on a
+ Lustre file system.</para>
+ <section remap="h5">
+ <title>Synopsis</title>
+ <screen>#include <lustre/lustreapi.h>
+int llapi_file_open(const char *<emphasis>name</emphasis>, int <emphasis>flags</emphasis>, int <emphasis>mode</emphasis>,
+ unsigned long long <emphasis>stripe_size</emphasis>, int <emphasis>stripe_offset</emphasis>,
+ int <emphasis>stripe_count</emphasis>, int <emphasis>stripe_pattern</emphasis>);
+int llapi_file_create(const char *<emphasis>name</emphasis>, unsigned long long <emphasis>stripe_size</emphasis>,
+ int <emphasis>stripe_offset</emphasis>, int <emphasis>stripe_count</emphasis>,
+ int <emphasis>stripe_pattern</emphasis>);
</screen>
- </section>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297183" xreflabel=""/>Description</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297184" xreflabel=""/>The llapi_quotactl() command manipulates disk quotas on a Lustre file system mount. qc_cmd indicates a command to be applied to UID qc_id or GID qc_id.</para>
- <informaltable frame="all">
- <tgroup cols="2">
- <colspec colname="c1" colwidth="50*"/>
- <colspec colname="c2" colwidth="50*"/>
- <thead>
- <row>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1297187" xreflabel=""/>Option</emphasis></para></entry>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1297189" xreflabel=""/>Description</emphasis></para></entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297191" xreflabel=""/><emphasis role="bold">LUSTRE_Q_QUOTAON</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297193" xreflabel=""/>Turns on quotas for a Lustre file system. <emphasis>qc_type</emphasis> is USRQUOTA, GRPQUOTA or UGQUOTA (both user and group quota). The quota files must exist. They are normally created with the llapi_quotacheck call. This call is restricted to the super user privilege.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297195" xreflabel=""/><emphasis role="bold">LUSTRE_Q_QUOTAOFF</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297197" xreflabel=""/>Turns off quotas for a Lustre file system. <emphasis>qc_type</emphasis> is USRQUOTA, GRPQUOTA or UGQUOTA (both user and group quota). This call is restricted to the super user privilege.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297199" xreflabel=""/><emphasis role="bold">LUSTRE_Q_GETQUOTA</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297201" xreflabel=""/>Gets disk quota limits and current usage for user or group <emphasis>qc_id</emphasis>. <emphasis>qc_type</emphasis> is USRQUOTA or GRPQUOTA. <emphasis>uuid</emphasis> may be filled with OBD UUID string to query quota information from a specific node. <emphasis>dqb_valid</emphasis> may be set nonzero to query information only from MDS. If <emphasis>uuid</emphasis> is an empty string and <emphasis>dqb_valid</emphasis> is zero then cluster-wide limits and usage are returned. On return, <emphasis>obd_dqblk</emphasis> contains the requested information (block limits unit is kilobyte). Quotas must be turned on before using this command.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297203" xreflabel=""/><emphasis role="bold">LUSTRE_Q_SETQUOTA</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297205" xreflabel=""/>Sets disk quota limits for user or group <emphasis>qc_id</emphasis>. <emphasis>qc_type</emphasis> is USRQUOTA or GRPQUOTA. <emphasis>dqb_valid</emphasis> must be set to QIF_ILIMITS, QIF_BLIMITS or QIF_LIMITS (both inode limits and block limits) dependent on updating limits. <emphasis>obd_dqblk</emphasis> must be filled with limits values (as set in <emphasis>dqb_valid</emphasis>, block limits unit is kilobyte). Quotas must be turned on before using this command.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297207" xreflabel=""/><emphasis role="bold">LUSTRE_Q_GETINFO</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297209" xreflabel=""/>Gets information about quotas. <emphasis>qc_type</emphasis> is either USRQUOTA or GRPQUOTA. On return, <emphasis>dqi_igrace</emphasis> is inode grace time (in seconds), <emphasis>dqi_bgrace</emphasis> is block grace time (in seconds), <emphasis>dqi_flags</emphasis> is not used by the current Lustre version.</para></entry>
- </row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297211" xreflabel=""/><emphasis role="bold">LUSTRE_Q_SETINFO</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297213" xreflabel=""/>Sets quota information (like grace times). <emphasis>qc_type</emphasis> is either USRQUOTA or GRPQUOTA. <emphasis>dqi_igrace</emphasis> is inode grace time (in seconds), <emphasis>dqi_bgrace</emphasis> is block grace time (in seconds), <emphasis>dqi_flags</emphasis> is not used by the current Lustre version and must be zeroed.</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </section>
+ </section>
+ <section remap="h5">
+ <title>Description</title>
+ <para>The <literal>llapi_file_create()</literal> call is equivalent to the <literal>llapi_file_open</literal> call with <emphasis>flags</emphasis> equal to <literal>O_CREAT|O_WRONLY</literal> and <emphasis>mode</emphasis> equal to <literal>0644</literal>, followed by file close.</para>
+ <para><literal>llapi_file_open()</literal> opens a file with a given name on a Lustre file
+ system.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Option</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para> <literal>flags</literal></para>
+ </entry>
+ <entry>
+ <para>Can be a combination of <literal>O_RDONLY</literal>, <literal>O_WRONLY</literal>, <literal>O_RDWR</literal>, <literal>O_CREAT</literal>, <literal>O_EXCL</literal>, <literal>O_NOCTTY</literal>, <literal>O_TRUNC</literal>, <literal>O_APPEND</literal>, <literal>O_NONBLOCK</literal>, <literal>O_SYNC</literal>, <literal>FASYNC</literal>, <literal>O_DIRECT</literal>, <literal>O_LARGEFILE</literal>, <literal>O_DIRECTORY</literal>, <literal>O_NOFOLLOW</literal>, <literal>O_NOATIME</literal>.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>mode</literal></para>
+ </entry>
+ <entry>
+ <para>Specifies the permission bits to be used for a new file when <literal>O_CREAT</literal> is used.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>stripe_size</literal></para>
+ </entry>
+ <entry>
+ <para>Specifies stripe size (in bytes). Should be multiple of 64 KB, not exceeding 4 GB.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>stripe_offset</literal></para>
+ </entry>
+ <entry>
+ <para>Specifies an OST index from which the file should start. The default value is -1.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>stripe_count</literal></para>
+ </entry>
+ <entry>
+ <para>Specifies the number of OSTs to stripe the file across. The default value is -1.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>stripe_pattern</literal></para>
+ </entry>
+ <entry>
+ <para>Specifies the striping pattern. In this release of the Lustre software, only
+ <literal>LOV_PATTERN_RAID0</literal> is available. The default value is
+ 0.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section remap="h5">
+ <title>Return Values</title>
+ <para><literal>llapi_file_open()</literal> and <literal>llapi_file_create()</literal> return:</para>
+ <para><literal>>=0</literal> On success, for <literal>llapi_file_open</literal> the return value is a file descriptor</para>
+ <para><literal><0</literal> On failure, the absolute value is an error code</para>
+ </section>
+ <section remap="h5">
+ <title>Errors</title>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Errors</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para> <literal>EINVAL</literal></para>
+ </entry>
+ <entry>
+ <para><literal>stripe_size</literal> or <literal>stripe_offset</literal> or <literal>stripe_count</literal> or <literal>stripe_pattern</literal> is invalid.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>EEXIST</literal></para>
+ </entry>
+ <entry>
+ <para>Striping information has already been set and cannot be altered; <literal>name</literal> already exists.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>EALREADY</literal></para>
+ </entry>
+ <entry>
+ <para>Striping information has already been set and cannot be altered</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENOTTY</literal></para>
+ </entry>
+ <entry>
+ <para>
+ <literal>name</literal> may not point to a Lustre file system.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section remap="h5">
+ <title>Example</title>
+ <programlisting>
+#include <stdio.h>
+#include <lustre/lustreapi.h>
+
+int main(int argc, char *argv[])
+{
+ int rc;
+ if (argc != 2)
+ return -1;
+ rc = llapi_file_create(argv[1], 1048576, 0, 2, LOV_PATTERN_RAID0);
+ if (rc < 0) {
+ fprintf(stderr, "file creation has failed, %s\n", strerror(-rc));
+ return -1;
+ }
+ printf("%s with stripe size 1048576, striped across 2 OSTs,"
+ " has been created!\n", argv[1]);
+ return 0;
+}
+</programlisting>
+ </section>
+ </section>
+ <section xml:id="dbdoclet.50438215_12433">
+ <title>
+ <literal>llapi_quotactl</literal>
+ </title>
+ <para>Use <literal>llapi_quotact</literal>l to manipulate disk quotas on a Lustre file system.</para>
+ <section remap="h5">
+ <title>Synopsis</title>
+ <screen>#include <lustre/lustreapi.h>
+int llapi_quotactl(char" " *mnt," " struct if_quotactl" " *qctl)
+
+struct if_quotactl {
+ __u32 qc_cmd;
+ __u32 qc_type;
+ __u32 qc_id;
+ __u32 qc_stat;
+ struct obd_dqinfo qc_dqinfo;
+ struct obd_dqblk qc_dqblk;
+ char obd_type[16];
+ struct obd_uuid obd_uuid;
+};
+struct obd_dqblk {
+ __u64 dqb_bhardlimit;
+ __u64 dqb_bsoftlimit;
+ __u64 dqb_curspace;
+ __u64 dqb_ihardlimit;
+ __u64 dqb_isoftlimit;
+ __u64 dqb_curinodes;
+ __u64 dqb_btime;
+ __u64 dqb_itime;
+ __u32 dqb_valid;
+ __u32 padding;
+};
+struct obd_dqinfo {
+ __u64 dqi_bgrace;
+ __u64 dqi_igrace;
+ __u32 dqi_flags;
+ __u32 dqi_valid;
+};
+struct obd_uuid {
+ char uuid[40];
+};</screen>
+ </section>
+ <section remap="h5">
+ <title>Description</title>
+ <para>The <literal>llapi_quotactl()</literal> command manipulates disk quotas on a Lustre file system mount. qc_cmd indicates a command to be applied to UID <literal>qc_id</literal> or GID <literal>qc_id</literal>.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Option</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para> <literal>LUSTRE_Q_GETQUOTA</literal></para>
+ </entry>
+ <entry>
+ <para>Gets disk quota limits and current usage for user or group <emphasis>qc_id</emphasis>. <emphasis>qc_type</emphasis> is <literal>USRQUOTA</literal> or <literal>GRPQUOTA</literal>. <emphasis>uuid</emphasis> may be filled with <literal>OBD UUID</literal> string to query quota information from a specific node. <emphasis>dqb_valid</emphasis> may be set nonzero to query information only from MDS. If <emphasis>uuid</emphasis> is an empty string and <emphasis>dqb_valid</emphasis> is zero then cluster-wide limits and usage are returned. On return, <emphasis>obd_dqblk</emphasis> contains the requested information (block limits unit is kilobyte). Quotas must be turned on before using this command.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>LUSTRE_Q_SETQUOTA</literal></para>
+ </entry>
+ <entry>
+ <para>Sets disk quota limits for user or group <emphasis>qc_id</emphasis>. <emphasis>qc_type</emphasis> is <literal>USRQUOTA</literal> or <literal>GRPQUOTA</literal>. <emphasis>dqb_valid</emphasis> must be set to <literal>QIF_ILIMITS</literal>, <literal>QIF_BLIMITS</literal> or <literal>QIF_LIMITS</literal> (both inode limits and block limits) dependent on updating limits. <emphasis>obd_dqblk</emphasis> must be filled with limits values (as set in <emphasis>dqb_valid</emphasis>, block limits unit is kilobyte). Quotas must be turned on before using this command.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>LUSTRE_Q_GETINFO</literal></para>
+ </entry>
+ <entry>
+ <para>Gets information about quotas. <emphasis>qc_type</emphasis> is either
+ <literal>USRQUOTA</literal> or <literal>GRPQUOTA</literal>. On return,
+ <emphasis>dqi_igrace</emphasis> is inode grace time (in seconds),
+ <emphasis>dqi_bgrace</emphasis> is block grace time (in seconds),
+ <emphasis>dqi_flags</emphasis> is not used by the current release of the Lustre
+ software.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>LUSTRE_Q_SETINFO</literal></para>
+ </entry>
+ <entry>
+ <para>Sets quota information (like grace times). <emphasis>qc_type</emphasis> is
+ either <literal>USRQUOTA</literal> or <literal>GRPQUOTA</literal>.
+ <emphasis>dqi_igrace</emphasis> is inode grace time (in seconds),
+ <emphasis>dqi_bgrace</emphasis> is block grace time (in seconds),
+ <emphasis>dqi_flags</emphasis> is not used by the current release of the Lustre
+ software and must be zeroed.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section remap="h5">
+ <title>Return Values</title>
+ <para><literal>llapi_quotactl()</literal> returns:</para>
+ <para><literal>0</literal> On success</para>
+ <para><literal> -1 </literal> On failure and sets error number (<literal>errno</literal>) to indicate the error</para>
+ </section>
+ <section remap="h5">
+ <title>Errors</title>
+ <para><literal>llapi_quotactl</literal> errors are described below.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Errors</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para> <literal>EFAULT</literal></para>
+ </entry>
+ <entry>
+ <para><emphasis>qctl</emphasis> is invalid.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENOSYS</literal></para>
+ </entry>
+ <entry>
+ <para>Kernel or Lustre modules have not been compiled with the <literal>QUOTA</literal> option.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENOMEM</literal></para>
+ </entry>
+ <entry>
+ <para>Insufficient memory to complete operation.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENOTTY</literal></para>
+ </entry>
+ <entry>
+ <para> <emphasis>qc_cmd</emphasis> is invalid.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENOENT</literal></para>
+ </entry>
+ <entry>
+ <para> <emphasis>uuid</emphasis> does not correspond to OBD or <emphasis>mnt</emphasis> does not exist.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>EPERM</literal></para>
+ </entry>
+ <entry>
+ <para>The call is privileged and the caller is not the super user.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ESRCH</literal></para>
+ </entry>
+ <entry>
+ <para>No disk quota is found for the indicated user. Quotas have not been turned on for this file system.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ </section>
+ <section xml:id="dbdoclet.50438215_15718">
+ <title>
+ <literal>llapi_path2fid</literal>
+ </title>
+ <para>Use <literal>llapi_path2fid</literal> to get the FID from the pathname.</para>
+ <section remap="h5">
+ <title>Synopsis</title>
+ <screen>#include <lustre/lustreapi.h>
+
+int llapi_path2fid(const char *path, unsigned long long *seq, unsigned long *oid, unsigned long *ver)</screen>
+ </section>
+ <section remap="h5">
+ <title>Description</title>
+ <para>The <literal>llapi_path2fid</literal> function returns the FID (sequence : object ID : version) for the pathname.</para>
+ </section>
+ <section remap="h5">
+ <title>Return Values</title>
+ <para><literal>llapi_path2fid</literal> returns:</para>
+ <para><literal>0</literal> On success</para>
+ <para>non-zero value On failure</para>
+ </section>
+ </section>
+ <section condition="l29">
+ <title>
+ <literal>llapi_ladvise</literal>
+ </title>
+ <para>Use <literal>llapi_ladvise</literal> to give IO advice/hints on a
+ Lustre file to the server.</para>
<section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297216" xreflabel=""/>Return Values</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298911" xreflabel=""/>llapi_quotactl() returns:</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298922" xreflabel=""/><emphasis role="bold">0</emphasis> On success</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1298923" xreflabel=""/><emphasis role="bold">-1</emphasis> On failure and sets error number (errno) to indicate the error</para>
+ <title>Synopsis</title>
+ <screen>
+#include <lustre/lustreapi.h>
+int llapi_ladvise(int fd, unsigned long long flags,
+ int num_advise, struct llapi_lu_ladvise *ladvise);
+
+struct llapi_lu_ladvise {
+ __u16 lla_advice; /* advice type */
+ __u16 lla_value1; /* values for different advice types */
+ __u32 lla_value2;
+ __u64 lla_start; /* first byte of extent for advice */
+ __u64 lla_end; /* last byte of extent for advice */
+ __u32 lla_value3;
+ __u32 lla_value4;
+};
+ </screen>
</section>
<section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297220" xreflabel=""/>Errors</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297258" xreflabel=""/>llapi_quotactl errors are described below.</para>
- <informaltable frame="all">
- <tgroup cols="2">
- <colspec colname="c1" colwidth="50*"/>
- <colspec colname="c2" colwidth="50*"/>
- <thead>
- <row>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1297223" xreflabel=""/>Errors</emphasis></para></entry>
- <entry><para><emphasis role="bold"><anchor xml:id="dbdoclet.50438215_pgfId-1297225" xreflabel=""/>Description</emphasis></para></entry>
- </row>
- </thead>
- <tbody>
+ <title>Description</title>
+ <para>The <literal>llapi_ladvise</literal> function passes an array of
+ <emphasis>num_advise</emphasis> I/O hints (up to a maximum of
+ <emphasis>LAH_COUNT_MAX</emphasis> items) in ladvise for the file
+ descriptor <emphasis>fd</emphasis> from an application to one or more
+ Lustre servers. Optionally, <emphasis>flags</emphasis> can modify how
+ the advice will be processed via bitwise-or'd values:</para>
+ <itemizedlist>
+ <listitem>
+ <para><literal>LF_ASYNC</literal>: Clients return to userspace
+ immediately after submitting ladvise RPCs, leaving server threads to
+ handle the advices asynchronously.</para>
+ </listitem>
+ <listitem>
+ <para><literal>LF_UNSET</literal>: Unset/clear a previous advice
+ (Currently only supports LU_ADVISE_LOCKNOEXPAND).</para>
+ </listitem>
+ </itemizedlist>
+ <para>Each of the <emphasis>ladvise</emphasis> elements is an
+ <emphasis>llapi_lu_ladvise</emphasis> structure, which contains the
+ following fields:
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Field</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
<row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297227" xreflabel=""/><emphasis role="bold">EFAULT</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298931" xreflabel=""/><emphasis>qctl</emphasis> is invalid.</para></entry>
+ <entry>
+ <para> <literal>lla_ladvice</literal></para>
+ </entry>
+ <entry>
+ <para>Specifies the advice for the given file range, currently
+ one of:</para>
+ <para><literal>LU_LADVISE_WILLREAD</literal>: Prefetch data
+ into server cache using optimum I/O size for the server.</para>
+ <para><literal>LU_LADVISE_DONTNEED</literal>: Clean cached data
+ for the specified file range(s) on the server.</para>
+ </entry>
</row>
<row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297231" xreflabel=""/><emphasis role="bold">ENOSYS</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298933" xreflabel=""/>Kernel or Lustre modules have not been compiled with the QUOTA option.</para></entry>
+ <entry>
+ <para> <literal>lla_start</literal></para>
+ </entry>
+ <entry>
+ <para>The offset in bytes for the start of this advice.</para>
+ </entry>
</row>
<row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297235" xreflabel=""/><emphasis role="bold">ENOMEM</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298935" xreflabel=""/>Insufficient memory to complete operation.</para></entry>
+ <entry>
+ <para> <literal>lla_end</literal></para>
+ </entry>
+ <entry>
+ <para>The offset in bytes (non-inclusive) for the end of this
+ advice.</para>
+ </entry>
</row>
<row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297239" xreflabel=""/><emphasis role="bold">ENOTTY</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298937" xreflabel=""/><emphasis>qc_cmd</emphasis> is invalid.</para></entry>
+ <entry>
+ <para> <literal>lla_value1</literal></para>
+ <para> <literal>lla_value2</literal></para>
+ <para> <literal>lla_value3</literal></para>
+ <para> <literal>lla_value4</literal></para>
+ </entry>
+ <entry>
+ <para>Additional arguments for future advice types and
+ should be set to zero if not explicitly required for a given
+ advice type. Advice-specific names for these fields
+ follow.</para>
+ </entry>
</row>
<row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297243" xreflabel=""/><emphasis role="bold">EBUSY</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298939" xreflabel=""/> Cannot process during quotacheck.</para></entry>
+ <entry>
+ <para> <literal>lla_lockahead_mode</literal></para>
+ </entry>
+ <entry>
+ <para>When using LU_ADVISE_LOCKAHEAD, the 'lla_value1' field
+ is used to communicate the requested lock mode, and can be
+ referred to as lla_lockahead_mode.</para>
+ </entry>
</row>
<row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297247" xreflabel=""/><emphasis role="bold">ENOENT</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298941" xreflabel=""/><emphasis>uuid</emphasis> does not correspond to OBD or <emphasis>mnt</emphasis> does not exist.</para></entry>
+ <entry>
+ <para> <literal>lla_peradvice_flags</literal></para>
+ </entry>
+ <entry>
+ <para>When using advices which support them, the 'lla_value2'
+ field is used to communicate per-advice flags and can be
+ referred to as 'lla_peradvice_flags'. Both LF_ASYNC and
+ LF_UNSET are supported as peradvice flags.</para>
+ </entry>
</row>
<row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297251" xreflabel=""/><emphasis role="bold">EPERM</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298943" xreflabel=""/> The call is privileged and the caller is not the super user.</para></entry>
+ <entry>
+ <para> <literal>lla_lockahead_result</literal></para>
+ </entry>
+ <entry>
+ <para>When using LU_ADVISE_LOCKAHEAD, the 'lla_value3' field
+ is used to communicate the result of the request, and can be
+ referred to as lla_lockahead_result.</para>
+ </entry>
</row>
- <row>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1297255" xreflabel=""/><emphasis role="bold">ESRCH</emphasis></para></entry>
- <entry><para> <anchor xml:id="dbdoclet.50438215_pgfId-1298945" xreflabel=""/> No disk quota is found for the indicated user. Quotas have not been turned on for this file system.</para></entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </section>
- </section>
- <section remap="h2">
- <title>34.5 <anchor xml:id="dbdoclet.50438215_15718" xreflabel=""/>llapi_path2fid</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297262" xreflabel=""/>Use llapi_path2fid to get the FID from the pathname.</para>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297263" xreflabel=""/>Synopsis</title>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1297264" xreflabel=""/>#include <lustre/liblustreapi.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297265" xreflabel=""/>#include <lustre/lustre_user.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297266" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297267" xreflabel=""/>int llapi_path2fid(const char *path, unsigned long long *seq, unsigned long\
- *oid, unsigned long *ver)
-</screen>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ <para><literal>llapi_ladvise()</literal> forwards the advice to Lustre
+ servers without guaranteeing how and when servers will react to the
+ advice. Actions may or may not be triggered when the advices are
+ received, depending on the type of the advice as well as the real-time
+ decision of the affected server-side components.
+ </para>
+ <para> A typical usage of <literal>llapi_ladvise()</literal> is to
+ enable applications and users (via <literal>lfs ladvise</literal>)
+ with external knowledge about application I/O patterns to intervene in
+ server-side I/O handling. For example, if a group of different clients
+ are doing small random reads of a file, prefetching pages into OSS
+ cache with big linear reads before the random IO is an overall net
+ benefit. Fetching that data into each client cache with
+ <emphasis>fadvise()</emphasis> may not be beneficial, due to much more
+ data being sent to the clients.
+ </para>
+ <para>
+ LU_LADVISE_LOCKAHEAD merits a special comment. While it is possible
+ and encouraged to use it directly in your application to avoid lock
+ contention (primarily for writing to a single file from multiple
+ clients), it will also be available in the MPI-I/O / MPICH library
+ from ANL for use with the i/o aggregation mode of that library. This
+ is intended (eventually) to be the primary way this feature is used.
+ </para>
+ <para>
+ At the time of writing, this support is proposed as a patch but is
+ not yet merged in to the public ANL code base. Users are encouraged
+ to check their MPICH documentation and/or check with their library
+ provider about support.
+ </para>
+ <para>While conceptually similar to the
+ <emphasis>posix_fadvise</emphasis> and Linux
+ <emphasis>fadvise</emphasis> system calls, the main difference of
+ <literal>llapi_ladvise()</literal> is that
+ <emphasis>fadvise() / posix_fadvise()</emphasis> are client side
+ mechanisms that do not pass advice to the filesystem, while
+ <literal>llapi_ladvise()</literal> sends advice or hints to one or
+ more Lustre servers on which the file is stored. In some cases it may
+ be desirable to use both interfaces.
+ </para>
</section>
<section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297268" xreflabel=""/>Description</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297269" xreflabel=""/>The llapi_path2fid function returns the FID (sequence : object ID : version) for the pathname.</para>
+ <title>Return Values</title>
+ <para><literal>llapi_ladvise</literal> returns:</para>
+ <para><literal>0</literal> On success</para>
+ <para><literal>-1</literal> if an error occurred (in which case, errno
+ is set appropriately).</para>
</section>
<section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297270" xreflabel=""/>Return Values</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297271" xreflabel=""/>llapi_path2fid returns:</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297272" xreflabel=""/><emphasis role="bold">0</emphasis> On success</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297273" xreflabel=""/>non-zero value On failure</para>
+ <title>Errors</title>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="50*"/>
+ <colspec colname="c2" colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>
+ <para><emphasis role="bold">Error</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis role="bold">Description</emphasis></para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para> <literal>ENOMEM</literal></para>
+ </entry>
+ <entry>
+ <para>Insufficient memory to complete operation.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>EINVAL</literal></para>
+ </entry>
+ <entry>
+ <para>One or more invalid arguments are given.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>EFAULT</literal></para>
+ </entry>
+ <entry>
+ <para>Memory region pointed by
+ <literal>ladvise</literal> is not properly mapped.
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para> <literal>ENOTSUPP</literal></para>
+ </entry>
+ <entry>
+ <para>Advice type is not supported.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
</section>
- </section>
- <section remap="h2">
- <title>34.6 Example <anchor xml:id="dbdoclet.50438215_marker-1297700" xreflabel=""/>Using the llapi Library</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297702" xreflabel=""/>Use llapi_file_create to set Lustre properties for a new file. For a synopsis and description of llapi_file_create and examples of how to use it, see <link xl:href="ConfigurationFilesModuleParameters.html#50438293_72504">Chapter 35</link>: <link xl:href="ConfigurationFilesModuleParameters.html#50438293_66186">Configuration Files and Module Parameters</link>.</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297709" xreflabel=""/>You can set striping from inside programs like ioctl. To compile the sample program, you need to download libtest.c and liblustreapi.c files from the Lustre source tree.</para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297710" xreflabel=""/><emphasis role="bold">A simple C program to demonstrate striping API - libtest.c</emphasis></para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1297711" xreflabel=""/>/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
-<anchor xml:id="dbdoclet.50438215_pgfId-1297712" xreflabel=""/> * vim:expandtab:shiftwidth=8:tabstop=8:
-<anchor xml:id="dbdoclet.50438215_pgfId-1297713" xreflabel=""/> *
-<anchor xml:id="dbdoclet.50438215_pgfId-1297714" xreflabel=""/> * lustredemo - simple code examples of liblustreapi functions
-<anchor xml:id="dbdoclet.50438215_pgfId-1297715" xreflabel=""/> */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297716" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297717" xreflabel=""/>#include <stdio.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297718" xreflabel=""/>#include <fcntl.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297719" xreflabel=""/>#include <sys/stat.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297720" xreflabel=""/>#include <sys/types.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297721" xreflabel=""/>#include <dirent.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297722" xreflabel=""/>#include <errno.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297723" xreflabel=""/>#include <string.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297724" xreflabel=""/>#include <unistd.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297725" xreflabel=""/>#include <stdlib.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297726" xreflabel=""/>#include <lustre/liblustreapi.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297727" xreflabel=""/>#include <lustre/lustre_user.h>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297728" xreflabel=""/>#define MAX_OSTS 1024
-<anchor xml:id="dbdoclet.50438215_pgfId-1297729" xreflabel=""/>#define LOV_EA_SIZE(lum, num) (sizeof(*lum) + num * sizeof(*lum->lmm_objects\
-))
-<anchor xml:id="dbdoclet.50438215_pgfId-1297730" xreflabel=""/>#define LOV_EA_MAX(lum) LOV_EA_SIZE(lum, MAX_OSTS)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297731" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297732" xreflabel=""/>/*
-<anchor xml:id="dbdoclet.50438215_pgfId-1297733" xreflabel=""/>This program provides crude examples of using the liblustre API functions
-<anchor xml:id="dbdoclet.50438215_pgfId-1297734" xreflabel=""/>*/
-<anchor xml:id="dbdoclet.50438215_pgfId-1297735" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297736" xreflabel=""/>/* Change these definitions to suit */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297737" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297738" xreflabel=""/>#define TESTDIR "/tmp" /* R\
-esults directory */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297739" xreflabel=""/>#define TESTFILE "lustre_dummy" \
- /* Name for the file we create/destroy */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297740" xreflabel=""/>#define FILESIZE 262144 \
-/* Size of the file in words */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297741" xreflabel=""/>#define DUMWORD "DEADBEEF" \
- /* Dummy word used to fill files */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297742" xreflabel=""/>#define MY_STRIPE_WIDTH 2 \
-/* Set this to the number of OST required */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297743" xreflabel=""/>#define MY_LUSTRE_DIR "/mnt/lustre/ftest"
-<anchor xml:id="dbdoclet.50438215_pgfId-1297744" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297745" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297746" xreflabel=""/>int close_file(int fd)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297747" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297748" xreflabel=""/> if (close(fd) < 0) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297749" xreflabel=""/> fprintf(stderr, "File close failed: %d (%s)\n", errno, strerror(er\
-rno));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297750" xreflabel=""/> return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297751" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297752" xreflabel=""/> return 0;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297753" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297754" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297755" xreflabel=""/>int write_file(int fd)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297756" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297757" xreflabel=""/> char *stng = DUMWORD;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297758" xreflabel=""/> int cnt = 0;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297759" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297760" xreflabel=""/> for( cnt = 0; cnt < FILESIZE; cnt++) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297761" xreflabel=""/> write(fd, stng, sizeof(stng));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297762" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297763" xreflabel=""/> return 0;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297764" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297765" xreflabel=""/>/* Open a file, set a specific stripe count, size and starting OST
-<anchor xml:id="dbdoclet.50438215_pgfId-1297766" xreflabel=""/> Adjust the parameters to suit */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297767" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297768" xreflabel=""/>int open_stripe_file()
-<anchor xml:id="dbdoclet.50438215_pgfId-1297769" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297770" xreflabel=""/> char *tfile = TESTFILE;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297771" xreflabel=""/> int stripe_size = 65536; \
- /* System default is 4M */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297772" xreflabel=""/> int stripe_offset = -1; \
- /* Start at default */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297773" xreflabel=""/> int stripe_count = MY_STRIPE_WIDTH; \
- /*Single stripe for this demo*/
-<anchor xml:id="dbdoclet.50438215_pgfId-1297774" xreflabel=""/> int stripe_pattern = 0; \
- /* only RAID 0 at this time */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297775" xreflabel=""/> int rc, fd;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297776" xreflabel=""/> /*
-<anchor xml:id="dbdoclet.50438215_pgfId-1297777" xreflabel=""/> */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297778" xreflabel=""/> rc = llapi_file_create(tfile,
-<anchor xml:id="dbdoclet.50438215_pgfId-1297779" xreflabel=""/>stripe_size,stripe_offset,stripe_count,stripe_pattern);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297780" xreflabel=""/> /* result code is inverted, we may return -EINVAL or an ioctl error.
-<anchor xml:id="dbdoclet.50438215_pgfId-1297781" xreflabel=""/> We borrow an error message from sanity.c
-<anchor xml:id="dbdoclet.50438215_pgfId-1297782" xreflabel=""/> */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297783" xreflabel=""/> if (rc) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297784" xreflabel=""/> fprintf(stderr,"llapi_file_create failed: %d (%s) \n", rc, st\
-rerror(-rc));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297785" xreflabel=""/> return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297786" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297787" xreflabel=""/> /* llapi_file_create closes the file descriptor, we must re-open */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297788" xreflabel=""/> fd = open(tfile, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297789" xreflabel=""/> if (fd < 0) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297790" xreflabel=""/> fprintf(stderr, "Can't open %s file: %d (%s)\n", tfile, errno\
-, strerror(errno));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297791" xreflabel=""/> return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297792" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297793" xreflabel=""/> return fd;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297794" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297795" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297796" xreflabel=""/>/* output a list of uuids for this file */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297797" xreflabel=""/>int get_my_uuids(int fd)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297798" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297799" xreflabel=""/> struct obd_uuid uuids[1024], *uuidp; \
- /* Output var */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297800" xreflabel=""/> int obdcount = 1024;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297801" xreflabel=""/> int rc,i;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297802" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297803" xreflabel=""/> rc = llapi_lov_get_uuids(fd, uuids, &obdcount);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297804" xreflabel=""/> if (rc != 0) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297805" xreflabel=""/> fprintf(stderr, "get uuids failed: %d (%s)\n",errno, strerror(errn\
-o));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297806" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297807" xreflabel=""/> printf("This file system has %d obds\n", obdcount);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297808" xreflabel=""/> for (i = 0, uuidp = uuids; i < obdcount; i++, uuidp++) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297809" xreflabel=""/> printf("UUID %d is %s\n",i, uuidp->uuid);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297810" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297811" xreflabel=""/> return 0;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297812" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297813" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297814" xreflabel=""/>/* Print out some LOV attributes. List our objects */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297815" xreflabel=""/>int get_file_info(char *path)
-<anchor xml:id="dbdoclet.50438215_pgfId-1297816" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297817" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297818" xreflabel=""/> struct lov_user_md *lump;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297819" xreflabel=""/> int rc;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297820" xreflabel=""/> int i;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297821" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297822" xreflabel=""/> lump = malloc(LOV_EA_MAX(lump));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297823" xreflabel=""/> if (lump == NULL) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297824" xreflabel=""/> return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297825" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297826" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297827" xreflabel=""/> rc = llapi_file_get_stripe(path, lump);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297828" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297829" xreflabel=""/> if (rc != 0) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297830" xreflabel=""/> fprintf(stderr, "get_stripe failed: %d (%s)\n",errno, strerror(err\
-no));
-<anchor xml:id="dbdoclet.50438215_pgfId-1297831" xreflabel=""/> return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297832" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297833" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297834" xreflabel=""/> printf("Lov magic %u\n", lump->lmm_magic);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297835" xreflabel=""/> printf("Lov pattern %u\n", lump->lmm_pattern);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297836" xreflabel=""/> printf("Lov object id %llu\n", lump->lmm_object_id);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297837" xreflabel=""/> printf("Lov object group %llu\n", lump->lmm_object_gr);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297838" xreflabel=""/> printf("Lov stripe size %u\n", lump->lmm_stripe_size);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297839" xreflabel=""/> printf("Lov stripe count %hu\n", lump->lmm_stripe_count);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297840" xreflabel=""/> printf("Lov stripe offset %u\n", lump->lmm_stripe_offset);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297841" xreflabel=""/> for (i = 0; i < lump->lmm_stripe_count; i++) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297842" xreflabel=""/> printf("Object index %d Objid %llu\n", lump->lmm_objects[i].l_ost_i\
-dx, lump->lmm_objects[i].l_object_id);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297843" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297844" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297845" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297846" xreflabel=""/> free(lump);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297847" xreflabel=""/> return rc;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297848" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297849" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297850" xreflabel=""/>/* Ping all OSTs that belong to this filesysem */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297851" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297852" xreflabel=""/>int ping_osts()
-<anchor xml:id="dbdoclet.50438215_pgfId-1297853" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297854" xreflabel=""/> DIR *dir;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297855" xreflabel=""/> struct dirent *d;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297856" xreflabel=""/> char osc_dir[100];
-<anchor xml:id="dbdoclet.50438215_pgfId-1297857" xreflabel=""/> int rc;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297858" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297859" xreflabel=""/> sprintf(osc_dir, "/proc/fs/lustre/osc");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297860" xreflabel=""/> dir = opendir(osc_dir);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297861" xreflabel=""/> if (dir == NULL) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297862" xreflabel=""/> printf("Can't open dir\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297863" xreflabel=""/> return -1;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297864" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297865" xreflabel=""/> while((d = readdir(dir)) != NULL) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297866" xreflabel=""/> if ( d->d_type == DT_DIR ) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297867" xreflabel=""/> if (! strncmp(d->d_name, "OSC", 3)) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297868" xreflabel=""/> printf("Pinging OSC %s ", d->d_name);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297869" xreflabel=""/> rc = llapi_ping("osc", d->d_name);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297870" xreflabel=""/> if (rc) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297871" xreflabel=""/> printf(" bad\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297872" xreflabel=""/> } else {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297873" xreflabel=""/> printf(" good\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297874" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297875" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297876" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297877" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297878" xreflabel=""/> return 0;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297879" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297880" xreflabel=""/>}
-<anchor xml:id="dbdoclet.50438215_pgfId-1297881" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297882" xreflabel=""/>int main()
-<anchor xml:id="dbdoclet.50438215_pgfId-1297883" xreflabel=""/>{
-<anchor xml:id="dbdoclet.50438215_pgfId-1297884" xreflabel=""/> int file;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297885" xreflabel=""/> int rc;
-<anchor xml:id="dbdoclet.50438215_pgfId-1297886" xreflabel=""/> char filename[100];
-<anchor xml:id="dbdoclet.50438215_pgfId-1297887" xreflabel=""/> char sys_cmd[100];
-<anchor xml:id="dbdoclet.50438215_pgfId-1297888" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297889" xreflabel=""/> sprintf(filename, "%s/%s",MY_LUSTRE_DIR, TESTFILE);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297890" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297891" xreflabel=""/> printf("Open a file with striping\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297892" xreflabel=""/> file = open_stripe_file();
-<anchor xml:id="dbdoclet.50438215_pgfId-1297893" xreflabel=""/> if ( file < 0 ) {
-<anchor xml:id="dbdoclet.50438215_pgfId-1297894" xreflabel=""/> printf("Exiting\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297895" xreflabel=""/> exit(1);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297896" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297897" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297898" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297899" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297900" xreflabel=""/> }
-<anchor xml:id="dbdoclet.50438215_pgfId-1297901" xreflabel=""/> printf("Getting uuid list\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297902" xreflabel=""/> rc = get_my_uuids(file);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297903" xreflabel=""/> rintf("Write to the file\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297904" xreflabel=""/> rc = write_file(file);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297905" xreflabel=""/> rc = close_file(file);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297906" xreflabel=""/> printf("Listing LOV data\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297907" xreflabel=""/> rc = get_file_info(filename);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297908" xreflabel=""/> printf("Ping our OSTs\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297909" xreflabel=""/> rc = ping_osts();
-<anchor xml:id="dbdoclet.50438215_pgfId-1297910" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297911" xreflabel=""/> /* the results should match lfs getstripe */
-<anchor xml:id="dbdoclet.50438215_pgfId-1297912" xreflabel=""/> printf("Confirming our results with lfs getsrtipe\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297913" xreflabel=""/> sprintf(sys_cmd, "/usr/bin/lfs getstripe %s/%s", MY_LUSTRE_DIR, TESTFILE);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297914" xreflabel=""/> system(sys_cmd);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297915" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297916" xreflabel=""/> printf("All done\n");
-<anchor xml:id="dbdoclet.50438215_pgfId-1297917" xreflabel=""/> exit(rc);
-<anchor xml:id="dbdoclet.50438215_pgfId-1297918" xreflabel=""/>}
-</screen>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297919" xreflabel=""/><emphasis role="bold">Makefile for sample application:</emphasis></para>
- <screen><anchor xml:id="dbdoclet.50438215_pgfId-1297920" xreflabel=""/>
-<anchor xml:id="dbdoclet.50438215_pgfId-1297921" xreflabel=""/>gcc -g -O2 -Wall -o lustredemo libtest.c -llustreapi
-<anchor xml:id="dbdoclet.50438215_pgfId-1297922" xreflabel=""/>clean:
-<anchor xml:id="dbdoclet.50438215_pgfId-1297923" xreflabel=""/>rm -f core lustredemo *.o
-<anchor xml:id="dbdoclet.50438215_pgfId-1297924" xreflabel=""/>run:
-<anchor xml:id="dbdoclet.50438215_pgfId-1297925" xreflabel=""/>make
-<anchor xml:id="dbdoclet.50438215_pgfId-1297926" xreflabel=""/>rm -f /mnt/lustre/ftest/lustredemo
-<anchor xml:id="dbdoclet.50438215_pgfId-1297927" xreflabel=""/>rm -f /mnt/lustre/ftest/lustre_dummy
-<anchor xml:id="dbdoclet.50438215_pgfId-1297928" xreflabel=""/>cp lustredemo /mnt/lustre/ftest/
+ </section>
+ <section xml:id="dbdoclet.50438215_marker-1297700">
+ <title>Example Using the <literal>llapi</literal> Library</title>
+ <para>Use <literal>llapi_file_create</literal> to set Lustre software properties for a new file.
+ For a synopsis and description of <literal>llapi_file_create</literal> and examples of how to
+ use it, see <xref linkend="configurationfilesmoduleparameters"/>.</para>
+ <para>You can set striping from inside programs like <literal>ioctl</literal>. To compile the sample program, you need to install the Lustre client source RPM.</para>
+ <para><emphasis role="bold">A simple C program to demonstrate striping API - libtest.c</emphasis></para>
+ <programlisting>
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * lustredemo - a simple example of lustreapi functions
+ */
+#include <stdio.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <lustre/lustreapi.h>
+#define MAX_OSTS 1024
+#define LOV_EA_SIZE(lum, num) (sizeof(*lum) + num * sizeof(*lum->lmm_objects))
+#define LOV_EA_MAX(lum) LOV_EA_SIZE(lum, MAX_OSTS)
+
+/*
+ * This program provides crude examples of using the lustreapi API functions
+ */
+/* Change these definitions to suit */
+
+#define TESTDIR "/tmp" /* Results directory */
+#define TESTFILE "lustre_dummy" /* Name for the file we create/destroy */
+#define FILESIZE 262144 /* Size of the file in words */
+#define DUMWORD "DEADBEEF" /* Dummy word used to fill files */
+#define MY_STRIPE_WIDTH 2 /* Set this to the number of OST required */
+#define MY_LUSTRE_DIR "/mnt/lustre/ftest"
+
+int close_file(int fd)
+{
+ if (close(fd) < 0) {
+ fprintf(stderr, "File close failed: %d (%s)\n", errno, strerror(errno));
+ return -1;
+ }
+ return 0;
+}
+
+int write_file(int fd)
+{
+ char *stng = DUMWORD;
+ int cnt = 0;
+
+ for( cnt = 0; cnt < FILESIZE; cnt++) {
+ write(fd, stng, sizeof(stng));
+ }
+ return 0;
+}
+/* Open a file, set a specific stripe count, size and starting OST
+ * Adjust the parameters to suit */
+int open_stripe_file()
+{
+ char *tfile = TESTFILE;
+ int stripe_size = 65536; /* System default is 4M */
+ int stripe_offset = -1; /* Start at default */
+ int stripe_count = MY_STRIPE_WIDTH; /*Single stripe for this demo*/
+ int stripe_pattern = 0; /* only RAID 0 at this time */
+ int rc, fd;
+
+ rc = llapi_file_create(tfile,
+ stripe_size,stripe_offset,stripe_count,stripe_pattern);
+ /* result code is inverted, we may return -EINVAL or an ioctl error.
+ * We borrow an error message from sanity.c
+ */
+ if (rc) {
+ fprintf(stderr,"llapi_file_create failed: %d (%s) \n", rc, strerror(-rc));
+ return -1;
+ }
+ /* llapi_file_create closes the file descriptor, we must re-open */
+ fd = open(tfile, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644);
+ if (fd < 0) {
+ fprintf(stderr, "Can't open %s file: %d (%s)\n", tfile, errno, strerror(errno));
+ return -1;
+ }
+ return fd;
+}
+
+/* output a list of uuids for this file */
+int get_my_uuids(int fd)
+{
+ struct obd_uuid uuids[1024], *uuidp; /* Output var */
+ int obdcount = 1024;
+ int rc,i;
+
+ rc = llapi_lov_get_uuids(fd, uuids, &obdcount);
+ if (rc != 0) {
+ fprintf(stderr, "get uuids failed: %d (%s)\n",errno, strerror(errno));
+ }
+ printf("This file system has %d obds\n", obdcount);
+ for (i = 0, uuidp = uuids; i < obdcount; i++, uuidp++) {
+ printf("UUID %d is %s\n",i, uuidp->uuid);
+ }
+ return 0;
+}
+
+/* Print out some LOV attributes. List our objects */
+int get_file_info(char *path)
+{
+
+ struct lov_user_md *lump;
+ int rc;
+ int i;
+
+ lump = malloc(LOV_EA_MAX(lump));
+ if (lump == NULL) {
+ return -1;
+ }
+
+ rc = llapi_file_get_stripe(path, lump);
+
+ if (rc != 0) {
+ fprintf(stderr, "get_stripe failed: %d (%s)\n",errno, strerror(errno));
+ return -1;
+ }
+
+ printf("Lov magic %u\n", lump->lmm_magic);
+ printf("Lov pattern %u\n", lump->lmm_pattern);
+ printf("Lov object id %llu\n", lump->lmm_object_id);
+ printf("Lov stripe size %u\n", lump->lmm_stripe_size);
+ printf("Lov stripe count %hu\n", lump->lmm_stripe_count);
+ printf("Lov stripe offset %u\n", lump->lmm_stripe_offset);
+ for (i = 0; i < lump->lmm_stripe_count; i++) {
+ printf("Object index %d Objid %llu\n", lump->lmm_objects[i].l_ost_idx, lump->lmm_objects[i].l_object_id);
+ }
+
+ free(lump);
+ return rc;
+
+}
+
+/* Ping all OSTs that belong to this filesystem */
+int ping_osts()
+{
+ DIR *dir;
+ struct dirent *d;
+ char osc_dir[100];
+ int rc;
+
+ sprintf(osc_dir, "/proc/fs/lustre/osc");
+ dir = opendir(osc_dir);
+ if (dir == NULL) {
+ printf("Can't open dir\n");
+ return -1;
+ }
+ while((d = readdir(dir)) != NULL) {
+ if ( d->d_type == DT_DIR ) {
+ if (! strncmp(d->d_name, "OSC", 3)) {
+ printf("Pinging OSC %s ", d->d_name);
+ rc = llapi_ping("osc", d->d_name);
+ if (rc) {
+ printf(" bad\n");
+ } else {
+ printf(" good\n");
+ }
+ }
+ }
+ }
+ return 0;
+
+}
+
+int main()
+{
+ int file;
+ int rc;
+ char filename[100];
+ char sys_cmd[100];
+
+ sprintf(filename, "%s/%s",MY_LUSTRE_DIR, TESTFILE);
+
+ printf("Open a file with striping\n");
+ file = open_stripe_file();
+ if ( file < 0 ) {
+ printf("Exiting\n");
+ exit(1);
+ }
+ printf("Getting uuid list\n");
+ rc = get_my_uuids(file);
+ printf("Write to the file\n");
+ rc = write_file(file);
+ rc = close_file(file);
+ printf("Listing LOV data\n");
+ rc = get_file_info(filename);
+ printf("Ping our OSTs\n");
+ rc = ping_osts();
+
+ /* the results should match lfs getstripe */
+ printf("Confirming our results with lfs getstripe\n");
+ sprintf(sys_cmd, "/usr/bin/lfs getstripe %s/%s", MY_LUSTRE_DIR, TESTFILE);
+ system(sys_cmd);
+
+ printf("All done\n");
+ exit(rc);
+}
+</programlisting>
+ <para><emphasis role="bold">Makefile for sample application:</emphasis></para>
+ <screen>
+gcc -g -O2 -Wall -o lustredemo libtest.c -llustreapi
+clean:
+rm -f core lustredemo *.o
+run:
+make
+rm -f /mnt/lustre/ftest/lustredemo
+rm -f /mnt/lustre/ftest/lustre_dummy
+cp lustredemo /mnt/lustre/ftest/
</screen>
- <section remap="h5">
- <title><anchor xml:id="dbdoclet.50438215_pgfId-1297929" xreflabel=""/>See Also</title>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297942" xreflabel=""/><link xl:href="SettingLustreProperties_HTML.html#50438215_30970">llapi_file_create</link>, <link xl:href="SettingLustreProperties_HTML.html#50438215_50149">llapi_file_get_stripe</link>, <link xl:href="SettingLustreProperties_HTML.html#50438215_86607">llapi_file_open</link>, <link xl:href="SettingLustreProperties_HTML.html#50438215_12433">llapi_quotactl</link></para>
- <para><anchor xml:id="dbdoclet.50438215_pgfId-1297943" xreflabel=""/> </para>
- </section>
+ <section remap="h5">
+ <title>See Also</title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <xref linkend="dbdoclet.50438215_30970"/>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <xref linkend="dbdoclet.50438215_50149"/>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <xref linkend="dbdoclet.50438215_86607"/>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <xref linkend="dbdoclet.50438215_12433"/>
+ </para>
+ </listitem>
+ </itemizedlist>
</section>
</section>
</chapter>