From nobody@FreeBSD.org  Fri Aug 15 13:54:57 2008
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 E8D37106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 15 Aug 2008 13:54:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id C771A8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 15 Aug 2008 13:54:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m7FDsv0r009934
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 15 Aug 2008 13:54:57 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m7FDsvvn009921;
	Fri, 15 Aug 2008 13:54:57 GMT
	(envelope-from nobody)
Message-Id: <200808151354.m7FDsvvn009921@www.freebsd.org>
Date: Fri, 15 Aug 2008 13:54:57 GMT
From: GW <gw.freebsd@tnode.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: unionfs move directory problem 1
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         126552
>Category:       kern
>Synopsis:       [unionfs] unionfs move directory problem 1
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    daichi
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 15 14:00:03 UTC 2008
>Closed-Date:    Fri Oct 17 15:36:07 UTC 2008
>Last-Modified:  Fri Oct 17 15:36:07 UTC 2008
>Originator:     GW
>Release:        7.0-STABLE
>Organization:
Tnode.com
>Environment:
FreeBSD server.domain.com 7.0-STABLE FreeBSD 7.0-STABLE #5: Sun Aug 10 09:54:42 CEST 2008 root@server.domain.com:/usr/src/sys/amd64/compile/SERVER  amd64 
>Description:
I assume that this is a new bug, because there was no response on the freebsd-fs mailing list.

Moving directories around in unionfs mounts isn't handled correctly as can be seen from the long example below. It behaves the same if there is no "-o below" parameter.

>How-To-Repeat:
Create original directory hierarchy:
~# mkdir rw ro ro/orig
~# touch ro/orig/file ro/orig/file2
~# mount -t unionfs -o below ro rw
~# cd rw
~/rw# ls -aFloWi
total 6
49874 drwx------  3 root  wheel  - 512 Aug 12 01:32 ./
49872 drwx------  4 root  wheel  - 512 Aug 12 01:20 ../
49878 drwx------  2 root  wheel  - 512 Aug 12 01:20 orig/
~/rw# ls -aFloWi orig/
total 4
49878 drwx------  2 root  wheel  - 512 Aug 12 01:20 ./
49874 drwx------  3 root  wheel  - 512 Aug 12 01:32 ../
49876 -rw-------  1 root  wheel  -   0 Aug 12 01:20 file
49877 -rw-------  1 root  wheel  -   0 Aug 12 01:20 file2

Problem appears (lost directory contents):
~/rw# mv orig moved
~/rw# ls -aFloWi
total 6
49874 drwx------  3 root  wheel  - 512 Aug 12 01:33 ./
49872 drwx------  4 root  wheel  - 512 Aug 12 01:20 ../
49878 drwx------  2 root  wheel  - 512 Aug 12 01:20 moved/
    0 w---------  0 root  wheel  -   0 Jan  1  1970 orig%
~/rw# ls -aFloWi moved
total 4
49878 drwx------  2 root  wheel  - 512 Aug 12 01:20 ./
49874 drwx------  3 root  wheel  - 512 Aug 12 01:33 ../

<< WTF!??? PROBLEM 1

And now some magic (content reappears):
~/rw# mv moved orig
~/rw# ls -aFloWi
total 6
49874 drwx------  3 root  wheel  - 512 Aug 12 01:33 ./
49872 drwx------  4 root  wheel  - 512 Aug 12 01:20 ../
49878 drwx------  2 root  wheel  - 512 Aug 12 01:20 orig/
~/rw# ls -aFloWi orig
total 4
49878 drwx------  2 root  wheel  - 512 Aug 12 01:20 ./
49874 drwx------  3 root  wheel  - 512 Aug 12 01:33 ../
49876 -rw-------  1 root  wheel  -   0 Aug 12 01:20 file
49877 -rw-------  1 root  wheel  -   0 Aug 12 01:20 file2

>Fix:
I see two possible solutions to this problem 1:

- on directory rename/move the whole file hierarchy should be exactly duplicated under a new directory tree
- if both layers exist on the same partition, inodes of files can be reused as it is done with hard links, but the directory structure needs to be duplicated so that it has correct parent inodes

Any better idea?

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->daichi 
Responsible-Changed-By: remko 
Responsible-Changed-When: Fri Aug 15 14:18:38 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=126552 
State-Changed-From-To: open->closed 
State-Changed-By: daichi 
State-Changed-When: Fri Oct 17 15:26:07 UTC 2008 
State-Changed-Why:  
This is not a bug, just a specification. From the "The new unionfs implementation 
for FreeBSD and status of merging", section "Known Problems",  
http://people.freebsd.org/~daichi/unionfs/ 

* If you rename a directory in the lower layer, you cannot access  
the files in the directory anymore. This is the result of creating  
the white-out after creating a shadow directory in the upper layer  
and renaming it. To rename a directory while keeping the files in  
the directory accessible, make a full copy in the upper layer and  
rename it. It is a feature, not a bug. 

Prevent that kind of operation. Thanks 


http://www.freebsd.org/cgi/query-pr.cgi?pr=126552 
>Unformatted:
