File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,25 @@ typedef struct zfs_dbgmsg {
35
35
36
36
static list_t zfs_dbgmsgs ;
37
37
static kmutex_t zfs_dbgmsgs_lock ;
38
+ static uint_t zfs_dbgmsg_size = 0 ;
39
+ static uint_t zfs_dbgmsg_maxsize = 4 <<20 ; /* 4MB */
38
40
39
41
int zfs_dbgmsg_enable = B_TRUE ;
40
42
43
+ static void
44
+ zfs_dbgmsg_purge (uint_t max_size )
45
+ {
46
+ while (zfs_dbgmsg_size > max_size ) {
47
+ zfs_dbgmsg_t * zdm = list_remove_head (& zfs_dbgmsgs );
48
+ if (zdm == NULL )
49
+ return ;
50
+
51
+ uint_t size = zdm -> zdm_size ;
52
+ kmem_free (zdm , size );
53
+ zfs_dbgmsg_size -= size ;
54
+ }
55
+ }
56
+
41
57
void
42
58
zfs_dbgmsg_init (void )
43
59
{
@@ -74,6 +90,8 @@ __zfs_dbgmsg(char *buf)
74
90
75
91
mutex_enter (& zfs_dbgmsgs_lock );
76
92
list_insert_tail (& zfs_dbgmsgs , zdm );
93
+ zfs_dbgmsg_size += size ;
94
+ zfs_dbgmsg_purge (zfs_dbgmsg_maxsize );
77
95
mutex_exit (& zfs_dbgmsgs_lock );
78
96
}
79
97
You can’t perform that action at this time.
0 commit comments