Bug 126553 - [unionfs] unionfs move directory problem 2 (files appear)
Summary: [unionfs] unionfs move directory problem 2 (files appear)
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 7.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-15 15:10 UTC by GW
Modified: 2017-12-31 22:27 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description GW 2008-08-15 15:10:02 UTC
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.

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?
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
Comment 1 Remko Lodder freebsd_committer freebsd_triage 2008-08-15 15:18:44 UTC
Responsible Changed
From-To: freebsd-bugs->daichi

Over to maintainer.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2013-07-03 01:50:32 UTC
State Changed
From-To: open->open

commit bit has been taken in for safekeeping. 


Comment 3 Mark Linimon freebsd_committer freebsd_triage 2013-07-03 01:50:32 UTC
Responsible Changed
From-To: daichi->freebsd-fs
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:43 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped