[kernel] r20079 - in dists/trunk/linux: . debian debian/config/amd64 debian/config/amd64/none debian/config/i386 debian/config/i386/none debian/config/kernelarch-x86 debian/installer/amd64/modules/amd64 debian/installer/armel/modules/armel-iop32x debian/installer/armel/modules/armel-kirkwood debian/installer/armel/modules/armel-orion5x debian/installer/armel/modules/armel-versatile debian/installer/armhf/modules/armhf-mx5 debian/installer/armhf/modules/armhf-vexpress debian/installer/i386/modules/i386 debian/installer/ia64/modules/ia64 debian/installer/mips/modules/mips debian/installer/mips/modules/mips-sb1-bcm91250a debian/installer/mipsel/modules/mipsel-loongson-2f debian/installer/mipsel/modules/mipsel-r5k-cobalt debian/installer/mipsel/modules/mipsel-sb1-bcm91250a debian/installer/modules debian/installer/powerpc/modules/powerpc debian/installer/powerpc/modules/powerpc-powerpc-miboot debian/installer/powerpc/modules/powerpc-powerpc64 debian/installer/powerpcspe/modules/powerpcspe debian/installer/powerpcspe/modules/powerpcspe-powerpcspe-miboot debian/installer/ppc64/modules/ppc64 debian/installer/sparc/modules/sparc debian/patches/features/all/aufs3
Ben Hutchings
benh at alioth.debian.org
Sun May 12 00:53:14 UTC 2013
Author: benh
Date: Sun May 12 00:53:14 2013
New Revision: 20079
Log:
Merge changes from sid up to 3.8.12-1
Added:
dists/trunk/linux/debian/config/amd64/none/
- copied from r20071, dists/sid/linux/debian/config/amd64/none/
dists/trunk/linux/debian/config/i386/none/
- copied from r20071, dists/sid/linux/debian/config/i386/none/
dists/trunk/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/crc-modules
- copied unchanged from r20071, dists/sid/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/crc-modules
dists/trunk/linux/debian/installer/modules/nic-shared-modules
- copied unchanged from r20071, dists/sid/linux/debian/installer/modules/nic-shared-modules
dists/trunk/linux/debian/installer/sparc/modules/sparc/crc-modules
- copied unchanged from r20071, dists/sid/linux/debian/installer/sparc/modules/sparc/crc-modules
Deleted:
dists/trunk/linux/debian/installer/armhf/modules/armhf-vexpress/ipv6-modules
Modified:
dists/trunk/linux/ (props changed)
dists/trunk/linux/debian/changelog
dists/trunk/linux/debian/config/amd64/defines
dists/trunk/linux/debian/config/i386/defines
dists/trunk/linux/debian/config/kernelarch-x86/config
dists/trunk/linux/debian/installer/amd64/modules/amd64/nic-shared-modules
dists/trunk/linux/debian/installer/armel/modules/armel-iop32x/nic-shared-modules
dists/trunk/linux/debian/installer/armel/modules/armel-kirkwood/nic-shared-modules
dists/trunk/linux/debian/installer/armel/modules/armel-orion5x/nic-shared-modules
dists/trunk/linux/debian/installer/armel/modules/armel-versatile/nic-shared-modules
dists/trunk/linux/debian/installer/armhf/modules/armhf-mx5/nic-shared-modules
dists/trunk/linux/debian/installer/armhf/modules/armhf-vexpress/nic-shared-modules
dists/trunk/linux/debian/installer/i386/modules/i386/nic-shared-modules
dists/trunk/linux/debian/installer/ia64/modules/ia64/nic-shared-modules
dists/trunk/linux/debian/installer/mips/modules/mips-sb1-bcm91250a/nic-shared-modules
dists/trunk/linux/debian/installer/mips/modules/mips/nic-shared-modules
dists/trunk/linux/debian/installer/mipsel/modules/mipsel-loongson-2f/nic-shared-modules
dists/trunk/linux/debian/installer/mipsel/modules/mipsel-r5k-cobalt/nic-shared-modules
dists/trunk/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/nic-shared-modules
dists/trunk/linux/debian/installer/powerpc/modules/powerpc-powerpc-miboot/nic-shared-modules
dists/trunk/linux/debian/installer/powerpc/modules/powerpc-powerpc64/nic-shared-modules
dists/trunk/linux/debian/installer/powerpc/modules/powerpc/nic-shared-modules
dists/trunk/linux/debian/installer/powerpcspe/modules/powerpcspe-powerpcspe-miboot/nic-shared-modules
dists/trunk/linux/debian/installer/powerpcspe/modules/powerpcspe/nic-shared-modules
dists/trunk/linux/debian/installer/ppc64/modules/ppc64/nic-shared-modules
dists/trunk/linux/debian/patches/features/all/aufs3/aufs3-add.patch
dists/trunk/linux/debian/patches/features/all/aufs3/gen-patch
Modified: dists/trunk/linux/debian/changelog
==============================================================================
--- dists/trunk/linux/debian/changelog Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/changelog Sun May 12 00:53:14 2013 (r20079)
@@ -16,6 +16,71 @@
-- Ben Hutchings <ben at decadent.org.uk> Mon, 06 May 2013 13:17:52 +0100
+linux (3.8.12-1) unstable; urgency=low
+
+ * New upstream stable update:
+ http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.8.12
+ - [powerpc] spufs: Initialise inode->i_ino in spufs_new_inode()
+ (possibly fixes: #707175)
+ - iwlwifi: fix freeing uninitialized pointer
+ - tty: fix up atime/mtime mess, take three
+ - sysfs: fix use after free in case of concurrent read/write and readdir
+ - [ia64] Fix initialization of CMCI/CMCP interrupts
+ - [ia64] Wrong asm register contraints in the futex implementation
+ (Closes: #702641)
+ - [ia64] Wrong asm register contraints in the kvm implementation
+ (Closes: #702639)
+ - fs/fscache/stats.c: fix memory leak
+ - hrtimer: Fix ktime_add_ns() overflow on 32bit architectures
+ - swap: redirty page if page write fails on swap file
+ - mm: swap: mark swap pages writeback before queueing for direct IO
+ - ACPI: Fix wrong parameter passed to memblock_reserve
+ - cgroup: fix an off-by-one bug which may trigger BUG_ON()
+ - cgroup: fix broken file xattrs
+ - clockevents: Set dummy handler on CPU_DEAD shutdown (Closes: #700333)
+ - inotify: invalid mask should return a error number but not set it
+ (fixes regression in 3.8.1)
+ - exec: do not abuse ->cred_guard_mutex in threadgroup_lock()
+ - md: bad block list should default to disabled.
+ - MD: ignore discard request for hard disks of hybid raid1/raid10 array
+ (fixes regression in 3.6)
+ - nfsd4: don't close read-write opens too soon
+ - wireless: regulatory: fix channel disabling race condition
+ - ext4/jbd2: don't wait (forever) for stale tid caused by wraparound
+ - jbd2: fix race between jbd2_journal_remove_checkpoint and
+ ->j_commit_callback
+ - ext4: fix journal callback list traversal
+ - ext4: fix big-endian bug in metadata checksum calculations
+ - [x86] KVM: X86 emulator: fix source operand decoding for 8bit mov[zs]x
+ instructions
+
+ [ Ben Hutchings ]
+ * [rt] Remove xen-linux-system packages and references to Xen support,
+ as Xen does not support real-time scheduling
+ * udeb: Fix configuration errors causing FTBFS:
+ - [armhf/vexpress] Remove ipv6-modules; ipv6 is now built-in
+ - [mipsel/sb1-bcm91250a,sparc] Add crc-modules as common dependency of
+ btrfs-modules and xfs-modules (and others)
+ - [powerpc] Add nic-shared-modules as common dependency of nic-modules
+ and nic-extra-modules
+ - Unify module list for nic-shared-modules across architectures [!m68k]
+ * [rt] Update to 3.8.11-rt8:
+ - time/timekeeping: shadow tk->cycle_last together with clock->cycle_last
+ - sched/workqueue: Only wake up idle workers if not blocked on sleeping
+ spin lock
+ * aufs: Update to aufs3.8-20130506
+ - for linux-3.7, btrfs limits the link count explicitly
+ - for linux-3.6, push mnt_want_write() outside of i_mutex
+ - possible bugfix, make sure the target branch is upper
+ - possible bugfix, error handling in reopen_nondir()
+ - new copyup implementation
+ - pin the branch dir
+ - convert the plink list into hlist
+ * linux-doc: Include aufs documentation
+ * [x86] zsmalloc: Change to built-in, as it can no longer be modular
+
+ -- Ben Hutchings <ben at decadent.org.uk> Fri, 10 May 2013 04:46:36 +0100
+
linux (3.8.11-1) unstable; urgency=high
* New upstream stable update:
Modified: dists/trunk/linux/debian/config/amd64/defines
==============================================================================
--- dists/trunk/linux/debian/config/amd64/defines Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/config/amd64/defines Sun May 12 00:53:14 2013 (r20079)
@@ -1,5 +1,6 @@
[base]
featuresets:
+ none
rt
flavours:
amd64
@@ -15,12 +16,7 @@
[amd64_description]
hardware: 64-bit PCs
hardware-long: PCs with AMD64, Intel 64 or VIA Nano processors
-parts: xen
[amd64_image]
configs:
kernelarch-x86/config-arch-64
-
-[amd64_xen]
-flavours:
- amd64
Modified: dists/trunk/linux/debian/config/i386/defines
==============================================================================
--- dists/trunk/linux/debian/config/i386/defines Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/config/i386/defines Sun May 12 00:53:14 2013 (r20079)
@@ -1,10 +1,7 @@
[base]
featuresets:
+ none
rt
-flavours:
- 486
- 686-pae
- amd64
kernel-arch: x86
[description]
@@ -33,7 +30,7 @@
[686-pae_description]
hardware: modern PCs
hardware-long: PCs with one or more processors supporting PAE
-parts: pae xen
+parts: pae
[686-pae_image]
configs:
@@ -41,11 +38,6 @@
i386/config.686-pae
recommends: libc6-i686
-[686-pae_xen]
-flavours:
- i386
- amd64
-
[amd64_description]
hardware: 64-bit PCs
hardware-long: PCs with AMD64, Intel 64 or VIA Nano processors
@@ -55,7 +47,3 @@
configs:
kernelarch-x86/config-arch-64
recommends: libc6-i686
-
-[amd64_xen]
-flavours:
- amd64
Modified: dists/trunk/linux/debian/config/kernelarch-x86/config
==============================================================================
--- dists/trunk/linux/debian/config/kernelarch-x86/config Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/config/kernelarch-x86/config Sun May 12 00:53:14 2013 (r20079)
@@ -1418,7 +1418,7 @@
##
## file: drivers/staging/zsmalloc/Kconfig
##
-CONFIG_ZSMALLOC=m
+CONFIG_ZSMALLOC=y
##
## file: drivers/thermal/Kconfig
Modified: dists/trunk/linux/debian/installer/amd64/modules/amd64/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/amd64/modules/amd64/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/amd64/modules/amd64/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,5 +1 @@
-8390
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/armel/modules/armel-iop32x/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/armel/modules/armel-iop32x/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/armel/modules/armel-iop32x/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,4 +1 @@
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/armel/modules/armel-kirkwood/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/armel/modules/armel-kirkwood/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/armel/modules/armel-kirkwood/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,4 +1 @@
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/armel/modules/armel-orion5x/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/armel/modules/armel-orion5x/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/armel/modules/armel-orion5x/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,3 +1 @@
-mii
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/armel/modules/armel-versatile/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/armel/modules/armel-versatile/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/armel/modules/armel-versatile/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,4 +1 @@
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/armhf/modules/armhf-mx5/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/armhf/modules/armhf-mx5/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/armhf/modules/armhf-mx5/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,4 +1 @@
-mii
-#libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/armhf/modules/armhf-vexpress/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/armhf/modules/armhf-vexpress/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/armhf/modules/armhf-vexpress/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,4 +1 @@
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/i386/modules/i386/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/i386/modules/i386/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/i386/modules/i386/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,5 +1 @@
-8390
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/ia64/modules/ia64/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/ia64/modules/ia64/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/ia64/modules/ia64/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,5 +1 @@
-8390
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/mips/modules/mips-sb1-bcm91250a/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/mips/modules/mips-sb1-bcm91250a/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/mips/modules/mips-sb1-bcm91250a/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,3 +1 @@
-mii
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/mips/modules/mips/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/mips/modules/mips/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/mips/modules/mips/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,4 +1 @@
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/mipsel/modules/mipsel-loongson-2f/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/mipsel/modules/mipsel-loongson-2f/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/mipsel/modules/mipsel-loongson-2f/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,3 +1 @@
-mii
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/mipsel/modules/mipsel-r5k-cobalt/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/mipsel/modules/mipsel-r5k-cobalt/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/mipsel/modules/mipsel-r5k-cobalt/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,4 +1 @@
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Copied: dists/trunk/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/crc-modules (from r20071, dists/sid/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/crc-modules)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dists/trunk/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/crc-modules Sun May 12 00:53:14 2013 (r20079, copy of r20071, dists/sid/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/crc-modules)
@@ -0,0 +1 @@
+#include <crc-modules>
Modified: dists/trunk/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/mipsel/modules/mipsel-sb1-bcm91250a/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,3 +1 @@
-mii
-pps_core
-ptp
+#include <nic-shared-modules>
Copied: dists/trunk/linux/debian/installer/modules/nic-shared-modules (from r20071, dists/sid/linux/debian/installer/modules/nic-shared-modules)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dists/trunk/linux/debian/installer/modules/nic-shared-modules Sun May 12 00:53:14 2013 (r20079, copy of r20071, dists/sid/linux/debian/installer/modules/nic-shared-modules)
@@ -0,0 +1,5 @@
+8390 ?
+libphy ?
+mii ?
+pps_core ?
+ptp ?
Modified: dists/trunk/linux/debian/installer/powerpc/modules/powerpc-powerpc-miboot/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/powerpc/modules/powerpc-powerpc-miboot/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/powerpc/modules/powerpc-powerpc-miboot/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,2 +1 @@
-8390
-libphy
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/powerpc/modules/powerpc-powerpc64/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/powerpc/modules/powerpc-powerpc64/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/powerpc/modules/powerpc-powerpc64/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,5 +1 @@
-8390
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/powerpc/modules/powerpc/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/powerpc/modules/powerpc/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/powerpc/modules/powerpc/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,2 +1 @@
-8390
-libphy
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/powerpcspe/modules/powerpcspe-powerpcspe-miboot/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/powerpcspe/modules/powerpcspe-powerpcspe-miboot/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/powerpcspe/modules/powerpcspe-powerpcspe-miboot/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,2 +1 @@
-8390
-libphy
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/powerpcspe/modules/powerpcspe/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/powerpcspe/modules/powerpcspe/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/powerpcspe/modules/powerpcspe/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,2 +1 @@
-8390
-libphy
+#include <nic-shared-modules>
Modified: dists/trunk/linux/debian/installer/ppc64/modules/ppc64/nic-shared-modules
==============================================================================
--- dists/trunk/linux/debian/installer/ppc64/modules/ppc64/nic-shared-modules Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/installer/ppc64/modules/ppc64/nic-shared-modules Sun May 12 00:53:14 2013 (r20079)
@@ -1,5 +1 @@
-8390
-mii
-libphy
-pps_core
-ptp
+#include <nic-shared-modules>
Copied: dists/trunk/linux/debian/installer/sparc/modules/sparc/crc-modules (from r20071, dists/sid/linux/debian/installer/sparc/modules/sparc/crc-modules)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dists/trunk/linux/debian/installer/sparc/modules/sparc/crc-modules Sun May 12 00:53:14 2013 (r20079, copy of r20071, dists/sid/linux/debian/installer/sparc/modules/sparc/crc-modules)
@@ -0,0 +1 @@
+#include <crc-modules>
Modified: dists/trunk/linux/debian/patches/features/all/aufs3/aufs3-add.patch
==============================================================================
--- dists/trunk/linux/debian/patches/features/all/aufs3/aufs3-add.patch Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/patches/features/all/aufs3/aufs3-add.patch Sun May 12 00:53:14 2013 (r20079)
@@ -1,3 +1,1390 @@
+--- a/Documentation/ABI/testing/debugfs-aufs 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/ABI/testing/debugfs-aufs 2013-05-09 01:36:20.741181631 +0100
+@@ -0,0 +1,50 @@
++What: /debug/aufs/si_<id>/
++Date: March 2009
++Contact: J. R. Okajima <hooanon05 at yahoo.co.jp>
++Description:
++ Under /debug/aufs, a directory named si_<id> is created
++ per aufs mount, where <id> is a unique id generated
++ internally.
++
++What: /debug/aufs/si_<id>/plink
++Date: Apr 2013
++Contact: J. R. Okajima <hooanon05 at yahoo.co.jp>
++Description:
++ It has three lines and shows the information about the
++ pseudo-link. The first line is a single number
++ representing a number of buckets. The second line is a
++ number of pseudo-links per buckets (separated by a
++ blank). The last line is a single number representing a
++ total number of psedo-links.
++ When the aufs mount option 'noplink' is specified, it
++ will show "1\n0\n0\n".
++
++What: /debug/aufs/si_<id>/xib
++Date: March 2009
++Contact: J. R. Okajima <hooanon05 at yahoo.co.jp>
++Description:
++ It shows the consumed blocks by xib (External Inode Number
++ Bitmap), its block size and file size.
++ When the aufs mount option 'noxino' is specified, it
++ will be empty. About XINO files, see the aufs manual.
++
++What: /debug/aufs/si_<id>/xino0, xino1 ... xinoN
++Date: March 2009
++Contact: J. R. Okajima <hooanon05 at yahoo.co.jp>
++Description:
++ It shows the consumed blocks by xino (External Inode Number
++ Translation Table), its link count, block size and file
++ size.
++ When the aufs mount option 'noxino' is specified, it
++ will be empty. About XINO files, see the aufs manual.
++
++What: /debug/aufs/si_<id>/xigen
++Date: March 2009
++Contact: J. R. Okajima <hooanon05 at yahoo.co.jp>
++Description:
++ It shows the consumed blocks by xigen (External Inode
++ Generation Table), its block size and file size.
++ If CONFIG_AUFS_EXPORT is disabled, this entry will not
++ be created.
++ When the aufs mount option 'noxino' is specified, it
++ will be empty. About XINO files, see the aufs manual.
+--- a/Documentation/ABI/testing/sysfs-aufs 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/ABI/testing/sysfs-aufs 2012-01-10 02:15:56.000000000 +0000
+@@ -0,0 +1,24 @@
++What: /sys/fs/aufs/si_<id>/
++Date: March 2009
++Contact: J. R. Okajima <hooanon05 at yahoo.co.jp>
++Description:
++ Under /sys/fs/aufs, a directory named si_<id> is created
++ per aufs mount, where <id> is a unique id generated
++ internally.
++
++What: /sys/fs/aufs/si_<id>/br0, br1 ... brN
++Date: March 2009
++Contact: J. R. Okajima <hooanon05 at yahoo.co.jp>
++Description:
++ It shows the abolute path of a member directory (which
++ is called branch) in aufs, and its permission.
++
++What: /sys/fs/aufs/si_<id>/xi_path
++Date: March 2009
++Contact: J. R. Okajima <hooanon05 at yahoo.co.jp>
++Description:
++ It shows the abolute path of XINO (External Inode Number
++ Bitmap, Translation Table and Generation Table) file
++ even if it is the default path.
++ When the aufs mount option 'noxino' is specified, it
++ will be empty. About XINO files, see the aufs manual.
+--- a/Documentation/filesystems/aufs/README 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/README 2013-05-09 01:36:20.741181631 +0100
+@@ -0,0 +1,337 @@
++
++Aufs3 -- advanced multi layered unification filesystem version 3.x
++http://aufs.sf.net
++Junjiro R. Okajima
++
++
++0. Introduction
++----------------------------------------
++In the early days, aufs was entirely re-designed and re-implemented
++Unionfs Version 1.x series. After many original ideas, approaches,
++improvements and implementations, it becomes totally different from
++Unionfs while keeping the basic features.
++Recently, Unionfs Version 2.x series begin taking some of the same
++approaches to aufs1's.
++Unionfs is being developed by Professor Erez Zadok at Stony Brook
++University and his team.
++
++Aufs3 supports linux-3.0 and later.
++If you want older kernel version support, try aufs2-2.6.git or
++aufs2-standalone.git repository, aufs1 from CVS on SourceForge.
++
++Note: it becomes clear that "Aufs was rejected. Let's give it up."
++According to Christoph Hellwig, linux rejects all union-type filesystems
++but UnionMount.
++<http://marc.info/?l=linux-kernel&m=123938533724484&w=2>
++
++
++1. Features
++----------------------------------------
++- unite several directories into a single virtual filesystem. The member
++ directory is called as a branch.
++- you can specify the permission flags to the branch, which are 'readonly',
++ 'readwrite' and 'whiteout-able.'
++- by upper writable branch, internal copyup and whiteout, files/dirs on
++ readonly branch are modifiable logically.
++- dynamic branch manipulation, add, del.
++- etc...
++
++Also there are many enhancements in aufs1, such as:
++- readdir(3) in userspace.
++- keep inode number by external inode number table
++- keep the timestamps of file/dir in internal copyup operation
++- seekable directory, supporting NFS readdir.
++- whiteout is hardlinked in order to reduce the consumption of inodes
++ on branch
++- do not copyup, nor create a whiteout when it is unnecessary
++- revert a single systemcall when an error occurs in aufs
++- remount interface instead of ioctl
++- maintain /etc/mtab by an external command, /sbin/mount.aufs.
++- loopback mounted filesystem as a branch
++- kernel thread for removing the dir who has a plenty of whiteouts
++- support copyup sparse file (a file which has a 'hole' in it)
++- default permission flags for branches
++- selectable permission flags for ro branch, whether whiteout can
++ exist or not
++- export via NFS.
++- support <sysfs>/fs/aufs and <debugfs>/aufs.
++- support multiple writable branches, some policies to select one
++ among multiple writable branches.
++- a new semantics for link(2) and rename(2) to support multiple
++ writable branches.
++- no glibc changes are required.
++- pseudo hardlink (hardlink over branches)
++- allow a direct access manually to a file on branch, e.g. bypassing aufs.
++ including NFS or remote filesystem branch.
++- userspace wrapper for pathconf(3)/fpathconf(3) with _PC_LINK_MAX.
++- and more...
++
++Currently these features are dropped temporary from aufs3.
++See design/08plan.txt in detail.
++- test only the highest one for the directory permission (dirperm1)
++- copyup on open (coo=)
++- nested mount, i.e. aufs as readonly no-whiteout branch of another aufs
++ (robr)
++- statistics of aufs thread (/sys/fs/aufs/stat)
++- delegation mode (dlgt)
++ a delegation of the internal branch access to support task I/O
++ accounting, which also supports Linux Security Modules (LSM) mainly
++ for Suse AppArmor.
++- intent.open/create (file open in a single lookup)
++
++Features or just an idea in the future (see also design/*.txt),
++- reorder the branch index without del/re-add.
++- permanent xino files for NFSD
++- an option for refreshing the opened files after add/del branches
++- 'move' policy for copy-up between two writable branches, after
++ checking free space.
++- light version, without branch manipulation. (unnecessary?)
++- copyup in userspace
++- inotify in userspace
++- readv/writev
++- xattr, acl
++
++
++2. Download
++----------------------------------------
++There were three GIT trees for aufs3, aufs3-linux.git,
++aufs3-standalone.git, and aufs-util.git. Note that there is no "3" in
++"aufs-util.git."
++While the aufs-util is always necessary, you need either of aufs3-linux
++or aufs3-standalone.
++
++The aufs3-linux tree includes the whole linux mainline GIT tree,
++git://git.kernel.org/.../torvalds/linux.git.
++And you cannot select CONFIG_AUFS_FS=m for this version, eg. you cannot
++build aufs3 as an external kernel module.
++
++On the other hand, the aufs3-standalone tree has only aufs source files
++and necessary patches, and you can select CONFIG_AUFS_FS=m.
++
++You will find GIT branches whose name is in form of "aufs3.x" where "x"
++represents the linux kernel version, "linux-3.x". For instance,
++"aufs3.0" is for linux-3.0. For latest "linux-3.x-rcN", use
++"aufs3.x-rcN" branch.
++
++o aufs3-linux tree
++$ git clone --reference /your/linux/git/tree \
++ git://git.code.sf.net/p/aufs/aufs3-linux aufs-aufs3-linux \
++ aufs3-linux.git
++- if you don't have linux GIT tree, then remove "--reference ..."
++$ cd aufs3-linux.git
++$ git checkout origin/aufs3.0
++
++o aufs3-standalone tree
++$ git clone git://git.code.sf.net/p/aufs/aufs3-standalone \
++ aufs3-standalone.git
++$ cd aufs3-standalone.git
++$ git checkout origin/aufs3.0
++
++o aufs-util tree
++$ git clone git://git.code.sf.net/p/aufs/aufs-util \
++ aufs-util.git
++$ cd aufs-util.git
++$ git checkout origin/aufs3.0
++
++Note: The 3.x-rcN branch is to be used with `rc' kernel versions ONLY.
++The minor version number, 'x' in '3.x', of aufs may not always
++follow the minor version number of the kernel.
++Because changes in the kernel that cause the use of a new
++minor version number do not always require changes to aufs-util.
++
++Since aufs-util has its own minor version number, you may not be
++able to find a GIT branch in aufs-util for your kernel's
++exact minor version number.
++In this case, you should git-checkout the branch for the
++nearest lower number.
++
++For (an unreleased) example:
++If you are using "linux-3.10" and the "aufs3.10" branch
++does not exist in aufs-util repository, then "aufs3.9", "aufs3.8"
++or something numerically smaller is the branch for your kernel.
++
++Also you can view all branches by
++ $ git branch -a
++
++
++3. Configuration and Compilation
++----------------------------------------
++Make sure you have git-checkout'ed the correct branch.
++
++For aufs3-linux tree,
++- enable CONFIG_EXPERIMENTAL and CONFIG_AUFS_FS.
++- set other aufs configurations if necessary.
++
++For aufs3-standalone tree,
++There are several ways to build.
++
++1.
++- apply ./aufs3-kbuild.patch to your kernel source files.
++- apply ./aufs3-base.patch too.
++- apply ./aufs3-proc_map.patch too, if you want to make /proc/PID/maps (and
++ others including lsof(1)) show the file path on aufs instead of the
++ path on the branch fs.
++- apply ./aufs3-standalone.patch too, if you have a plan to set
++ CONFIG_AUFS_FS=m. otherwise you don't need ./aufs3-standalone.patch.
++- copy ./{Documentation,fs,include/uapi/linux/aufs_type.h} files to your
++ kernel source tree. Never copy $PWD/include/uapi/linux/Kbuild.
++- enable CONFIG_EXPERIMENTAL and CONFIG_AUFS_FS, you can select either
++ =m or =y.
++- and build your kernel as usual.
++- install the built kernel.
++- install the header files too by "make headers_install" to the
++ directory where you specify. By default, it is $PWD/usr.
++ "make help" shows a brief note for headers_install.
++- and reboot your system.
++
++2.
++- module only (CONFIG_AUFS_FS=m).
++- apply ./aufs3-base.patch to your kernel source files.
++- apply ./aufs3-proc_map.patch too to your kernel source files,
++ if you want to make /proc/PID/maps (and others including lsof(1)) show
++ the file path on aufs instead of the path on the branch fs.
++- apply ./aufs3-standalone.patch too.
++- build your kernel, don't forget "make headers_install", and reboot.
++- edit ./config.mk and set other aufs configurations if necessary.
++ Note: You should read $PWD/fs/aufs/Kconfig carefully which describes
++ every aufs configurations.
++- build the module by simple "make".
++- you can specify ${KDIR} make variable which points to your kernel
++ source tree.
++- install the files
++ + run "make install" to install the aufs module, or copy the built
++ $PWD/aufs.ko to /lib/modules/... and run depmod -a (or reboot simply).
++ + run "make install_headers" (instead of headers_install) to install
++ the modified aufs header file (you can specify DESTDIR which is
++ available in aufs standalone version's Makefile only), or copy
++ $PWD/usr/include/linux/aufs_type.h to /usr/include/linux or wherever
++ you like manually. By default, the target directory is $PWD/usr.
++- no need to apply aufs3-kbuild.patch, nor copying source files to your
++ kernel source tree.
++
++Note: The header file aufs_type.h is necessary to build aufs-util
++ as well as "make headers_install" in the kernel source tree.
++ headers_install is subject to be forgotten, but it is essentially
++ necessary, not only for building aufs-util.
++ You may not meet problems without headers_install in some older
++ version though.
++
++And then,
++- read README in aufs-util, build and install it
++- note that your distribution may contain an obsoleted version of
++ aufs_type.h in /usr/include/linux or something. When you build aufs
++ utilities, make sure that your compiler refers the correct aufs header
++ file which is built by "make headers_install."
++- if you want to use readdir(3) in userspace or pathconf(3) wrapper,
++ then run "make install_ulib" too. And refer to the aufs manual in
++ detail.
++
++
++4. Usage
++----------------------------------------
++At first, make sure aufs-util are installed, and please read the aufs
++manual, aufs.5 in aufs-util.git tree.
++$ man -l aufs.5
++
++And then,
++$ mkdir /tmp/rw /tmp/aufs
++# mount -t aufs -o br=/tmp/rw:${HOME} none /tmp/aufs
++
++Here is another example. The result is equivalent.
++# mount -t aufs -o br=/tmp/rw=rw:${HOME}=ro none /tmp/aufs
++ Or
++# mount -t aufs -o br:/tmp/rw none /tmp/aufs
++# mount -o remount,append:${HOME} /tmp/aufs
++
++Then, you can see whole tree of your home dir through /tmp/aufs. If
++you modify a file under /tmp/aufs, the one on your home directory is
++not affected, instead the same named file will be newly created under
++/tmp/rw. And all of your modification to a file will be applied to
++the one under /tmp/rw. This is called the file based Copy on Write
++(COW) method.
++Aufs mount options are described in aufs.5.
++If you run chroot or something and make your aufs as a root directory,
++then you need to customize the shutdown script. See the aufs manual in
++detail.
++
++Additionally, there are some sample usages of aufs which are a
++diskless system with network booting, and LiveCD over NFS.
++See sample dir in CVS tree on SourceForge.
++
++
++5. Contact
++----------------------------------------
++When you have any problems or strange behaviour in aufs, please let me
++know with:
++- /proc/mounts (instead of the output of mount(8))
++- /sys/module/aufs/*
++- /sys/fs/aufs/* (if you have them)
++- /debug/aufs/* (if you have them)
++- linux kernel version
++ if your kernel is not plain, for example modified by distributor,
++ the url where i can download its source is necessary too.
++- aufs version which was printed at loading the module or booting the
++ system, instead of the date you downloaded.
++- configuration (define/undefine CONFIG_AUFS_xxx)
++- kernel configuration or /proc/config.gz (if you have it)
++- behaviour which you think to be incorrect
++- actual operation, reproducible one is better
++- mailto: aufs-users at lists.sourceforge.net
++
++Usually, I don't watch the Public Areas(Bugs, Support Requests, Patches,
++and Feature Requests) on SourceForge. Please join and write to
++aufs-users ML.
++
++
++6. Acknowledgements
++----------------------------------------
++Thanks to everyone who have tried and are using aufs, whoever
++have reported a bug or any feedback.
++
++Especially donators:
++Tomas Matejicek(slax.org) made a donation (much more than once).
++ Since Apr 2010, Tomas M (the author of Slax and Linux Live
++ scripts) is making "doubling" donations.
++ Unfortunately I cannot list all of the donators, but I really
++ appreciate.
++ It ends Aug 2010, but the ordinary donation URL is still available.
++ <http://sourceforge.net/donate/index.php?group_id=167503>
++Dai Itasaka made a donation (2007/8).
++Chuck Smith made a donation (2008/4, 10 and 12).
++Henk Schoneveld made a donation (2008/9).
++Chih-Wei Huang, ASUS, CTC donated Eee PC 4G (2008/10).
++Francois Dupoux made a donation (2008/11).
++Bruno Cesar Ribas and Luis Carlos Erpen de Bona, C3SL serves public
++ aufs2 GIT tree (2009/2).
++William Grant made a donation (2009/3).
++Patrick Lane made a donation (2009/4).
++The Mail Archive (mail-archive.com) made donations (2009/5).
++Nippy Networks (Ed Wildgoose) made a donation (2009/7).
++New Dream Network, LLC (www.dreamhost.com) made a donation (2009/11).
++Pavel Pronskiy made a donation (2011/2).
++Iridium and Inmarsat satellite phone retailer (www.mailasail.com), Nippy
++ Networks (Ed Wildgoose) made a donation for hardware (2011/3).
++Max Lekomcev (DOM-TV project) made a donation (2011/7, 12, 2012/3, 6 and
++11).
++Sam Liddicott made a donation (2011/9).
++Era Scarecrow made a donation (2013/4).
++Bor Ratajc made a donation (2013/4).
++Alessandro Gorreta made a donation (2013/4).
++POIRETTE Marc made a donation (2013/4).
++
++Thank you very much.
++Donations are always, including future donations, very important and
++helpful for me to keep on developing aufs.
++
++
++7.
++----------------------------------------
++If you are an experienced user, no explanation is needed. Aufs is
++just a linux filesystem.
++
++
++Enjoy!
++
++# Local variables: ;
++# mode: text;
++# End: ;
+--- a/Documentation/filesystems/aufs/design/01intro.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/01intro.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,162 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Introduction
++----------------------------------------
++
++aufs [ei ju: ef es] | [a u f s]
++1. abbrev. for "advanced multi-layered unification filesystem".
++2. abbrev. for "another unionfs".
++3. abbrev. for "auf das" in German which means "on the" in English.
++ Ex. "Butter aufs Brot"(G) means "butter onto bread"(E).
++ But "Filesystem aufs Filesystem" is hard to understand.
++
++AUFS is a filesystem with features:
++- multi layered stackable unification filesystem, the member directory
++ is called as a branch.
++- branch permission and attribute, 'readonly', 'real-readonly',
++ 'readwrite', 'whiteout-able', 'link-able whiteout' and their
++ combination.
++- internal "file copy-on-write".
++- logical deletion, whiteout.
++- dynamic branch manipulation, adding, deleting and changing permission.
++- allow bypassing aufs, user's direct branch access.
++- external inode number translation table and bitmap which maintains the
++ persistent aufs inode number.
++- seekable directory, including NFS readdir.
++- file mapping, mmap and sharing pages.
++- pseudo-link, hardlink over branches.
++- loopback mounted filesystem as a branch.
++- several policies to select one among multiple writable branches.
++- revert a single systemcall when an error occurs in aufs.
++- and more...
++
++
++Multi Layered Stackable Unification Filesystem
++----------------------------------------------------------------------
++Most people already knows what it is.
++It is a filesystem which unifies several directories and provides a
++merged single directory. When users access a file, the access will be
++passed/re-directed/converted (sorry, I am not sure which English word is
++correct) to the real file on the member filesystem. The member
++filesystem is called 'lower filesystem' or 'branch' and has a mode
++'readonly' and 'readwrite.' And the deletion for a file on the lower
++readonly branch is handled by creating 'whiteout' on the upper writable
++branch.
++
++On LKML, there have been discussions about UnionMount (Jan Blunck,
++Bharata B Rao and Valerie Aurora) and Unionfs (Erez Zadok). They took
++different approaches to implement the merged-view.
++The former tries putting it into VFS, and the latter implements as a
++separate filesystem.
++(If I misunderstand about these implementations, please let me know and
++I shall correct it. Because it is a long time ago when I read their
++source files last time).
++
++UnionMount's approach will be able to small, but may be hard to share
++branches between several UnionMount since the whiteout in it is
++implemented in the inode on branch filesystem and always
++shared. According to Bharata's post, readdir does not seems to be
++finished yet.
++There are several missing features known in this implementations such as
++- for users, the inode number may change silently. eg. copy-up.
++- link(2) may break by copy-up.
++- read(2) may get an obsoleted filedata (fstat(2) too).
++- fcntl(F_SETLK) may be broken by copy-up.
++- unnecessary copy-up may happen, for example mmap(MAP_PRIVATE) after
++ open(O_RDWR).
++
++Unionfs has a longer history. When I started implementing a stacking filesystem
++(Aug 2005), it already existed. It has virtual super_block, inode,
++dentry and file objects and they have an array pointing lower same kind
++objects. After contributing many patches for Unionfs, I re-started my
++project AUFS (Jun 2006).
++
++In AUFS, the structure of filesystem resembles to Unionfs, but I
++implemented my own ideas, approaches and enhancements and it became
++totally different one.
++
++Comparing DM snapshot and fs based implementation
++- the number of bytes to be copied between devices is much smaller.
++- the type of filesystem must be one and only.
++- the fs must be writable, no readonly fs, even for the lower original
++ device. so the compression fs will not be usable. but if we use
++ loopback mount, we may address this issue.
++ for instance,
++ mount /cdrom/squashfs.img /sq
++ losetup /sq/ext2.img
++ losetup /somewhere/cow
++ dmsetup "snapshot /dev/loop0 /dev/loop1 ..."
++- it will be difficult (or needs more operations) to extract the
++ difference between the original device and COW.
++- DM snapshot-merge may help a lot when users try merging. in the
++ fs-layer union, users will use rsync(1).
++
++
++Several characters/aspects of aufs
++----------------------------------------------------------------------
++
++Aufs has several characters or aspects.
++1. a filesystem, callee of VFS helper
++2. sub-VFS, caller of VFS helper for branches
++3. a virtual filesystem which maintains persistent inode number
++4. reader/writer of files on branches such like an application
++
++1. Callee of VFS Helper
++As an ordinary linux filesystem, aufs is a callee of VFS. For instance,
++unlink(2) from an application reaches sys_unlink() kernel function and
++then vfs_unlink() is called. vfs_unlink() is one of VFS helper and it
++calls filesystem specific unlink operation. Actually aufs implements the
++unlink operation but it behaves like a redirector.
++
++2. Caller of VFS Helper for Branches
++aufs_unlink() passes the unlink request to the branch filesystem as if
++it were called from VFS. So the called unlink operation of the branch
++filesystem acts as usual. As a caller of VFS helper, aufs should handle
++every necessary pre/post operation for the branch filesystem.
++- acquire the lock for the parent dir on a branch
++- lookup in a branch
++- revalidate dentry on a branch
++- mnt_want_write() for a branch
++- vfs_unlink() for a branch
++- mnt_drop_write() for a branch
++- release the lock on a branch
++
++3. Persistent Inode Number
++One of the most important issue for a filesystem is to maintain inode
++numbers. This is particularly important to support exporting a
++filesystem via NFS. Aufs is a virtual filesystem which doesn't have a
++backend block device for its own. But some storage is necessary to
++maintain inode number. It may be a large space and may not suit to keep
++in memory. Aufs rents some space from its first writable branch
++filesystem (by default) and creates file(s) on it. These files are
++created by aufs internally and removed soon (currently) keeping opened.
++Note: Because these files are removed, they are totally gone after
++ unmounting aufs. It means the inode numbers are not persistent
++ across unmount or reboot. I have a plan to make them really
++ persistent which will be important for aufs on NFS server.
++
++4. Read/Write Files Internally (copy-on-write)
++Because a branch can be readonly, when you write a file on it, aufs will
++"copy-up" it to the upper writable branch internally. And then write the
++originally requested thing to the file. Generally kernel doesn't
++open/read/write file actively. In aufs, even a single write may cause a
++internal "file copy". This behaviour is very similar to cp(1) command.
++
++Some people may think it is better to pass such work to user space
++helper, instead of doing in kernel space. Actually I am still thinking
++about it. But currently I have implemented it in kernel space.
+--- a/Documentation/filesystems/aufs/design/02struct.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/02struct.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,226 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Basic Aufs Internal Structure
++
++Superblock/Inode/Dentry/File Objects
++----------------------------------------------------------------------
++As like an ordinary filesystem, aufs has its own
++superblock/inode/dentry/file objects. All these objects have a
++dynamically allocated array and store the same kind of pointers to the
++lower filesystem, branch.
++For example, when you build a union with one readwrite branch and one
++readonly, mounted /au, /rw and /ro respectively.
++- /au = /rw + /ro
++- /ro/fileA exists but /rw/fileA
++
++Aufs lookup operation finds /ro/fileA and gets dentry for that. These
++pointers are stored in a aufs dentry. The array in aufs dentry will be,
++- [0] = NULL
++- [1] = /ro/fileA
++
++This style of an array is essentially same to the aufs
++superblock/inode/dentry/file objects.
++
++Because aufs supports manipulating branches, ie. add/delete/change
++dynamically, these objects has its own generation. When branches are
++changed, the generation in aufs superblock is incremented. And a
++generation in other object are compared when it is accessed.
++When a generation in other objects are obsoleted, aufs refreshes the
++internal array.
++
++
++Superblock
++----------------------------------------------------------------------
++Additionally aufs superblock has some data for policies to select one
++among multiple writable branches, XIB files, pseudo-links and kobject.
++See below in detail.
++About the policies which supports copy-down a directory, see policy.txt
++too.
++
++
++Branch and XINO(External Inode Number Translation Table)
++----------------------------------------------------------------------
++Every branch has its own xino (external inode number translation table)
++file. The xino file is created and unlinked by aufs internally. When two
++members of a union exist on the same filesystem, they share the single
++xino file.
++The struct of a xino file is simple, just a sequence of aufs inode
++numbers which is indexed by the lower inode number.
++In the above sample, assume the inode number of /ro/fileA is i111 and
++aufs assigns the inode number i999 for fileA. Then aufs writes 999 as
++4(8) bytes at 111 * 4(8) bytes offset in the xino file.
++
++When the inode numbers are not contiguous, the xino file will be sparse
++which has a hole in it and doesn't consume as much disk space as it
++might appear. If your branch filesystem consumes disk space for such
++holes, then you should specify 'xino=' option at mounting aufs.
++
++Also a writable branch has three kinds of "whiteout bases". All these
++are existed when the branch is joined to aufs and the names are
++whiteout-ed doubly, so that users will never see their names in aufs
++hierarchy.
++1. a regular file which will be linked to all whiteouts.
++2. a directory to store a pseudo-link.
++3. a directory to store an "orphan-ed" file temporary.
++
++1. Whiteout Base
++ When you remove a file on a readonly branch, aufs handles it as a
++ logical deletion and creates a whiteout on the upper writable branch
++ as a hardlink of this file in order not to consume inode on the
++ writable branch.
++2. Pseudo-link Dir
++ See below, Pseudo-link.
++3. Step-Parent Dir
++ When "fileC" exists on the lower readonly branch only and it is
++ opened and removed with its parent dir, and then user writes
++ something into it, then aufs copies-up fileC to this
++ directory. Because there is no other dir to store fileC. After
++ creating a file under this dir, the file is unlinked.
++
++Because aufs supports manipulating branches, ie. add/delete/change
++dynamically, a branch has its own id. When the branch order changes, aufs
++finds the new index by searching the branch id.
++
++
++Pseudo-link
++----------------------------------------------------------------------
++Assume "fileA" exists on the lower readonly branch only and it is
++hardlinked to "fileB" on the branch. When you write something to fileA,
++aufs copies-up it to the upper writable branch. Additionally aufs
++creates a hardlink under the Pseudo-link Directory of the writable
++branch. The inode of a pseudo-link is kept in aufs super_block as a
++simple list. If fileB is read after unlinking fileA, aufs returns
++filedata from the pseudo-link instead of the lower readonly
++branch. Because the pseudo-link is based upon the inode, to keep the
++inode number by xino (see above) is important.
++
++All the hardlinks under the Pseudo-link Directory of the writable branch
++should be restored in a proper location later. Aufs provides a utility
++to do this. The userspace helpers executed at remounting and unmounting
++aufs by default.
++During this utility is running, it puts aufs into the pseudo-link
++maintenance mode. In this mode, only the process which began the
++maintenance mode (and its child processes) is allowed to operate in
++aufs. Some other processes which are not related to the pseudo-link will
++be allowed to run too, but the rest have to return an error or wait
++until the maintenance mode ends. If a process already acquires an inode
++mutex (in VFS), it has to return an error.
++
++
++XIB(external inode number bitmap)
++----------------------------------------------------------------------
++Addition to the xino file per a branch, aufs has an external inode number
++bitmap in a superblock object. It is also a file such like a xino file.
++It is a simple bitmap to mark whether the aufs inode number is in-use or
++not.
++To reduce the file I/O, aufs prepares a single memory page to cache xib.
++
++Aufs implements a feature to truncate/refresh both of xino and xib to
++reduce the number of consumed disk blocks for these files.
++
++
++Virtual or Vertical Dir, and Readdir in Userspace
++----------------------------------------------------------------------
++In order to support multiple layers (branches), aufs readdir operation
++constructs a virtual dir block on memory. For readdir, aufs calls
++vfs_readdir() internally for each dir on branches, merges their entries
++with eliminating the whiteout-ed ones, and sets it to file (dir)
++object. So the file object has its entry list until it is closed. The
++entry list will be updated when the file position is zero and becomes
++old. This decision is made in aufs automatically.
++
++The dynamically allocated memory block for the name of entries has a
++unit of 512 bytes (by default) and stores the names contiguously (no
++padding). Another block for each entry is handled by kmem_cache too.
++During building dir blocks, aufs creates hash list and judging whether
++the entry is whiteouted by its upper branch or already listed.
++The merged result is cached in the corresponding inode object and
++maintained by a customizable life-time option.
++
++Some people may call it can be a security hole or invite DoS attack
++since the opened and once readdir-ed dir (file object) holds its entry
++list and becomes a pressure for system memory. But I'd say it is similar
++to files under /proc or /sys. The virtual files in them also holds a
++memory page (generally) while they are opened. When an idea to reduce
++memory for them is introduced, it will be applied to aufs too.
++For those who really hate this situation, I've developed readdir(3)
++library which operates this merging in userspace. You just need to set
++LD_PRELOAD environment variable, and aufs will not consume no memory in
++kernel space for readdir(3).
++
++
++Workqueue
++----------------------------------------------------------------------
++Aufs sometimes requires privilege access to a branch. For instance,
++in copy-up/down operation. When a user process is going to make changes
++to a file which exists in the lower readonly branch only, and the mode
++of one of ancestor directories may not be writable by a user
++process. Here aufs copy-up the file with its ancestors and they may
++require privilege to set its owner/group/mode/etc.
++This is a typical case of a application character of aufs (see
++Introduction).
++
++Aufs uses workqueue synchronously for this case. It creates its own
++workqueue. The workqueue is a kernel thread and has privilege. Aufs
++passes the request to call mkdir or write (for example), and wait for
++its completion. This approach solves a problem of a signal handler
++simply.
++If aufs didn't adopt the workqueue and changed the privilege of the
++process, and if the mkdir/write call arises SIGXFSZ or other signal,
++then the user process might gain a privilege or the generated core file
++was owned by a superuser.
++
++Also aufs uses the system global workqueue ("events" kernel thread) too
++for asynchronous tasks, such like handling inotify/fsnotify, re-creating a
++whiteout base and etc. This is unrelated to a privilege.
++Most of aufs operation tries acquiring a rw_semaphore for aufs
++superblock at the beginning, at the same time waits for the completion
++of all queued asynchronous tasks.
++
++
++Whiteout
++----------------------------------------------------------------------
++The whiteout in aufs is very similar to Unionfs's. That is represented
++by its filename. UnionMount takes an approach of a file mode, but I am
++afraid several utilities (find(1) or something) will have to support it.
++
++Basically the whiteout represents "logical deletion" which stops aufs to
++lookup further, but also it represents "dir is opaque" which also stop
++lookup.
++
++In aufs, rmdir(2) and rename(2) for dir uses whiteout alternatively.
++In order to make several functions in a single systemcall to be
++revertible, aufs adopts an approach to rename a directory to a temporary
++unique whiteouted name.
++For example, in rename(2) dir where the target dir already existed, aufs
++renames the target dir to a temporary unique whiteouted name before the
++actual rename on a branch and then handles other actions (make it opaque,
++update the attributes, etc). If an error happens in these actions, aufs
++simply renames the whiteouted name back and returns an error. If all are
++succeeded, aufs registers a function to remove the whiteouted unique
++temporary name completely and asynchronously to the system global
++workqueue.
++
++
++Copy-up
++----------------------------------------------------------------------
++It is a well-known feature or concept.
++When user modifies a file on a readonly branch, aufs operate "copy-up"
++internally and makes change to the new file on the upper writable branch.
++When the trigger systemcall does not update the timestamps of the parent
++dir, aufs reverts it after copy-up.
+--- a/Documentation/filesystems/aufs/design/03lookup.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/03lookup.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,106 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Lookup in a Branch
++----------------------------------------------------------------------
++Since aufs has a character of sub-VFS (see Introduction), it operates
++lookup for branches as VFS does. It may be a heavy work. Generally
++speaking struct nameidata is a bigger structure and includes many
++information. But almost all lookup operation in aufs is the simplest
++case, ie. lookup only an entry directly connected to its parent. Digging
++down the directory hierarchy is unnecessary.
++
++VFS has a function lookup_one_len() for that use, but it is not usable
++for a branch filesystem which requires struct nameidata. So aufs
++implements a simple lookup wrapper function. When a branch filesystem
++allows NULL as nameidata, it calls lookup_one_len(). Otherwise it builds
++a simplest nameidata and calls lookup_hash().
++Here aufs applies "a principle in NFSD", ie. if the filesystem supports
++NFS-export, then it has to support NULL as a nameidata parameter for
++->create(), ->lookup() and ->d_revalidate(). So the lookup wrapper in
++aufs tests if ->s_export_op in the branch is NULL or not.
++
++When a branch is a remote filesystem, aufs basically trusts its
++->d_revalidate(), also aufs forces the hardest revalidate tests for
++them.
++For d_revalidate, aufs implements three levels of revalidate tests. See
++"Revalidate Dentry and UDBA" in detail.
++
++
++Loopback Mount
++----------------------------------------------------------------------
++Basically aufs supports any type of filesystem and block device for a
++branch (actually there are some exceptions). But it is prohibited to add
++a loopback mounted one whose backend file exists in a filesystem which is
++already added to aufs. The reason is to protect aufs from a recursive
++lookup. If it was allowed, the aufs lookup operation might re-enter a
++lookup for the loopback mounted branch in the same context, and will
++cause a deadlock.
++
++
++Revalidate Dentry and UDBA (User's Direct Branch Access)
++----------------------------------------------------------------------
++Generally VFS helpers re-validate a dentry as a part of lookup.
++0. digging down the directory hierarchy.
++1. lock the parent dir by its i_mutex.
++2. lookup the final (child) entry.
++3. revalidate it.
++4. call the actual operation (create, unlink, etc.)
++5. unlock the parent dir
++
++If the filesystem implements its ->d_revalidate() (step 3), then it is
++called. Actually aufs implements it and checks the dentry on a branch is
++still valid.
++But it is not enough. Because aufs has to release the lock for the
++parent dir on a branch at the end of ->lookup() (step 2) and
++->d_revalidate() (step 3) while the i_mutex of the aufs dir is still
++held by VFS.
++If the file on a branch is changed directly, eg. bypassing aufs, after
++aufs released the lock, then the subsequent operation may cause
++something unpleasant result.
++
++This situation is a result of VFS architecture, ->lookup() and
++->d_revalidate() is separated. But I never say it is wrong. It is a good
++design from VFS's point of view. It is just not suitable for sub-VFS
++character in aufs.
++
++Aufs supports such case by three level of revalidation which is
++selectable by user.
++1. Simple Revalidate
++ Addition to the native flow in VFS's, confirm the child-parent
++ relationship on the branch just after locking the parent dir on the
++ branch in the "actual operation" (step 4). When this validation
++ fails, aufs returns EBUSY. ->d_revalidate() (step 3) in aufs still
++ checks the validation of the dentry on branches.
++2. Monitor Changes Internally by Inotify/Fsnotify
++ Addition to above, in the "actual operation" (step 4) aufs re-lookup
++ the dentry on the branch, and returns EBUSY if it finds different
++ dentry.
++ Additionally, aufs sets the inotify/fsnotify watch for every dir on branches
++ during it is in cache. When the event is notified, aufs registers a
++ function to kernel 'events' thread by schedule_work(). And the
++ function sets some special status to the cached aufs dentry and inode
++ private data. If they are not cached, then aufs has nothing to
++ do. When the same file is accessed through aufs (step 0-3) later,
++ aufs will detect the status and refresh all necessary data.
++ In this mode, aufs has to ignore the event which is fired by aufs
++ itself.
++3. No Extra Validation
++ This is the simplest test and doesn't add any additional revalidation
++ test, and skip therevalidatin in step 4. It is useful and improves
++ aufs performance when system surely hide the aufs branches from user,
++ by over-mounting something (or another method).
+--- a/Documentation/filesystems/aufs/design/04branch.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/04branch.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,76 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Branch Manipulation
++
++Since aufs supports dynamic branch manipulation, ie. add/remove a branch
++and changing its permission/attribute, there are a lot of works to do.
++
++
++Add a Branch
++----------------------------------------------------------------------
++o Confirm the adding dir exists outside of aufs, including loopback
++ mount.
++- and other various attributes...
++o Initialize the xino file and whiteout bases if necessary.
++ See struct.txt.
++
++o Check the owner/group/mode of the directory
++ When the owner/group/mode of the adding directory differs from the
++ existing branch, aufs issues a warning because it may impose a
++ security risk.
++ For example, when a upper writable branch has a world writable empty
++ top directory, a malicious user can create any files on the writable
++ branch directly, like copy-up and modify manually. If something like
++ /etc/{passwd,shadow} exists on the lower readonly branch but the upper
++ writable branch, and the writable branch is world-writable, then a
++ malicious guy may create /etc/passwd on the writable branch directly
++ and the infected file will be valid in aufs.
++ I am afraid it can be a security issue, but nothing to do except
++ producing a warning.
++
++
++Delete a Branch
++----------------------------------------------------------------------
++o Confirm the deleting branch is not busy
++ To be general, there is one merit to adopt "remount" interface to
++ manipulate branches. It is to discard caches. At deleting a branch,
++ aufs checks the still cached (and connected) dentries and inodes. If
++ there are any, then they are all in-use. An inode without its
++ corresponding dentry can be alive alone (for example, inotify/fsnotify case).
++
++ For the cached one, aufs checks whether the same named entry exists on
++ other branches.
++ If the cached one is a directory, because aufs provides a merged view
++ to users, as long as one dir is left on any branch aufs can show the
++ dir to users. In this case, the branch can be removed from aufs.
++ Otherwise aufs rejects deleting the branch.
++
++ If any file on the deleting branch is opened by aufs, then aufs
++ rejects deleting.
++
++
++Modify the Permission of a Branch
++----------------------------------------------------------------------
++o Re-initialize or remove the xino file and whiteout bases if necessary.
++ See struct.txt.
++
++o rw --> ro: Confirm the modifying branch is not busy
++ Aufs rejects the request if any of these conditions are true.
++ - a file on the branch is mmap-ed.
++ - a regular file on the branch is opened for write and there is no
++ same named entry on the upper branch.
+--- a/Documentation/filesystems/aufs/design/05wbr_policy.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/05wbr_policy.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,65 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Policies to Select One among Multiple Writable Branches
++----------------------------------------------------------------------
++When the number of writable branch is more than one, aufs has to decide
++the target branch for file creation or copy-up. By default, the highest
++writable branch which has the parent (or ancestor) dir of the target
++file is chosen (top-down-parent policy).
++By user's request, aufs implements some other policies to select the
++writable branch, for file creation two policies, round-robin and
++most-free-space policies. For copy-up three policies, top-down-parent,
++bottom-up-parent and bottom-up policies.
++
++As expected, the round-robin policy selects the branch in circular. When
++you have two writable branches and creates 10 new files, 5 files will be
++created for each branch. mkdir(2) systemcall is an exception. When you
++create 10 new directories, all will be created on the same branch.
++And the most-free-space policy selects the one which has most free
++space among the writable branches. The amount of free space will be
++checked by aufs internally, and users can specify its time interval.
++
++The policies for copy-up is more simple,
++top-down-parent is equivalent to the same named on in create policy,
++bottom-up-parent selects the writable branch where the parent dir
++exists and the nearest upper one from the copyup-source,
++bottom-up selects the nearest upper writable branch from the
++copyup-source, regardless the existence of the parent dir.
++
++There are some rules or exceptions to apply these policies.
++- If there is a readonly branch above the policy-selected branch and
++ the parent dir is marked as opaque (a variation of whiteout), or the
++ target (creating) file is whiteout-ed on the upper readonly branch,
++ then the result of the policy is ignored and the target file will be
++ created on the nearest upper writable branch than the readonly branch.
++- If there is a writable branch above the policy-selected branch and
++ the parent dir is marked as opaque or the target file is whiteouted
++ on the branch, then the result of the policy is ignored and the target
++ file will be created on the highest one among the upper writable
++ branches who has diropq or whiteout. In case of whiteout, aufs removes
++ it as usual.
++- link(2) and rename(2) systemcalls are exceptions in every policy.
++ They try selecting the branch where the source exists as possible
++ since copyup a large file will take long time. If it can't be,
++ ie. the branch where the source exists is readonly, then they will
++ follow the copyup policy.
++- There is an exception for rename(2) when the target exists.
++ If the rename target exists, aufs compares the index of the branches
++ where the source and the target exists and selects the higher
++ one. If the selected branch is readonly, then aufs follows the
++ copyup policy.
+--- a/Documentation/filesystems/aufs/design/06mmap.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/06mmap.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,47 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++mmap(2) -- File Memory Mapping
++----------------------------------------------------------------------
++In aufs, the file-mapped pages are handled by a branch fs directly, no
++interaction with aufs. It means aufs_mmap() calls the branch fs's
++->mmap().
++This approach is simple and good, but there is one problem.
++Under /proc, several entries show the mmap-ped files by its path (with
++device and inode number), and the printed path will be the path on the
++branch fs's instead of virtual aufs's.
++This is not a problem in most cases, but some utilities lsof(1) (and its
++user) may expect the path on aufs.
++
++To address this issue, aufs adds a new member called vm_prfile in struct
++vm_area_struct (and struct vm_region). The original vm_file points to
++the file on the branch fs in order to handle everything correctly as
++usual. The new vm_prfile points to a virtual file in aufs, and the
++show-functions in procfs refers to vm_prfile if it is set.
++Also we need to maintain several other places where touching vm_file
++such like
++- fork()/clone() copies vma and the reference count of vm_file is
++ incremented.
++- merging vma maintains the ref count too.
++
++This is not a good approach. It just faking the printed path. But it
++leaves all behaviour around f_mapping unchanged. This is surely an
++advantage.
++Actually aufs had adopted another complicated approach which calls
++generic_file_mmap() and handles struct vm_operations_struct. In this
++approach, aufs met a hard problem and I could not solve it without
++switching the approach.
+--- a/Documentation/filesystems/aufs/design/07export.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/07export.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,59 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Export Aufs via NFS
++----------------------------------------------------------------------
++Here is an approach.
++- like xino/xib, add a new file 'xigen' which stores aufs inode
++ generation.
++- iget_locked(): initialize aufs inode generation for a new inode, and
++ store it in xigen file.
++- destroy_inode(): increment aufs inode generation and store it in xigen
++ file. it is necessary even if it is not unlinked, because any data of
++ inode may be changed by UDBA.
++- encode_fh(): for a root dir, simply return FILEID_ROOT. otherwise
++ build file handle by
++ + branch id (4 bytes)
++ + superblock generation (4 bytes)
++ + inode number (4 or 8 bytes)
++ + parent dir inode number (4 or 8 bytes)
++ + inode generation (4 bytes))
++ + return value of exportfs_encode_fh() for the parent on a branch (4
++ bytes)
++ + file handle for a branch (by exportfs_encode_fh())
++- fh_to_dentry():
++ + find the index of a branch from its id in handle, and check it is
++ still exist in aufs.
++ + 1st level: get the inode number from handle and search it in cache.
++ + 2nd level: if not found, get the parent inode number from handle and
++ search it in cache. and then open the parent dir, find the matching
++ inode number by vfs_readdir() and get its name, and call
++ lookup_one_len() for the target dentry.
++ + 3rd level: if the parent dir is not cached, call
++ exportfs_decode_fh() for a branch and get the parent on a branch,
++ build a pathname of it, convert it a pathname in aufs, call
++ path_lookup(). now aufs gets a parent dir dentry, then handle it as
++ the 2nd level.
++ + to open the dir, aufs needs struct vfsmount. aufs keeps vfsmount
++ for every branch, but not itself. to get this, (currently) aufs
++ searches in current->nsproxy->mnt_ns list. it may not be a good
++ idea, but I didn't get other approach.
++ + test the generation of the gotten inode.
++- every inode operation: they may get EBUSY due to UDBA. in this case,
++ convert it into ESTALE for NFSD.
++- readdir(): call lockdep_on/off() because filldir in NFSD calls
++ lookup_one_len(), vfs_getattr(), encode_fh() and others.
+--- a/Documentation/filesystems/aufs/design/08shwh.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/08shwh.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,53 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Show Whiteout Mode (shwh)
++----------------------------------------------------------------------
++Generally aufs hides the name of whiteouts. But in some cases, to show
++them is very useful for users. For instance, creating a new middle layer
++(branch) by merging existing layers.
++
++(borrowing aufs1 HOW-TO from a user, Michael Towers)
++When you have three branches,
++- Bottom: 'system', squashfs (underlying base system), read-only
++- Middle: 'mods', squashfs, read-only
++- Top: 'overlay', ram (tmpfs), read-write
++
++The top layer is loaded at boot time and saved at shutdown, to preserve
++the changes made to the system during the session.
++When larger changes have been made, or smaller changes have accumulated,
++the size of the saved top layer data grows. At this point, it would be
++nice to be able to merge the two overlay branches ('mods' and 'overlay')
++and rewrite the 'mods' squashfs, clearing the top layer and thus
++restoring save and load speed.
++
++This merging is simplified by the use of another aufs mount, of just the
++two overlay branches using the 'shwh' option.
++# mount -t aufs -o ro,shwh,br:/livesys/overlay=ro+wh:/livesys/mods=rr+wh \
++ aufs /livesys/merge_union
++
++A merged view of these two branches is then available at
++/livesys/merge_union, and the new feature is that the whiteouts are
++visible!
++Note that in 'shwh' mode the aufs mount must be 'ro', which will disable
++writing to all branches. Also the default mode for all branches is 'ro'.
++It is now possible to save the combined contents of the two overlay
++branches to a new squashfs, e.g.:
++# mksquashfs /livesys/merge_union /path/to/newmods.squash
++
++This new squashfs archive can be stored on the boot device and the
++initramfs will use it to replace the old one at the next boot.
+--- a/Documentation/filesystems/aufs/design/10dynop.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/10dynop.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,47 @@
++
++# Copyright (C) 2010-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Dynamically customizable FS operations
++----------------------------------------------------------------------
++Generally FS operations (struct inode_operations, struct
++address_space_operations, struct file_operations, etc.) are defined as
++"static const", but it never means that FS have only one set of
++operation. Some FS have multiple sets of them. For instance, ext2 has
++three sets, one for XIP, for NOBH, and for normal.
++Since aufs overrides and redirects these operations, sometimes aufs has
++to change its behaviour according to the branch FS type. More imporantly
++VFS acts differently if a function (member in the struct) is set or
++not. It means aufs should have several sets of operations and select one
++among them according to the branch FS definition.
++
++In order to solve this problem and not to affect the behavour of VFS,
++aufs defines these operations dynamically. For instance, aufs defines
++aio_read function for struct file_operations, but it may not be set to
++the file_operations. When the branch FS doesn't have it, aufs doesn't
++set it to its file_operations while the function definition itself is
++still alive. So the behaviour of io_submit(2) will not change, and it
++will return an error when aio_read is not defined.
++
++The lifetime of these dynamically generated operation object is
++maintained by aufs branch object. When the branch is removed from aufs,
++the reference counter of the object is decremented. When it reaches
++zero, the dynamically generated operation object will be freed.
++
++This approach is designed to support AIO (io_submit), Direcit I/O and
++XIP mainly.
++Currently this approach is applied to file_operations and
++vm_operations_struct for regular files only.
+--- a/Documentation/filesystems/aufs/design/99plan.txt 1970-01-01 01:00:00.000000000 +0100
++++ b/Documentation/filesystems/aufs/design/99plan.txt 2013-03-10 01:48:58.459093058 +0000
+@@ -0,0 +1,96 @@
++
++# Copyright (C) 2005-2013 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++
++Plan
++
++Restoring some features which was implemented in aufs1.
++They were dropped in aufs2 in order to make source files simpler and
++easier to be reviewed.
++
++
++Test Only the Highest One for the Directory Permission (dirperm1 option)
++----------------------------------------------------------------------
++Let's try case study.
++- aufs has two branches, upper readwrite and lower readonly.
++ /au = /rw + /ro
++- "dirA" exists under /ro, but /rw. and its mode is 0700.
++- user invoked "chmod a+rx /au/dirA"
++- then "dirA" becomes world readable?
++
++In this case, /ro/dirA is still 0700 since it exists in readonly branch,
++or it may be a natively readonly filesystem. If aufs respects the lower
++branch, it should not respond readdir request from other users. But user
++allowed it by chmod. Should really aufs rejects showing the entries
++under /ro/dirA?
++
++To be honest, I don't have a best solution for this case. So I
++implemented 'dirperm1' and 'nodirperm1' option in aufs1, and leave it to
++users.
++When dirperm1 is specified, aufs checks only the highest one for the
++directory permission, and shows the entries. Otherwise, as usual, checks
++every dir existing on all branches and rejects the request.
++
++As a side effect, dirperm1 option improves the performance of aufs
++because the number of permission check is reduced.
++
++
++Being Another Aufs's Readonly Branch (robr)
++----------------------------------------------------------------------
++Aufs1 allows aufs to be another aufs's readonly branch.
++This feature was developed by a user's request. But it may not be used
++currecnly.
++
++
++Copy-up on Open (coo=)
++----------------------------------------------------------------------
++By default the internal copy-up is executed when it is really necessary.
++It is not done when a file is opened for writing, but when write(2) is
++done. Users who have many (over 100) branches want to know and analyse
++when and what file is copied-up. To insert a new upper branch which
++contains such files only may improve the performance of aufs.
++
++Aufs1 implemented "coo=none | leaf | all" option.
++
++
++Refresh the Opened File (refrof)
++----------------------------------------------------------------------
++This option is implemented in aufs1 but incomplete.
++
++When user reads from a file, he expects to get its latest filedata
++generally. If the file is removed and a new same named file is created,
++the content he gets is unchanged, ie. the unlinked filedata.
++
++Let's try case study again.
++- aufs has two branches.
++ /au = /rw + /ro
++- "fileA" exists under /ro, but /rw.
++- user opened "/au/fileA".
++- he or someone else inserts a branch (/new) between /rw and /ro.
++ /au = /rw + /new + /ro
++- the new branch has "fileA".
++- user reads from the opened "fileA"
++- which filedata should aufs return, from /ro or /new?
++
++Some people says it has to be "from /ro" and it is a semantics of Unix.
++The others say it should be "from /new" because the file is not removed
++and it is equivalent to the case of someone else modifies the file.
++
++Here again I don't have a best and final answer. I got an idea to
++implement 'refrof' and 'norefrof' option. When 'refrof' (REFResh the
++Opened File) is specified (by default), aufs returns the filedata from
++/new.
++Otherwise from /new.
--- a/fs/aufs/Kconfig 1970-01-01 01:00:00.000000000 +0100
+++ b/fs/aufs/Kconfig 2012-01-10 02:15:56.000000000 +0000
@@ -0,0 +1,203 @@
@@ -313,8 +1700,8 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_H__ */
--- a/fs/aufs/branch.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/branch.c 2013-05-04 18:39:17.031157464 +0100
-@@ -0,0 +1,1172 @@
++++ b/fs/aufs/branch.c 2013-05-09 01:36:20.741181631 +0100
+@@ -0,0 +1,1213 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -344,6 +1731,34 @@
+/*
+ * free a single branch
+ */
++
++/* prohibit rmdir to the root of the branch */
++/* todo: another new flag? */
++static void au_br_dflags_force(struct au_branch *br)
++{
++ struct dentry *h_dentry;
++
++ h_dentry = au_br_dentry(br);
++ spin_lock(&h_dentry->d_lock);
++ br->br_dflags = h_dentry->d_flags & DCACHE_MOUNTED;
++ h_dentry->d_flags |= DCACHE_MOUNTED;
++ spin_unlock(&h_dentry->d_lock);
++}
++
++/* restore its d_flags */
++static void au_br_dflags_restore(struct au_branch *br)
++{
++ struct dentry *h_dentry;
++
++ if (br->br_dflags)
++ return;
++
++ h_dentry = au_br_dentry(br);
++ spin_lock(&h_dentry->d_lock);
++ h_dentry->d_flags &= ~DCACHE_MOUNTED;
++ spin_unlock(&h_dentry->d_lock);
++}
++
+static void au_br_do_free(struct au_branch *br)
+{
+ int i;
@@ -373,9 +1788,11 @@
+ else
+ break;
+
++ au_br_dflags_restore(br);
++
+ /* recursive lock, s_umount of branch's */
+ lockdep_off();
-+ mntput(br->br_mnt);
++ path_put(&br->br_path);
+ lockdep_on();
+ kfree(wbr);
+ kfree(br);
@@ -589,7 +2006,7 @@
+ * initialize or clean the whiteouts for an adding branch
+ */
+static int au_br_init_wh(struct super_block *sb, struct au_branch *br,
-+ int new_perm, struct dentry *h_root)
++ int new_perm)
+{
+ int err, old_perm;
+ aufs_bindex_t bindex;
@@ -597,6 +2014,10 @@
+ struct au_wbr *wbr;
+ struct au_hinode *hdir;
+
++ err = vfsub_mnt_want_write(au_br_mnt(br));
++ if (unlikely(err))
++ goto out;
++
+ wbr = br->br_wbr;
+ old_perm = br->br_perm;
+ br->br_perm = new_perm;
@@ -607,20 +2028,21 @@
+ hdir = au_hi(sb->s_root->d_inode, bindex);
+ au_hn_imtx_lock_nested(hdir, AuLsc_I_PARENT);
+ } else {
-+ h_mtx = &h_root->d_inode->i_mutex;
++ h_mtx = &au_br_dentry(br)->d_inode->i_mutex;
+ mutex_lock_nested(h_mtx, AuLsc_I_PARENT);
+ }
+ if (!wbr)
-+ err = au_wh_init(h_root, br, sb);
++ err = au_wh_init(br, sb);
+ else {
+ wbr_wh_write_lock(wbr);
-+ err = au_wh_init(h_root, br, sb);
++ err = au_wh_init(br, sb);
+ wbr_wh_write_unlock(wbr);
+ }
+ if (hdir)
+ au_hn_imtx_unlock(hdir);
+ else
+ mutex_unlock(h_mtx);
++ vfsub_mnt_drop_write(au_br_mnt(br));
+ br->br_perm = old_perm;
+
+ if (!err && wbr && !au_br_writable(new_perm)) {
@@ -628,16 +2050,16 @@
+ br->br_wbr = NULL;
+ }
+
++out:
+ return err;
+}
+
+static int au_wbr_init(struct au_branch *br, struct super_block *sb,
-+ int perm, struct path *path)
++ int perm)
+{
+ int err;
+ struct kstatfs kst;
+ struct au_wbr *wbr;
-+ struct dentry *h_dentry;
+
+ wbr = br->br_wbr;
+ au_rw_init(&wbr->wbr_wh_rwsem);
@@ -649,17 +2071,16 @@
+ * a limit for rmdir/rename a dir
+ * cf. AUFS_MAX_NAMELEN in include/linux/aufs_type.h
+ */
-+ err = vfs_statfs(path, &kst);
++ err = vfs_statfs(&br->br_path, &kst);
+ if (unlikely(err))
+ goto out;
+ err = -EINVAL;
-+ h_dentry = path->dentry;
+ if (kst.f_namelen >= NAME_MAX)
-+ err = au_br_init_wh(sb, br, perm, h_dentry);
++ err = au_br_init_wh(sb, br, perm);
+ else
+ pr_err("%.*s(%s), unsupported namelen %ld\n",
-+ AuDLNPair(h_dentry), au_sbtype(h_dentry->d_sb),
-+ kst.f_namelen);
++ AuDLNPair(au_br_dentry(br)),
++ au_sbtype(au_br_dentry(br)->d_sb), kst.f_namelen);
+
+out:
+ return err;
@@ -675,7 +2096,10 @@
+ memset(&br->br_xino, 0, sizeof(br->br_xino));
+ mutex_init(&br->br_xino.xi_nondir_mtx);
+ br->br_perm = add->perm;
-+ br->br_mnt = add->path.mnt; /* set first, mntget() later */
++ BUILD_BUG_ON(sizeof(br->br_dflags)
++ != sizeof(br->br_path.dentry->d_flags));
++ br->br_dflags = DCACHE_MOUNTED;
++ br->br_path = add->path; /* set first, path_get() later */
+ spin_lock_init(&br->br_dykey_lock);
+ memset(br->br_dykey, 0, sizeof(br->br_dykey));
+ atomic_set(&br->br_count, 0);
@@ -685,7 +2109,7 @@
+ AuDebugOn(br->br_id < 0);
+
+ if (au_br_writable(add->perm)) {
-+ err = au_wbr_init(br, sb, add->perm, &add->path);
++ err = au_wbr_init(br, sb, add->perm);
+ if (unlikely(err))
+ goto out_err;
+ }
@@ -700,11 +2124,11 @@
+ }
+
+ sysaufs_br_init(br);
-+ mntget(add->path.mnt);
++ path_get(&br->br_path);
+ goto out; /* success */
+
+out_err:
-+ br->br_mnt = NULL;
++ memset(&br->br_path, 0, sizeof(br->br_path));
+out:
+ return err;
+}
@@ -756,17 +2180,20 @@
+ iinfo->ii_bstart = 0;
+}
+
-+static void au_br_do_add(struct super_block *sb, struct dentry *h_dentry,
-+ struct au_branch *br, aufs_bindex_t bindex)
++static void au_br_do_add(struct super_block *sb, struct au_branch *br,
++ aufs_bindex_t bindex)
+{
-+ struct dentry *root;
++ struct dentry *root, *h_dentry;
+ struct inode *root_inode;
+ aufs_bindex_t bend, amount;
+
++ au_br_dflags_force(br);
++
+ root = sb->s_root;
+ root_inode = root->d_inode;
+ bend = au_sbend(sb);
+ amount = bend + 1 - bindex;
++ h_dentry = au_br_dentry(br);
+ au_sbilist_lock();
+ au_br_do_add_brp(au_sbi(sb), bindex, br, bend, amount);
+ au_br_do_add_hdp(au_di(root), bindex, bend, amount);
@@ -809,15 +2236,15 @@
+ }
+
+ add_bindex = add->bindex;
-+ h_dentry = add->path.dentry;
+ if (!remount)
-+ au_br_do_add(sb, h_dentry, add_branch, add_bindex);
++ au_br_do_add(sb, add_branch, add_bindex);
+ else {
+ sysaufs_brs_del(sb, add_bindex);
-+ au_br_do_add(sb, h_dentry, add_branch, add_bindex);
++ au_br_do_add(sb, add_branch, add_bindex);
+ sysaufs_brs_add(sb, add_bindex);
+ }
+
++ h_dentry = add->path.dentry;
+ if (!add_bindex) {
+ au_cpup_attr_all(root_inode, /*force*/1);
+ sb->s_maxbytes = h_dentry->d_sb->s_maxbytes;
@@ -1123,6 +2550,7 @@
+ goto out;
+ }
+ br = au_sbr(sb, bindex);
++ AuDebugOn(!path_equal(&br->br_path, &del->h_path));
+ i = atomic_read(&br->br_count);
+ if (unlikely(i)) {
+ AuVerbose(verbose, "%d file(s) opened\n", i);
@@ -1171,7 +2599,7 @@
+
+out_wh:
+ /* revert */
-+ rerr = au_br_init_wh(sb, br, br->br_perm, del->h_path.dentry);
++ rerr = au_br_init_wh(sb, br, br->br_perm);
+ if (rerr)
+ pr_warn("failed re-creating base whiteout, %s. (%d)\n",
+ del->pathname, rerr);
@@ -1408,7 +2836,6 @@
+{
+ int err, rerr;
+ aufs_bindex_t bindex;
-+ struct path path;
+ struct dentry *root;
+ struct au_branch *br;
+
@@ -1428,12 +2855,13 @@
+ goto out;
+
+ br = au_sbr(sb, bindex);
++ AuDebugOn(mod->h_root != au_br_dentry(br));
+ if (br->br_perm == mod->perm)
+ return 0; /* success */
+
+ if (au_br_writable(br->br_perm)) {
+ /* remove whiteout base */
-+ err = au_br_init_wh(sb, br, mod->perm, mod->h_root);
++ err = au_br_init_wh(sb, br, mod->perm);
+ if (unlikely(err))
+ goto out;
+
@@ -1450,12 +2878,8 @@
+ rerr = -ENOMEM;
+ br->br_wbr = kmalloc(sizeof(*br->br_wbr),
+ GFP_NOFS);
-+ if (br->br_wbr) {
-+ path.mnt = br->br_mnt;
-+ path.dentry = mod->h_root;
-+ rerr = au_wbr_init(br, sb, br->br_perm,
-+ &path);
-+ }
++ if (br->br_wbr)
++ rerr = au_wbr_init(br, sb, br->br_perm);
+ if (unlikely(rerr)) {
+ AuIOErr("nested error %d (%d)\n",
+ rerr, err);
@@ -1468,9 +2892,7 @@
+ err = -ENOMEM;
+ br->br_wbr = kmalloc(sizeof(*br->br_wbr), GFP_NOFS);
+ if (br->br_wbr) {
-+ path.mnt = br->br_mnt;
-+ path.dentry = mod->h_root;
-+ err = au_wbr_init(br, sb, mod->perm, &path);
++ err = au_wbr_init(br, sb, mod->perm);
+ if (unlikely(err)) {
+ kfree(br->br_wbr);
+ br->br_wbr = NULL;
@@ -1479,6 +2901,12 @@
+ }
+
+ if (!err) {
++ if ((br->br_perm & AuBrAttr_UNPIN)
++ && !(mod->perm & AuBrAttr_UNPIN))
++ au_br_dflags_force(br);
++ else if (!(br->br_perm & AuBrAttr_UNPIN)
++ && (mod->perm & AuBrAttr_UNPIN))
++ au_br_dflags_restore(br);
+ *do_refresh |= need_sigen_inc(br->br_perm, mod->perm);
+ br->br_perm = mod->perm;
+ }
@@ -1488,8 +2916,8 @@
+ return err;
+}
--- a/fs/aufs/branch.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/branch.h 2013-05-04 18:39:11.231157327 +0100
-@@ -0,0 +1,236 @@
++++ b/fs/aufs/branch.h 2013-05-09 01:36:20.741181631 +0100
+@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -1567,7 +2995,8 @@
+ aufs_bindex_t br_id;
+
+ int br_perm;
-+ struct vfsmount *br_mnt;
++ unsigned int br_dflags;
++ struct path br_path;
+ spinlock_t br_dykey_lock;
+ struct au_dykey *br_dykey[AuBrDynOp];
+ atomic_t br_count;
@@ -1591,6 +3020,21 @@
+
+/* ---------------------------------------------------------------------- */
+
++static inline struct vfsmount *au_br_mnt(struct au_branch *br)
++{
++ return br->br_path.mnt;
++}
++
++static inline struct dentry *au_br_dentry(struct au_branch *br)
++{
++ return br->br_path.dentry;
++}
++
++static inline struct super_block *au_br_sb(struct au_branch *br)
++{
++ return au_br_mnt(br)->mnt_sb;
++}
++
+/* branch permissions and attributes */
+#define AuBrPerm_RW 1 /* writable, hardlinkable wh */
+#define AuBrPerm_RO (1 << 1) /* readonly */
@@ -1601,6 +3045,9 @@
+
+#define AuBrWAttr_NoLinkWH (1 << 4) /* un-hardlinkable whiteouts */
+
++#define AuBrAttr_UNPIN (1 << 5) /* rename-able top dir of
++ branch */
++
+static inline int au_br_writable(int brperm)
+{
+ return brperm & AuBrPerm_RW;
@@ -1618,7 +3065,7 @@
+
+static inline int au_br_rdonly(struct au_branch *br)
+{
-+ return ((br->br_mnt->mnt_sb->s_flags & MS_RDONLY)
++ return ((au_br_sb(br)->s_flags & MS_RDONLY)
+ || !au_br_writable(br->br_perm))
+ ? -EROFS : 0;
+}
@@ -1688,13 +3135,13 @@
+static inline
+struct vfsmount *au_sbr_mnt(struct super_block *sb, aufs_bindex_t bindex)
+{
-+ return au_sbr(sb, bindex)->br_mnt;
++ return au_br_mnt(au_sbr(sb, bindex));
+}
+
+static inline
+struct super_block *au_sbr_sb(struct super_block *sb, aufs_bindex_t bindex)
+{
-+ return au_sbr_mnt(sb, bindex)->mnt_sb;
++ return au_br_sb(au_sbr(sb, bindex));
+}
+
+static inline void au_sbr_put(struct super_block *sb, aufs_bindex_t bindex)
@@ -1768,8 +3215,8 @@
+
+-include ${srctree}/${src}/conf_priv.mk
--- a/fs/aufs/cpup.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/cpup.c 2013-05-04 18:39:11.231157327 +0100
-@@ -0,0 +1,1085 @@
++++ b/fs/aufs/cpup.c 2013-05-09 01:36:20.741181631 +0100
+@@ -0,0 +1,1221 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -1796,12 +3243,14 @@
+#include <linux/mm.h>
+#include "aufs.h"
+
-+void au_cpup_attr_flags(struct inode *dst, struct inode *src)
++void au_cpup_attr_flags(struct inode *dst, unsigned int iflags)
+{
+ const unsigned int mask = S_DEAD | S_SWAPFILE | S_PRIVATE
+ | S_NOATIME | S_NOCMTIME;
+
-+ dst->i_flags |= src->i_flags & ~mask;
++ BUILD_BUG_ON(sizeof(iflags) != sizeof(dst->i_flags));
++
++ dst->i_flags |= iflags & ~mask;
+ if (au_test_fs_notime(dst->i_sb))
+ dst->i_flags |= S_NOATIME | S_NOCMTIME;
+}
@@ -1860,7 +3309,7 @@
+ inode->i_uid = h_inode->i_uid;
+ inode->i_gid = h_inode->i_gid;
+ au_cpup_attr_timesizes(inode);
-+ au_cpup_attr_flags(inode, h_inode);
++ au_cpup_attr_flags(inode, h_inode->i_flags);
+}
+
+void au_cpup_igen(struct inode *inode, struct inode *h_inode)
@@ -1921,13 +3370,22 @@
+
+/* ---------------------------------------------------------------------- */
+
++/* internal use only */
++struct au_cpup_reg_attr {
++ int valid;
++ struct kstat st;
++ unsigned int iflags; /* inode->i_flags */
++};
++
+static noinline_for_stack
-+int cpup_iattr(struct dentry *dst, aufs_bindex_t bindex, struct dentry *h_src)
++int cpup_iattr(struct dentry *dst, aufs_bindex_t bindex, struct dentry *h_src,
++ struct au_cpup_reg_attr *h_src_attr)
+{
+ int err, sbits;
+ struct iattr ia;
+ struct path h_path;
+ struct inode *h_isrc, *h_idst;
++ struct kstat *h_st;
+
+ h_path.dentry = au_h_dptr(dst, bindex);
+ h_idst = h_path.dentry->d_inode;
@@ -1936,17 +3394,32 @@
+ ia.ia_valid = ATTR_FORCE | ATTR_UID | ATTR_GID
+ | ATTR_ATIME | ATTR_MTIME
+ | ATTR_ATIME_SET | ATTR_MTIME_SET;
-+ ia.ia_uid = h_isrc->i_uid;
-+ ia.ia_gid = h_isrc->i_gid;
-+ ia.ia_atime = h_isrc->i_atime;
-+ ia.ia_mtime = h_isrc->i_mtime;
-+ if (h_idst->i_mode != h_isrc->i_mode
-+ && !S_ISLNK(h_idst->i_mode)) {
-+ ia.ia_valid |= ATTR_MODE;
-+ ia.ia_mode = h_isrc->i_mode;
++ if (h_src_attr && h_src_attr->valid) {
++ h_st = &h_src_attr->st;
++ ia.ia_uid = h_st->uid;
++ ia.ia_gid = h_st->gid;
++ ia.ia_atime = h_st->atime;
++ ia.ia_mtime = h_st->mtime;
++ if (h_idst->i_mode != h_st->mode
++ && !S_ISLNK(h_idst->i_mode)) {
++ ia.ia_valid |= ATTR_MODE;
++ ia.ia_mode = h_st->mode;
++ }
++ sbits = !!(h_st->mode & (S_ISUID | S_ISGID));
++ au_cpup_attr_flags(h_idst, h_src_attr->iflags);
++ } else {
++ ia.ia_uid = h_isrc->i_uid;
++ ia.ia_gid = h_isrc->i_gid;
++ ia.ia_atime = h_isrc->i_atime;
++ ia.ia_mtime = h_isrc->i_mtime;
++ if (h_idst->i_mode != h_isrc->i_mode
++ && !S_ISLNK(h_idst->i_mode)) {
++ ia.ia_valid |= ATTR_MODE;
++ ia.ia_mode = h_isrc->i_mode;
++ }
++ sbits = !!(h_isrc->i_mode & (S_ISUID | S_ISGID));
++ au_cpup_attr_flags(h_idst, h_isrc->i_flags);
+ }
-+ sbits = !!(h_isrc->i_mode & (S_ISUID | S_ISGID));
-+ au_cpup_attr_flags(h_idst, h_isrc);
+ err = vfsub_notify_change(&h_path, &ia);
+
+ /* is this nfs only? */
@@ -2091,12 +3564,18 @@
+ return err;
+}
+
++/* internal use only */
++struct au_cpup_basic {
++ struct dentry *dentry;
++ aufs_bindex_t bdst, bsrc;
++ loff_t len;
++};
++
+/*
+ * to support a sparse file which is opened with O_APPEND,
+ * we need to close the file.
+ */
-+static int au_cp_regular(struct dentry *dentry, aufs_bindex_t bdst,
-+ aufs_bindex_t bsrc, loff_t len)
++static int au_cp_regular(struct au_cpup_basic *basic)
+{
+ int err, i;
+ enum { SRC, DST };
@@ -2108,14 +3587,14 @@
+ void *label, *label_file;
+ } *f, file[] = {
+ {
-+ .bindex = bsrc,
++ .bindex = basic->bsrc,
+ .flags = O_RDONLY | O_NOATIME | O_LARGEFILE,
+ .file = NULL,
+ .label = &&out,
+ .label_file = &&out_src
+ },
+ {
-+ .bindex = bdst,
++ .bindex = basic->bdst,
+ .flags = O_WRONLY | O_NOATIME | O_LARGEFILE,
+ .file = NULL,
+ .label = &&out_src,
@@ -2125,11 +3604,12 @@
+ struct super_block *sb;
+
+ /* bsrc branch can be ro/rw. */
-+ sb = dentry->d_sb;
++ sb = basic->dentry->d_sb;
+ f = file;
+ for (i = 0; i < 2; i++, f++) {
-+ f->dentry = au_h_dptr(dentry, f->bindex);
-+ f->file = au_h_open(dentry, f->bindex, f->flags, /*file*/NULL);
++ f->dentry = au_h_dptr(basic->dentry, f->bindex);
++ f->file = au_h_open(basic->dentry, f->bindex, f->flags,
++ /*file*/NULL);
+ err = PTR_ERR(f->file);
+ if (IS_ERR(f->file))
+ goto *f->label;
@@ -2140,7 +3620,7 @@
+
+ /* try stopping to update while we copyup */
+ IMustLock(file[SRC].dentry->d_inode);
-+ err = au_copy_file(file[DST].file, file[SRC].file, len);
++ err = au_copy_file(file[DST].file, file[SRC].file, basic->len);
+
+out_dst:
+ fput(file[DST].file);
@@ -2152,27 +3632,39 @@
+ return err;
+}
+
-+static int au_do_cpup_regular(struct dentry *dentry, aufs_bindex_t bdst,
-+ aufs_bindex_t bsrc, loff_t len,
-+ struct inode *h_dir, struct path *h_path)
++static int au_do_cpup_regular(struct au_cpup_basic *basic, struct au_pin *pin,
++ struct au_cpup_reg_attr *h_src_attr)
+{
+ int err, rerr;
+ loff_t l;
++ struct dentry *h_src_dentry;
++ struct inode *h_src_inode;
++ struct vfsmount *h_src_mnt;
+
+ err = 0;
-+ l = i_size_read(au_h_iptr(dentry->d_inode, bsrc));
-+ if (len == -1 || l < len)
-+ len = l;
-+ if (len)
-+ err = au_cp_regular(dentry, bdst, bsrc, len);
-+ if (!err)
-+ goto out; /* success */
++ h_src_inode = au_h_iptr(basic->dentry->d_inode, basic->bsrc);
++ l = i_size_read(h_src_inode);
++ if (basic->len == -1 || l < basic->len)
++ basic->len = l;
++ if (basic->len) {
++ /* try stopping to update while we are referencing */
++ mutex_lock_nested(&h_src_inode->i_mutex, AuLsc_I_CHILD);
++ au_pin_hdir_unlock(pin);
+
-+ rerr = vfsub_unlink(h_dir, h_path, /*force*/0);
-+ if (rerr) {
-+ AuIOErr("failed unlinking cpup-ed %.*s(%d, %d)\n",
-+ AuDLNPair(h_path->dentry), err, rerr);
-+ err = -EIO;
++ h_src_dentry = au_h_dptr(basic->dentry, basic->bsrc);
++ h_src_mnt = au_sbr_mnt(basic->dentry->d_sb, basic->bsrc);
++ h_src_attr->iflags = h_src_inode->i_flags;
++ err = vfs_getattr(h_src_mnt, h_src_dentry, &h_src_attr->st);
++ if (unlikely(err)) {
++ mutex_unlock(&h_src_inode->i_mutex);
++ goto out;
++ }
++ h_src_attr->valid = 1;
++ err = au_cp_regular(basic);
++ mutex_unlock(&h_src_inode->i_mutex);
++ rerr = au_pin_hdir_relock(pin);
++ if (!err && rerr)
++ err = rerr;
+ }
+
+out:
@@ -2215,11 +3707,10 @@
+ return err;
+}
+
-+/* return with the lower dst inode is locked */
+static noinline_for_stack
-+int cpup_entry(struct dentry *dentry, aufs_bindex_t bdst,
-+ aufs_bindex_t bsrc, loff_t len, unsigned int flags,
-+ struct dentry *dst_parent)
++int cpup_entry(struct au_cpup_basic *basic, unsigned int flags,
++ struct dentry *dst_parent, struct au_pin *pin,
++ struct au_cpup_reg_attr *h_src_attr)
+{
+ int err;
+ umode_t mode;
@@ -2233,19 +3724,22 @@
+ struct super_block *sb;
+
+ /* bsrc branch can be ro/rw. */
-+ h_src = au_h_dptr(dentry, bsrc);
++ h_src = au_h_dptr(basic->dentry, basic->bsrc);
+ h_inode = h_src->d_inode;
-+ AuDebugOn(h_inode != au_h_iptr(dentry->d_inode, bsrc));
++ AuDebugOn(h_inode != au_h_iptr(basic->dentry->d_inode, basic->bsrc));
+
+ /* try stopping to be referenced while we are creating */
-+ h_dst = au_h_dptr(dentry, bdst);
++ h_dst = au_h_dptr(basic->dentry, basic->bdst);
++ if (au_ftest_cpup(flags, RENAME))
++ AuDebugOn(strncmp(h_dst->d_name.name, AUFS_WH_PFX,
++ AUFS_WH_PFX_LEN));
+ h_parent = h_dst->d_parent; /* dir inode is locked */
+ h_dir = h_parent->d_inode;
+ IMustLock(h_dir);
+ AuDebugOn(h_parent != h_dst->d_parent);
+
-+ sb = dentry->d_sb;
-+ h_path.mnt = au_sbr_mnt(sb, bdst);
++ sb = basic->dentry->d_sb;
++ h_path.mnt = au_sbr_mnt(sb, basic->bdst);
+ if (do_dt) {
+ h_path.dentry = h_parent;
+ au_dtime_store(&dt, dst_parent, &h_path);
@@ -2256,14 +3750,10 @@
+ mode = h_inode->i_mode;
+ switch (mode & S_IFMT) {
+ case S_IFREG:
-+ /* try stopping to update while we are referencing */
-+ IMustLock(h_inode);
+ err = vfsub_create(h_dir, &h_path, mode | S_IWUSR,
+ /*want_excl*/true);
+ if (!err)
-+ err = au_do_cpup_regular
-+ (dentry, bdst, bsrc, len,
-+ au_h_iptr(dst_parent->d_inode, bdst), &h_path);
++ err = au_do_cpup_regular(basic, pin, h_src_attr);
+ break;
+ case S_IFDIR:
+ isdir = 1;
@@ -2273,10 +3763,10 @@
+ * strange behaviour from the users view,
+ * particularry setattr case
+ */
-+ if (au_ibstart(dst_parent->d_inode) == bdst)
++ if (au_ibstart(dst_parent->d_inode) == basic->bdst)
+ au_cpup_attr_nlink(dst_parent->d_inode,
+ /*force*/1);
-+ au_cpup_attr_nlink(dentry->d_inode, /*force*/1);
++ au_cpup_attr_nlink(basic->dentry->d_inode, /*force*/1);
+ }
+ break;
+ case S_IFLNK:
@@ -2301,10 +3791,10 @@
+ && au_opt_test(mnt_flags, XINO)
+ && h_inode->i_nlink == 1
+ /* todo: unnecessary? */
-+ /* && dentry->d_inode->i_nlink == 1 */
-+ && bdst < bsrc
++ /* && basic->dentry->d_inode->i_nlink == 1 */
++ && basic->bdst < basic->bsrc
+ && !au_ftest_cpup(flags, KEEPLINO))
-+ au_xino_write(sb, bsrc, h_inode->i_ino, /*ino*/0);
++ au_xino_write(sb, basic->bsrc, h_inode->i_ino, /*ino*/0);
+ /* ignore this error */
+
+ if (do_dt)
@@ -2312,15 +3802,42 @@
+ return err;
+}
+
++static int au_do_ren_after_cpup(struct dentry *dentry, aufs_bindex_t bdst,
++ struct path *h_path)
++{
++ int err;
++ struct dentry *h_dentry, *h_parent;
++ struct inode *h_dir;
++
++ h_dentry = dget(au_h_dptr(dentry, bdst));
++ au_set_h_dptr(dentry, bdst, NULL);
++ err = au_lkup_neg(dentry, bdst, /*wh*/0);
++ if (unlikely(err)) {
++ au_set_h_dptr(dentry, bdst, h_dentry);
++ goto out;
++ }
++
++ h_path->dentry = dget(au_h_dptr(dentry, bdst));
++ au_set_h_dptr(dentry, bdst, h_dentry);
++ h_parent = h_dentry->d_parent; /* dir inode is locked */
++ h_dir = h_parent->d_inode;
++ IMustLock(h_dir);
++ AuDbg("%.*s %.*s\n", AuDLNPair(h_dentry), AuDLNPair(h_path->dentry));
++ err = vfsub_rename(h_dir, h_dentry, h_dir, h_path);
++ dput(h_path->dentry);
++
++out:
++ return err;
++}
++
+/*
+ * copyup the @dentry from @bsrc to @bdst.
+ * the caller must set the both of lower dentries.
+ * @len is for truncating when it is -1 copyup the entire file.
+ * in link/rename cases, @dst_parent may be different from the real one.
+ */
-+static int au_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
-+ aufs_bindex_t bsrc, loff_t len, unsigned int flags,
-+ struct dentry *dst_parent)
++static int au_cpup_single(struct au_cpup_basic *basic, unsigned int flags,
++ struct dentry *dst_parent, struct au_pin *pin)
+{
+ int err, rerr;
+ aufs_bindex_t old_ibstart;
@@ -2330,39 +3847,44 @@
+ struct dentry *h_src, *h_dst, *h_parent;
+ struct inode *dst_inode, *h_dir, *inode;
+ struct super_block *sb;
++ struct au_branch *br;
++ struct au_cpup_reg_attr h_src_attr = {
++ .valid = 0
++ };
+
-+ AuDebugOn(bsrc <= bdst);
++ AuDebugOn(basic->bsrc <= basic->bdst);
+
-+ sb = dentry->d_sb;
-+ h_path.mnt = au_sbr_mnt(sb, bdst);
-+ h_dst = au_h_dptr(dentry, bdst);
++ sb = basic->dentry->d_sb;
++ br = au_sbr(sb, basic->bdst);
++ h_path.mnt = au_br_mnt(br);
++ h_dst = au_h_dptr(basic->dentry, basic->bdst);
+ h_parent = h_dst->d_parent; /* dir inode is locked */
+ h_dir = h_parent->d_inode;
+ IMustLock(h_dir);
+
-+ h_src = au_h_dptr(dentry, bsrc);
-+ inode = dentry->d_inode;
++ h_src = au_h_dptr(basic->dentry, basic->bsrc);
++ inode = basic->dentry->d_inode;
+
+ if (!dst_parent)
-+ dst_parent = dget_parent(dentry);
++ dst_parent = dget_parent(basic->dentry);
+ else
+ dget(dst_parent);
+
+ plink = !!au_opt_test(au_mntflags(sb), PLINK);
-+ dst_inode = au_h_iptr(inode, bdst);
++ dst_inode = au_h_iptr(inode, basic->bdst);
+ if (dst_inode) {
+ if (unlikely(!plink)) {
+ err = -EIO;
+ AuIOErr("hi%lu(i%lu) exists on b%d "
+ "but plink is disabled\n",
-+ dst_inode->i_ino, inode->i_ino, bdst);
++ dst_inode->i_ino, inode->i_ino, basic->bdst);
+ goto out;
+ }
+
+ if (dst_inode->i_nlink) {
+ const int do_dt = au_ftest_cpup(flags, DTIME);
+
-+ h_src = au_plink_lkup(inode, bdst);
++ h_src = au_plink_lkup(inode, basic->bdst);
+ err = PTR_ERR(h_src);
+ if (IS_ERR(h_src))
+ goto out;
@@ -2379,8 +3901,12 @@
+ h_path.dentry = h_parent;
+ au_dtime_store(&dt, dst_parent, &h_path);
+ }
++
+ h_path.dentry = h_dst;
+ err = vfsub_link(h_src, h_dir, &h_path);
++ if (!err && au_ftest_cpup(flags, RENAME))
++ err = au_do_ren_after_cpup
++ (basic->dentry, basic->bdst, &h_path);
+ if (do_dt)
+ au_dtime_revert(&dt);
+ dput(h_src);
@@ -2391,50 +3917,73 @@
+ au_update_ibrange(inode, /*do_put_zero*/1);
+ }
+
++ isdir = S_ISDIR(inode->i_mode);
+ old_ibstart = au_ibstart(inode);
-+ err = cpup_entry(dentry, bdst, bsrc, len, flags, dst_parent);
++ err = cpup_entry(basic, flags, dst_parent, pin, &h_src_attr);
+ if (unlikely(err))
-+ goto out;
++ goto out_rev;
+ dst_inode = h_dst->d_inode;
+ mutex_lock_nested(&dst_inode->i_mutex, AuLsc_I_CHILD2);
++ /* todo: necessary? */
++ /* au_pin_hdir_unlock(pin); */
+
-+ err = cpup_iattr(dentry, bdst, h_src);
-+ isdir = S_ISDIR(dst_inode->i_mode);
-+ if (!err) {
-+ if (bdst < old_ibstart) {
-+ if (S_ISREG(inode->i_mode)) {
-+ err = au_dy_iaop(inode, bdst, dst_inode);
-+ if (unlikely(err))
-+ goto out_rev;
++ err = cpup_iattr(basic->dentry, basic->bdst, h_src, &h_src_attr);
++ if (unlikely(err)) {
++ /* todo: necessary? */
++ /* au_pin_hdir_relock(pin); */ /* ignore an error */
++ mutex_unlock(&dst_inode->i_mutex);
++ goto out_rev;
++ }
++
++ if (basic->bdst < old_ibstart) {
++ if (S_ISREG(inode->i_mode)) {
++ err = au_dy_iaop(inode, basic->bdst, dst_inode);
++ if (unlikely(err)) {
++ /* au_pin_hdir_relock(pin); ignore an error */
++ mutex_unlock(&dst_inode->i_mutex);
++ goto out_rev;
+ }
-+ au_set_ibstart(inode, bdst);
+ }
-+ au_set_h_iptr(inode, bdst, au_igrab(dst_inode),
-+ au_hi_flags(inode, isdir));
-+ mutex_unlock(&dst_inode->i_mutex);
-+ if (!isdir
-+ && h_src->d_inode->i_nlink > 1
-+ && plink)
-+ au_plink_append(inode, bdst, h_dst);
-+ goto out; /* success */
++ au_set_ibstart(inode, basic->bdst);
++ }
++ au_set_h_iptr(inode, basic->bdst, au_igrab(dst_inode),
++ au_hi_flags(inode, isdir));
++
++ /* todo: necessary? */
++ /* err = au_pin_hdir_relock(pin); */
++ mutex_unlock(&dst_inode->i_mutex);
++ if (unlikely(err))
++ goto out_rev;
++
++ if (!isdir
++ && h_src->d_inode->i_nlink > 1
++ && plink)
++ au_plink_append(inode, basic->bdst, h_dst);
++
++ if (au_ftest_cpup(flags, RENAME)) {
++ h_path.dentry = h_dst;
++ err = au_do_ren_after_cpup(basic->dentry, basic->bdst, &h_path);
+ }
++ if (!err)
++ goto out; /* success */
+
+ /* revert */
+out_rev:
+ h_path.dentry = h_parent;
-+ mutex_unlock(&dst_inode->i_mutex);
+ au_dtime_store(&dt, dst_parent, &h_path);
+ h_path.dentry = h_dst;
-+ if (!isdir)
-+ rerr = vfsub_unlink(h_dir, &h_path, /*force*/0);
-+ else
-+ rerr = vfsub_rmdir(h_dir, &h_path);
++ rerr = 0;
++ if (h_dst->d_inode) {
++ if (!isdir)
++ rerr = vfsub_unlink(h_dir, &h_path, /*force*/0);
++ else
++ rerr = vfsub_rmdir(h_dir, &h_path);
++ }
+ au_dtime_revert(&dt);
+ if (rerr) {
+ AuIOErr("failed removing broken entry(%d, %d)\n", err, rerr);
+ err = -EIO;
+ }
-+
+out:
+ dput(dst_parent);
+ return err;
@@ -2442,18 +3991,19 @@
+
+struct au_cpup_single_args {
+ int *errp;
-+ struct dentry *dentry;
-+ aufs_bindex_t bdst, bsrc;
-+ loff_t len;
++ struct au_cpup_basic *basic;
+ unsigned int flags;
+ struct dentry *dst_parent;
++ struct au_pin *pin;
+};
+
+static void au_call_cpup_single(void *args)
+{
+ struct au_cpup_single_args *a = args;
-+ *a->errp = au_cpup_single(a->dentry, a->bdst, a->bsrc, a->len,
-+ a->flags, a->dst_parent);
++
++ au_pin_hdir_acquire_nest(a->pin);
++ *a->errp = au_cpup_single(a->basic, a->flags, a->dst_parent, a->pin);
++ au_pin_hdir_release(a->pin);
+}
+
+/*
@@ -2489,24 +4039,27 @@
+
+int au_sio_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
+ aufs_bindex_t bsrc, loff_t len, unsigned int flags,
-+ struct dentry *dst_parent)
++ struct dentry *dst_parent, struct au_pin *pin)
+{
+ int err, wkq_err;
+ struct dentry *h_dentry;
++ struct au_cpup_basic basic = {
++ .dentry = dentry,
++ .bdst = bdst,
++ .bsrc = bsrc,
++ .len = len
++ };
+
+ h_dentry = au_h_dptr(dentry, bsrc);
+ if (!au_cpup_sio_test(dentry->d_sb, h_dentry->d_inode->i_mode))
-+ err = au_cpup_single(dentry, bdst, bsrc, len, flags,
-+ dst_parent);
++ err = au_cpup_single(&basic, flags, dst_parent, pin);
+ else {
+ struct au_cpup_single_args args = {
+ .errp = &err,
-+ .dentry = dentry,
-+ .bdst = bdst,
-+ .bsrc = bsrc,
-+ .len = len,
++ .basic = &basic,
+ .flags = flags,
-+ .dst_parent = dst_parent
++ .dst_parent = dst_parent,
++ .pin = pin
+ };
+ wkq_err = au_wkq_wait(au_call_cpup_single, &args);
+ if (unlikely(wkq_err))
@@ -2521,19 +4074,32 @@
+ * using au_cpup_single().
+ */
+static int au_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+ unsigned int flags)
++ unsigned int flags, struct au_pin *pin)
+{
+ int err;
+ aufs_bindex_t bsrc, bend;
++ struct dentry *h_dentry;
+
++ DiMustWriteLock(dentry);
+ bend = au_dbend(dentry);
-+ for (bsrc = bdst + 1; bsrc <= bend; bsrc++)
-+ if (au_h_dptr(dentry, bsrc))
++ for (bsrc = bdst + 1; bsrc <= bend; bsrc++) {
++ h_dentry = au_h_dptr(dentry, bsrc);
++ if (h_dentry) {
++ AuDebugOn(!h_dentry->d_inode);
+ break;
++ }
++ }
++ AuDebugOn(bsrc > bend);
+
-+ err = au_lkup_neg(dentry, bdst);
++ err = au_lkup_neg(dentry, bdst, /*wh*/1);
+ if (!err) {
-+ err = au_cpup_single(dentry, bdst, bsrc, len, flags, NULL);
++ struct au_cpup_basic basic = {
++ .dentry = dentry,
++ .bdst = bdst,
++ .bsrc = bsrc,
++ .len = len
++ };
++ err = au_cpup_single(&basic, flags | AuCpup_RENAME, NULL, pin);
+ if (!err)
+ return 0; /* success */
+
@@ -2551,16 +4117,20 @@
+ aufs_bindex_t bdst;
+ loff_t len;
+ unsigned int flags;
++ struct au_pin *pin;
+};
+
+static void au_call_cpup_simple(void *args)
+{
+ struct au_cpup_simple_args *a = args;
-+ *a->errp = au_cpup_simple(a->dentry, a->bdst, a->len, a->flags);
++
++ au_pin_hdir_acquire_nest(a->pin);
++ *a->errp = au_cpup_simple(a->dentry, a->bdst, a->len, a->flags, a->pin);
++ au_pin_hdir_release(a->pin);
+}
+
+int au_sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+ unsigned int flags)
++ unsigned int flags, struct au_pin *pin)
+{
+ int err, wkq_err;
+ struct dentry *parent;
@@ -2570,14 +4140,15 @@
+ h_dir = au_h_iptr(parent->d_inode, bdst);
+ if (!au_test_h_perm_sio(h_dir, MAY_EXEC | MAY_WRITE)
+ && !au_cpup_sio_test(dentry->d_sb, dentry->d_inode->i_mode))
-+ err = au_cpup_simple(dentry, bdst, len, flags);
++ err = au_cpup_simple(dentry, bdst, len, flags, pin);
+ else {
+ struct au_cpup_simple_args args = {
+ .errp = &err,
+ .dentry = dentry,
+ .bdst = bdst,
+ .len = len,
-+ .flags = flags
++ .flags = flags,
++ .pin = pin
+ };
+ wkq_err = au_wkq_wait(au_call_cpup_simple, &args);
+ if (unlikely(wkq_err))
@@ -2595,10 +4166,15 @@
+ */
+static int au_do_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst,
+ struct dentry *wh_dentry, struct file *file,
-+ loff_t len)
++ loff_t len, struct au_pin *pin)
+{
+ int err;
-+ aufs_bindex_t bstart;
++ struct au_cpup_basic basic = {
++ .dentry = dentry,
++ .bdst = bdst,
++ .bsrc = -1,
++ .len = len
++ };
+ struct au_dinfo *dinfo;
+ struct dentry *h_d_dst, *h_d_start;
+ struct au_hdentry *hdp;
@@ -2606,30 +4182,30 @@
+ dinfo = au_di(dentry);
+ AuRwMustWriteLock(&dinfo->di_rwsem);
+
-+ bstart = dinfo->di_bstart;
++ basic.bsrc = dinfo->di_bstart;
+ hdp = dinfo->di_hdentry;
+ h_d_dst = hdp[0 + bdst].hd_dentry;
+ dinfo->di_bstart = bdst;
+ hdp[0 + bdst].hd_dentry = wh_dentry;
++ h_d_start = NULL;
+ if (file) {
-+ h_d_start = hdp[0 + bstart].hd_dentry;
-+ hdp[0 + bstart].hd_dentry = au_hf_top(file)->f_dentry;
++ h_d_start = hdp[0 + basic.bsrc].hd_dentry;
++ hdp[0 + basic.bsrc].hd_dentry = au_hf_top(file)->f_dentry;
+ }
-+ err = au_cpup_single(dentry, bdst, bstart, len, !AuCpup_DTIME,
-+ /*h_parent*/NULL);
++ err = au_cpup_single(&basic, !AuCpup_DTIME, /*h_parent*/NULL, pin);
+ if (file) {
+ if (!err)
+ err = au_reopen_nondir(file);
-+ hdp[0 + bstart].hd_dentry = h_d_start;
++ hdp[0 + basic.bsrc].hd_dentry = h_d_start;
+ }
+ hdp[0 + bdst].hd_dentry = h_d_dst;
-+ dinfo->di_bstart = bstart;
++ dinfo->di_bstart = basic.bsrc;
+
+ return err;
+}
+
+static int au_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+ struct file *file)
++ struct file *file, struct au_pin *pin)
+{
+ int err;
+ struct au_dtime dt;
@@ -2646,9 +4222,9 @@
+ goto out;
+
+ h_path.dentry = h_parent;
-+ h_path.mnt = br->br_mnt;
++ h_path.mnt = au_br_mnt(br);
+ au_dtime_store(&dt, parent, &h_path);
-+ err = au_do_cpup_wh(dentry, bdst, wh_dentry, file, len);
++ err = au_do_cpup_wh(dentry, bdst, wh_dentry, file, len, pin);
+ if (unlikely(err))
+ goto out_wh;
+
@@ -2679,21 +4255,26 @@
+ aufs_bindex_t bdst;
+ loff_t len;
+ struct file *file;
++ struct au_pin *pin;
+};
+
+static void au_call_cpup_wh(void *args)
+{
+ struct au_cpup_wh_args *a = args;
-+ *a->errp = au_cpup_wh(a->dentry, a->bdst, a->len, a->file);
++
++ au_pin_hdir_acquire_nest(a->pin);
++ *a->errp = au_cpup_wh(a->dentry, a->bdst, a->len, a->file, a->pin);
++ au_pin_hdir_release(a->pin);
+}
+
+int au_sio_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+ struct file *file)
++ struct file *file, struct au_pin *pin)
+{
+ int err, wkq_err;
+ struct dentry *parent, *h_orph, *h_parent, *h_dentry;
-+ struct inode *dir, *h_dir, *h_tmpdir, *h_inode;
++ struct inode *dir, *h_dir, *h_tmpdir;
+ struct au_wbr *wbr;
++ struct au_pin wh_pin;
+
+ parent = dget_parent(dentry);
+ dir = parent->d_inode;
@@ -2710,29 +4291,29 @@
+ h_tmpdir = h_orph->d_inode;
+ au_set_h_iptr(dir, bdst, au_igrab(h_tmpdir), /*flags*/0);
+
-+ /* this temporary unlock is safe */
+ if (file)
+ h_dentry = au_hf_top(file)->f_dentry;
+ else
+ h_dentry = au_h_dptr(dentry, au_dbstart(dentry));
-+ h_inode = h_dentry->d_inode;
-+ IMustLock(h_inode);
-+ mutex_unlock(&h_inode->i_mutex);
+ mutex_lock_nested(&h_tmpdir->i_mutex, AuLsc_I_PARENT3);
-+ mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
+ /* todo: au_h_open_pre()? */
++
++ au_pin_init(&wh_pin, dentry, bdst, AuLsc_DI_PARENT,
++ AuLsc_I_PARENT3, pin->udba, AuPin_DI_LOCKED);
++ pin = &wh_pin;
+ }
+
+ if (!au_test_h_perm_sio(h_tmpdir, MAY_EXEC | MAY_WRITE)
+ && !au_cpup_sio_test(dentry->d_sb, dentry->d_inode->i_mode))
-+ err = au_cpup_wh(dentry, bdst, len, file);
++ err = au_cpup_wh(dentry, bdst, len, file, pin);
+ else {
+ struct au_cpup_wh_args args = {
+ .errp = &err,
+ .dentry = dentry,
+ .bdst = bdst,
+ .len = len,
-+ .file = file
++ .file = file,
++ .pin = pin
+ };
+ wkq_err = au_wkq_wait(au_call_cpup_wh, &args);
+ if (unlikely(wkq_err))
@@ -2759,6 +4340,7 @@
+/* cf. revalidate function in file.c */
+int au_cp_dirs(struct dentry *dentry, aufs_bindex_t bdst,
+ int (*cp)(struct dentry *dentry, aufs_bindex_t bdst,
++ struct au_pin *pin,
+ struct dentry *h_parent, void *arg),
+ void *arg)
+{
@@ -2804,7 +4386,7 @@
+ au_pin_set_dentry(&pin, d);
+ err = au_do_pin(&pin);
+ if (!err) {
-+ err = cp(d, bdst, h_parent, arg);
++ err = cp(d, bdst, &pin, h_parent, arg);
+ au_unpin(&pin);
+ }
+ }
@@ -2821,10 +4403,11 @@
+}
+
+static int au_cpup_dir(struct dentry *dentry, aufs_bindex_t bdst,
++ struct au_pin *pin,
+ struct dentry *h_parent __maybe_unused ,
+ void *arg __maybe_unused)
+{
-+ return au_sio_cpup_simple(dentry, bdst, -1, AuCpup_DTIME);
++ return au_sio_cpup_simple(dentry, bdst, -1, AuCpup_DTIME, pin);
+}
+
+int au_cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst)
@@ -2856,8 +4439,8 @@
+ return err;
+}
--- a/fs/aufs/cpup.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/cpup.h 2013-03-10 01:48:58.459093058 +0000
-@@ -0,0 +1,81 @@
++++ b/fs/aufs/cpup.h 2013-05-09 01:36:20.741181631 +0100
+@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -2889,8 +4472,9 @@
+
+struct inode;
+struct file;
++struct au_pin;
+
-+void au_cpup_attr_flags(struct inode *dst, struct inode *src);
++void au_cpup_attr_flags(struct inode *dst, unsigned int iflags);
+void au_cpup_attr_timesizes(struct inode *inode);
+void au_cpup_attr_nlink(struct inode *inode, int force);
+void au_cpup_attr_changeable(struct inode *inode);
@@ -2903,6 +4487,7 @@
+#define AuCpup_DTIME 1 /* do dtime_store/revert */
+#define AuCpup_KEEPLINO (1 << 1) /* do not clear the lower xino,
+ for link(2) */
++#define AuCpup_RENAME (1 << 2) /* rename after cpup */
+#define au_ftest_cpup(flags, name) ((flags) & AuCpup_##name)
+#define au_fset_cpup(flags, name) \
+ do { (flags) |= AuCpup_##name; } while (0)
@@ -2912,14 +4497,15 @@
+int au_copy_file(struct file *dst, struct file *src, loff_t len);
+int au_sio_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
+ aufs_bindex_t bsrc, loff_t len, unsigned int flags,
-+ struct dentry *dst_parent);
++ struct dentry *dst_parent, struct au_pin *pin);
+int au_sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+ unsigned int flags);
++ unsigned int flags, struct au_pin *pin);
+int au_sio_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+ struct file *file);
++ struct file *file, struct au_pin *pin);
+
+int au_cp_dirs(struct dentry *dentry, aufs_bindex_t bdst,
+ int (*cp)(struct dentry *dentry, aufs_bindex_t bdst,
++ struct au_pin *pin,
+ struct dentry *h_parent, void *arg),
+ void *arg);
+int au_cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst);
@@ -2940,8 +4526,8 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_CPUP_H__ */
--- a/fs/aufs/dbgaufs.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/dbgaufs.c 2013-05-04 18:39:17.031157464 +0100
-@@ -0,0 +1,332 @@
++++ b/fs/aufs/dbgaufs.c 2013-05-09 01:36:20.741181631 +0100
+@@ -0,0 +1,433 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -3040,6 +4626,101 @@
+
+/* ---------------------------------------------------------------------- */
+
++struct dbgaufs_plink_arg {
++ int n;
++ char a[];
++};
++
++static int dbgaufs_plink_release(struct inode *inode __maybe_unused,
++ struct file *file)
++{
++ free_page((unsigned long)file->private_data);
++ return 0;
++}
++
++static int dbgaufs_plink_open(struct inode *inode, struct file *file)
++{
++ int err, i, limit;
++ unsigned long n, sum;
++ struct dbgaufs_plink_arg *p;
++ struct au_sbinfo *sbinfo;
++ struct super_block *sb;
++ struct au_sphlhead *sphl;
++
++ err = -ENOMEM;
++ p = (void *)get_zeroed_page(GFP_NOFS);
++ if (unlikely(!p))
++ goto out;
++
++ err = -EFBIG;
++ sbinfo = inode->i_private;
++ sb = sbinfo->si_sb;
++ si_noflush_read_lock(sb);
++ if (au_opt_test(au_mntflags(sb), PLINK)) {
++ limit = PAGE_SIZE - sizeof(p->n);
++
++ /* the number of buckets */
++ n = snprintf(p->a + p->n, limit, "%d\n", AuPlink_NHASH);
++ p->n += n;
++ limit -= n;
++
++ sum = 0;
++ for (i = 0, sphl = sbinfo->si_plink;
++ i < AuPlink_NHASH;
++ i++, sphl++) {
++ n = au_sphl_count(sphl);
++ sum += n;
++
++ n = snprintf(p->a + p->n, limit, "%lu ", n);
++ p->n += n;
++ limit -= n;
++ if (unlikely(limit <= 0))
++ goto out_free;
++ }
++ p->a[p->n - 1] = '\n';
++
++ /* the sum of plinks */
++ n = snprintf(p->a + p->n, limit, "%lu\n", sum);
++ p->n += n;
++ limit -= n;
++ if (unlikely(limit <= 0))
++ goto out_free;
++ } else {
++#define str "1\n0\n0\n"
++ p->n = sizeof(str) - 1;
++ strcpy(p->a, str);
++#undef str
++ }
++ si_read_unlock(sb);
++
++ err = 0;
++ file->private_data = p;
++ goto out; /* success */
++
++out_free:
++ free_page((unsigned long)p);
++out:
++ return err;
++}
++
++static ssize_t dbgaufs_plink_read(struct file *file, char __user *buf,
++ size_t count, loff_t *ppos)
++{
++ struct dbgaufs_plink_arg *p;
++
++ p = file->private_data;
++ return simple_read_from_buffer(buf, count, ppos, p->a, p->n);
++}
++
++static const struct file_operations dbgaufs_plink_fop = {
++ .owner = THIS_MODULE,
++ .open = dbgaufs_plink_open,
++ .release = dbgaufs_plink_release,
++ .read = dbgaufs_plink_read
++};
++
++/* ---------------------------------------------------------------------- */
++
+static int dbgaufs_xib_open(struct inode *inode, struct file *file)
+{
+ int err;
@@ -3247,6 +4928,12 @@
+ if (unlikely(!sbinfo->si_dbgaufs_xib))
+ goto out_dir;
+
++ sbinfo->si_dbgaufs_plink = debugfs_create_file
++ ("plink", dbgaufs_mode, sbinfo->si_dbgaufs, sbinfo,
++ &dbgaufs_plink_fop);
++ if (unlikely(!sbinfo->si_dbgaufs_plink))
++ goto out_dir;
++
+ err = dbgaufs_xigen_init(sbinfo);
+ if (!err)
+ goto out; /* success */
@@ -3670,7 +5357,7 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_DCSUB_H__ */
--- a/fs/aufs/debug.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/debug.c 2013-05-04 18:39:17.031157464 +0100
++++ b/fs/aufs/debug.c 2013-05-09 01:36:20.741181631 +0100
@@ -0,0 +1,493 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
@@ -3931,7 +5618,7 @@
+
+ if (!br || IS_ERR(br))
+ goto out;
-+ mnt = br->br_mnt;
++ mnt = au_br_mnt(br);
+ if (!mnt || IS_ERR(mnt))
+ goto out;
+ sb = mnt->mnt_sb;
@@ -3972,7 +5659,7 @@
+
+ a->mnt.mnt_sb = sb;
+ a->fake.br_perm = 0;
-+ a->fake.br_mnt = &a->mnt;
++ a->fake.br_path.mnt = &a->mnt;
+ a->fake.br_xino.xi_file = NULL;
+ atomic_set(&a->fake.br_count, 0);
+ smp_mb(); /* atomic_set */
@@ -4411,8 +6098,8 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_DEBUG_H__ */
--- a/fs/aufs/dentry.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/dentry.c 2013-05-04 18:39:11.235157327 +0100
-@@ -0,0 +1,1060 @@
++++ b/fs/aufs/dentry.c 2013-05-09 01:36:20.741181631 +0100
+@@ -0,0 +1,1064 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -4661,15 +6348,19 @@
+/*
+ * lookup @dentry on @bindex which should be negative.
+ */
-+int au_lkup_neg(struct dentry *dentry, aufs_bindex_t bindex)
++int au_lkup_neg(struct dentry *dentry, aufs_bindex_t bindex, int wh)
+{
+ int err;
+ struct dentry *parent, *h_parent, *h_dentry;
++ struct au_branch *br;
+
+ parent = dget_parent(dentry);
+ h_parent = au_h_dptr(parent, bindex);
-+ h_dentry = au_sio_lkup_one(&dentry->d_name, h_parent,
-+ au_sbr(dentry->d_sb, bindex));
++ br = au_sbr(dentry->d_sb, bindex);
++ if (wh)
++ h_dentry = au_whtmp_lkup(h_parent, br, &dentry->d_name);
++ else
++ h_dentry = au_sio_lkup_one(&dentry->d_name, h_parent, br);
+ err = PTR_ERR(h_dentry);
+ if (IS_ERR(h_dentry))
+ goto out;
@@ -5474,7 +7165,7 @@
+ .d_release = aufs_d_release
+};
--- a/fs/aufs/dentry.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/dentry.h 2013-05-04 18:39:11.235157327 +0100
++++ b/fs/aufs/dentry.h 2013-05-09 01:36:20.741181631 +0100
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
@@ -5530,7 +7221,7 @@
+ struct dentry *h_parent, struct au_branch *br);
+
+int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type);
-+int au_lkup_neg(struct dentry *dentry, aufs_bindex_t bindex);
++int au_lkup_neg(struct dentry *dentry, aufs_bindex_t bindex, int wh);
+int au_refresh_dentry(struct dentry *dentry, struct dentry *parent);
+int au_reval_dpath(struct dentry *dentry, unsigned int sigen);
+
@@ -7033,7 +8724,7 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_DIR_H__ */
--- a/fs/aufs/dynop.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/dynop.c 2013-05-04 18:39:11.235157327 +0100
++++ b/fs/aufs/dynop.c 2013-05-09 01:36:20.741181631 +0100
@@ -0,0 +1,379 @@
+/*
+ * Copyright (C) 2010-2013 Junjiro R. Okajima
@@ -7276,7 +8967,7 @@
+
+ key->dk_op.dy_hop = op->dy_hop;
+ kref_init(&key->dk_kref);
-+ p->set(key, op->dy_hop, br->br_mnt->mnt_sb);
++ p->set(key, op->dy_hop, au_br_sb(br));
+ old = dy_gadd(spl, key);
+ if (old) {
+ kfree(key);
@@ -7494,7 +9185,7 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_DYNOP_H__ */
--- a/fs/aufs/export.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/export.c 2013-05-04 18:39:11.235157327 +0100
++++ b/fs/aufs/export.c 2013-05-09 01:36:20.741181631 +0100
@@ -0,0 +1,827 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
@@ -8006,7 +9697,7 @@
+ struct path path;
+
+ br = au_sbr(sb, nsi_lock->bindex);
-+ h_mnt = br->br_mnt;
++ h_mnt = au_br_mnt(br);
+ h_sb = h_mnt->mnt_sb;
+ /* todo: call lower fh_to_dentry()? fh_to_parent()? */
+ h_parent = exportfs_decode_fh(h_mnt, (void *)(fh + Fh_tail),
@@ -8230,7 +9921,7 @@
+
+ err = -EPERM;
+ br = au_sbr(sb, bindex);
-+ h_sb = br->br_mnt->mnt_sb;
++ h_sb = au_br_sb(br);
+ if (unlikely(!h_sb->s_export_op)) {
+ AuErr1("%s branch is not exportable\n", au_sbtype(h_sb));
+ goto out_hparent;
@@ -9050,7 +10741,7 @@
+#endif
+};
--- a/fs/aufs/f_op_sp.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/f_op_sp.c 2013-05-04 18:39:11.235157327 +0100
++++ b/fs/aufs/f_op_sp.c 2013-05-09 01:36:20.745181631 +0100
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
@@ -9250,7 +10941,7 @@
+ err = au_pin(&pin, dentry, bcpup, au_opt_udba(dentry->d_sb),
+ AuPin_MNT_WRITE);
+ if (!err) {
-+ err = au_sio_cpup_simple(dentry, bcpup, -1, AuCpup_DTIME);
++ err = au_sio_cpup_simple(dentry, bcpup, -1, AuCpup_DTIME, &pin);
+ au_unpin(&pin);
+ }
+
@@ -9348,8 +11039,8 @@
+ return ret;
+}
--- a/fs/aufs/file.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/file.c 2013-05-04 18:39:11.235157327 +0100
-@@ -0,0 +1,683 @@
++++ b/fs/aufs/file.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,692 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -9419,7 +11110,7 @@
+ br = au_sbr(sb, bindex);
+ h_file = ERR_PTR(-EACCES);
+ exec_flag = flags & __FMODE_EXEC;
-+ if (exec_flag && (br->br_mnt->mnt_flags & MNT_NOEXEC))
++ if (exec_flag && (au_br_mnt(br)->mnt_flags & MNT_NOEXEC))
+ goto out;
+
+ /* drop flags for writing */
@@ -9428,7 +11119,7 @@
+ flags &= ~O_CREAT;
+ atomic_inc(&br->br_count);
+ h_path.dentry = h_dentry;
-+ h_path.mnt = br->br_mnt;
++ h_path.mnt = au_br_mnt(br);
+ if (!au_special_file(h_inode->i_mode))
+ h_file = vfsub_dentry_open(&h_path, flags);
+ else {
@@ -9506,13 +11197,29 @@
+ au_set_h_fptr(file, bstart, NULL);
+ }
+ AuDebugOn(au_fi(file)->fi_hdir);
-+ AuDebugOn(au_fbstart(file) < bstart);
++ /*
++ * it can happen
++ * file exists on both of rw and ro
++ * open --> dbstart and fbstart are both 0
++ * prepend a branch as rw, "rw" become ro
++ * remove rw/file
++ * delete the top branch, "rw" becomes rw again
++ * --> dbstart is 1, fbstart is still 0
++ * write --> fbstart is 0 but dbstart is 1
++ */
++ /* AuDebugOn(au_fbstart(file) < bstart); */
+
+ h_file = au_h_open(dentry, bstart, vfsub_file_flags(file) & ~O_TRUNC,
+ file);
+ err = PTR_ERR(h_file);
-+ if (IS_ERR(h_file))
++ if (IS_ERR(h_file)) {
++ if (h_file_tmp) {
++ atomic_inc(&au_sbr(dentry->d_sb, bstart)->br_count);
++ au_set_h_fptr(file, bstart, h_file_tmp);
++ h_file_tmp = NULL;
++ }
+ goto out; /* todo: close all? */
++ }
+
+ err = 0;
+ au_set_fbstart(file, bstart);
@@ -9554,7 +11261,7 @@
+}
+
+static int au_ready_to_write_wh(struct file *file, loff_t len,
-+ aufs_bindex_t bcpup)
++ aufs_bindex_t bcpup, struct au_pin *pin)
+{
+ int err;
+ struct inode *inode, *h_inode;
@@ -9571,7 +11278,7 @@
+ }
+ hi_wh = au_hi_wh(inode, bcpup);
+ if (!hi_wh && !h_inode)
-+ err = au_sio_cpup_wh(dentry, bcpup, len, file);
++ err = au_sio_cpup_wh(dentry, bcpup, len, file, pin);
+ else
+ /* already copied-up after unlink */
+ err = au_reopen_wh(file, bcpup, hi_wh);
@@ -9592,7 +11299,7 @@
+ int err;
+ aufs_bindex_t bstart, bcpup, dbstart;
+ struct dentry *dentry, *parent, *h_dentry;
-+ struct inode *h_inode, *inode;
++ struct inode *inode;
+ struct super_block *sb;
+ struct file *h_file;
+
@@ -9628,43 +11335,35 @@
+ goto out_dgrade;
+
+ h_dentry = au_hf_top(file)->f_dentry;
-+ h_inode = h_dentry->d_inode;
+ dbstart = au_dbstart(dentry);
+ if (dbstart <= bcpup) {
+ h_dentry = au_h_dptr(dentry, bcpup);
+ AuDebugOn(!h_dentry);
-+ h_inode = h_dentry->d_inode;
-+ AuDebugOn(!h_inode);
+ bstart = bcpup;
+ }
+
+ if (dbstart <= bcpup /* just reopen */
+ || !d_unhashed(dentry) /* copyup and reopen */
+ ) {
-+ mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
+ h_file = au_h_open_pre(dentry, bstart);
-+ if (IS_ERR(h_file)) {
++ if (IS_ERR(h_file))
+ err = PTR_ERR(h_file);
-+ h_file = NULL;
-+ } else {
++ else {
+ di_downgrade_lock(parent, AuLock_IR);
+ if (dbstart > bcpup)
+ err = au_sio_cpup_simple(dentry, bcpup, len,
-+ AuCpup_DTIME);
++ AuCpup_DTIME, pin);
+ if (!err)
+ err = au_reopen_nondir(file);
++ au_h_open_post(dentry, bstart, h_file);
+ }
-+ mutex_unlock(&h_inode->i_mutex);
-+ au_h_open_post(dentry, bstart, h_file);
+ } else { /* copyup as wh and reopen */
+ /*
+ * since writable hfsplus branch is not supported,
+ * h_open_pre/post() are unnecessary.
+ */
-+ mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
-+ err = au_ready_to_write_wh(file, len, bcpup);
++ err = au_ready_to_write_wh(file, len, bcpup, pin);
+ di_downgrade_lock(parent, AuLock_IR);
-+ mutex_unlock(&h_inode->i_mutex);
+ }
+
+ if (!err) {
@@ -9749,7 +11448,8 @@
+ if (!S_ISDIR(inode->i_mode)
+ && au_opt_test(au_mntflags(sb), PLINK)
+ && au_plink_test(inode)
-+ && !d_unhashed(dentry)) {
++ && !d_unhashed(dentry)
++ && bstart < au_dbstart(dentry)) {
+ err = au_test_and_cpup_dirs(dentry, bstart);
+ if (unlikely(err))
+ goto out_unlock;
@@ -9759,7 +11459,7 @@
+ AuPin_DI_LOCKED | AuPin_MNT_WRITE);
+ if (!err)
+ err = au_sio_cpup_simple(dentry, bstart, -1,
-+ AuCpup_DTIME);
++ AuCpup_DTIME, &pin);
+ au_unpin(&pin);
+ } else if (hi_wh) {
+ /* already copied-up after unlink */
@@ -10495,8 +12195,8 @@
+ return err;
+}
--- a/fs/aufs/fstype.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/fstype.h 2013-05-04 18:39:11.235157327 +0100
-@@ -0,0 +1,481 @@
++++ b/fs/aufs/fstype.h 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,480 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -10910,7 +12610,6 @@
+ || au_test_ramfs(sb)
+#endif
+ || au_test_ubifs(sb)
-+ || au_test_btrfs(sb)
+ || au_test_hfsplus(sb);
+}
+
@@ -11278,8 +12977,8 @@
+ .init_br = au_hfsn_init_br
+};
--- a/fs/aufs/hfsplus.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/hfsplus.c 2013-03-10 01:48:58.463093058 +0000
-@@ -0,0 +1,57 @@
++++ b/fs/aufs/hfsplus.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010-2013 Junjiro R. Okajima
+ *
@@ -11318,7 +13017,6 @@
+ h_dentry = au_h_dptr(dentry, bindex);
+ AuDebugOn(!h_dentry);
+ AuDebugOn(!h_dentry->d_inode);
-+ IMustLock(h_dentry->d_inode);
+
+ h_file = NULL;
+ if (au_test_hfsplus(h_dentry->d_sb)
@@ -12054,8 +13752,8 @@
+ au_hn_destroy_cache();
+}
--- a/fs/aufs/i_op.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/i_op.c 2013-05-04 18:39:11.235157327 +0100
-@@ -0,0 +1,1030 @@
++++ b/fs/aufs/i_op.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,1107 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -12172,7 +13870,7 @@
+ err = 0;
+ bindex = au_ibstart(inode);
+ br = au_sbr(sb, bindex);
-+ err = h_permission(h_inode, mask, br->br_mnt, br->br_perm);
++ err = h_permission(h_inode, mask, au_br_mnt(br), br->br_perm);
+ if (write_mask
+ && !err
+ && !special_file(h_inode->i_mode)) {
@@ -12198,7 +13896,7 @@
+ break;
+
+ br = au_sbr(sb, bindex);
-+ err = h_permission(h_inode, mask, br->br_mnt,
++ err = h_permission(h_inode, mask, au_br_mnt(br),
+ br->br_perm);
+ }
+ }
@@ -12327,7 +14025,8 @@
+ h_parent = au_h_dptr(parent, bcpup);
+ h_dir = h_parent->d_inode;
+ mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
-+ err = au_lkup_neg(dentry, bcpup);
++ err = au_lkup_neg(dentry, bcpup,
++ au_ftest_wrdir(add_entry, TMP_WHENTRY));
+ /* todo: no unlock here */
+ mutex_unlock(&h_dir->i_mutex);
+
@@ -12358,8 +14057,9 @@
+{
+ int err;
+ aufs_bindex_t bcpup, bstart, src_bstart;
-+ const unsigned char add_entry = !!au_ftest_wrdir(args->flags,
-+ ADD_ENTRY);
++ const unsigned char add_entry
++ = au_ftest_wrdir(args->flags, ADD_ENTRY)
++ | au_ftest_wrdir(args->flags, TMP_WHENTRY);
+ struct super_block *sb;
+ struct dentry *parent;
+ struct au_sbinfo *sbinfo;
@@ -12423,6 +14123,85 @@
+
+/* ---------------------------------------------------------------------- */
+
++void au_pin_hdir_unlock(struct au_pin *p)
++{
++ if (p->hdir)
++ au_hn_imtx_unlock(p->hdir);
++}
++
++static int au_pin_hdir_lock(struct au_pin *p)
++{
++ int err;
++
++ err = 0;
++ if (!p->hdir)
++ goto out;
++
++ /* even if an error happens later, keep this lock */
++ au_hn_imtx_lock_nested(p->hdir, p->lsc_hi);
++
++ err = -EBUSY;
++ if (unlikely(p->hdir->hi_inode != p->h_parent->d_inode))
++ goto out;
++
++ err = 0;
++ if (p->h_dentry)
++ err = au_h_verify(p->h_dentry, p->udba, p->hdir->hi_inode,
++ p->h_parent, p->br);
++
++out:
++ return err;
++}
++
++int au_pin_hdir_relock(struct au_pin *p)
++{
++ int err, i;
++ struct inode *h_i;
++ struct dentry *h_d[] = {
++ p->h_dentry,
++ p->h_parent
++ };
++
++ err = au_pin_hdir_lock(p);
++ if (unlikely(err))
++ goto out;
++
++ for (i = 0; !err && i < sizeof(h_d)/sizeof(*h_d); i++) {
++ if (!h_d[i])
++ continue;
++ h_i = h_d[i]->d_inode;
++ if (h_i)
++ err = !h_i->i_nlink;
++ }
++
++out:
++ return err;
++}
++
++void au_pin_hdir_set_owner(struct au_pin *p, struct task_struct *task)
++{
++#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP)
++ p->hdir->hi_inode->i_mutex.owner = task;
++#endif
++}
++
++void au_pin_hdir_acquire_nest(struct au_pin *p)
++{
++ if (p->hdir) {
++ mutex_acquire_nest(&p->hdir->hi_inode->i_mutex.dep_map,
++ p->lsc_hi, 0, NULL, _RET_IP_);
++ au_pin_hdir_set_owner(p, current);
++ }
++}
++
++void au_pin_hdir_release(struct au_pin *p)
++{
++ if (p->hdir) {
++ au_pin_hdir_set_owner(p, p->task);
++ mutex_release(&p->hdir->hi_inode->i_mutex.dep_map, 1, _RET_IP_);
++ }
++}
++
+struct dentry *au_pinned_h_parent(struct au_pin *pin)
+{
+ if (pin && pin->parent)
@@ -12432,12 +14211,13 @@
+
+void au_unpin(struct au_pin *p)
+{
++ if (p->hdir)
++ au_pin_hdir_unlock(p);
+ if (p->h_mnt && au_ftest_pin(p->flags, MNT_WRITE))
+ vfsub_mnt_drop_write(p->h_mnt);
+ if (!p->hdir)
+ return;
+
-+ au_hn_imtx_unlock(p->hdir);
+ if (!au_ftest_pin(p->flags, DI_LOCKED))
+ di_read_unlock(p->parent, AuLock_IR);
+ iput(p->hdir->hi_inode);
@@ -12445,22 +14225,21 @@
+ p->parent = NULL;
+ p->hdir = NULL;
+ p->h_mnt = NULL;
++ /* do not clear p->task */
+}
+
+int au_do_pin(struct au_pin *p)
+{
+ int err;
+ struct super_block *sb;
-+ struct dentry *h_dentry, *h_parent;
-+ struct au_branch *br;
+ struct inode *h_dir;
+
+ err = 0;
+ sb = p->dentry->d_sb;
-+ br = au_sbr(sb, p->bindex);
++ p->br = au_sbr(sb, p->bindex);
+ if (IS_ROOT(p->dentry)) {
+ if (au_ftest_pin(p->flags, MNT_WRITE)) {
-+ p->h_mnt = br->br_mnt;
++ p->h_mnt = au_br_mnt(p->br);
+ err = vfsub_mnt_want_write(p->h_mnt);
+ if (unlikely(err)) {
+ au_fclr_pin(p->flags, MNT_WRITE);
@@ -12470,16 +14249,16 @@
+ goto out;
+ }
+
-+ h_dentry = NULL;
++ p->h_dentry = NULL;
+ if (p->bindex <= au_dbend(p->dentry))
-+ h_dentry = au_h_dptr(p->dentry, p->bindex);
++ p->h_dentry = au_h_dptr(p->dentry, p->bindex);
+
+ p->parent = dget_parent(p->dentry);
+ if (!au_ftest_pin(p->flags, DI_LOCKED))
+ di_read_lock(p->parent, AuLock_IR, p->lsc_di);
+
+ h_dir = NULL;
-+ h_parent = au_h_dptr(p->parent, p->bindex);
++ p->h_parent = au_h_dptr(p->parent, p->bindex);
+ p->hdir = au_hi(p->parent->d_inode, p->bindex);
+ if (p->hdir)
+ h_dir = p->hdir->hi_inode;
@@ -12489,7 +14268,7 @@
+ * if DI_LOCKED is not set, then p->parent may be different
+ * and h_parent can be NULL.
+ */
-+ if (unlikely(!p->hdir || !h_dir || !h_parent)) {
++ if (unlikely(!p->hdir || !h_dir || !p->h_parent)) {
+ err = -EBUSY;
+ if (!au_ftest_pin(p->flags, DI_LOCKED))
+ di_read_unlock(p->parent, AuLock_IR);
@@ -12498,33 +14277,24 @@
+ goto out_err;
+ }
+
-+ au_igrab(h_dir);
-+ au_hn_imtx_lock_nested(p->hdir, p->lsc_hi);
-+
-+ if (unlikely(p->hdir->hi_inode != h_parent->d_inode)) {
-+ err = -EBUSY;
-+ goto out_unpin;
-+ }
-+ if (h_dentry) {
-+ err = au_h_verify(h_dentry, p->udba, h_dir, h_parent, br);
-+ if (unlikely(err)) {
-+ au_fclr_pin(p->flags, MNT_WRITE);
-+ goto out_unpin;
-+ }
-+ }
-+
+ if (au_ftest_pin(p->flags, MNT_WRITE)) {
-+ p->h_mnt = br->br_mnt;
++ p->h_mnt = au_br_mnt(p->br);
+ err = vfsub_mnt_want_write(p->h_mnt);
+ if (unlikely(err)) {
+ au_fclr_pin(p->flags, MNT_WRITE);
-+ goto out_unpin;
++ if (!au_ftest_pin(p->flags, DI_LOCKED))
++ di_read_unlock(p->parent, AuLock_IR);
++ dput(p->parent);
++ p->parent = NULL;
++ goto out_err;
+ }
+ }
-+ goto out; /* success */
+
-+out_unpin:
-+ au_unpin(p);
++ au_igrab(h_dir);
++ err = au_pin_hdir_lock(p);
++ if (!err)
++ goto out; /* success */
++
+out_err:
+ pr_err("err %d\n", err);
+ err = au_busy_or_stale();
@@ -12546,6 +14316,11 @@
+ p->parent = NULL;
+ p->hdir = NULL;
+ p->h_mnt = NULL;
++
++ p->h_dentry = NULL;
++ p->h_parent = NULL;
++ p->br = NULL;
++ p->task = current;
+}
+
+int au_pin(struct au_pin *pin, struct dentry *dentry, aufs_bindex_t bindex,
@@ -12651,13 +14426,15 @@
+ sz = -1;
+ if ((ia->ia_valid & ATTR_SIZE) && ia->ia_size < i_size_read(a->h_inode))
+ sz = ia->ia_size;
++ mutex_unlock(&a->h_inode->i_mutex);
+
+ h_file = NULL;
+ hi_wh = NULL;
+ if (au_ftest_icpup(a->flags, DID_CPUP) && d_unlinked(dentry)) {
+ hi_wh = au_hi_wh(inode, a->btgt);
+ if (!hi_wh) {
-+ err = au_sio_cpup_wh(dentry, a->btgt, sz, /*file*/NULL);
++ err = au_sio_cpup_wh(dentry, a->btgt, sz, /*file*/NULL,
++ &a->pin);
+ if (unlikely(err))
+ goto out_unlock;
+ hi_wh = au_hi_wh(inode, a->btgt);
@@ -12676,12 +14453,13 @@
+
+ if (!d_unhashed(dentry)) {
+ h_file = au_h_open_pre(dentry, bstart);
-+ if (IS_ERR(h_file)) {
++ if (IS_ERR(h_file))
+ err = PTR_ERR(h_file);
-+ h_file = NULL;
-+ } else
++ else {
+ err = au_sio_cpup_simple(dentry, a->btgt, sz,
-+ AuCpup_DTIME);
++ AuCpup_DTIME, &a->pin);
++ au_h_open_post(dentry, bstart, h_file);
++ }
+ if (!err)
+ a->h_path.dentry = au_h_dptr(dentry, a->btgt);
+ } else if (!hi_wh)
@@ -12690,14 +14468,9 @@
+ a->h_path.dentry = hi_wh; /* do not dget here */
+
+out_unlock:
-+ mutex_unlock(&a->h_inode->i_mutex);
-+ au_h_open_post(dentry, bstart, h_file);
+ a->h_inode = a->h_path.dentry->d_inode;
-+ if (!err) {
-+ mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
++ if (!err)
+ goto out; /* success */
-+ }
-+
+ au_unpin(&a->pin);
+out_parent:
+ if (parent) {
@@ -12705,6 +14478,8 @@
+ dput(parent);
+ }
+out:
++ if (!err)
++ mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
+ return err;
+}
+
@@ -12773,8 +14548,7 @@
+ goto out_unlock;
+ } else if ((ia->ia_valid & (ATTR_UID | ATTR_GID))
+ && (ia->ia_valid & ATTR_CTIME)) {
-+ err = security_path_chown(&a->h_path, vfsub_ia_uid(ia),
-+ vfsub_ia_gid(ia));
++ err = security_path_chown(&a->h_path, ia->ia_uid, ia->ia_gid);
+ if (unlikely(err))
+ goto out_unlock;
+ }
@@ -12824,8 +14598,9 @@
+ unsigned int n;
+
+ inode->i_mode = st->mode;
-+ i_uid_write(inode, st->uid);
-+ i_gid_write(inode, st->gid);
++ /* don't i_[ug]id_write() here */
++ inode->i_uid = st->uid;
++ inode->i_gid = st->gid;
+ inode->i_atime = st->atime;
+ inode->i_mtime = st->mtime;
+ inode->i_ctime = st->ctime;
@@ -13087,8 +14862,8 @@
+ .update_time = aufs_update_time
+};
--- a/fs/aufs/i_op_add.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/i_op_add.c 2013-05-04 18:39:11.235157327 +0100
-@@ -0,0 +1,713 @@
++++ b/fs/aufs/i_op_add.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,722 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -13281,7 +15056,7 @@
+ if (dt) {
+ struct path tmp = {
+ .dentry = h_parent,
-+ .mnt = br->br_mnt
++ .mnt = au_br_mnt(br)
+ };
+ au_dtime_store(dt, au_pinned_parent(pin), &tmp);
+ }
@@ -13450,7 +15225,6 @@
+{
+ int err;
+ struct dentry *h_src_dentry;
-+ struct mutex *h_mtx;
+ struct file *h_file;
+
+ di_read_lock_parent(a->src_parent, AuLock_IR);
@@ -13459,22 +15233,20 @@
+ goto out;
+
+ h_src_dentry = au_h_dptr(src_dentry, a->bsrc);
-+ h_mtx = &h_src_dentry->d_inode->i_mutex;
+ err = au_pin(&a->pin, src_dentry, a->bdst,
+ au_opt_udba(src_dentry->d_sb),
+ AuPin_DI_LOCKED | AuPin_MNT_WRITE);
+ if (unlikely(err))
+ goto out;
-+ mutex_lock_nested(h_mtx, AuLsc_I_CHILD);
+ h_file = au_h_open_pre(src_dentry, a->bsrc);
-+ if (IS_ERR(h_file)) {
++ if (IS_ERR(h_file))
+ err = PTR_ERR(h_file);
-+ h_file = NULL;
-+ } else
++ else {
+ err = au_sio_cpup_simple(src_dentry, a->bdst, -1,
-+ AuCpup_DTIME /* | AuCpup_KEEPLINO */);
-+ mutex_unlock(h_mtx);
-+ au_h_open_post(src_dentry, a->bsrc, h_file);
++ AuCpup_DTIME /* | AuCpup_KEEPLINO */,
++ &a->pin);
++ au_h_open_post(src_dentry, a->bsrc, h_file);
++ }
+ au_unpin(&a->pin);
+
+out:
@@ -13482,12 +15254,14 @@
+ return err;
+}
+
-+static int au_cpup_or_link(struct dentry *src_dentry, struct au_link_args *a)
++static int au_cpup_or_link(struct dentry *src_dentry, struct dentry *dentry,
++ struct au_link_args *a)
+{
+ int err;
+ unsigned char plink;
-+ struct inode *h_inode, *inode;
++ aufs_bindex_t bend;
+ struct dentry *h_src_dentry;
++ struct inode *h_inode, *inode;
+ struct super_block *sb;
+ struct file *h_file;
+
@@ -13499,22 +15273,31 @@
+ h_inode = au_h_iptr(inode, a->bdst);
+ if (!h_inode || !h_inode->i_nlink) {
+ /* copyup src_dentry as the name of dentry. */
-+ au_set_dbstart(src_dentry, a->bdst);
-+ au_set_h_dptr(src_dentry, a->bdst, dget(a->h_path.dentry));
-+ h_inode = au_h_dptr(src_dentry, a->bsrc)->d_inode;
-+ mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
-+ h_file = au_h_open_pre(src_dentry, a->bsrc);
-+ if (IS_ERR(h_file)) {
++ bend = au_dbend(dentry);
++ if (bend < a->bsrc)
++ au_set_dbend(dentry, a->bsrc);
++ au_set_h_dptr(dentry, a->bsrc,
++ dget(au_h_dptr(src_dentry, a->bsrc)));
++ dget(a->h_path.dentry);
++ au_set_h_dptr(dentry, a->bdst, NULL);
++ dentry->d_inode = src_dentry->d_inode; /* tmp */
++ h_file = au_h_open_pre(dentry, a->bsrc);
++ if (IS_ERR(h_file))
+ err = PTR_ERR(h_file);
-+ h_file = NULL;
-+ } else
-+ err = au_sio_cpup_single(src_dentry, a->bdst, a->bsrc,
-+ -1, AuCpup_KEEPLINO,
-+ a->parent);
-+ mutex_unlock(&h_inode->i_mutex);
-+ au_h_open_post(src_dentry, a->bsrc, h_file);
-+ au_set_h_dptr(src_dentry, a->bdst, NULL);
-+ au_set_dbstart(src_dentry, a->bsrc);
++ else {
++ err = au_sio_cpup_simple(dentry, a->bdst, -1,
++ AuCpup_KEEPLINO, &a->pin);
++ au_h_open_post(dentry, a->bsrc, h_file);
++ if (!err) {
++ dput(a->h_path.dentry);
++ a->h_path.dentry = au_h_dptr(dentry, a->bdst);
++ } else
++ au_set_h_dptr(dentry, a->bdst,
++ a->h_path.dentry);
++ }
++ dentry->d_inode = NULL; /* restore */
++ au_set_h_dptr(dentry, a->bsrc, NULL);
++ au_set_dbend(dentry, bend);
+ } else {
+ /* the inode of src_dentry already exists on a.bdst branch */
+ h_src_dentry = d_find_alias(h_inode);
@@ -13613,7 +15396,7 @@
+ if (au_opt_test(au_mntflags(sb), PLINK)) {
+ if (a->bdst < a->bsrc
+ /* && h_src_dentry->d_sb != a->h_path.dentry->d_sb */)
-+ err = au_cpup_or_link(src_dentry, a);
++ err = au_cpup_or_link(src_dentry, dentry, a);
+ else
+ err = vfsub_link(h_src_dentry, au_pinned_h_dir(&a->pin),
+ &a->h_path);
@@ -13692,6 +15475,7 @@
+out_kfree:
+ kfree(a);
+out:
++ AuTraceErr(err);
+ return err;
+}
+
@@ -14283,8 +16067,8 @@
+ return err;
+}
--- a/fs/aufs/i_op_ren.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/i_op_ren.c 2013-05-04 18:39:11.235157327 +0100
-@@ -0,0 +1,1026 @@
++++ b/fs/aufs/i_op_ren.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,1053 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -14496,22 +16280,22 @@
+ err = vfsub_rename(a->src_h_dir, au_h_dptr(d, a->btgt),
+ a->dst_h_dir, &a->h_path);
+ } else {
-+ struct mutex *h_mtx = &a->src_h_dentry->d_inode->i_mutex;
++#if 1
++ BUG();
++#else
+ struct file *h_file;
+
+ au_fset_ren(a->flags, CPUP);
-+ mutex_lock_nested(h_mtx, AuLsc_I_CHILD);
+ au_set_dbstart(d, a->btgt);
+ au_set_h_dptr(d, a->btgt, dget(a->dst_h_dentry));
+ h_file = au_h_open_pre(d, a->src_bstart);
-+ if (IS_ERR(h_file)) {
++ if (IS_ERR(h_file))
+ err = PTR_ERR(h_file);
-+ h_file = NULL;
-+ } else
++ else {
+ err = au_sio_cpup_single(d, a->btgt, a->src_bstart, -1,
+ !AuCpup_DTIME, a->dst_parent);
-+ mutex_unlock(h_mtx);
-+ au_h_open_post(d, a->src_bstart, h_file);
++ au_h_open_post(d, a->src_bstart, h_file);
++ }
+ if (!err) {
+ d = a->dst_dentry;
+ au_set_h_dptr(d, a->btgt, NULL);
@@ -14520,6 +16304,7 @@
+ au_set_h_dptr(d, a->btgt, NULL);
+ au_set_dbstart(d, a->src_bstart);
+ }
++#endif
+ }
+ if (!err && a->h_dst)
+ /* it will be set to dinfo later */
@@ -14621,7 +16406,7 @@
+
+ d = a->dst_dentry;
+ au_set_h_dptr(d, a->btgt, NULL);
-+ err = au_lkup_neg(d, a->btgt);
++ err = au_lkup_neg(d, a->btgt, /*wh*/0);
+ if (unlikely(err))
+ goto out_whtmp;
+ a->dst_h_dentry = au_h_dptr(d, a->btgt);
@@ -14629,22 +16414,22 @@
+
+ /* cpup src */
+ if (a->dst_h_dentry->d_inode && a->src_bstart != a->btgt) {
-+ struct mutex *h_mtx = &a->src_h_dentry->d_inode->i_mutex;
++#if 1
++ BUG();
++#else
+ struct file *h_file;
+
-+ mutex_lock_nested(h_mtx, AuLsc_I_CHILD);
-+ AuDebugOn(au_dbstart(a->src_dentry) != a->src_bstart);
+ h_file = au_h_open_pre(a->src_dentry, a->src_bstart);
-+ if (IS_ERR(h_file)) {
++ if (IS_ERR(h_file))
+ err = PTR_ERR(h_file);
-+ h_file = NULL;
-+ } else
++ else {
+ err = au_sio_cpup_simple(a->src_dentry, a->btgt, -1,
+ !AuCpup_DTIME);
-+ mutex_unlock(h_mtx);
-+ au_h_open_post(a->src_dentry, a->src_bstart, h_file);
++ au_h_open_post(a->src_dentry, a->src_bstart, h_file);
++ }
+ if (unlikely(err))
+ goto out_whtmp;
++#endif
+ }
+
+ /* rename by vfs_rename or cpup */
@@ -14897,13 +16682,10 @@
+ */
+static void au_ren_unlock(struct au_ren_args *a)
+{
-+ struct super_block *sb;
-+
-+ sb = a->dst_dentry->d_sb;
-+ if (au_ftest_ren(a->flags, MNT_WRITE))
-+ vfsub_mnt_drop_write(a->br->br_mnt);
+ vfsub_unlock_rename(a->src_h_parent, a->src_hdir,
+ a->dst_h_parent, a->dst_hdir);
++ if (au_ftest_ren(a->flags, MNT_WRITE))
++ vfsub_mnt_drop_write(au_br_mnt(a->br));
+}
+
+static int au_ren_lock(struct au_ren_args *a)
@@ -14916,6 +16698,11 @@
+ a->src_hdir = au_hi(a->src_dir, a->btgt);
+ a->dst_h_parent = au_h_dptr(a->dst_parent, a->btgt);
+ a->dst_hdir = au_hi(a->dst_dir, a->btgt);
++
++ err = vfsub_mnt_want_write(au_br_mnt(a->br));
++ if (unlikely(err))
++ goto out;
++ au_fset_ren(a->flags, MNT_WRITE);
+ a->h_trap = vfsub_lock_rename(a->src_h_parent, a->src_hdir,
+ a->dst_h_parent, a->dst_hdir);
+ udba = au_opt_udba(a->src_dentry->d_sb);
@@ -14930,18 +16717,12 @@
+ err = au_h_verify(a->dst_h_dentry, udba,
+ a->dst_h_parent->d_inode, a->dst_h_parent,
+ a->br);
-+ if (!err) {
-+ err = vfsub_mnt_want_write(a->br->br_mnt);
-+ if (unlikely(err))
-+ goto out_unlock;
-+ au_fset_ren(a->flags, MNT_WRITE);
++ if (!err)
+ goto out; /* success */
-+ }
+
+ err = au_busy_or_stale();
-+
-+out_unlock:
+ au_ren_unlock(a);
++
+out:
+ return err;
+}
@@ -15211,7 +16992,7 @@
+ if (unlikely(err < 0))
+ goto out_parent;
+ a->br = au_sbr(a->dst_dentry->d_sb, a->btgt);
-+ a->h_path.mnt = a->br->br_mnt;
++ a->h_path.mnt = au_br_mnt(a->br);
+
+ /* are they available to be renamed */
+ err = au_ren_may_dir(a);
@@ -15249,9 +17030,39 @@
+ if (err)
+ au_fset_ren(a->flags, WHSRC);
+
++ /* cpup src */
++ if (a->src_bstart != a->btgt) {
++ struct file *h_file;
++ struct au_pin pin;
++
++ err = au_pin(&pin, a->src_dentry, a->btgt,
++ au_opt_udba(a->src_dentry->d_sb),
++ AuPin_DI_LOCKED | AuPin_MNT_WRITE);
++ if (unlikely(err))
++ goto out_children;
++
++ AuDebugOn(au_dbstart(a->src_dentry) != a->src_bstart);
++ h_file = au_h_open_pre(a->src_dentry, a->src_bstart);
++ if (IS_ERR(h_file)) {
++ err = PTR_ERR(h_file);
++ h_file = NULL;
++ } else {
++ err = au_sio_cpup_simple(a->src_dentry, a->btgt, -1,
++ AuCpup_DTIME, &pin);
++ au_h_open_post(a->src_dentry, a->src_bstart, h_file);
++ }
++ au_unpin(&pin);
++ if (unlikely(err))
++ goto out_children;
++ a->src_bstart = a->btgt;
++ a->src_h_dentry = au_h_dptr(a->src_dentry, a->btgt);
++ au_fset_ren(a->flags, WHSRC);
++ }
++
+ /* lock them all */
+ err = au_ren_lock(a);
+ if (unlikely(err))
++ /* leave the copied-up one */
+ goto out_children;
+
+ if (!au_opt_test(au_mntflags(a->dst_dir->i_sb), UDBA_NONE))
@@ -16086,8 +17897,8 @@
+ return au_test_h_perm(h_inode, mask);
+}
--- a/fs/aufs/inode.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/inode.h 2013-05-04 18:39:11.239157326 +0100
-@@ -0,0 +1,588 @@
++++ b/fs/aufs/inode.h 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,600 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -16191,8 +18002,19 @@
+ struct dentry *parent;
+ struct au_hinode *hdir;
+ struct vfsmount *h_mnt;
++
++ /* temporary unlock/relock for copyup */
++ struct dentry *h_dentry, *h_parent;
++ struct au_branch *br;
++ struct task_struct *task;
+};
+
++void au_pin_hdir_unlock(struct au_pin *p);
++int au_pin_hdir_relock(struct au_pin *p);
++void au_pin_hdir_set_owner(struct au_pin *p, struct task_struct *task);
++void au_pin_hdir_acquire_nest(struct au_pin *p);
++void au_pin_hdir_release(struct au_pin *p);
++
+/* ---------------------------------------------------------------------- */
+
+static inline struct au_iinfo *au_ii(struct inode *inode)
@@ -16234,7 +18056,8 @@
+
+/* au_wr_dir flags */
+#define AuWrDir_ADD_ENTRY 1
-+#define AuWrDir_ISDIR (1 << 1)
++#define AuWrDir_TMP_WHENTRY (1 << 1)
++#define AuWrDir_ISDIR (1 << 2)
+#define au_ftest_wrdir(flags, name) ((flags) & AuWrDir_##name)
+#define au_fset_wrdir(flags, name) \
+ do { (flags) |= AuWrDir_##name; } while (0)
@@ -17437,8 +19260,8 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_MODULE_H__ */
--- a/fs/aufs/opts.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/opts.c 2013-03-10 01:48:58.463093058 +0000
-@@ -0,0 +1,1677 @@
++++ b/fs/aufs/opts.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,1697 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -17627,17 +19450,16 @@
+ {0, NULL}
+};
+
-+static match_table_t brrattr = {
++static match_table_t brattr = {
++ {AuBrAttr_UNPIN, AUFS_BRATTR_UNPIN},
+ {AuBrRAttr_WH, AUFS_BRRATTR_WH},
-+ {0, NULL}
-+};
-+
-+static match_table_t brwattr = {
+ {AuBrWAttr_NoLinkWH, AUFS_BRWATTR_NLWH},
+ {0, NULL}
+};
+
-+#define AuBrStr_LONGEST AUFS_BRPERM_RW "+" AUFS_BRWATTR_NLWH
++#define AuBrStr_LONGEST AUFS_BRPERM_RW \
++ "+" AUFS_BRATTR_UNPIN \
++ "+" AUFS_BRWATTR_NLWH
+
+static int br_attr_val(char *str, match_table_t table, substring_t args[])
+{
@@ -17668,7 +19490,7 @@
+static int noinline_for_stack br_perm_val(char *perm)
+{
+ int val;
-+ char *p;
++ char *p, *q;
+ substring_t args[MAX_OPT_ARGS];
+
+ p = strchr(perm, '+');
@@ -17685,13 +19507,33 @@
+ if (!p)
+ goto out;
+
-+ switch (val) {
++ p++;
++ while (1) {
++ q = strchr(p, '+');
++ if (q)
++ *q = 0;
++ val |= br_attr_val(p, brattr, args);
++ if (q) {
++ *q = '+';
++ p = q + 1;
++ } else
++ break;
++ }
++ switch (val & AuBrPerm_Mask) {
+ case AuBrPerm_RO:
+ case AuBrPerm_RR:
-+ val |= br_attr_val(p + 1, brrattr, args);
++ if (unlikely(val & AuBrWAttr_NoLinkWH)) {
++ pr_warn("ignored branch attribute %s\n",
++ AUFS_BRWATTR_NLWH);
++ val &= ~AuBrWAttr_NoLinkWH;
++ }
+ break;
+ case AuBrPerm_RW:
-+ val |= br_attr_val(p + 1, brwattr, args);
++ if (unlikely(val & AuBrRAttr_WH)) {
++ pr_warn("ignored branch attribute %s\n",
++ AUFS_BRRATTR_WH);
++ val &= ~AuBrRAttr_WH;
++ }
+ break;
+ }
+
@@ -17734,6 +19576,7 @@
+ AuDebugOn(1);
+ }
+
++ AppendAttr(AuBrAttr_UNPIN, AUFS_BRATTR_UNPIN);
+ AppendAttr(AuBrRAttr_WH, AUFS_BRRATTR_WH);
+ AppendAttr(AuBrWAttr_NoLinkWH, AUFS_BRWATTR_NLWH);
+
@@ -18959,7 +20802,7 @@
+ au_hn_imtx_lock_nested(hdir, AuLsc_I_PARENT);
+ if (wbr)
+ wbr_wh_write_lock(wbr);
-+ err = au_wh_init(au_h_dptr(root, bindex), br, sb);
++ err = au_wh_init(br, sb);
+ if (wbr)
+ wbr_wh_write_unlock(wbr);
+ au_hn_imtx_unlock(hdir);
@@ -19329,8 +21172,8 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_OPTS_H__ */
--- a/fs/aufs/plink.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/plink.c 2013-05-04 18:39:11.239157326 +0100
-@@ -0,0 +1,511 @@
++++ b/fs/aufs/plink.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,523 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -19452,19 +21295,13 @@
+
+/* ---------------------------------------------------------------------- */
+
-+struct pseudo_link {
-+ union {
-+ struct list_head list;
-+ struct rcu_head rcu;
-+ };
-+ struct inode *inode;
-+};
-+
+#ifdef CONFIG_AUFS_DEBUG
+void au_plink_list(struct super_block *sb)
+{
++ int i;
+ struct au_sbinfo *sbinfo;
-+ struct list_head *plink_list;
++ struct hlist_head *plink_hlist;
++ struct hlist_node *pos;
+ struct pseudo_link *plink;
+
+ SiMustAnyLock(sb);
@@ -19473,20 +21310,23 @@
+ AuDebugOn(!au_opt_test(au_mntflags(sb), PLINK));
+ AuDebugOn(au_plink_maint(sb, AuLock_NOPLM));
+
-+ plink_list = &sbinfo->si_plink.head;
-+ rcu_read_lock();
-+ list_for_each_entry_rcu(plink, plink_list, list)
-+ AuDbg("%lu\n", plink->inode->i_ino);
-+ rcu_read_unlock();
++ for (i = 0; i < AuPlink_NHASH; i++) {
++ plink_hlist = &sbinfo->si_plink[i].head;
++ rcu_read_lock();
++ hlist_for_each_entry_rcu(plink, pos, plink_hlist, hlist)
++ AuDbg("%lu\n", plink->inode->i_ino);
++ rcu_read_unlock();
++ }
+}
+#endif
+
+/* is the inode pseudo-linked? */
+int au_plink_test(struct inode *inode)
+{
-+ int found;
++ int found, i;
+ struct au_sbinfo *sbinfo;
-+ struct list_head *plink_list;
++ struct hlist_head *plink_hlist;
++ struct hlist_node *pos;
+ struct pseudo_link *plink;
+
+ sbinfo = au_sbi(inode->i_sb);
@@ -19495,9 +21335,10 @@
+ AuDebugOn(au_plink_maint(inode->i_sb, AuLock_NOPLM));
+
+ found = 0;
-+ plink_list = &sbinfo->si_plink.head;
++ i = au_plink_hash(inode->i_ino);
++ plink_hlist = &sbinfo->si_plink[i].head;
+ rcu_read_lock();
-+ list_for_each_entry_rcu(plink, plink_list, list)
++ hlist_for_each_entry_rcu(plink, pos, plink_hlist, hlist)
+ if (plink->inode == inode) {
+ found = 1;
+ break;
@@ -19593,7 +21434,7 @@
+{
+ int err;
+ struct path h_path = {
-+ .mnt = br->br_mnt
++ .mnt = au_br_mnt(br)
+ };
+ struct inode *h_dir;
+
@@ -19676,7 +21517,7 @@
+static void do_put_plink(struct pseudo_link *plink, int do_del)
+{
+ if (do_del)
-+ list_del(&plink->list);
++ hlist_del(&plink->hlist);
+ iput(plink->inode);
+ kfree(plink);
+}
@@ -19699,30 +21540,24 @@
+{
+ struct super_block *sb;
+ struct au_sbinfo *sbinfo;
-+ struct list_head *plink_list;
++ struct hlist_head *plink_hlist;
++ struct hlist_node *pos;
+ struct pseudo_link *plink, *tmp;
-+ int found, err, cnt;
++ struct au_sphlhead *sphl;
++ int found, err, cnt, i;
+
+ sb = inode->i_sb;
+ sbinfo = au_sbi(sb);
+ AuDebugOn(!au_opt_test(au_mntflags(sb), PLINK));
+ AuDebugOn(au_plink_maint(sb, AuLock_NOPLM));
+
-+ cnt = 0;
-+ found = 0;
-+ plink_list = &sbinfo->si_plink.head;
-+ rcu_read_lock();
-+ list_for_each_entry_rcu(plink, plink_list, list) {
-+ cnt++;
-+ if (plink->inode == inode) {
-+ found = 1;
-+ break;
-+ }
-+ }
-+ rcu_read_unlock();
++ found = au_plink_test(inode);
+ if (found)
+ return;
+
++ i = au_plink_hash(inode->i_ino);
++ sphl = sbinfo->si_plink + i;
++ plink_hlist = &sphl->head;
+ tmp = kmalloc(sizeof(*plink), GFP_NOFS);
+ if (tmp)
+ tmp->inode = au_igrab(inode);
@@ -19731,20 +21566,22 @@
+ goto out;
+ }
+
-+ spin_lock(&sbinfo->si_plink.spin);
-+ list_for_each_entry(plink, plink_list, list) {
++ spin_lock(&sphl->spin);
++ hlist_for_each_entry(plink, pos, plink_hlist, hlist) {
+ if (plink->inode == inode) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found)
-+ list_add_rcu(&tmp->list, plink_list);
-+ spin_unlock(&sbinfo->si_plink.spin);
++ hlist_add_head_rcu(&tmp->hlist, plink_hlist);
++ spin_unlock(&sphl->spin);
+ if (!found) {
-+ cnt++;
-+ WARN_ONCE(cnt > AUFS_PLINK_WARN,
-+ "unexpectedly many pseudo links, %d\n", cnt);
++ cnt = au_sphl_count(sphl);
++#define msg "unexpectedly unblanced or too many pseudo-links"
++ if (cnt > AUFS_PLINK_WARN)
++ AuWarn1(msg ", %d\n", cnt);
++#undef msg
+ err = whplink(h_dentry, inode, bindex, au_sbr(sb, bindex));
+ } else {
+ do_put_plink(tmp, 0);
@@ -19755,7 +21592,7 @@
+ if (unlikely(err)) {
+ pr_warn("err %d, damaged pseudo link.\n", err);
+ if (tmp) {
-+ au_spl_del_rcu(&tmp->list, &sbinfo->si_plink);
++ au_sphl_del_rcu(&tmp->hlist, sphl);
+ call_rcu(&tmp->rcu, do_put_plink_rcu);
+ }
+ }
@@ -19764,9 +21601,11 @@
+/* free all plinks */
+void au_plink_put(struct super_block *sb, int verbose)
+{
++ int i, warned;
+ struct au_sbinfo *sbinfo;
-+ struct list_head *plink_list;
-+ struct pseudo_link *plink, *tmp;
++ struct hlist_head *plink_hlist;
++ struct hlist_node *pos, *tmp;
++ struct pseudo_link *plink;
+
+ SiMustWriteLock(sb);
+
@@ -19774,12 +21613,18 @@
+ AuDebugOn(!au_opt_test(au_mntflags(sb), PLINK));
+ AuDebugOn(au_plink_maint(sb, AuLock_NOPLM));
+
-+ plink_list = &sbinfo->si_plink.head;
+ /* no spin_lock since sbinfo is write-locked */
-+ WARN(verbose && !list_empty(plink_list), "pseudo-link is not flushed");
-+ list_for_each_entry_safe(plink, tmp, plink_list, list)
-+ do_put_plink(plink, 0);
-+ INIT_LIST_HEAD(plink_list);
++ warned = 0;
++ for (i = 0; i < AuPlink_NHASH; i++) {
++ plink_hlist = &sbinfo->si_plink[i].head;
++ if (!warned && verbose && !hlist_empty(plink_hlist)) {
++ pr_warn("pseudo-link is not flushed");
++ warned = 1;
++ }
++ hlist_for_each_entry_safe(plink, pos, tmp, plink_hlist, hlist)
++ do_put_plink(plink, 0);
++ INIT_HLIST_HEAD(plink_hlist);
++ }
+}
+
+void au_plink_clean(struct super_block *sb, int verbose)
@@ -19793,15 +21638,44 @@
+ aufs_write_unlock(root);
+}
+
++static int au_plink_do_half_refresh(struct inode *inode, aufs_bindex_t br_id)
++{
++ int do_put;
++ aufs_bindex_t bstart, bend, bindex;
++
++ do_put = 0;
++ bstart = au_ibstart(inode);
++ bend = au_ibend(inode);
++ if (bstart >= 0) {
++ for (bindex = bstart; bindex <= bend; bindex++) {
++ if (!au_h_iptr(inode, bindex)
++ || au_ii_br_id(inode, bindex) != br_id)
++ continue;
++ au_set_h_iptr(inode, bindex, NULL, 0);
++ do_put = 1;
++ break;
++ }
++ if (do_put)
++ for (bindex = bstart; bindex <= bend; bindex++)
++ if (au_h_iptr(inode, bindex)) {
++ do_put = 0;
++ break;
++ }
++ } else
++ do_put = 1;
++
++ return do_put;
++}
++
+/* free the plinks on a branch specified by @br_id */
+void au_plink_half_refresh(struct super_block *sb, aufs_bindex_t br_id)
+{
+ struct au_sbinfo *sbinfo;
-+ struct list_head *plink_list;
-+ struct pseudo_link *plink, *tmp;
++ struct hlist_head *plink_hlist;
++ struct hlist_node *pos, *tmp;
++ struct pseudo_link *plink;
+ struct inode *inode;
-+ aufs_bindex_t bstart, bend, bindex;
-+ unsigned char do_put;
++ int i, do_put;
+
+ SiMustWriteLock(sb);
+
@@ -19809,37 +21683,18 @@
+ AuDebugOn(!au_opt_test(au_mntflags(sb), PLINK));
+ AuDebugOn(au_plink_maint(sb, AuLock_NOPLM));
+
-+ plink_list = &sbinfo->si_plink.head;
+ /* no spin_lock since sbinfo is write-locked */
-+ list_for_each_entry_safe(plink, tmp, plink_list, list) {
-+ do_put = 0;
-+ inode = au_igrab(plink->inode);
-+ ii_write_lock_child(inode);
-+ bstart = au_ibstart(inode);
-+ bend = au_ibend(inode);
-+ if (bstart >= 0) {
-+ for (bindex = bstart; bindex <= bend; bindex++) {
-+ if (!au_h_iptr(inode, bindex)
-+ || au_ii_br_id(inode, bindex) != br_id)
-+ continue;
-+ au_set_h_iptr(inode, bindex, NULL, 0);
-+ do_put = 1;
-+ break;
-+ }
-+ } else
-+ do_put_plink(plink, 1);
-+
-+ if (do_put) {
-+ for (bindex = bstart; bindex <= bend; bindex++)
-+ if (au_h_iptr(inode, bindex)) {
-+ do_put = 0;
-+ break;
-+ }
++ for (i = 0; i < AuPlink_NHASH; i++) {
++ plink_hlist = &sbinfo->si_plink[i].head;
++ hlist_for_each_entry_safe(plink, pos, tmp, plink_hlist, hlist) {
++ inode = au_igrab(plink->inode);
++ ii_write_lock_child(inode);
++ do_put = au_plink_do_half_refresh(inode, br_id);
+ if (do_put)
+ do_put_plink(plink, 1);
++ ii_write_unlock(inode);
++ iput(inode);
+ }
-+ ii_write_unlock(inode);
-+ iput(inode);
+ }
+}
--- a/fs/aufs/poll.c 1970-01-01 01:00:00.000000000 +0100
@@ -20653,8 +22508,8 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_RWSEM_H__ */
--- a/fs/aufs/sbinfo.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/sbinfo.c 2013-03-10 01:48:58.463093058 +0000
-@@ -0,0 +1,343 @@
++++ b/fs/aufs/sbinfo.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,346 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -20684,11 +22539,13 @@
+ */
+void au_si_free(struct kobject *kobj)
+{
++ int i;
+ struct au_sbinfo *sbinfo;
+ char *locked __maybe_unused; /* debug only */
+
+ sbinfo = container_of(kobj, struct au_sbinfo, si_kobj);
-+ AuDebugOn(!list_empty(&sbinfo->si_plink.head));
++ for (i = 0; i < AuPlink_NHASH; i++)
++ AuDebugOn(!hlist_empty(&sbinfo->si_plink[i].head));
+ AuDebugOn(atomic_read(&sbinfo->si_nowait.nw_len));
+
+ au_rw_write_lock(&sbinfo->si_rwsem);
@@ -20710,7 +22567,7 @@
+
+int au_si_alloc(struct super_block *sb)
+{
-+ int err;
++ int err, i;
+ struct au_sbinfo *sbinfo;
+ static struct lock_class_key aufs_si;
+
@@ -20763,7 +22620,8 @@
+ sbinfo->si_rdhash = AUFS_RDHASH_DEF;
+ sbinfo->si_dirwh = AUFS_DIRWH_DEF;
+
-+ au_spl_init(&sbinfo->si_plink);
++ for (i = 0; i < AuPlink_NHASH; i++)
++ au_sphl_init(sbinfo->si_plink + i);
+ init_waitqueue_head(&sbinfo->si_plink_wq);
+ spin_lock_init(&sbinfo->si_plink_maint_lock);
+
@@ -20999,8 +22857,8 @@
+ spin_unlock(&sbinfo->au_si_pid.tree_lock);
+}
--- a/fs/aufs/spl.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/spl.h 2013-03-10 01:48:58.463093058 +0000
-@@ -0,0 +1,62 @@
++++ b/fs/aufs/spl.h 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -21061,10 +22919,60 @@
+ spin_unlock(&spl->spin);
+}
+
++/* ---------------------------------------------------------------------- */
++
++struct au_sphlhead {
++ spinlock_t spin;
++ struct hlist_head head;
++};
++
++static inline void au_sphl_init(struct au_sphlhead *sphl)
++{
++ spin_lock_init(&sphl->spin);
++ INIT_HLIST_HEAD(&sphl->head);
++}
++
++static inline void au_sphl_add(struct hlist_node *hlist,
++ struct au_sphlhead *sphl)
++{
++ spin_lock(&sphl->spin);
++ hlist_add_head(hlist, &sphl->head);
++ spin_unlock(&sphl->spin);
++}
++
++static inline void au_sphl_del(struct hlist_node *hlist,
++ struct au_sphlhead *sphl)
++{
++ spin_lock(&sphl->spin);
++ hlist_del(hlist);
++ spin_unlock(&sphl->spin);
++}
++
++static inline void au_sphl_del_rcu(struct hlist_node *hlist,
++ struct au_sphlhead *sphl)
++{
++ spin_lock(&sphl->spin);
++ hlist_del_rcu(hlist);
++ spin_unlock(&sphl->spin);
++}
++
++static inline unsigned long au_sphl_count(struct au_sphlhead *sphl)
++{
++ unsigned long cnt;
++ struct hlist_node *pos;
++
++ cnt = 0;
++ spin_lock(&sphl->spin);
++ hlist_for_each(pos, &sphl->head)
++ cnt++;
++ spin_unlock(&sphl->spin);
++ return cnt;
++}
++
+#endif /* __KERNEL__ */
+#endif /* __AUFS_SPL_H__ */
--- a/fs/aufs/super.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/super.c 2013-05-04 18:39:11.239157326 +0100
++++ b/fs/aufs/super.c 2013-05-09 01:36:20.745181631 +0100
@@ -0,0 +1,993 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
@@ -21172,7 +23080,7 @@
+ hdp = au_di(sb->s_root)->di_hdentry;
+ for (bindex = 0; !err && bindex <= bend; bindex++) {
+ br = au_sbr(sb, bindex);
-+ path.mnt = br->br_mnt;
++ path.mnt = au_br_mnt(br);
+ path.dentry = hdp[bindex].hd_dentry;
+ err = au_seq_path(seq, &path);
+ if (err > 0) {
@@ -22060,8 +23968,8 @@
+ .owner = THIS_MODULE,
+};
--- a/fs/aufs/super.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/super.h 2013-03-10 01:48:58.463093058 +0000
-@@ -0,0 +1,538 @@
++++ b/fs/aufs/super.h 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,555 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -22119,6 +24027,20 @@
+ unsigned long long mfsrr_watermark;
+};
+
++struct pseudo_link {
++ union {
++ struct hlist_node hlist;
++ struct rcu_head rcu;
++ };
++ struct inode *inode;
++};
++
++#define AuPlink_NHASH 100
++static inline int au_plink_hash(ino_t ino)
++{
++ return ino % AuPlink_NHASH;
++}
++
+struct au_branch;
+struct au_sbinfo {
+ /* nowait tasks in the system-wide workqueue */
@@ -22209,7 +24131,7 @@
+ /* int si_rendir; */
+
+ /* pseudo_link list */
-+ struct au_splhead si_plink;
++ struct au_sphlhead si_plink[AuPlink_NHASH];
+ wait_queue_head_t si_plink_wq;
+ spinlock_t si_plink_maint_lock;
+ pid_t si_plink_maint_pid;
@@ -22222,7 +24144,9 @@
+ */
+ struct kobject si_kobj;
+#ifdef CONFIG_DEBUG_FS
-+ struct dentry *si_dbgaufs, *si_dbgaufs_xib;
++ struct dentry *si_dbgaufs;
++ struct dentry *si_dbgaufs_plink;
++ struct dentry *si_dbgaufs_xib;
+#ifdef CONFIG_AUFS_EXPORT
+ struct dentry *si_dbgaufs_xigen;
+#endif
@@ -22413,6 +24337,7 @@
+ /* AuRwMustWriteLock(&sbinfo->si_rwsem); */
+#ifdef CONFIG_DEBUG_FS
+ sbinfo->si_dbgaufs = NULL;
++ sbinfo->si_dbgaufs_plink = NULL;
+ sbinfo->si_dbgaufs_xib = NULL;
+#ifdef CONFIG_AUFS_EXPORT
+ sbinfo->si_dbgaufs_xigen = NULL;
@@ -22816,7 +24741,7 @@
+#endif /* __KERNEL__ */
+#endif /* __SYSAUFS_H__ */
--- a/fs/aufs/sysfs.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/sysfs.c 2013-03-10 01:48:58.463093058 +0000
++++ b/fs/aufs/sysfs.c 2013-05-09 01:36:20.745181631 +0100
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
@@ -22912,7 +24837,7 @@
+ root = sb->s_root;
+ di_read_lock_parent(root, !AuLock_IR);
+ br = au_sbr(sb, bindex);
-+ path.mnt = br->br_mnt;
++ path.mnt = au_br_mnt(br);
+ path.dentry = au_h_dptr(root, bindex);
+ au_seq_path(seq, &path);
+ di_read_unlock(root, !AuLock_IR);
@@ -24890,8 +26815,8 @@
+ return err;
+}
--- a/fs/aufs/vfsub.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/vfsub.h 2013-05-04 18:39:17.031157464 +0100
-@@ -0,0 +1,302 @@
++++ b/fs/aufs/vfsub.h 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,289 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -24997,19 +26922,6 @@
+
+/* ---------------------------------------------------------------------- */
+
-+/* cf. i_[ug]id_read() in linux/include/fs.h */
-+static inline uid_t vfsub_ia_uid(struct iattr *ia)
-+{
-+ return from_kuid(&init_user_ns, ia->ia_uid);
-+}
-+
-+static inline gid_t vfsub_ia_gid(struct iattr *ia)
-+{
-+ return from_kgid(&init_user_ns, ia->ia_gid);
-+}
-+
-+/* ---------------------------------------------------------------------- */
-+
+int vfsub_update_h_iattr(struct path *h_path, int *did);
+struct file *vfsub_dentry_open(struct path *path, int flags);
+struct file *vfsub_filp_open(const char *path, int oflags, int mode);
@@ -25195,8 +27107,8 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_VFSUB_H__ */
--- a/fs/aufs/wbr_policy.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/wbr_policy.c 2013-03-10 01:48:58.463093058 +0000
-@@ -0,0 +1,700 @@
++++ b/fs/aufs/wbr_policy.c 2013-05-09 01:36:20.745181631 +0100
+@@ -0,0 +1,701 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -25236,7 +27148,7 @@
+ ia.ia_uid = h_isrc->i_uid;
+ ia.ia_gid = h_isrc->i_gid;
+ sbits = !!(ia.ia_mode & (S_ISUID | S_ISGID));
-+ au_cpup_attr_flags(h_path->dentry->d_inode, h_isrc);
++ au_cpup_attr_flags(h_path->dentry->d_inode, h_isrc->i_flags);
+ err = vfsub_sio_notify_change(h_path, &ia);
+
+ /* is this nfs only? */
@@ -25296,7 +27208,7 @@
+
+ err = 0;
+ if (h_path.dentry->d_inode) {
-+ h_path.mnt = br->br_mnt;
++ h_path.mnt = au_br_mnt(br);
+ err = au_wh_unlink_dentry(au_h_iptr(dir, bdst), &h_path,
+ dentry);
+ }
@@ -25307,6 +27219,7 @@
+}
+
+static int au_cpdown_dir(struct dentry *dentry, aufs_bindex_t bdst,
++ struct au_pin *pin,
+ struct dentry *h_parent, void *arg)
+{
+ int err, rerr;
@@ -25324,7 +27237,7 @@
+ AuDebugOn(h_dir != au_h_iptr(dir, bdst));
+ IMustLock(h_dir);
+
-+ err = au_lkup_neg(dentry, bdst);
++ err = au_lkup_neg(dentry, bdst, /*wh*/0);
+ if (unlikely(err < 0))
+ goto out;
+ h_path.dentry = au_h_dptr(dentry, bdst);
@@ -25630,7 +27543,7 @@
+ continue;
+
+ /* sb->s_root for NFS is unreliable */
-+ h_path.mnt = br->br_mnt;
++ h_path.mnt = au_br_mnt(br);
+ h_path.dentry = h_path.mnt->mnt_root;
+ err = vfs_statfs(&h_path, st);
+ if (unlikely(err)) {
@@ -25898,8 +27811,8 @@
+ }
+};
--- a/fs/aufs/whout.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/whout.c 2013-05-04 18:39:11.239157326 +0100
-@@ -0,0 +1,1042 @@
++++ b/fs/aufs/whout.c 2013-05-09 01:36:20.749181631 +0100
+@@ -0,0 +1,1023 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -26076,7 +27989,7 @@
+{
+ int err;
+ struct path h_path = {
-+ .mnt = br->br_mnt
++ .mnt = au_br_mnt(br)
+ };
+ struct inode *h_dir;
+ struct dentry *h_parent;
@@ -26135,7 +28048,7 @@
+{
+ int err;
+ struct path h_path = {
-+ .mnt = br->br_mnt
++ .mnt = au_br_mnt(br)
+ };
+
+ err = 0;
@@ -26165,14 +28078,10 @@
+ if (!whpath->dentry->d_inode)
+ return;
+
-+ err = vfsub_mnt_want_write(whpath->mnt);
-+ if (!err) {
-+ if (isdir)
-+ err = vfsub_rmdir(h_dir, whpath);
-+ else
-+ err = vfsub_unlink(h_dir, whpath, /*force*/0);
-+ vfsub_mnt_drop_write(whpath->mnt);
-+ }
++ if (isdir)
++ err = vfsub_rmdir(h_dir, whpath);
++ else
++ err = vfsub_unlink(h_dir, whpath, /*force*/0);
+ if (unlikely(err))
+ pr_warn("failed removing %.*s (%d), ignored.\n",
+ AuDLNPair(whpath->dentry), err);
@@ -26201,11 +28110,7 @@
+
+ if (au_test_nfs(path->dentry->d_sb))
+ mode |= S_IXUGO;
-+ err = vfsub_mnt_want_write(path->mnt);
-+ if (!err) {
-+ err = vfsub_mkdir(h_dir, path, mode);
-+ vfsub_mnt_drop_write(path->mnt);
-+ }
++ err = vfsub_mkdir(h_dir, path, mode);
+ } else if (S_ISDIR(path->dentry->d_inode->i_mode))
+ err = 0;
+ else
@@ -26299,13 +28204,8 @@
+ err = -EEXIST;
+ h_dir = h_root->d_inode;
+ if (!base[AuBrWh_BASE].dentry->d_inode) {
-+ err = vfsub_mnt_want_write(h_path->mnt);
-+ if (!err) {
-+ h_path->dentry = base[AuBrWh_BASE].dentry;
-+ err = vfsub_create(h_dir, h_path, WH_MASK,
-+ /*want_excl*/true);
-+ vfsub_mnt_drop_write(h_path->mnt);
-+ }
++ h_path->dentry = base[AuBrWh_BASE].dentry;
++ err = vfsub_create(h_dir, h_path, WH_MASK, /*want_excl*/true);
+ } else if (S_ISREG(base[AuBrWh_BASE].dentry->d_inode->i_mode))
+ err = 0;
+ else
@@ -26337,16 +28237,14 @@
+/*
+ * initialize the whiteout base file/dir for @br.
+ */
-+int au_wh_init(struct dentry *h_root, struct au_branch *br,
-+ struct super_block *sb)
++int au_wh_init(struct au_branch *br, struct super_block *sb)
+{
+ int err, i;
+ const unsigned char do_plink
+ = !!au_opt_test(au_mntflags(sb), PLINK);
-+ struct path path = {
-+ .mnt = br->br_mnt
-+ };
+ struct inode *h_dir;
++ struct path path = br->br_path;
++ struct dentry *h_root = path.dentry;
+ struct au_wbr *wbr = br->br_wbr;
+ static const struct qstr base_name[] = {
+ [AuBrWh_BASE] = QSTR_INIT(AUFS_BASE_NAME,
@@ -26460,19 +28358,16 @@
+ dir = a->sb->s_root->d_inode;
+ hdir = au_hi(dir, bindex);
+ h_root = au_h_dptr(a->sb->s_root, bindex);
++ AuDebugOn(h_root != au_br_dentry(a->br));
+
+ au_hn_imtx_lock_nested(hdir, AuLsc_I_PARENT);
+ wbr_wh_write_lock(wbr);
+ err = au_h_verify(wbr->wbr_whbase, au_opt_udba(a->sb), hdir->hi_inode,
+ h_root, a->br);
+ if (!err) {
-+ err = vfsub_mnt_want_write(a->br->br_mnt);
-+ if (!err) {
-+ h_path.dentry = wbr->wbr_whbase;
-+ h_path.mnt = a->br->br_mnt;
-+ err = vfsub_unlink(hdir->hi_inode, &h_path, /*force*/0);
-+ vfsub_mnt_drop_write(a->br->br_mnt);
-+ }
++ h_path.dentry = wbr->wbr_whbase;
++ h_path.mnt = au_br_mnt(a->br);
++ err = vfsub_unlink(hdir->hi_inode, &h_path, /*force*/0);
+ } else {
+ pr_warn("%.*s is moved, ignored\n",
+ AuDLNPair(wbr->wbr_whbase));
@@ -26481,7 +28376,7 @@
+ dput(wbr->wbr_whbase);
+ wbr->wbr_whbase = NULL;
+ if (!err)
-+ err = au_wh_init(h_root, a->br, a->sb);
++ err = au_wh_init(a->br, a->sb);
+ wbr_wh_write_unlock(wbr);
+ au_hn_imtx_unlock(hdir);
+ di_read_unlock(a->sb->s_root, AuLock_IR);
@@ -26552,7 +28447,7 @@
+ IMustLock(h_dir);
+
+ br = au_sbr(sb, bindex);
-+ h_path.mnt = br->br_mnt;
++ h_path.mnt = au_br_mnt(br);
+ wbr = br->br_wbr;
+ wbr_wh_read_lock(wbr);
+ if (wbr->wbr_whbase) {
@@ -26601,7 +28496,7 @@
+ } else {
+ struct path tmp = {
+ .dentry = opq_dentry,
-+ .mnt = br->br_mnt
++ .mnt = au_br_mnt(br)
+ };
+ err = do_unlink_wh(au_h_iptr(dentry->d_inode, bindex), &tmp);
+ if (!err)
@@ -26853,7 +28748,7 @@
+
+ if (!err) {
+ h_tmp.dentry = wh_dentry;
-+ h_tmp.mnt = br->br_mnt;
++ h_tmp.mnt = au_br_mnt(br);
+ err = vfsub_rmdir(h_dir, &h_tmp);
+ }
+
@@ -26897,21 +28792,20 @@
+ h_parent = dget_parent(a->wh_dentry);
+ h_dir = h_parent->d_inode;
+ hdir = au_hi(a->dir, bindex);
++ err = vfsub_mnt_want_write(au_br_mnt(a->br));
++ if (unlikely(err))
++ goto out_mnt;
+ au_hn_imtx_lock_nested(hdir, AuLsc_I_PARENT);
+ err = au_h_verify(a->wh_dentry, au_opt_udba(sb), h_dir, h_parent,
+ a->br);
-+ if (!err) {
-+ err = vfsub_mnt_want_write(a->br->br_mnt);
-+ if (!err) {
-+ err = au_whtmp_rmdir(a->dir, bindex, a->wh_dentry,
-+ &a->whlist);
-+ vfsub_mnt_drop_write(a->br->br_mnt);
-+ }
-+ }
++ if (!err)
++ err = au_whtmp_rmdir(a->dir, bindex, a->wh_dentry, &a->whlist);
+ au_hn_imtx_unlock(hdir);
++ vfsub_mnt_drop_write(au_br_mnt(a->br));
++
++out_mnt:
+ dput(h_parent);
+ ii_write_unlock(a->dir);
-+
+out:
+ /* mutex_unlock(&a->dir->i_mutex); */
+ au_whtmp_rmdir_free(a);
@@ -26943,8 +28837,8 @@
+ }
+}
--- a/fs/aufs/whout.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/whout.h 2013-03-10 01:48:58.463093058 +0000
-@@ -0,0 +1,88 @@
++++ b/fs/aufs/whout.h 2013-05-09 01:36:20.749181631 +0100
+@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -26985,8 +28879,7 @@
+int au_whtmp_ren(struct dentry *h_dentry, struct au_branch *br);
+int au_wh_unlink_dentry(struct inode *h_dir, struct path *h_path,
+ struct dentry *dentry);
-+int au_wh_init(struct dentry *h_parent, struct au_branch *br,
-+ struct super_block *sb);
++int au_wh_init(struct au_branch *br, struct super_block *sb);
+
+/* diropq flags */
+#define AuDiropq_CREATE 1
@@ -27346,7 +29239,7 @@
+#endif /* __KERNEL__ */
+#endif /* __AUFS_WKQ_H__ */
--- a/fs/aufs/xino.c 1970-01-01 01:00:00.000000000 +0100
-+++ b/fs/aufs/xino.c 2013-05-04 18:39:11.239157326 +0100
++++ b/fs/aufs/xino.c 2013-05-09 01:36:20.749181631 +0100
@@ -0,0 +1,1265 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
@@ -27619,12 +29512,12 @@
+ fput(file);
+ br->br_xino.xi_file = new_xino;
+
-+ h_sb = br->br_mnt->mnt_sb;
++ h_sb = au_br_sb(br);
+ for (bi = 0; bi <= bend; bi++) {
+ if (unlikely(bi == bindex))
+ continue;
+ br = au_sbr(sb, bi);
-+ if (br->br_mnt->mnt_sb != h_sb)
++ if (au_br_sb(br) != h_sb)
+ continue;
+
+ fput(br->br_xino.xi_file);
@@ -27759,7 +29652,7 @@
+ h_ino, ino);
+ if (!err) {
+ if (au_opt_test(mnt_flags, TRUNC_XINO)
-+ && au_test_fs_trunc_xino(br->br_mnt->mnt_sb))
++ && au_test_fs_trunc_xino(au_br_sb(br)))
+ xino_try_trunc(sb, br);
+ return 0; /* success */
+ }
@@ -27912,7 +29805,7 @@
+ err = au_xino_do_write(xwrite, br->br_xino.xi_file,
+ h_inode->i_ino, /*ino*/0);
+ if (!err && try_trunc
-+ && au_test_fs_trunc_xino(br->br_mnt->mnt_sb))
++ && au_test_fs_trunc_xino(au_br_sb(br)))
+ xino_try_trunc(sb, br);
+ }
+}
@@ -28119,10 +30012,10 @@
+ shared_br = NULL;
+ bend = au_sbend(sb);
+ if (do_test) {
-+ tgt_sb = br->br_mnt->mnt_sb;
++ tgt_sb = au_br_sb(br);
+ for (bindex = 0; bindex <= bend; bindex++) {
+ b = au_sbr(sb, bindex);
-+ if (tgt_sb == b->br_mnt->mnt_sb) {
++ if (tgt_sb == au_br_sb(b)) {
+ shared_br = b;
+ break;
+ }
@@ -28551,7 +30444,7 @@
+ for (bindex = 0; bindex <= bend; bindex++) {
+ br = au_sbr(sb, bindex);
+ if (au_br_writable(br->br_perm)
-+ && !au_test_fs_bad_xino(br->br_mnt->mnt_sb)) {
++ && !au_test_fs_bad_xino(au_br_sb(br))) {
+ bwr = bindex;
+ break;
+ }
@@ -28562,7 +30455,7 @@
+ page = (void *)__get_free_page(GFP_NOFS);
+ if (unlikely(!page))
+ goto out;
-+ path.mnt = br->br_mnt;
++ path.mnt = au_br_mnt(br);
+ path.dentry = au_h_dptr(sb->s_root, bwr);
+ p = d_path(&path, page, PATH_MAX - sizeof(AUFS_XINO_FNAME));
+ file = (void *)p;
@@ -28636,8 +30529,8 @@
+
+#include <uapi/linux/aufs_type.h>
--- a/include/uapi/linux/aufs_type.h 1970-01-01 01:00:00.000000000 +0100
-+++ b/include/uapi/linux/aufs_type.h 2013-05-04 18:39:17.031157464 +0100
-@@ -0,0 +1,234 @@
++++ b/include/uapi/linux/aufs_type.h 2013-05-09 01:36:20.749181631 +0100
+@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2005-2013 Junjiro R. Okajima
+ *
@@ -28680,7 +30573,7 @@
+
+#include <linux/limits.h>
+
-+#define AUFS_VERSION "3.8-20130325"
++#define AUFS_VERSION "3.8-20130506"
+
+/* todo? move this to linux-2.6.19/include/magic.h */
+#define AUFS_SUPER_MAGIC ('a' << 24 | 'u' << 16 | 'f' << 8 | 's')
@@ -28717,7 +30610,7 @@
+#define AUFS_WH_PFX ".wh."
+#define AUFS_WH_PFX_LEN ((int)sizeof(AUFS_WH_PFX) - 1)
+#define AUFS_WH_TMP_LEN 4
-+/* a limit for rmdir/rename a dir */
++/* a limit for rmdir/rename a dir and copyup */
+#define AUFS_MAX_NAMELEN (NAME_MAX \
+ - AUFS_WH_PFX_LEN * 2 /* doubly whiteouted */\
+ - 1 /* dot */\
@@ -28734,7 +30627,7 @@
+#define AUFS_WKQ_NAME AUFS_NAME "d"
+#define AUFS_MFS_DEF_SEC 30 /* seconds */
+#define AUFS_MFS_MAX_SEC 3600 /* seconds */
-+#define AUFS_PLINK_WARN 100 /* number of plinks */
++#define AUFS_PLINK_WARN 50 /* number of plinks in a single bucket */
+
+/* pseudo-link maintenace under /proc */
+#define AUFS_PLINK_MAINT_NAME "plink_maint"
@@ -28759,6 +30652,7 @@
+#define AUFS_BRPERM_RR "rr"
+#define AUFS_BRRATTR_WH "wh"
+#define AUFS_BRWATTR_NLWH "nolwh"
++#define AUFS_BRATTR_UNPIN "unpin"
+
+/* ---------------------------------------------------------------------- */
+
Modified: dists/trunk/linux/debian/patches/features/all/aufs3/gen-patch
==============================================================================
--- dists/trunk/linux/debian/patches/features/all/aufs3/gen-patch Sun May 12 00:45:33 2013 (r20078)
+++ dists/trunk/linux/debian/patches/features/all/aufs3/gen-patch Sun May 12 00:53:14 2013 (r20079)
@@ -9,7 +9,8 @@
{
cd "$aufs_dir" && \
- { find fs -type f; ls include/{uapi/,}linux/aufs_type.h; } | \
+ { find Documentation fs -type f; \
+ ls include/{uapi/,}linux/aufs_type.h; } | \
LC_ALL=C sort | \
while read file; do
diff -uN a/"$file" "$file" | filterdiff --addnewprefix=b/
More information about the Kernel-svn-changes
mailing list