[Lustre-discuss] building example taken from manual page, api, 1.8.1.1

Andreas Dilger adilger at sun.com
Sun Jan 31 22:21:57 PST 2010


On 2010-01-30, at 13:51, DT Piotr Wadas wrote:
> I'm trying to build test program found in manual page  
> llapi_file_create(3).
>
> Lustre suite, including server, client, utils and liblustre was
> configured, source-build and installed by me, machine is booted with
> lustre-enabled kernel, and lustre filesystem is mounted from remote
> server. I use gcc 4.1, machine is x86 (Xeon)
>
> configure options used to build lustre were as follows
>
> ./configure --with-linux=/usr/src/linux-2.6.27.29-0.1_lustre.1.8.1.1
> --enable-server --enable-client --enable-utils --enable-tests
> --enable-liblustre --enable-quota --enable-modules --enable-snmp
>
> The example I pasted from manualpage is ( extern definition added by  
> hand
> same effect, like I wouldn't have done it ).
>
> -------------
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <errno.h>
> #include <stdio.h>
> #include <liblustre.h>
> #include <lustre/lustre_idl.h>
> #include <lustre/liblustreapi.h>
> #include <lustre/lustre_user.h>

FYI, liblustreapi.h includes lustre_user.h, and you shouldn't need  
anything in lustre_idl.h directly.

> extern int llapi_file_create(const char *name, unsigned long long
> 		stripe_size,
>                             int stripe_offset, int stripe_count,
>                             int stripe_pattern);

Also, since liblustreapi.h declares llapi_file_create() itself, I'm  
not sure why you added this.

> 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);

Note that "stripe_offset = 0" actually will force the file to be  
allocated on OST0 + OST1, and in most cases you really want to specify  
"stripe_offset = -1" to allow the MDS to pick the best OST.

> gcc -Wall -g -O2 \
>        -include /usr/src/modules/lustre/config.h \
>        -I/usr/include/lustre \
>        -I/usr/src/modules/lustre/lnet/include \
>        -I/usr/src/modules/lustre/lustre/include \
>        -I/usr/src/modules/lustre/lustre/include/lustre \
>        -L/usr/src/modules/lustre/lnet/utils \
>        -llustre -llustreapi -lncurses -lreadline \
> 	-lnetsnmpagent -lnetsnmphelpers -lnetsnmpmibs -lnetsnmp \
>        -o lopenex lopenex.c

You don't need most of these, just "-llustreapi".  See "lustre/tests/ 
multiop.c" for and example program that links liblustreapi without any  
such complication.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.




More information about the lustre-discuss mailing list