Skip to content

Commit fba6a90

Browse files
authored
zfs_debug: Restore log size limit for userspace
For some reason it was dropped when split from kernel, that makes raidz_test to accumulate in RAM up to 100GB of logs we don't need. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Igor Kozhukhov <[email protected]> Reviewed-by: Rob Norris <[email protected]> Reviewed-by: Tino Reichardt <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #16492 Closes #16566 Closes #16664
1 parent b85c564 commit fba6a90

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/libzpool/zfs_debug.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,25 @@ typedef struct zfs_dbgmsg {
3535

3636
static list_t zfs_dbgmsgs;
3737
static kmutex_t zfs_dbgmsgs_lock;
38+
static uint_t zfs_dbgmsg_size = 0;
39+
static uint_t zfs_dbgmsg_maxsize = 4<<20; /* 4MB */
3840

3941
int zfs_dbgmsg_enable = B_TRUE;
4042

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+
4157
void
4258
zfs_dbgmsg_init(void)
4359
{
@@ -74,6 +90,8 @@ __zfs_dbgmsg(char *buf)
7490

7591
mutex_enter(&zfs_dbgmsgs_lock);
7692
list_insert_tail(&zfs_dbgmsgs, zdm);
93+
zfs_dbgmsg_size += size;
94+
zfs_dbgmsg_purge(zfs_dbgmsg_maxsize);
7795
mutex_exit(&zfs_dbgmsgs_lock);
7896
}
7997

0 commit comments

Comments
 (0)