From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heming Zhao Date: Sun, 19 Sep 2021 14:43:18 +0800 Subject: [Cluster-devel] [PATCH 06/10] dlm_controld: change dlm_options[] to shared memory type In-Reply-To: <20210919064322.1670-1-heming.zhao@suse.com> References: <20210919064322.1670-1-heming.zhao@suse.com> Message-ID: <20210919064322.1670-7-heming.zhao@suse.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This commit makes dlm_options[] could be modified after fork(). The patch is foundation to dynamic setting feature. Signed-off-by: Heming Zhao --- dlm_controld/dlm_daemon.h | 2 +- dlm_controld/main.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h index 76f5f4d082a5..e20e98e78707 100644 --- a/dlm_controld/dlm_daemon.h +++ b/dlm_controld/dlm_daemon.h @@ -159,7 +159,7 @@ struct dlm_option { unsigned int dynamic_uint; }; -EXTERN struct dlm_option dlm_options[dlm_options_max]; +EXTERN struct dlm_option *dlm_options; #define opt(x) dlm_options[x].use_int #define opts(x) dlm_options[x].use_str #define optu(x) dlm_options[x].use_uint diff --git a/dlm_controld/main.c b/dlm_controld/main.c index 504cafa12ec6..2a4f33b1b455 100644 --- a/dlm_controld/main.c +++ b/dlm_controld/main.c @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef USE_SD_NOTIFY #include @@ -2104,11 +2105,21 @@ int main(int argc, char **argv) struct sigaction act; int fd, rv; + /* share the cfg memory for helper process */ + dlm_options = mmap(NULL, sizeof(struct dlm_option)*dlm_options_max, + PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0); + if (dlm_options == MAP_FAILED) { + perror("mmap failed"); + return 1; + } + /* - * config priority: cli, config file, default + * config priority: dynamic, cli, config file, default * - explicit cli setting will override default, * - explicit file setting will override default * - explicit file setting will not override explicit cli setting + * - explicit dynamic setting will override using value, + * "dlm_tool dump_config" will show which option is using dynamic setting. */ set_opt_defaults(); -- 2.32.0