Skip to content

Commit af4f0eb

Browse files
karasevbartpol84
authored andcommitted
pmix/pmix112: dstore/sm: small refactoring
of `posix_fallocate` check ret code. This refactoring to avoid duplication of code (cherry picked from commit on PMIx v1.2 branch openpmix/openpmix@1b86a6e) Signed-off-by: Boris Karasev <[email protected]>
1 parent 20a276c commit af4f0eb

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,35 @@ int _mmap_segment_create(pmix_sm_seg_t *sm_seg, const char *file_name, size_t si
6767
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 ((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) {
70+
if (ENOSPC == rc) {
8671
rc = PMIX_ERR_OUT_OF_RESOURCE;
8772
goto out;
88-
} else {
73+
} else if ((ENOTSUP != rc)
74+
#ifdef EOPNOTSUPP
75+
&& (EOPNOTSUPP != rc)
76+
#endif
77+
){
8978
rc = PMIX_ERROR;
9079
goto out;
9180
}
81+
/* else:
82+
* Not supported by OS and/or filesystem.
83+
* Must fall-back to ftruncate().
84+
*/
85+
} else {
86+
goto map_memory;
9287
}
93-
#else
88+
#endif
9489
if (0 != ftruncate(sm_seg->seg_id, size)) {
9590
pmix_output_verbose(2, pmix_globals.debug_output,
9691
"sys call ftruncate(2) fail\n");
9792
rc = PMIX_ERROR;
9893
goto out;
94+
} else {
95+
rc = PMIX_SUCCESS;
9996
}
100-
#endif
97+
98+
map_memory:
10199
if (MAP_FAILED == (seg_addr = mmap(NULL, size,
102100
PROT_READ | PROT_WRITE, MAP_SHARED,
103101
sm_seg->seg_id, 0))) {

0 commit comments

Comments
 (0)