Project

General

Profile

Bug #1952

memory leak when adding a file-based l2arc device

Added by George Wilson about 8 years ago. Updated about 8 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Start date:
2012-01-05
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

While investigating '1951 leaking a vdev when removing an l2cache device' we
uncovered another leak:

::findleaks

CACHE LEAKED BUFCTL CALLER
ffffff0189033508 1 ffffff01a4f4ccf0 allocb+0x64
ffffff0189033008 1 ffffff0198674710 dblk_constructor+0x58
ffffff0189025788 1 ffffff01a553db50 spa_strdup+0x2a
ffffff018902c788 1 ffffff01b53bfd08 vdev_alloc_common+0x3e
------------------------------------------------------------------------
Total 4 buffers, 1872 bytes

ffffff01b53bfd08::bufctl -v

ADDR BUFADDR TIMESTAMP THREAD
CACHE LASTLOG CONTENTS
ffffff01b53bfd08 ffffff01b543b180 3081635b8794b ffffff01a42b6820
ffffff018902c788 ffffff018bcbf200 ffffff01901a8178
kmem_cache_alloc_debug+0x283
kmem_cache_alloc+0x115
kmem_zalloc+0x6a
vdev_alloc_common+0x3e
vdev_alloc+0x2e0
spa_config_parse+0x4a
spa_validate_aux_devs+0xf1
spa_validate_aux+0x8a
spa_vdev_add+0x12b
zfs_ioc_vdev_add+0xb5
zfsdev_ioctl+0x183
cdev_ioctl+0x45
spec_ioctl+0x5a
fop_ioctl+0x7b
ioctl+0x18e

This is happening in the spa_vdev_add() code path. The following is the
offending code:

spa_validate_aux_devs() {
<snip>
if (!vd->vdev_ops->vdev_op_leaf) {
vdev_free(vd);
error = EINVAL;
goto out;
}

/*
                 * The L2ARC currently only supports disk devices in
                 * kernel context.  For user-level testing, we allow it.
*/
#ifdef _KERNEL
if ((strcmp(config, ZPOOL_CONFIG_L2CACHE) == 0) &&
strcmp(vd->vdev_ops->vdev_op_type, VDEV_TYPE_DISK) != 0) {
error = ENOTBLK;
goto out; <===== NEED TO FREE THE VDEV
}
#endif
vd->vdev_top = vd;
if ((error = vdev_open(vd))  0 &&
(error = vdev_label_init(vd, crtxg, label)) 0) {
VERIFY(nvlist_add_uint64(dev[i], ZPOOL_CONFIG_GUID,
vd->vdev_guid) == 0);
}
vdev_free(vd);

The error path above does not free the vdev and we end up leaking it.

History

#1

Updated by Albert Lee about 8 years ago

  • Project changed from site to illumos gate
#2

Updated by Eric Schrock about 8 years ago

  • Status changed from New to Resolved

changeset: 13574:d0fde6cacaac
tag: tip
user: George Wilson <>
date: Mon Jan 23 19:46:52 2012 -0800

description:
1951 leaking a vdev when removing an l2cache device
1952 memory leak when adding a file-based l2arc device
1954 leak in ZFS from metaslab_group_create and zfs_ereport_checksum
Reviewed by: Adam Leventhal <>
Reviewed by: Matt Ahrens <>
Reviewed by: Eric Schrock <>
Reviewed by: Bill Pijewski <>
Reviewed by: Dan McDonald <>
Approved by: Eric Schrock <>

modified:
usr/src/uts/common/fs/zfs/spa.c
usr/src/uts/common/fs/zfs/sys/vdev_impl.h
usr/src/uts/common/fs/zfs/vdev.c
usr/src/uts/common/fs/zfs/zfs_fm.c

Also available in: Atom PDF