Bug 201735

Summary: zpool export fails after process accesses .zfs/snapshot directory
Product: Base System Reporter: Marcus Reid <marcus>
Component: kernAssignee: freebsd-fs (Nobody) <fs>
Status: Open ---    
Severity: Affects Some People    
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Marcus Reid 2015-07-21 08:30:32 UTC
This is broken:
 
    # zpool import derp
    # cd /derp/archive/archive/.zfs/snapshot
    # ls
    20141204 20141227 20150209 20150708 20150720
    # cd /
    # zpool export derp
    cannot unmount '/derp/archive/archive': Device busy
 
This works:
 
    # zpool import derp
    cd# cd /derp/archive/archive/.zfs/snapshot
    # ls
    20141204 20141227 20150209 20150708 20150720
    # cd /
    # zfs unmount derp/archive/archive
    # zpool export derp
    #
 
However, if you trigger the export bug first, the unmount is broken too.
This might provide a clue as to where the problem is.
 
    # zpool import derp
    # cd /derp/archive/archive/.zfs/snapshot
    # ls
    20141204 20141227 20150209 20150708 20150720
    # cd /
    # zpool export derp
    cannot unmount '/derp/archive/archive': Device busy
    # zfs unmount derp/archive/archive
    cannot unmount '/derp/archive/archive': Device busy
Comment 1 Graham Perrin freebsd_committer freebsd_triage 2023-09-11 06:52:31 UTC
Not reproducible for me with OpenZFS in CURRENT. 

Below: 

* a first attempt to export was made very soon after changing directory

* the second attempt, a few seconds later, succeeded.

root@mowa219-gjp4-8570p-freebsd:~ # mount | grep Transcend
Transcend on /media/t1000 (zfs, local, nfsv4acls)
Transcend/VirtualBox on /media/t1000/VirtualBox (zfs, local, nfsv4acls)
root@mowa219-gjp4-8570p-freebsd:~ # cd /media/t1000/.zfs/snapshot
root@mowa219-gjp4-8570p-freebsd:/media/t1000/.zfs/snapshot # cd
root@mowa219-gjp4-8570p-freebsd:~ # time zpool export Transcend
cannot unmount '/media/t1000/VirtualBox': pool or dataset is busy
0.006u 0.006s 0:00.02 0.0%      0+0k 3+0io 3pf+0w
root@mowa219-gjp4-8570p-freebsd:~ # date ; time ; zpool export Transcend
Mon Sep 11 07:49:41 BST 2023
0.394u 1.228s 17:29:44.80 0.0%  389+199k 1304+0io 953pf+0w
root@mowa219-gjp4-8570p-freebsd:~ # 

----

% zfs version
zfs-2.2.99-FreeBSD_g804414aad
zfs-kmod-2.2.99-FreeBSD_g804414aad
% zpool version
zfs-2.2.99-FreeBSD_g804414aad
zfs-kmod-2.2.99-FreeBSD_g804414aad
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 15.0-CURRENT FreeBSD 15.0-CURRENT amd64 1500000 #11 main-n265135-07bc20e4740d-dirty: Sat Sep  2 19:40:08 BST 2023     grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1500000 1500000
%