Print this page
7857 zfs/zpool commands print scary errors after 7741
7887 get_zfs_dataset() optimised path leaks zfs handle
Reviewed by: Sam Zaydel <szaydel@racktopsystems.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
@@ -23,10 +23,11 @@
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 2012 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
+ * Copyright 2017 RackTop Systems.
*/
#include <stdio.h>
#include <libzfs.h>
#include <string.h>
@@ -334,15 +335,24 @@
* (extremely slow) search of all the filesystems.
*/
cutpath = path + strspn(path, "/");
assert(impl_handle->zfs_libhandle != NULL);
+ libzfs_print_on_error(impl_handle->zfs_libhandle, B_FALSE);
if ((handle_from_path = zfs_open(impl_handle->zfs_libhandle, cutpath,
- ZFS_TYPE_FILESYSTEM)) != NULL)
+ ZFS_TYPE_FILESYSTEM)) != NULL) {
if ((ret = verify_zfs_handle(handle_from_path, path,
- search_mnttab)) != NULL)
+ search_mnttab)) != NULL) {
+ zfs_close(handle_from_path);
+ libzfs_print_on_error(impl_handle->zfs_libhandle,
+ B_TRUE);
return (ret);
+ }
+ zfs_close(handle_from_path);
+ }
+ libzfs_print_on_error(impl_handle->zfs_libhandle, B_TRUE);
+
/*
* Couldn't find a filesystem optimistically, check all the handles we
* can.
*/
get_all_filesystems(impl_handle, &zlist, &count);