Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Aug 2008 13:54:57 GMT
From:      GW <gw.freebsd@tnode.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/126552: unionfs move directory problem 1
Message-ID:  <200808151354.m7FDsvvn009921@www.freebsd.org>
Resent-Message-ID: <200808151400.m7FE03R3034487@freefall.freebsd.org>

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

>Number:         126552
>Category:       kern
>Synopsis:       unionfs move directory problem 1
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 15 14:00:03 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.

>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:
>Unformatted:



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