Skip to content

Commit

Permalink
Fix 'zfs diff' shares error
Browse files Browse the repository at this point in the history
When creating a dataset with ZoL a zsb->z_shares_dir ZAP object
will not be created because shares are unimplemented.  Instead ZoL
just sets zsb->z_shares_dir to zero to indicate there are no shares.

However, if you import a pool which was created with a different
ZFS implementation then the shares ZAP object may exist.  Code was
added to handle this case but it clearly wasn't sufficiently tested
with other ZFS pools.

There was a bug in the zpl_shares_getattr() function which passed
the wrong inode to zfs_getattr_fast() for the case where are shares
ZAP object does exist.  This causes an EIO to be returned to stat64()
which in turn causes 'zfs diff' to fail.

This fix is the pass the correct inode after a sucessful zfs_zget().
Additionally, only put away the references if we were able to get one.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Graham Booker <https://github.com/gbooker>
Signed-off-by: timemaster67 <https://github.com/timemaster67>
Closes openzfs#1426
Closes openzfs#481
  • Loading branch information
behlendorf authored and FransUrbo committed Dec 6, 2013
1 parent 9e17afd commit 573fcec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions module/zfs/zpl_ctldir.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,11 @@ zpl_shares_getattr(struct vfsmount *mnt, struct dentry *dentry,
}

error = -zfs_zget(zsb, zsb->z_shares_dir, &dzp);
if (error == 0)
error = -zfs_getattr_fast(dentry->d_inode, stat);
if (error == 0) {
error = -zfs_getattr_fast(ZTOI(dzp), stat);
iput(ZTOI(dzp));
}

iput(ZTOI(dzp));
ZFS_EXIT(zsb);
ASSERT3S(error, <=, 0);

Expand Down

0 comments on commit 573fcec

Please sign in to comment.