Skip to content

Commit 477083b

Browse files
committed
the memory chunk that has to be allocated for the llapi_get_stripe function seems to have changed compared to earlier version. This implementation now follows the code snipplet from the man pages.
1 parent 217dcca commit 477083b

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

ompi/mca/fs/lustre/fs_lustre_file_open.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@
4040
* Accepts: - same arguments as MPI_File_open()
4141
* Returns: - Success if new file handle
4242
*/
43+
static void *alloc_lum()
44+
{
45+
int v1, v3, join;
46+
47+
v1 = sizeof(struct lov_user_md_v1) +
48+
LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
49+
v3 = sizeof(struct lov_user_md_v3) +
50+
LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
51+
52+
return malloc(MAX(v1, v3));
53+
}
54+
55+
4356
int
4457
mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
4558
char* filename,
@@ -97,7 +110,6 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
97110
fs_lustre_stripe_width = mca_fs_lustre_stripe_width;
98111
}
99112

100-
101113
if ( (fs_lustre_stripe_size>0 || fs_lustre_stripe_width>0) &&
102114
(amode&O_CREAT) && (amode&O_RDWR)) {
103115
if (0 == fh->f_rank) {
@@ -121,24 +133,29 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
121133

122134
fh->fd = open (filename, amode, perm);
123135
if (fh->fd < 0) {
136+
opal_output(1, "error opening file %s\n", filename);
124137
return OMPI_ERROR;
125138
}
126139

127140
if (mca_fs_lustre_stripe_size > 0) {
128141
fh->f_stripe_size = mca_fs_lustre_stripe_size;
129142
}
130143
else {
131-
lump = (struct lov_user_md *) malloc (sizeof(struct lov_user_md));
144+
lump = alloc_lum();
132145
if (NULL == lump ){
133146
fprintf(stderr,"Cannot allocate memory for extracting stripe size\n");
134147
return OMPI_ERROR;
135148
}
136149
rc = llapi_file_get_stripe(filename, lump);
137150
if (rc != 0) {
138-
fprintf(stderr, "get_stripe failed: %d (%s)\n",errno, strerror(errno));
151+
opal_output(1, "get_stripe failed: %d (%s)\n", errno, strerror(errno));
139152
return OMPI_ERROR;
140153
}
141154
fh->f_stripe_size = lump->lmm_stripe_size;
155+
156+
// if ( NULL != lump ) {
157+
// free ( lump );
158+
// }
142159
}
143160
return OMPI_SUCCESS;
144161
}

0 commit comments

Comments
 (0)