Skip to content

Commit 3fae3b0

Browse files
committed
fs/ufs and fs/lustre: change mca var type
use an enum to specify the valid values for the lock_algorithm used by the fs/ufs and fs/lustre components. Signed-off-by: Edgar Gabriel <[email protected]>
1 parent a0af26a commit 3fae3b0

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

ompi/mca/fs/lustre/fs_lustre_component.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ int mca_fs_lustre_priority = 20;
4747
int mca_fs_lustre_stripe_size = 0;
4848
int mca_fs_lustre_stripe_width = 0;
4949
int mca_fs_lustre_lock_algorithm = 0; /* auto */
50+
51+
static const mca_base_var_enum_value_t ompi_fs_lustre_lock_algorithm_modes[] = {
52+
{.value = 0, .string = "auto"},
53+
{.value = 1, .string = "skip locking"},
54+
{.value = 2, .string = "always lock entire file"},
55+
{.value = 3, .string = "lock specific ranges"},
56+
{.string = NULL},
57+
};
58+
5059
/*
5160
* Instantiate the public struct with all of our public information
5261
* and pointers to our public functions in it
@@ -77,6 +86,8 @@ mca_fs_base_component_2_0_0_t mca_fs_lustre_component = {
7786
static int
7887
lustre_register(void)
7988
{
89+
mca_base_var_enum_t *new_enum;
90+
8091
mca_fs_lustre_priority = 20;
8192
(void) mca_base_component_var_register(&mca_fs_lustre_component.fsm_version,
8293
"priority", "Priority of the lustre fs component",
@@ -95,15 +106,18 @@ lustre_register(void)
95106
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
96107
OPAL_INFO_LVL_9,
97108
MCA_BASE_VAR_SCOPE_READONLY, &mca_fs_lustre_stripe_width);
109+
110+
(void) mca_base_var_enum_create("mca_fs_lustre_lock_algorithm", ompi_fs_lustre_lock_algorithm_modes, &new_enum);
111+
98112
mca_fs_lustre_lock_algorithm = 0;
99113
(void) mca_base_component_var_register(&mca_fs_lustre_component.fsm_version,
100-
"lock_algorithm", "Locking algorithm used by the fs ufs component. "
101-
" 0: auto (default), 1: skip locking, 2: always lock entire file, "
102-
"3: lock only specific ranges",
103-
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
114+
"lock_algorithm", "Locking algorithm used by the fs lustre component. "
115+
"(default: auto)",
116+
MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0,
104117
OPAL_INFO_LVL_9,
105118
MCA_BASE_VAR_SCOPE_READONLY,
106-
&mca_fs_lustre_lock_algorithm );
119+
&mca_fs_lustre_lock_algorithm);
120+
OBJ_RELEASE(new_enum);
107121

108122
return OMPI_SUCCESS;
109123
}

ompi/mca/fs/ufs/fs_ufs_component.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232

3333
int mca_fs_ufs_priority = 10;
3434
int mca_fs_ufs_lock_algorithm=0; /* auto */
35+
36+
static const mca_base_var_enum_value_t ompi_fs_ufs_lock_algorithm_modes[] = {
37+
{.value = 0, .string = "auto"},
38+
{.value = 1, .string = "skip locking"},
39+
{.value = 2, .string = "always lock entire file"},
40+
{.value = 3, .string = "lock specific ranges"},
41+
{.string = NULL},
42+
};
43+
3544
/*
3645
* Private functions
3746
*/
@@ -73,6 +82,8 @@ mca_fs_base_component_2_0_0_t mca_fs_ufs_component = {
7382

7483
static int register_component(void)
7584
{
85+
mca_base_var_enum_t *new_enum;
86+
7687
mca_fs_ufs_priority = 10;
7788
(void) mca_base_component_var_register(&mca_fs_ufs_component.fsm_version,
7889
"priority", "Priority of the fs ufs component",
@@ -81,15 +92,17 @@ static int register_component(void)
8192
MCA_BASE_VAR_SCOPE_READONLY,
8293
&mca_fs_ufs_priority);
8394

95+
(void) mca_base_var_enum_create("mca_fs_ufs_lock_algorithm", ompi_fs_ufs_lock_algorithm_modes, &new_enum);
96+
8497
mca_fs_ufs_lock_algorithm = 0;
8598
(void) mca_base_component_var_register(&mca_fs_ufs_component.fsm_version,
8699
"lock_algorithm", "Locking algorithm used by the fs ufs component. "
87-
" 0: auto (default), 1: skip locking, 2: always lock entire file, "
88-
"3: lock only specific ranges",
89-
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
100+
"(default: auto)",
101+
MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0,
90102
OPAL_INFO_LVL_9,
91103
MCA_BASE_VAR_SCOPE_READONLY,
92-
&mca_fs_ufs_lock_algorithm );
104+
&mca_fs_ufs_lock_algorithm);
105+
OBJ_RELEASE(new_enum);
93106

94107
return OMPI_SUCCESS;
95108
}

0 commit comments

Comments
 (0)