Skip to content

Commit 88db5e3

Browse files
committed
update the lustre fs component to use direct I/O if requested
1 parent fdb47cd commit 88db5e3

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

ompi/mca/fs/lustre/fs_lustre.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
extern int mca_fs_lustre_priority;
3131
extern int mca_fs_lustre_stripe_size;
3232
extern int mca_fs_lustre_stripe_width;
33+
extern int mca_fs_lustre_use_directio;
3334

3435
BEGIN_C_DECLS
3536

ompi/mca/fs/lustre/fs_lustre_component.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ int mca_fs_lustre_priority = 20;
4545
runtime also*/
4646
int mca_fs_lustre_stripe_size = 0;
4747
int mca_fs_lustre_stripe_width = 0;
48+
int mca_fs_lustre_use_drectio = 0;
4849
/*
4950
* Instantiate the public struct with all of our public information
5051
* and pointers to our public functions in it
@@ -94,5 +95,12 @@ lustre_register(void)
9495
OPAL_INFO_LVL_9,
9596
MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_lustre_stripe_width);
9697

98+
mca_fs_lustre_use_directio = 0;
99+
(void) mca_base_component_var_register(&mca_fs_lustre_component.fsm_version,
100+
"use_directio", "whether to use direct I/O",
101+
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
102+
OPAL_INFO_LVL_9,
103+
MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_lustre_use_directio);
104+
97105
return OMPI_SUCCESS;
98106
}

ompi/mca/fs/lustre/fs_lustre_file_close.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,12 @@ mca_fs_lustre_file_close (mca_io_ompio_file_t *fh)
4040
fh->f_comm->c_coll.coll_barrier (fh->f_comm,
4141
fh->f_comm->c_coll.coll_barrier_module);
4242
close (fh->fd);
43+
44+
if (0 != fh->f_fs_ptr ) {
45+
int fs_ptr;
46+
memcpy ( &fs_ptr, &fh->f_fs_ptr, sizeof(int));
47+
// fsync ( fs_ptr );
48+
close (fs_ptr );
49+
}
4350
return OMPI_SUCCESS;
4451
}

ompi/mca/fs/lustre/fs_lustre_file_open.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
6969
int fs_lustre_stripe_size = -1;
7070
int fs_lustre_stripe_width = -1;
7171
char char_stripe[MPI_MAX_INFO_KEY];
72+
int fd_direct;
7273

7374
struct lov_user_md *lump=NULL;
7475

@@ -93,6 +94,7 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
9394
if (access_mode & MPI_MODE_EXCL)
9495
amode = amode | O_EXCL;
9596

97+
amode_direct = amode | O_DIRECT;
9698

9799
ompi_info_get (info, "stripe_size", MPI_MAX_INFO_VAL, char_stripe, &flag);
98100
if ( flag ) {
@@ -159,5 +161,14 @@ mca_fs_lustre_file_open (struct ompi_communicator_t *comm,
159161
// free ( lump );
160162
// }
161163
}
164+
165+
if ( mca_fs_lustre_use_directio ) {
166+
fd_direct = open ( filename, amode_direct, perm);
167+
if ( -1 != fd_direct ) {
168+
memcpy ( &fh->f_fs_ptr, &fd_direct, sizeof(int));
169+
}
170+
}
171+
172+
162173
return OMPI_SUCCESS;
163174
}

0 commit comments

Comments
 (0)