Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Aug 2008 14:01:11 GMT
From:      GW <gw.freebsd@tnode.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/126553: unionfs move directory problem 2 (files appear)
Message-ID:  <200808151401.m7FE1BiS016575@www.freebsd.org>
Resent-Message-ID: <200808151410.m7FEA28E034872@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         126553
>Category:       kern
>Synopsis:       unionfs move directory problem 2 (files appear)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 15 14:10:02 UTC 2008
>Closed-Date:
>Last-Modified:
>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.

This one makes files appear.
>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

Lets test something (it creates in upper layer):
~/rw# mkdir new
~/rw# touch new/newfile
~/rw# ls -aFloWi
total 8
49874 drwx------  4 root  wheel  - 512 Aug 12 02:04 ./
49872 drwx------  4 root  wheel  - 512 Aug 12 02:03 ../
49879 drwx------  2 root  wheel  - 512 Aug 12 02:04 new/
49878 drwx------  2 root  wheel  - 512 Aug 12 01:20 orig/
~/rw# ls -aFloWi new
total 4
49879 drwx------  2 root  wheel  - 512 Aug 12 02:04 ./
49874 drwx------  4 root  wheel  - 512 Aug 12 02:04 ../
49880 -rw-------  1 root  wheel  -   0 Aug 12 02:04 newfile
~/rw# ls -aFloWi orig
total 4
49878 drwx------  2 root  wheel  - 512 Aug 12 01:20 ./
49874 drwx------  4 root  wheel  - 512 Aug 12 02:04 ../
49876 -rw-------  1 root  wheel  -   0 Aug 12 01:20 file
49877 -rw-------  1 root  wheel  -   0 Aug 12 01:20 file2

And lets see if there is another problem:
~/rw# rm -rf orig
~/rw# ls -aFloWi
total 6
49874 drwx------  3 root  wheel  - 512 Aug 12 02:06 ./
49872 drwx------  4 root  wheel  - 512 Aug 12 02:03 ../
49879 drwx------  2 root  wheel  - 512 Aug 12 02:06 new/
    0 w---------  0 root  wheel  -   0 Jan  1  1970 orig%
~/rw# mv new orig
~/rw# ls -aFloWi
total 6
49874 drwx------  3 root  wheel  - 512 Aug 12 02:07 ./
49872 drwx------  4 root  wheel  - 512 Aug 12 02:03 ../
49879 drwx------  2 root  wheel  - 512 Aug 12 02:06 orig/

Looks fine till now, but (files appear from nowhere):
~/rw# ls -aFloWi orig
total 4
49879 drwx------  2 root  wheel  - 512 Aug 12 02:06 ./
49874 drwx------  3 root  wheel  - 512 Aug 12 02:07 ../
49876 -rw-------  1 root  wheel  -   0 Aug 12 01:20 file
49877 -rw-------  1 root  wheel  -   0 Aug 12 01:20 file2
49880 -rw-------  1 root  wheel  -   0 Aug 12 02:05 newfile

<< WTF!??? PROBLEM 2

>Fix:
For this problem 2 I see solutions:

- in all cases (option whiteout=always or whenneeded) when new directories get created unionfs should check whether such a directory exists in the lower layer and automaticly whiteout all of its entries

- or better (can not work for more than 2 layers) copying all files to upper layer in the moved directory and set the opaque flag, so that underlying files under the new directory name can't be seen through (with other words set opaque on new directory and copy all files in it)

Any better idea?

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808151401.m7FE1BiS016575>