@@ -113,17 +113,16 @@ option_help * POSIX_options(aiori_mod_opt_t ** init_backend_options, aiori_mod_o
113
113
}else {
114
114
memset (o , 0 , sizeof (posix_options_t ));
115
115
o -> direct_io = 0 ;
116
- o -> lustre_stripe_count = -1 ;
117
- #ifdef HAVE_LUSTRE_USER
118
- if (LOV_USER_MAGIC != LOV_USER_MAGIC_V1 ){
119
- strcpy (o -> lustre_pool , "" );
120
- }
121
- #endif /* HAVE_LUSTRE_USER */
116
+ o -> lustre_set_striping = 0 ;
117
+ o -> lustre_stripe_count = 0 ;
118
+ o -> lustre_stripe_size = 0 ;
119
+ o -> lustre_pool = NULL ;
120
+ o -> lustre_set_pool = 0 ;
122
121
o -> lustre_start_ost = -1 ;
123
122
o -> beegfs_numTargets = -1 ;
124
123
o -> beegfs_chunkSize = -1 ;
125
124
}
126
-
125
+
127
126
* init_backend_options = (aiori_mod_opt_t * ) o ;
128
127
129
128
option_help h [] = {
@@ -144,20 +143,23 @@ option_help * POSIX_options(aiori_mod_opt_t ** init_backend_options, aiori_mod_o
144
143
{0 , "posix.gpfs.createsharing" , " Enable efficient file creation in a shared directory" , OPTION_FLAG , 'd' , & o -> gpfs_createsharing },
145
144
#endif
146
145
#endif // HAVE_GPFS_FCNTL_H
147
- #ifdef HAVE_LUSTRE_USER
146
+ #if defined( HAVE_LUSTRE_USER ) || defined ( HAVE_LUSTRE_LUSTREAPI )
148
147
{0 , "posix.lustre.stripecount" , "" , OPTION_OPTIONAL_ARGUMENT , 'd' , & o -> lustre_stripe_count },
149
148
{0 , "posix.lustre.stripesize" , "" , OPTION_OPTIONAL_ARGUMENT , 'd' , & o -> lustre_stripe_size },
150
- {0 , "posix.lustre.pool" , "" , OPTION_OPTIONAL_ARGUMENT , 'd' , & o -> lustre_pool },
151
149
{0 , "posix.lustre.startost" , "" , OPTION_OPTIONAL_ARGUMENT , 'd' , & o -> lustre_start_ost },
152
150
{0 , "posix.lustre.ignorelocks" , "" , OPTION_FLAG , 'd' , & o -> lustre_ignore_locks },
153
151
#endif /* HAVE_LUSTRE_USER */
152
+ #ifdef HAVE_LUSTRE_LUSTREAPI
153
+ {0 , "posix.lustre.pool" , "Name for Lustre pool to use" , OPTION_OPTIONAL_ARGUMENT , 's' , & o -> lustre_pool },
154
+ #endif
154
155
#ifdef HAVE_GPU_DIRECT
155
156
{0 , "gpuDirect" , "allocate I/O buffers on the GPU" , OPTION_FLAG , 'd' , & o -> gpuDirect },
156
157
#endif
157
158
LAST_OPTION
158
159
};
159
160
option_help * help = malloc (sizeof (h ));
160
161
memcpy (help , h , sizeof (h ));
162
+
161
163
return help ;
162
164
}
163
165
@@ -204,26 +206,24 @@ int POSIX_check_params(aiori_mod_opt_t * param){
204
206
posix_options_t * o = (posix_options_t * ) param ;
205
207
if (o -> beegfs_chunkSize != -1 && (!ISPOWEROFTWO (o -> beegfs_chunkSize ) || o -> beegfs_chunkSize < (1 <<16 )))
206
208
ERR ("beegfsChunkSize must be a power of two and >64k" );
207
- if (o -> lustre_stripe_count != -1 || o -> lustre_stripe_size != 0 || o -> lustre_pool != "" ){
209
+ if (o -> lustre_stripe_count != 0 || o -> lustre_stripe_size != 0 || (o -> lustre_pool )){
210
+ #if defined(HAVE_LUSTRE_USER ) || defined(HAVE_LUSTRE_LUSTREAPI )
208
211
o -> lustre_set_striping = 1 ;
209
- /* Setting a lustre pool via the API is only support for Lustre API versions higher than V1 */
210
- /* This code checks that the user hasn't just specified a pool with no stripe size or stripe count */
211
- /* on the V1 API because in that scenario we cannot do anything. If that is the case disable trying */
212
- /* to set the stripe. If stripe count and/or stripe size are set the operation can continue but the */
213
- /* pool will not be applied. */
214
- #ifdef HAVE_LUSTRE_USER
215
- if (o -> lustre_pool != "" && LOV_USER_MAGIC == LOV_USER_MAGIC_V1 ){
216
- WARN ("Lustre pool specified, but the Lustre User API on this system does not support that." );
217
- if (o -> lustre_stripe_count == -1 && o -> lustre_stripe_size == 0 ){
218
- o -> lustre_set_striping = 0 ;
219
- ERR ("Setting Lustre pool is not supported for the version of the Lustre API used on this system" );
220
- }
221
- }else {
222
- if (o -> lustre_pool != "" && o -> lustre_stripe_count <= 0 ){
223
- o -> lustre_stripe_count = 1 ;
224
- }
225
- }
226
- #endif /* HAVE_LUSTRE_USER */
212
+ #else
213
+ WARN ("Lustre striping options set but not available" );
214
+ o -> lustre_set_striping = 0 ;
215
+ #endif
216
+ }
217
+ if ((o -> lustre_pool )){
218
+ if (o -> lustre_stripe_count == 0 || o -> lustre_stripe_size == 0 ){
219
+ ERR ("Lustre pool specified but no stripe count or stripe size specified" );
220
+ }
221
+ #ifdef HAVE_LUSTRE_LUSTREAPI
222
+ o -> lustre_set_pool = 1 ;
223
+ #else
224
+ WARN ("Lustre pool option set but the Lustre API is not available to do this" );
225
+ o -> lustre_set_pool = 0 ;
226
+ #endif
227
227
}
228
228
if (o -> gpuDirect && ! o -> direct_io ){
229
229
ERR ("GPUDirect required direct I/O to be used!" );
@@ -504,6 +504,7 @@ void lustre_disable_file_locks(const int fd) {
504
504
aiori_fd_t * POSIX_Create (char * testFileName , int flags , aiori_mod_opt_t * param )
505
505
{
506
506
int fd_oflag = O_BINARY ;
507
+ int fd_mode ;
507
508
int mode = 0664 ;
508
509
posix_fd * pfd = safeMalloc (sizeof (posix_fd ));
509
510
posix_options_t * o = (posix_options_t * ) param ;
@@ -514,16 +515,15 @@ aiori_fd_t *POSIX_Create(char *testFileName, int flags, aiori_mod_opt_t * param)
514
515
if (hints -> dryRun )
515
516
return (aiori_fd_t * ) 0 ;
516
517
517
- #ifdef HAVE_LUSTRE_USER
518
+ #if defined( HAVE_LUSTRE_USER ) || defined( HAVE_LUSTRE_LUSTREAPI )
518
519
/* Add a #define for FASYNC if not available, as it forms part of
519
520
* the Lustre O_LOV_DELAY_CREATE definition. */
520
521
#ifndef FASYNC
521
522
#define FASYNC 00020000 /* fcntl, for BSD compatibility */
522
523
#endif
523
- if (o -> lustre_set_striping ) {
524
- /* In the single-shared-file case, task 0 has to create the
525
- file with the Lustre striping options before any other
526
- processes open the file */
524
+ if (o -> lustre_set_striping || o -> lustre_set_pool ) {
525
+ #ifdef HAVE_LUSTRE_LUSTREAPI
526
+
527
527
if (!hints -> filePerProc && rank != 0 ) {
528
528
MPI_CHECK (MPI_Barrier (testComm ), "barrier error" );
529
529
fd_oflag |= O_RDWR ;
@@ -533,19 +533,46 @@ aiori_fd_t *POSIX_Create(char *testFileName, int flags, aiori_mod_opt_t * param)
533
533
testFileName , fd_oflag , mode , strerror (errno ));
534
534
}
535
535
} else {
536
- struct lov_user_md opts = { 0 };
537
536
537
+ fd_oflag |= O_CREAT | O_EXCL | O_RDWR ;
538
+ fd_mode = S_IRWXU ;
539
+ if (o -> lustre_set_pool ){
540
+ pfd -> fd = llapi_file_open_pool (testFileName , fd_oflag , fd_mode , o -> lustre_stripe_size ,
541
+ o -> lustre_start_ost , o -> lustre_stripe_count , 0 ,
542
+ o -> lustre_pool );
543
+ }else {
544
+ pfd -> fd = llapi_file_open (testFileName , fd_oflag , fd_mode , o -> lustre_stripe_size ,
545
+ o -> lustre_start_ost , o -> lustre_stripe_count , 0 );
546
+ }
547
+
548
+ if (pfd -> fd < 0 )
549
+ ERRF ("Unable to open '%s': %s\n" ,
550
+ testFileName , strerror (errno ));
551
+
552
+ if (!hints -> filePerProc )
553
+ MPI_CHECK (MPI_Barrier (testComm ),
554
+ "barrier error" );
555
+
556
+ }
557
+
558
+ #else
559
+ if (!hints -> filePerProc && rank != 0 ) {
560
+ MPI_CHECK (MPI_Barrier (testComm ), "barrier error" );
561
+ fd_oflag |= O_RDWR ;
562
+ pfd -> fd = open64 (testFileName , fd_oflag , mode );
563
+ if (pfd -> fd < 0 ){
564
+ ERRF ("open64(\"%s\", %d, %#o) failed. Error: %s" ,
565
+ testFileName , fd_oflag , mode , strerror (errno ));
566
+ }
567
+ } else {
568
+ struct lov_user_md opts = { 0 };
538
569
/* Setup Lustre IOCTL striping pattern structure */
539
570
opts .lmm_magic = LOV_USER_MAGIC ;
540
571
opts .lmm_stripe_size = o -> lustre_stripe_size ;
541
572
opts .lmm_stripe_offset = o -> lustre_start_ost ;
542
573
opts .lmm_stripe_count = o -> lustre_stripe_count ;
543
- #if (LOV_USER_MAGIC != LOV_USER_MAGIC_V1 )
544
- opts .lmm_pool_name = o -> lustre_pool ;
545
- #endif
546
574
/* File needs to be opened O_EXCL because we cannot set
547
575
* Lustre striping information on a pre-existing file.*/
548
-
549
576
fd_oflag |= O_CREAT | O_EXCL | O_RDWR | O_LOV_DELAY_CREATE ;
550
577
pfd -> fd = open64 (testFileName , fd_oflag , mode );
551
578
if (pfd -> fd < 0 ) {
@@ -558,12 +585,16 @@ aiori_fd_t *POSIX_Create(char *testFileName, int flags, aiori_mod_opt_t * param)
558
585
ERRF ("Error on ioctl for '%s' (%d): %s\n" ,
559
586
testFileName , pfd -> fd , errmsg );
560
587
}
588
+
561
589
if (!hints -> filePerProc )
562
590
MPI_CHECK (MPI_Barrier (testComm ),
563
- "barrier error" );
591
+ "barrier error" );
592
+
564
593
}
594
+ #endif
595
+
565
596
} else {
566
- #endif /* HAVE_LUSTRE_USER */
597
+ #endif /* HAVE_LUSTRE_USER || HAVE_LUSTRE_LUSTREAPI */
567
598
568
599
fd_oflag |= O_CREAT | O_RDWR ;
569
600
0 commit comments