From nobody@FreeBSD.org  Sun Oct  9 20:06:10 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 75DF2106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  9 Oct 2011 20:06:10 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 175988FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  9 Oct 2011 20:06:10 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p99K69oH041395
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 9 Oct 2011 20:06:09 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p99K69mQ041394;
	Sun, 9 Oct 2011 20:06:09 GMT
	(envelope-from nobody)
Message-Id: <201110092006.p99K69mQ041394@red.freebsd.org>
Date: Sun, 9 Oct 2011 20:06:09 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: umount -a -t <foo> doesn't work with nested filesystems
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         161439
>Category:       bin
>Synopsis:       umount(8): umount -a -t <foo> doesn't work with nested filesystems
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 09 20:10:02 UTC 2011
>Closed-Date:    
>Last-Modified:  Sun Feb 03 22:29:36 UTC 2013
>Originator:     Garrett Cooper
>Release:        10-CURRENT
>Organization:
n/a
>Environment:
FreeBSD fallout.local 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r226046M: Wed Oct  5 22:06:21 PDT 2011     gcooper@fallout.local:/usr/obj/usr/src/sys/FALLOUT  amd64
>Description:
If one is trying to unmount just unionfs mounted directories, one cannot do it simply via 'umount -a -t unionfs' because it isn't popping filesystems off the stack and is instead dequeueing them based on the order allocated via getfsent(2). This isn't restricted to unionfs though, as shown in the reproduction case below.

So simply put, unmounting nested filesystems via umount -a -t <foo> doesn't work today.
>How-To-Repeat:
#!/bin/sh

for i in 0 1 2; do
        rm -f md.$i
        touch md.$i
        md=/dev/$(mdconfig -a -f md.$i -s 1g)
        fdisk -Iq $md
        mds="$mds $md"
done
t=tank
v=zvol
zpool create $t $mds
zfs create $t/ds
mount | grep "^$t"
umount -a -t zfs
>Fix:
From a high-level:

1. All of the available filesystems need to be gathered and sorted by mountpoint.
2. The filesystems should be popped off the stack and unmounted.

>Release-Note:
>Audit-Trail:
>Unformatted:
