From 8adb798aa50849cc3f6e099fcae7c29db1b83e39 Mon Sep 17 00:00:00 2001 From: Dan McDonald Date: Wed, 11 May 2016 12:03:51 -0700 Subject: [PATCH] OpenZFS 6093 - zfsctl_shares_lookup 6093 zfsctl_shares_lookup should only VN_RELE() on zfs_zget() success Reviewed by: Gordon Ross Reviewed by: Matthew Ahrens Reviewed by: George Wilson Approved by: Robert Mustacchi Ported-by: Brian Behlendorf OpenZFS-issue: https://www.illumos.org/issues/6093 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/0f92170 Closes #4630 This function was always implemented slightly differently under Linux and therefore never suffered from this issue. The patch has been updated and applied as cleanup in order to minimize differences with the upstream OpenZFS code. --- module/zfs/zfs_ctldir.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c index 937feac23..8949a8ad1 100644 --- a/module/zfs/zfs_ctldir.c +++ b/module/zfs/zfs_ctldir.c @@ -28,6 +28,7 @@ * Rohan Puri * Brian Behlendorf * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. */ /* @@ -1245,21 +1246,16 @@ zfsctl_shares_lookup(struct inode *dip, char *name, struct inode **ipp, return (SET_ERROR(ENOTSUP)); } - error = zfs_zget(zsb, zsb->z_shares_dir, &dzp); - if (error) { - ZFS_EXIT(zsb); - return (error); + if ((error = zfs_zget(zsb, zsb->z_shares_dir, &dzp)) == 0) { + error = zfs_lookup(ZTOI(dzp), name, &ip, 0, cr, NULL, NULL); + iput(ZTOI(dzp)); } - error = zfs_lookup(ZTOI(dzp), name, &ip, 0, cr, NULL, NULL); - - iput(ZTOI(dzp)); ZFS_EXIT(zsb); return (error); } - /* * Initialize the various pieces we'll need to create and manipulate .zfs * directories. Currently this is unused but available.