Bug 251694

Summary: Spurious EBUSY after zfs receiving properties to an existing dataset
Product: Base System Reporter: Alan Somers <asomers>
Component: binAssignee: Alan Somers <asomers>
Status: Closed FIXED    
Severity: Affects Only Me CC: bapt, mmacy
Priority: ---    
Version: 12.2-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Fix the merge error from r344569 none

Description Alan Somers freebsd_committer freebsd_triage 2020-12-08 21:56:57 UTC
If you do a "zfs send -p <src> | zfs receive -F <dst>" to an existing but empty dataset, the receive will complete successfully but spuriously fail with exit status 1 and the message "cannot mount 'pool/dataset': mountpoint or dataset is busy".

For example,

zpool create pool vtbd
zfs create pool/src
zfs create pool/dst
touch /pool/src/foo
zfs snapshot pool/src@1
zfs send -p pool/src@1 | zfs receive -F pool/dst
cannot mount 'pool/dst': mountpoint or dataset is busy

The root cause is a merge error made in r344569 and MFCed in r345578, which merged changes a10d50f999 and e63ac16d25 from ZoL.  The merge:
* failed to flip a == to an != like the upstream change did, and
* Left out one chunk

This bug affects stable/12, but not head.  It looks like stable/11 is affected too, but I haven't tested yet.
Comment 1 Alan Somers freebsd_committer freebsd_triage 2020-12-08 21:58:38 UTC
Created attachment 220378 [details]
Fix the merge error from r344569

The attached patch fixes the issue, and introduces no regressions in the ZFS test suite.
Comment 2 Baptiste Daroussin freebsd_committer freebsd_triage 2020-12-09 05:03:48 UTC
Looks good to me and sorry about the mis merge!
Comment 3 commit-hook freebsd_committer freebsd_triage 2020-12-09 20:07:32 UTC
A commit references this bug:

Author: asomers
Date: Wed Dec  9 20:06:38 UTC 2020
New revision: 368491
URL: https://svnweb.freebsd.org/changeset/base/368491

Log:
  ZFS: fix spurious EBUSY after zfs receive to an existing dataset

  If you do a "zfs send -p <src> | zfs receive -F <dst>" to an existing but
  empty dataset, the receive will complete successfully but spuriously fail
  with exit status 1 and the message "cannot mount 'pool/dataset': mountpoint
  or dataset is busy".

  The root cause is a merge error made in r344569 and MFCed in r345578, which
  merged changes a10d50f999 and e63ac16d25 from ZoL.  The merge:
  * failed to flip a == to an != like the upstream change did, and
  * Left out one chunk

  Direct commit to stable/12 because head has moved on to OpenZFS.

  PR:		251694
  Reviewed by:	bapt
  Sponsored by:	Axcient

Changes:
  stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c