Skip to content

Commit 20a276c

Browse files
PHHargroveartpol84
authored andcommitted
opal/pmix112: dstore/sm: added the check posix_fallocate return code
Signed-off-by: Paul H. Hargrove <[email protected]> (cherry picked from commit on PMIx v1.2 branch openpmix/openpmix@14f865c)
1 parent 402dc8c commit 20a276c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

opal/mca/pmix/pmix112/pmix/src/sm/pmix_mmap.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,31 @@ int _mmap_segment_create(pmix_sm_seg_t *sm_seg, const char *file_name, size_t si
6464
}
6565
/* size backing file - note the use of real_size here */
6666
#ifdef HAVE_POSIX_FALLOCATE
67-
if (0 != posix_fallocate(sm_seg->seg_id, 0, size)) {
67+
if (0 != (rc = posix_fallocate(sm_seg->seg_id, 0, size))) {
6868
pmix_output_verbose(2, pmix_globals.debug_output,
6969
"sys call posix_fallocate(2) fail\n");
70-
if (ENOSPC == errno) {
70+
if ((ENOTSUP == rc)
71+
#ifdef EOPNOTSUPP
72+
|| (EOPNOTSUPP == rc)
73+
#endif
74+
) {
75+
/* Not supported by OS and/or filesystem.
76+
* Must fall-back to ftruncate().
77+
*/
78+
if (0 != ftruncate(sm_seg->seg_id, size)) {
79+
pmix_output_verbose(2, pmix_globals.debug_output,
80+
"sys call ftruncate(2) fail\n");
81+
rc = PMIX_ERROR;
82+
goto out;
83+
}
84+
rc = PMIX_SUCCESS;
85+
} else if (ENOSPC == rc) {
7186
rc = PMIX_ERR_OUT_OF_RESOURCE;
87+
goto out;
7288
} else {
7389
rc = PMIX_ERROR;
90+
goto out;
7491
}
75-
goto out;
7692
}
7793
#else
7894
if (0 != ftruncate(sm_seg->seg_id, size)) {

0 commit comments

Comments
 (0)