Skip to content

Commit 8d4a26e

Browse files
module/zfs: remove zfs_zevent_console and zfs_zevent_cols
zfs_zevent_console committed multiple printk()s per line without properly continuing them ‒ a single event could easily be fragmented across over thirty lines, making it useless for direct application zfs_zevent_cols exists purely to wrap the output from zfs_zevent_console The niche this was supposed to fill can be better served by something akin to the all-syslog ZEDLET Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #7082
1 parent c903a75 commit 8d4a26e

File tree

3 files changed

+0
-335
lines changed

3 files changed

+0
-335
lines changed

include/sys/fm/util.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ typedef struct zfs_zevent {
9292

9393
extern void fm_init(void);
9494
extern void fm_fini(void);
95-
extern void fm_nvprint(nvlist_t *);
9695
extern void zfs_zevent_post_cb(nvlist_t *nvl, nvlist_t *detector);
9796
extern int zfs_zevent_post(nvlist_t *, nvlist_t *, zevent_cb_t *);
9897
extern void zfs_zevent_drain_all(int *);

man/man5/zfs-module-parameters.5

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3844,28 +3844,6 @@ set.
38443844
.sp
38453845
.RE
38463846

3847-
.sp
3848-
.ne 2
3849-
.na
3850-
\fBzfs_zevent_cols\fR (int)
3851-
.ad
3852-
.RS 12n
3853-
When zevents are logged to the console use this as the word wrap width.
3854-
.sp
3855-
Default value: \fB80\fR.
3856-
.RE
3857-
3858-
.sp
3859-
.ne 2
3860-
.na
3861-
\fBzfs_zevent_console\fR (int)
3862-
.ad
3863-
.RS 12n
3864-
Log events to the console
3865-
.sp
3866-
Use \fB1\fR for yes and \fB0\fR for no (default).
3867-
.RE
3868-
38693847
.sp
38703848
.ne 2
38713849
.na

module/zfs/fm.c

Lines changed: 0 additions & 312 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@
7070
#include <sys/zfs_ioctl.h>
7171

7272
int zfs_zevent_len_max = 512;
73-
int zfs_zevent_cols = 80;
74-
int zfs_zevent_console = 0;
7573

7674
static int zevent_len_cur = 0;
7775
static int zevent_waiters = 0;
@@ -118,307 +116,6 @@ kstat_t *fm_ksp;
118116

119117
#ifdef _KERNEL
120118

121-
/*
122-
* Formatting utility function for fm_nvprintr. We attempt to wrap chunks of
123-
* output so they aren't split across console lines, and return the end column.
124-
*/
125-
/*PRINTFLIKE4*/
126-
static int
127-
fm_printf(int depth, int c, int cols, const char *format, ...)
128-
{
129-
va_list ap;
130-
int width;
131-
char c1;
132-
133-
va_start(ap, format);
134-
width = vsnprintf(&c1, sizeof (c1), format, ap);
135-
va_end(ap);
136-
137-
if (c + width >= cols) {
138-
console_printf("\n");
139-
c = 0;
140-
if (format[0] != ' ' && depth > 0) {
141-
console_printf(" ");
142-
c++;
143-
}
144-
}
145-
146-
va_start(ap, format);
147-
console_vprintf(format, ap);
148-
va_end(ap);
149-
150-
return ((c + width) % cols);
151-
}
152-
153-
/*
154-
* Recursively print an nvlist in the specified column width and return the
155-
* column we end up in. This function is called recursively by fm_nvprint(),
156-
* below. We generically format the entire nvpair using hexadecimal
157-
* integers and strings, and elide any integer arrays. Arrays are basically
158-
* used for cache dumps right now, so we suppress them so as not to overwhelm
159-
* the amount of console output we produce at panic time. This can be further
160-
* enhanced as FMA technology grows based upon the needs of consumers. All
161-
* FMA telemetry is logged using the dump device transport, so the console
162-
* output serves only as a fallback in case this procedure is unsuccessful.
163-
*/
164-
static int
165-
fm_nvprintr(nvlist_t *nvl, int d, int c, int cols)
166-
{
167-
nvpair_t *nvp;
168-
169-
for (nvp = nvlist_next_nvpair(nvl, NULL);
170-
nvp != NULL; nvp = nvlist_next_nvpair(nvl, nvp)) {
171-
172-
data_type_t type = nvpair_type(nvp);
173-
const char *name = nvpair_name(nvp);
174-
175-
boolean_t b;
176-
uint8_t i8;
177-
uint16_t i16;
178-
uint32_t i32;
179-
uint64_t i64;
180-
char *str;
181-
nvlist_t *cnv;
182-
183-
if (strcmp(name, FM_CLASS) == 0)
184-
continue; /* already printed by caller */
185-
186-
c = fm_printf(d, c, cols, " %s=", name);
187-
188-
switch (type) {
189-
case DATA_TYPE_BOOLEAN:
190-
c = fm_printf(d + 1, c, cols, " 1");
191-
break;
192-
193-
case DATA_TYPE_BOOLEAN_VALUE:
194-
(void) nvpair_value_boolean_value(nvp, &b);
195-
c = fm_printf(d + 1, c, cols, b ? "1" : "0");
196-
break;
197-
198-
case DATA_TYPE_BYTE:
199-
(void) nvpair_value_byte(nvp, &i8);
200-
c = fm_printf(d + 1, c, cols, "0x%x", i8);
201-
break;
202-
203-
case DATA_TYPE_INT8:
204-
(void) nvpair_value_int8(nvp, (void *)&i8);
205-
c = fm_printf(d + 1, c, cols, "0x%x", i8);
206-
break;
207-
208-
case DATA_TYPE_UINT8:
209-
(void) nvpair_value_uint8(nvp, &i8);
210-
c = fm_printf(d + 1, c, cols, "0x%x", i8);
211-
break;
212-
213-
case DATA_TYPE_INT16:
214-
(void) nvpair_value_int16(nvp, (void *)&i16);
215-
c = fm_printf(d + 1, c, cols, "0x%x", i16);
216-
break;
217-
218-
case DATA_TYPE_UINT16:
219-
(void) nvpair_value_uint16(nvp, &i16);
220-
c = fm_printf(d + 1, c, cols, "0x%x", i16);
221-
break;
222-
223-
case DATA_TYPE_INT32:
224-
(void) nvpair_value_int32(nvp, (void *)&i32);
225-
c = fm_printf(d + 1, c, cols, "0x%x", i32);
226-
break;
227-
228-
case DATA_TYPE_UINT32:
229-
(void) nvpair_value_uint32(nvp, &i32);
230-
c = fm_printf(d + 1, c, cols, "0x%x", i32);
231-
break;
232-
233-
case DATA_TYPE_INT64:
234-
(void) nvpair_value_int64(nvp, (void *)&i64);
235-
c = fm_printf(d + 1, c, cols, "0x%llx",
236-
(u_longlong_t)i64);
237-
break;
238-
239-
case DATA_TYPE_UINT64:
240-
(void) nvpair_value_uint64(nvp, &i64);
241-
c = fm_printf(d + 1, c, cols, "0x%llx",
242-
(u_longlong_t)i64);
243-
break;
244-
245-
case DATA_TYPE_HRTIME:
246-
(void) nvpair_value_hrtime(nvp, (void *)&i64);
247-
c = fm_printf(d + 1, c, cols, "0x%llx",
248-
(u_longlong_t)i64);
249-
break;
250-
251-
case DATA_TYPE_STRING:
252-
(void) nvpair_value_string(nvp, &str);
253-
c = fm_printf(d + 1, c, cols, "\"%s\"",
254-
str ? str : "<NULL>");
255-
break;
256-
257-
case DATA_TYPE_NVLIST:
258-
c = fm_printf(d + 1, c, cols, "[");
259-
(void) nvpair_value_nvlist(nvp, &cnv);
260-
c = fm_nvprintr(cnv, d + 1, c, cols);
261-
c = fm_printf(d + 1, c, cols, " ]");
262-
break;
263-
264-
case DATA_TYPE_NVLIST_ARRAY: {
265-
nvlist_t **val;
266-
uint_t i, nelem;
267-
268-
c = fm_printf(d + 1, c, cols, "[");
269-
(void) nvpair_value_nvlist_array(nvp, &val, &nelem);
270-
for (i = 0; i < nelem; i++) {
271-
c = fm_nvprintr(val[i], d + 1, c, cols);
272-
}
273-
c = fm_printf(d + 1, c, cols, " ]");
274-
}
275-
break;
276-
277-
case DATA_TYPE_INT8_ARRAY: {
278-
int8_t *val;
279-
uint_t i, nelem;
280-
281-
c = fm_printf(d + 1, c, cols, "[ ");
282-
(void) nvpair_value_int8_array(nvp, &val, &nelem);
283-
for (i = 0; i < nelem; i++)
284-
c = fm_printf(d + 1, c, cols, "0x%llx ",
285-
(u_longlong_t)val[i]);
286-
287-
c = fm_printf(d + 1, c, cols, "]");
288-
break;
289-
}
290-
291-
case DATA_TYPE_UINT8_ARRAY: {
292-
uint8_t *val;
293-
uint_t i, nelem;
294-
295-
c = fm_printf(d + 1, c, cols, "[ ");
296-
(void) nvpair_value_uint8_array(nvp, &val, &nelem);
297-
for (i = 0; i < nelem; i++)
298-
c = fm_printf(d + 1, c, cols, "0x%llx ",
299-
(u_longlong_t)val[i]);
300-
301-
c = fm_printf(d + 1, c, cols, "]");
302-
break;
303-
}
304-
305-
case DATA_TYPE_INT16_ARRAY: {
306-
int16_t *val;
307-
uint_t i, nelem;
308-
309-
c = fm_printf(d + 1, c, cols, "[ ");
310-
(void) nvpair_value_int16_array(nvp, &val, &nelem);
311-
for (i = 0; i < nelem; i++)
312-
c = fm_printf(d + 1, c, cols, "0x%llx ",
313-
(u_longlong_t)val[i]);
314-
315-
c = fm_printf(d + 1, c, cols, "]");
316-
break;
317-
}
318-
319-
case DATA_TYPE_UINT16_ARRAY: {
320-
uint16_t *val;
321-
uint_t i, nelem;
322-
323-
c = fm_printf(d + 1, c, cols, "[ ");
324-
(void) nvpair_value_uint16_array(nvp, &val, &nelem);
325-
for (i = 0; i < nelem; i++)
326-
c = fm_printf(d + 1, c, cols, "0x%llx ",
327-
(u_longlong_t)val[i]);
328-
329-
c = fm_printf(d + 1, c, cols, "]");
330-
break;
331-
}
332-
333-
case DATA_TYPE_INT32_ARRAY: {
334-
int32_t *val;
335-
uint_t i, nelem;
336-
337-
c = fm_printf(d + 1, c, cols, "[ ");
338-
(void) nvpair_value_int32_array(nvp, &val, &nelem);
339-
for (i = 0; i < nelem; i++)
340-
c = fm_printf(d + 1, c, cols, "0x%llx ",
341-
(u_longlong_t)val[i]);
342-
343-
c = fm_printf(d + 1, c, cols, "]");
344-
break;
345-
}
346-
347-
case DATA_TYPE_UINT32_ARRAY: {
348-
uint32_t *val;
349-
uint_t i, nelem;
350-
351-
c = fm_printf(d + 1, c, cols, "[ ");
352-
(void) nvpair_value_uint32_array(nvp, &val, &nelem);
353-
for (i = 0; i < nelem; i++)
354-
c = fm_printf(d + 1, c, cols, "0x%llx ",
355-
(u_longlong_t)val[i]);
356-
357-
c = fm_printf(d + 1, c, cols, "]");
358-
break;
359-
}
360-
361-
case DATA_TYPE_INT64_ARRAY: {
362-
int64_t *val;
363-
uint_t i, nelem;
364-
365-
c = fm_printf(d + 1, c, cols, "[ ");
366-
(void) nvpair_value_int64_array(nvp, &val, &nelem);
367-
for (i = 0; i < nelem; i++)
368-
c = fm_printf(d + 1, c, cols, "0x%llx ",
369-
(u_longlong_t)val[i]);
370-
371-
c = fm_printf(d + 1, c, cols, "]");
372-
break;
373-
}
374-
375-
case DATA_TYPE_UINT64_ARRAY: {
376-
uint64_t *val;
377-
uint_t i, nelem;
378-
379-
c = fm_printf(d + 1, c, cols, "[ ");
380-
(void) nvpair_value_uint64_array(nvp, &val, &nelem);
381-
for (i = 0; i < nelem; i++)
382-
c = fm_printf(d + 1, c, cols, "0x%llx ",
383-
(u_longlong_t)val[i]);
384-
385-
c = fm_printf(d + 1, c, cols, "]");
386-
break;
387-
}
388-
389-
case DATA_TYPE_STRING_ARRAY:
390-
case DATA_TYPE_BOOLEAN_ARRAY:
391-
case DATA_TYPE_BYTE_ARRAY:
392-
c = fm_printf(d + 1, c, cols, "[...]");
393-
break;
394-
395-
case DATA_TYPE_UNKNOWN:
396-
case DATA_TYPE_DONTCARE:
397-
c = fm_printf(d + 1, c, cols, "<unknown>");
398-
break;
399-
}
400-
}
401-
402-
return (c);
403-
}
404-
405-
void
406-
fm_nvprint(nvlist_t *nvl)
407-
{
408-
char *class;
409-
int c = 0;
410-
411-
console_printf("\n");
412-
413-
if (nvlist_lookup_string(nvl, FM_CLASS, &class) == 0)
414-
c = fm_printf(0, c, zfs_zevent_cols, "%s", class);
415-
416-
if (fm_nvprintr(nvl, 0, c, zfs_zevent_cols) != 0)
417-
console_printf("\n");
418-
419-
console_printf("\n");
420-
}
421-
422119
static zevent_t *
423120
zfs_zevent_alloc(void)
424121
{
@@ -542,9 +239,6 @@ zfs_zevent_post(nvlist_t *nvl, nvlist_t *detector, zevent_cb_t *cb)
542239
goto out;
543240
}
544241

545-
if (zfs_zevent_console)
546-
fm_nvprint(nvl);
547-
548242
ev = zfs_zevent_alloc();
549243
if (ev == NULL) {
550244
atomic_inc_64(&erpt_kstat_data.erpt_dropped.value.ui64);
@@ -1673,9 +1367,3 @@ fm_fini(void)
16731367

16741368
ZFS_MODULE_PARAM(zfs_zevent, zfs_zevent_, len_max, INT, ZMOD_RW,
16751369
"Max event queue length");
1676-
1677-
ZFS_MODULE_PARAM(zfs_zevent, zfs_zevent_, cols, INT, ZMOD_RW,
1678-
"Max event column width");
1679-
1680-
ZFS_MODULE_PARAM(zfs_zevent, zfs_zevent_, console, INT, ZMOD_RW,
1681-
"Log events to the console");

0 commit comments

Comments
 (0)