]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFOpenZFS: Fix zpool history unbounded memory usage
authormarkj <markj@FreeBSD.org>
Thu, 23 Jul 2020 14:21:45 +0000 (14:21 +0000)
committermarkj <markj@FreeBSD.org>
Thu, 23 Jul 2020 14:21:45 +0000 (14:21 +0000)
commit6fba629def37c0e1768823dc77f386b930505619
treec18ea42ea379e6bc250742bf48ac4e3113d4bdd4
parent8ae7ab7cc88927929b5e6066b9db0f547e63cd4f
MFOpenZFS: Fix zpool history unbounded memory usage

In original implementation, zpool history will read the whole history
before printing anything, causing memory usage goes unbounded. We fix
this by breaking it into read-print iterations.

Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Closes #9516

Note, this change changes the libzfs.so ABI by modifying the prototype
of zpool_get_history().  Since libzfs is effectively private to the base
system it is anticipated that this will not be a problem.

PR: 247557
Obtained from: OpenZFS
Reported and tested by: Sam Vaughan <samjvaughan@gmail.com>
Discussed with: freqlabs
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D25745
openzfs/zfs@7125a109dcc55628336ff3f58e59e503f4d7694d
cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c