aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zed
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-04-02 17:14:31 +0200
committerBrian Behlendorf <[email protected]>2021-04-07 14:51:15 -0700
commit1a05182ba0dd26204757cef1f22f4c229c3ee112 (patch)
tree94b3dc1aa70568dcc9020feca13f83dc80632fdf /cmd/zed
parentc52612ba0315409e4c47f753e41615d19131baf7 (diff)
zed: bump zfs_zevent_len_max if we miss any events
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11834
Diffstat (limited to 'cmd/zed')
-rw-r--r--cmd/zed/zed_event.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/cmd/zed/zed_event.c b/cmd/zed/zed_event.c
index 6d746b7b1..a2753ced0 100644
--- a/cmd/zed/zed_event.c
+++ b/cmd/zed/zed_event.c
@@ -100,6 +100,45 @@ zed_event_fini(struct zed_conf *zcp)
zed_exec_fini();
}
+static void
+_bump_event_queue_length(void)
+{
+ int zzlm = -1, wr;
+ char qlen_buf[12] = {0}; /* parameter is int => max "-2147483647\n" */
+ long int qlen;
+
+ zzlm = open("/sys/module/zfs/parameters/zfs_zevent_len_max", O_RDWR);
+ if (zzlm < 0)
+ goto done;
+
+ if (read(zzlm, qlen_buf, sizeof (qlen_buf)) < 0)
+ goto done;
+ qlen_buf[sizeof (qlen_buf) - 1] = '\0';
+
+ errno = 0;
+ qlen = strtol(qlen_buf, NULL, 10);
+ if (errno == ERANGE)
+ goto done;
+
+ if (qlen <= 0)
+ qlen = 512; /* default zfs_zevent_len_max value */
+ else
+ qlen *= 2;
+
+ if (qlen > INT_MAX)
+ qlen = INT_MAX;
+ wr = snprintf(qlen_buf, sizeof (qlen_buf), "%ld", qlen);
+
+ if (pwrite(zzlm, qlen_buf, wr, 0) < 0)
+ goto done;
+
+ zed_log_msg(LOG_WARNING, "Bumping queue length to %ld", qlen);
+
+done:
+ if (zzlm > -1)
+ (void) close(zzlm);
+}
+
/*
* Seek to the event specified by [saved_eid] and [saved_etime].
* This protects against processing a given event more than once.
@@ -138,10 +177,7 @@ zed_event_seek(struct zed_conf *zcp, uint64_t saved_eid, int64_t saved_etime[])
if (n_dropped > 0) {
zed_log_msg(LOG_WARNING, "Missed %d events", n_dropped);
- /*
- * FIXME: Increase max size of event nvlist in
- * /sys/module/zfs/parameters/zfs_zevent_len_max ?
- */
+ _bump_event_queue_length();
}
if (nvlist_lookup_uint64(nvl, "eid", &eid) != 0) {
zed_log_msg(LOG_WARNING, "Failed to lookup zevent eid");
@@ -914,10 +950,7 @@ zed_event_service(struct zed_conf *zcp)
if (n_dropped > 0) {
zed_log_msg(LOG_WARNING, "Missed %d events", n_dropped);
- /*
- * FIXME: Increase max size of event nvlist in
- * /sys/module/zfs/parameters/zfs_zevent_len_max ?
- */
+ _bump_event_queue_length();
}
if (nvlist_lookup_uint64(nvl, "eid", &eid) != 0) {
zed_log_msg(LOG_WARNING, "Failed to lookup zevent eid");