99 * University of Stuttgart. All rights reserved.
1010 * Copyright (c) 2004-2005 The Regents of the University of California.
1111 * All rights reserved.
12- * Copyright (c) 2008-2011 University of Houston. All rights reserved.
12+ * Copyright (c) 2008-2015 University of Houston. All rights reserved.
1313 * $COPYRIGHT$
1414 *
1515 * Additional copyrights may follow
@@ -50,6 +50,10 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
5050 int amode ;
5151 int old_mask , perm ;
5252 int rc ;
53+ int flag ;
54+ int fs_lustre_stripe_size = -1 ;
55+ int fs_lustre_stripe_width = -1 ;
56+ char char_stripe [MPI_MAX_INFO_KEY ];
5357
5458 struct lov_user_md * lump = NULL ;
5559
@@ -74,13 +78,33 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
7478 if (access_mode & MPI_MODE_EXCL )
7579 amode = amode | O_EXCL ;
7680
77- if ((mca_fs_lustre_stripe_size || mca_fs_lustre_stripe_width ) &&
81+
82+ ompi_info_get (info , "stripe_size" , MPI_MAX_INFO_VAL , char_stripe , & flag );
83+ if ( flag ) {
84+ sscanf ( char_stripe , "%d" , & fs_lustre_stripe_size );
85+ }
86+
87+ ompi_info_get (info , "stripe_width" , MPI_MAX_INFO_VAL , char_stripe , & flag );
88+ if ( flag ) {
89+ sscanf ( char_stripe , "%d" , & fs_lustre_stripe_width );
90+ }
91+
92+ if (fs_lustre_stripe_size < 0 ) {
93+ fs_lustre_stripe_size = mca_fs_lustre_stripe_size ;
94+ }
95+
96+ if (fs_lustre_stripe_width < 0 ) {
97+ fs_lustre_stripe_width = mca_fs_lustre_stripe_width ;
98+ }
99+
100+
101+ if ( (fs_lustre_stripe_size > 0 || fs_lustre_stripe_width > 0 ) &&
78102 (amode & O_CREAT ) && (amode & O_RDWR )) {
79103 if (0 == fh -> f_rank ) {
80- llapi_file_create (filename ,
81- mca_fs_lustre_stripe_size ,
104+ llapi_file_create (filename ,
105+ fs_lustre_stripe_size ,
82106 -1 , /* MSC need to change that */
83- mca_fs_lustre_stripe_width ,
107+ fs_lustre_stripe_width ,
84108 0 ); /* MSC need to change that */
85109
86110 fh -> fd = open (filename , O_CREAT | O_RDWR | O_LOV_DELAY_CREATE , perm );
@@ -106,13 +130,13 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
106130 else {
107131 lump = (struct lov_user_md * ) malloc (sizeof (struct lov_user_md ));
108132 if (NULL == lump ){
109- fprintf (stderr ,"Cannot Allocate Lump for extracting stripe size\n" );
133+ fprintf (stderr ,"Cannot allocate memory for extracting stripe size\n" );
110134 return OMPI_ERROR ;
111135 }
112136 rc = llapi_file_get_stripe (filename , lump );
113137 if (rc != 0 ) {
114138 fprintf (stderr , "get_stripe failed: %d (%s)\n" ,errno , strerror (errno ));
115- return -1 ;
139+ return OMPI_ERROR ;
116140 }
117141 fh -> f_stripe_size = lump -> lmm_stripe_size ;
118142 }
0 commit comments