I'm using FreeBSD 10.3 + ZFS as backup server with snapshots. Snapshots are renamed every day with script like : /sbin/zfs destroy data/backup/kaa@daily.6 /sbin/zfs rename data/backup/kaa@daily.5 data/backup/kaa@daily.6 /sbin/zfs rename data/backup/kaa@daily.4 data/backup/kaa@daily.5 /sbin/zfs rename data/backup/kaa@daily.3 data/backup/kaa@daily.4 /sbin/zfs rename data/backup/kaa@daily.2 data/backup/kaa@daily.3 /sbin/zfs rename data/backup/kaa@daily.1 data/backup/kaa@daily.2 /sbin/zfs rename data/backup/kaa@daily.0 data/backup/kaa@daily.1 The commands works and returns 0 but in the .zfs/snapshot directory the daily.* are not pointing to the right snapshot. Some directories returns "Device busy" because the snapshot doesn't exist anymore. I can't umount the ZFS filesystem (device busy) and I need to reboot in order to fix the .zfs/snapshot directory. Everything was working fine on FreeBSD 10.2, all backup servers are affected the same way.
A commit references this bug: Author: avg Date: Mon May 16 15:37:41 UTC 2016 New revision: 299949 URL: https://svnweb.freebsd.org/changeset/base/299949 Log: try to recycle "snap" vnodes as soon as possible Those vnodes should not linger. "Stale" nodes may get out of synchronization with actual snapshots. For example if we destroy a snapshot and create a new one with the same name. Or when we rename a snapshot. While there fix the argument type for zfsctl_snapshot_reclaim(). Also, its original argument can be passed to gfs_vop_reclaim() directly. Bug 209093 could be related although I have not specifically verified that. Referencing just in case. PR: 209093 MFC after: 5 weeks Changes: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Created attachment 170370 [details] proposed patch for testing I think I've found the cause of this problem. I can't believe it but it seems that the 'allow_mounted' check was reversed for 3 years since it was introduced in 2013.
A commit references this bug: Author: avg Date: Tue May 17 07:56:05 UTC 2016 New revision: 300024 URL: https://svnweb.freebsd.org/changeset/base/300024 Log: zfs_ioc_rename: fix a reversed condition FreeBSD zfs_ioc_rename() has an option, not present upstream, that allows to rename snapshots without unmounting them first. I am not sure what is a rationale for that option, but its actual behavior was the opposite of the intended behavior. That is, by default the snapshots were not unmounted. The option was introduced as part of a large update from upstream in r248498. One of the consequences was a havoc under .zfs/snapshot after the rename. The snapshots got new names but were mounted on top of directories with old names, so readdir would list the new names, but lookup would still find the old mounts. PR: 209093 Reported by: Fr?d?ric VANNI?RE <f.vanniere@planet-work.com> MFC after: 5 days Changes: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
A commit references this bug: Author: avg Date: Mon May 23 07:15:23 UTC 2016 New revision: 300482 URL: https://svnweb.freebsd.org/changeset/base/300482 Log: MFC r300024: zfs_ioc_rename: fix a reversed condition PR: 209093 Changes: _U stable/10/ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
A commit references this bug: Author: avg Date: Mon May 23 07:17:53 UTC 2016 New revision: 300483 URL: https://svnweb.freebsd.org/changeset/base/300483 Log: MFC r300024: zfs_ioc_rename: fix a reversed condition PR: 209093 Changes: _U stable/9/sys/ _U stable/9/sys/cddl/contrib/opensolaris/ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c