diff options
author | наб <[email protected]> | 2021-04-07 15:38:22 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2021-04-11 15:27:30 -0700 |
commit | 346c85b7229853a499a8dd069d8b15e0706f7d1a (patch) | |
tree | 1618940a5a6ae14dee7a9c2f3828926be349e829 /cmd/zed/zed.c | |
parent | 46d50eaf56eaee87e9ae0b5a5227b61a228a0fc2 (diff) |
zed: don't malloc() global zed_conf instance, optimise zed_conf layout
It's all of 40 bytes with 4-byte pointers and 64 with 8-byte ones
(previously 44 and 88, respectively) ‒
there's no reason it can't live on the stack
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #11860
Diffstat (limited to 'cmd/zed/zed.c')
-rw-r--r-- | cmd/zed/zed.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/cmd/zed/zed.c b/cmd/zed/zed.c index be1848ef1..e56b45fa7 100644 --- a/cmd/zed/zed.c +++ b/cmd/zed/zed.c @@ -216,15 +216,15 @@ _finish_daemonize(void) int main(int argc, char *argv[]) { - struct zed_conf *zcp; + struct zed_conf zcp; uint64_t saved_eid; int64_t saved_etime[2]; zed_log_init(argv[0]); zed_log_stderr_open(LOG_NOTICE); - zcp = zed_conf_create(); - zed_conf_parse_opts(zcp, argc, argv); - if (zcp->do_verbose) + zed_conf_init(&zcp); + zed_conf_parse_opts(&zcp, argc, argv); + if (zcp.do_verbose) zed_log_stderr_open(LOG_INFO); if (geteuid() != 0) @@ -237,32 +237,32 @@ main(int argc, char *argv[]) if (chdir("/") < 0) zed_log_die("Failed to change to root directory"); - if (zed_conf_scan_dir(zcp) < 0) + if (zed_conf_scan_dir(&zcp) < 0) exit(EXIT_FAILURE); - if (!zcp->do_foreground) { + if (!zcp.do_foreground) { _start_daemonize(); zed_log_syslog_open(LOG_DAEMON); } _setup_sig_handlers(); - if (zcp->do_memlock) + if (zcp.do_memlock) _lock_memory(); - if ((zed_conf_write_pid(zcp) < 0) && (!zcp->do_force)) + if ((zed_conf_write_pid(&zcp) < 0) && (!zcp.do_force)) exit(EXIT_FAILURE); - if (!zcp->do_foreground) + if (!zcp.do_foreground) _finish_daemonize(); zed_log_msg(LOG_NOTICE, "ZFS Event Daemon %s-%s (PID %d)", ZFS_META_VERSION, ZFS_META_RELEASE, (int)getpid()); - if (zed_conf_open_state(zcp) < 0) + if (zed_conf_open_state(&zcp) < 0) exit(EXIT_FAILURE); - if (zed_conf_read_state(zcp, &saved_eid, saved_etime) < 0) + if (zed_conf_read_state(&zcp, &saved_eid, saved_etime) < 0) exit(EXIT_FAILURE); idle: @@ -271,24 +271,24 @@ idle: * successful. */ do { - if (!zed_event_init(zcp)) + if (!zed_event_init(&zcp)) break; /* Wait for some time and try again. tunable? */ sleep(30); - } while (!_got_exit && zcp->do_idle); + } while (!_got_exit && zcp.do_idle); if (_got_exit) goto out; - zed_event_seek(zcp, saved_eid, saved_etime); + zed_event_seek(&zcp, saved_eid, saved_etime); while (!_got_exit) { int rv; if (_got_hup) { _got_hup = 0; - (void) zed_conf_scan_dir(zcp); + (void) zed_conf_scan_dir(&zcp); } - rv = zed_event_service(zcp); + rv = zed_event_service(&zcp); /* ENODEV: When kernel module is unloaded (osx) */ if (rv == ENODEV) @@ -296,13 +296,13 @@ idle: } zed_log_msg(LOG_NOTICE, "Exiting"); - zed_event_fini(zcp); + zed_event_fini(&zcp); - if (zcp->do_idle && !_got_exit) + if (zcp.do_idle && !_got_exit) goto idle; out: - zed_conf_destroy(zcp); + zed_conf_destroy(&zcp); zed_log_fini(); exit(EXIT_SUCCESS); } |