Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 88971f4

Browse files
committed
Merge pull request #454 from edgargabriel/pr/lustre-and-aggregatorlogic-fix
Pr/lustre and aggregatorlogic fix
2 parents 06978c1 + 13471d0 commit 88971f4

File tree

4 files changed

+46
-7
lines changed

4 files changed

+46
-7
lines changed

ompi/mca/fs/lustre/fs_lustre_file_get_size.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,18 @@
3333
* Returns: - Success if size is get
3434
*/
3535
int
36-
mca_fs_lustre_file_get_size (mca_io_ompio_file_t *file_handle,
36+
mca_fs_lustre_file_get_size (mca_io_ompio_file_t *fh,
3737
OMPI_MPI_OFFSET_TYPE *size)
3838
{
39-
printf ("LUSTRE GET SIZE\n");
39+
*size = lseek(fh->fd, 0, SEEK_END);
40+
if (-1 == *size) {
41+
perror ("lseek");
42+
return OMPI_ERROR;
43+
}
44+
45+
if (-1 == (lseek(fh->fd, fh->f_offset, SEEK_SET))) {
46+
perror ("lseek");
47+
return OMPI_ERROR;
48+
}
4049
return OMPI_SUCCESS;
4150
}

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
}

ompi/mca/fs/lustre/fs_lustre_file_set_size.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,21 @@
3333
* Returns: - Success if size is set
3434
*/
3535
int
36-
mca_fs_lustre_file_set_size (mca_io_ompio_file_t *file_handle,
36+
mca_fs_lustre_file_set_size (mca_io_ompio_file_t *fh,
3737
OMPI_MPI_OFFSET_TYPE size)
3838
{
39-
printf ("LUSTRE SET SIZE\n");
39+
int err = 0;
40+
41+
err = ftruncate(fh->fd, size);
42+
43+
fh->f_comm->c_coll.coll_bcast (&err,
44+
1,
45+
MPI_INT,
46+
OMPIO_ROOT,
47+
fh->f_comm,
48+
fh->f_comm->c_coll.coll_bcast_module);
49+
if (-1 == err) {
50+
return OMPI_ERROR;
51+
}
4052
return OMPI_SUCCESS;
4153
}

ompi/mca/io/ompio/io_ompio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ int ompi_io_ompio_set_aggregator_props (struct mca_io_ompio_file_t *fh,
10531053
}
10541054

10551055
fh->f_aggregator_index = 0;
1056+
fh->f_final_num_aggrs = num_aggregators;
10561057

10571058
return OMPI_SUCCESS;
10581059
}

0 commit comments

Comments
 (0)