]> git.pld-linux.org Git - packages/kernel.git/blobdiff - kernel-aufs3.patch
- disable user mode setting (DEPRECATED) on i915
[packages/kernel.git] / kernel-aufs3.patch
index 4f6f4aee7bda7925eca08653fe20f771b2bb7f48..1295576347d9f4d017c28f66e6e044a4fd51a9da 100644 (file)
@@ -1,10 +1,10 @@
-aufs3.x-rcN kbuild patch
+aufs3.14 kbuild patch
 
 diff --git a/fs/Kconfig b/fs/Kconfig
-index c229f82..397b473 100644
+index 7385e54..d5c769c 100644
 --- a/fs/Kconfig
 +++ b/fs/Kconfig
-@@ -212,6 +212,7 @@ source "fs/ufs/Kconfig"
+@@ -208,6 +208,7 @@ source "fs/ufs/Kconfig"
  source "fs/exofs/Kconfig"
  source "fs/f2fs/Kconfig"
  source "fs/efivarfs/Kconfig"
@@ -13,16 +13,16 @@ index c229f82..397b473 100644
  endif # MISC_FILESYSTEMS
  
 diff --git a/fs/Makefile b/fs/Makefile
-index 4fe6df3..4a57676 100644
+index 47ac07b..0c6a294 100644
 --- a/fs/Makefile
 +++ b/fs/Makefile
-@@ -126,3 +126,4 @@ obj-y                              += exofs/ # Multiple modules
+@@ -125,3 +125,4 @@ obj-y                              += exofs/ # Multiple modules
  obj-$(CONFIG_CEPH_FS)         += ceph/
  obj-$(CONFIG_PSTORE)          += pstore/
  obj-$(CONFIG_EFIVAR_FS)               += efivarfs/
 +obj-$(CONFIG_AUFS_FS)           += aufs/
 diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
-index ab5d499..ed438c0 100644
+index 3ce25b5..9faebdc 100644
 --- a/include/uapi/linux/Kbuild
 +++ b/include/uapi/linux/Kbuild
 @@ -56,6 +56,7 @@ header-y += atmppp.h
@@ -33,26 +33,42 @@ index ab5d499..ed438c0 100644
  header-y += auto_fs.h
  header-y += auto_fs4.h
  header-y += auxvec.h
-aufs3.x-rcN base patch
+aufs3.14 base patch
 
-diff --git a/fs/file_table.c b/fs/file_table.c
-index 485dc0e..8db8096 100644
---- a/fs/file_table.c
-+++ b/fs/file_table.c
-@@ -36,7 +36,7 @@ struct files_stat_struct files_stat = {
-       .max_files = NR_FILE
- };
+diff --git a/drivers/block/loop.c b/drivers/block/loop.c
+index 66e8c3b..ec278ac 100644
+--- a/drivers/block/loop.c
++++ b/drivers/block/loop.c
+@@ -692,6 +692,24 @@ static inline int is_loop_device(struct file *file)
+       return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
+ }
  
--DEFINE_STATIC_LGLOCK(files_lglock);
-+DEFINE_LGLOCK(files_lglock);
++/*
++ * for AUFS
++ * no get/put for file.
++ */
++struct file *loop_backing_file(struct super_block *sb)
++{
++      struct file *ret;
++      struct loop_device *l;
++
++      ret = NULL;
++      if (MAJOR(sb->s_dev) == LOOP_MAJOR) {
++              l = sb->s_bdev->bd_disk->private_data;
++              ret = l->lo_backing_file;
++      }
++      return ret;
++}
++EXPORT_SYMBOL(loop_backing_file);
++
+ /* loop sysfs attributes */
  
- /* SLAB cache for file structures */
- static struct kmem_cache *filp_cachep __read_mostly;
+ static ssize_t loop_attr_show(struct device *dev, char *page,
 diff --git a/fs/inode.c b/fs/inode.c
-index 00d5fc3..f324521 100644
+index 4bcdad3..bc83168 100644
 --- a/fs/inode.c
 +++ b/fs/inode.c
-@@ -1498,7 +1498,7 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
+@@ -1497,7 +1497,7 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
   * This does the actual work of updating an inodes time or version.  Must have
   * had called mnt_want_write() before calling this.
   */
@@ -62,10 +78,10 @@ index 00d5fc3..f324521 100644
        if (inode->i_op->update_time)
                return inode->i_op->update_time(inode, time, flags);
 diff --git a/fs/splice.c b/fs/splice.c
-index 9eca476..4ba1844 100644
+index 12028fa..f26cbaf 100644
 --- a/fs/splice.c
 +++ b/fs/splice.c
-@@ -1093,8 +1093,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
+@@ -1111,8 +1111,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
  /*
   * Attempt to initiate a splice from pipe to file.
   */
@@ -76,7 +92,7 @@ index 9eca476..4ba1844 100644
  {
        ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
                                loff_t *, size_t, unsigned int);
-@@ -1124,9 +1124,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+@@ -1128,9 +1128,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
  /*
   * Attempt to initiate a splice from a file to a pipe.
   */
@@ -90,10 +106,10 @@ index 9eca476..4ba1844 100644
        ssize_t (*splice_read)(struct file *, loff_t *,
                               struct pipe_inode_info *, size_t, unsigned int);
 diff --git a/include/linux/fs.h b/include/linux/fs.h
-index 65c2be2..0148214 100644
+index 23b2a35..f3f635c 100644
 --- a/include/linux/fs.h
 +++ b/include/linux/fs.h
-@@ -2574,6 +2574,7 @@ extern int inode_change_ok(const struct inode *, struct iattr *);
+@@ -2669,6 +2669,7 @@ extern int inode_change_ok(const struct inode *, struct iattr *);
  extern int inode_newsize_ok(const struct inode *, loff_t offset);
  extern void setattr_copy(struct inode *inode, const struct iattr *attr);
  
@@ -102,10 +118,10 @@ index 65c2be2..0148214 100644
  
  extern int generic_show_options(struct seq_file *m, struct dentry *root);
 diff --git a/include/linux/splice.h b/include/linux/splice.h
-index 74575cb..bfc6fb6 100644
+index 0e43906..304169e 100644
 --- a/include/linux/splice.h
 +++ b/include/linux/splice.h
-@@ -92,4 +92,10 @@ extern void splice_shrink_spd(struct splice_pipe_desc *);
+@@ -93,4 +93,10 @@ extern void splice_shrink_spd(struct splice_pipe_desc *);
  extern void spd_release_page(struct splice_pipe_desc *, unsigned int);
  
  extern const struct pipe_buf_operations page_cache_pipe_buf_ops;
@@ -116,34 +132,404 @@ index 74575cb..bfc6fb6 100644
 +                       struct pipe_inode_info *pipe, size_t len,
 +                       unsigned int flags);
  #endif
-aufs3.x-rcN standalone patch
+aufs3.14 mmap patch
 
-diff --git a/fs/file_table.c b/fs/file_table.c
-index 8db8096..e271e28 100644
---- a/fs/file_table.c
-+++ b/fs/file_table.c
-@@ -37,6 +37,7 @@ struct files_stat_struct files_stat = {
- };
+diff --git a/fs/buffer.c b/fs/buffer.c
+index 27265a8..75427a6 100644
+--- a/fs/buffer.c
++++ b/fs/buffer.c
+@@ -2448,7 +2448,7 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
+        * Update file times before taking page lock. We may end up failing the
+        * fault so this update may be superfluous but who really cares...
+        */
+-      file_update_time(vma->vm_file);
++      vma_file_update_time(vma);
  
- DEFINE_LGLOCK(files_lglock);
-+EXPORT_SYMBOL(files_lglock);
+       ret = __block_page_mkwrite(vma, vmf, get_block);
+       sb_end_pagefault(sb);
+diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
+index d4a3574..e44a744 100644
+--- a/fs/proc/nommu.c
++++ b/fs/proc/nommu.c
+@@ -45,7 +45,9 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
+       file = region->vm_file;
  
- /* SLAB cache for file structures */
- static struct kmem_cache *filp_cachep __read_mostly;
-@@ -405,6 +406,8 @@ void file_sb_list_del(struct file *file)
+       if (file) {
+-              struct inode *inode = file_inode(region->vm_file);
++              struct inode *inode;
++              file = vmr_pr_or_file(region);
++              inode = file_inode(file);
+               dev = inode->i_sb->s_dev;
+               ino = inode->i_ino;
        }
+diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
+index fb52b54..1aca72e 100644
+--- a/fs/proc/task_mmu.c
++++ b/fs/proc/task_mmu.c
+@@ -264,7 +264,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
+       const char *name = NULL;
+       if (file) {
+-              struct inode *inode = file_inode(vma->vm_file);
++              struct inode *inode;
++              file = vma_pr_or_file(vma);
++              inode = file_inode(file);
+               dev = inode->i_sb->s_dev;
+               ino = inode->i_ino;
+               pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
+@@ -1407,6 +1409,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
+       seq_printf(m, "%08lx %s", vma->vm_start, buffer);
+       if (file) {
++              file = vma_pr_or_file(vma);
+               seq_printf(m, " file=");
+               seq_path(m, &file->f_path, "\n\t= ");
+       } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
+diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
+index 678455d..ad0ce45 100644
+--- a/fs/proc/task_nommu.c
++++ b/fs/proc/task_nommu.c
+@@ -141,7 +141,9 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
+       file = vma->vm_file;
+       if (file) {
+-              struct inode *inode = file_inode(vma->vm_file);
++              struct inode *inode;
++              file = vma_pr_or_file(file);
++              inode = file_inode(file);
+               dev = inode->i_sb->s_dev;
+               ino = inode->i_ino;
+               pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
+diff --git a/include/linux/mm.h b/include/linux/mm.h
+index c1b7414..02036e0 100644
+--- a/include/linux/mm.h
++++ b/include/linux/mm.h
+@@ -18,6 +18,9 @@
+ #include <linux/pfn.h>
+ #include <linux/bit_spinlock.h>
+ #include <linux/shrinker.h>
++#include <linux/dcache.h>
++#include <linux/file.h>
++#include <linux/fs.h>
+ struct mempolicy;
+ struct anon_vma;
+@@ -1152,6 +1155,87 @@ static inline int fixup_user_fault(struct task_struct *tsk,
  }
+ #endif
  
-+EXPORT_SYMBOL(file_sb_list_del);
++/*
++ * Mainly for aufs which mmap(2) diffrent file and wants to print different path
++ * in /proc/PID/maps.
++ */
++/* #define AUFS_DEBUG_MMAP */
++static inline void aufs_trace(struct file *f, struct file *pr,
++                            const char func[], int line, const char func2[])
++{
++#ifdef AUFS_DEBUG_MMAP
++      if (pr)
++              pr_info("%s:%d: %s, %p\n", func, line, func2,
++                      f ? (char *)f->f_dentry->d_name.name : "(null)");
++#endif
++}
++
++static inline struct file *vmr_do_pr_or_file(struct vm_region *region,
++                                           const char func[], int line)
++{
++      struct file *f = region->vm_file, *pr = region->vm_prfile;
++      aufs_trace(f, pr, func, line, __func__);
++      return (f && pr) ? pr : f;
++}
++
++static inline void vmr_do_fput(struct vm_region *region,
++                             const char func[], int line)
++{
++      struct file *f = region->vm_file, *pr = region->vm_prfile;
++      aufs_trace(f, pr, func, line, __func__);
++      fput(f);
++      if (f && pr)
++              fput(pr);
++}
++
++static inline void vma_do_file_update_time(struct vm_area_struct *vma,
++                                         const char func[], int line)
++{
++      struct file *f = vma->vm_file, *pr = vma->vm_prfile;
++      aufs_trace(f, pr, func, line, __func__);
++      file_update_time(f);
++      if (f && pr)
++              file_update_time(pr);
++}
 +
- #ifdef CONFIG_SMP
++static inline struct file *vma_do_pr_or_file(struct vm_area_struct *vma,
++                                           const char func[], int line)
++{
++      struct file *f = vma->vm_file, *pr = vma->vm_prfile;
++      aufs_trace(f, pr, func, line, __func__);
++      return (f && pr) ? pr : f;
++}
++
++static inline void vma_do_get_file(struct vm_area_struct *vma,
++                                 const char func[], int line)
++{
++      struct file *f = vma->vm_file, *pr = vma->vm_prfile;
++      aufs_trace(f, pr, func, line, __func__);
++      get_file(f);
++      if (f && pr)
++              get_file(pr);
++}
++
++static inline void vma_do_fput(struct vm_area_struct *vma,
++                             const char func[], int line)
++{
++      struct file *f = vma->vm_file, *pr = vma->vm_prfile;
++      aufs_trace(f, pr, func, line, __func__);
++      fput(f);
++      if (f && pr)
++              fput(pr);
++}
++
++#define vmr_pr_or_file(region)                vmr_do_pr_or_file(region, __func__, \
++                                                        __LINE__)
++#define vmr_fput(region)              vmr_do_fput(region, __func__, __LINE__)
++#define vma_file_update_time(vma)     vma_do_file_update_time(vma, __func__, \
++                                                              __LINE__)
++#define vma_pr_or_file(vma)           vma_do_pr_or_file(vma, __func__, \
++                                                        __LINE__)
++#define vma_get_file(vma)             vma_do_get_file(vma, __func__, __LINE__)
++#define vma_fput(vma)                 vma_do_fput(vma, __func__, __LINE__)
++
+ extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
+ extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
+               void *buf, int len, int write);
+diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
+index 290901a..c21588b 100644
+--- a/include/linux/mm_types.h
++++ b/include/linux/mm_types.h
+@@ -231,6 +231,7 @@ struct vm_region {
+       unsigned long   vm_top;         /* region allocated to here */
+       unsigned long   vm_pgoff;       /* the offset in vm_file corresponding to vm_start */
+       struct file     *vm_file;       /* the backing file or NULL */
++      struct file     *vm_prfile;     /* the virtual backing file or NULL */
  
- /*
+       int             vm_usage;       /* region usage count (access under nommu_region_sem) */
+       bool            vm_icache_flushed : 1; /* true if the icache has been flushed for
+@@ -299,6 +300,7 @@ struct vm_area_struct {
+       unsigned long vm_pgoff;         /* Offset (within vm_file) in PAGE_SIZE
+                                          units, *not* PAGE_CACHE_SIZE */
+       struct file * vm_file;          /* File we map to (can be NULL). */
++      struct file *vm_prfile;         /* shadow of vm_file */
+       void * vm_private_data;         /* was vm_pte (shared mem) */
+ #ifndef CONFIG_MMU
+diff --git a/kernel/fork.c b/kernel/fork.c
+index a17621c..40d9f6a 100644
+--- a/kernel/fork.c
++++ b/kernel/fork.c
+@@ -412,7 +412,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
+                       struct inode *inode = file_inode(file);
+                       struct address_space *mapping = file->f_mapping;
+-                      get_file(file);
++                      vma_get_file(tmp);
+                       if (tmp->vm_flags & VM_DENYWRITE)
+                               atomic_dec(&inode->i_writecount);
+                       mutex_lock(&mapping->i_mmap_mutex);
+diff --git a/mm/filemap.c b/mm/filemap.c
+index 7a13f6a..f1805df 100644
+--- a/mm/filemap.c
++++ b/mm/filemap.c
+@@ -1733,7 +1733,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
+       int ret = VM_FAULT_LOCKED;
+       sb_start_pagefault(inode->i_sb);
+-      file_update_time(vma->vm_file);
++      vma_file_update_time(vma);
+       lock_page(page);
+       if (page->mapping != inode->i_mapping) {
+               unlock_page(page);
+diff --git a/mm/fremap.c b/mm/fremap.c
+index 34feba6..d857364 100644
+--- a/mm/fremap.c
++++ b/mm/fremap.c
+@@ -227,7 +227,9 @@ get_write_lock:
+                       /* mmap_region may free vma; grab the info now */
+                       vm_flags = vma->vm_flags;
++                      vma_get_file(vma);
+                       addr = mmap_region(file, start, size, vm_flags, pgoff);
++                      vma_fput(vma);
+                       fput(file);
+                       if (IS_ERR_VALUE(addr)) {
+                               err = addr;
+diff --git a/mm/madvise.c b/mm/madvise.c
+index 539eeb9..5e700b1 100644
+--- a/mm/madvise.c
++++ b/mm/madvise.c
+@@ -327,12 +327,12 @@ static long madvise_remove(struct vm_area_struct *vma,
+        * vma's reference to the file) can go away as soon as we drop
+        * mmap_sem.
+        */
+-      get_file(f);
++      vma_get_file(vma);
+       up_read(&current->mm->mmap_sem);
+       error = do_fallocate(f,
+                               FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+                               offset, end - start);
+-      fput(f);
++      vma_fput(vma);
+       down_read(&current->mm->mmap_sem);
+       return error;
+ }
+diff --git a/mm/memory.c b/mm/memory.c
+index 22dfa61..81813d9 100644
+--- a/mm/memory.c
++++ b/mm/memory.c
+@@ -2755,7 +2755,7 @@ reuse:
+                       set_page_dirty_balance(dirty_page, page_mkwrite);
+                       /* file_update_time outside page_lock */
+                       if (vma->vm_file)
+-                              file_update_time(vma->vm_file);
++                              vma_file_update_time(vma);
+               }
+               put_page(dirty_page);
+               if (page_mkwrite) {
+@@ -3467,7 +3467,7 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
+               /* file_update_time outside page_lock */
+               if (vma->vm_file && !page_mkwrite)
+-                      file_update_time(vma->vm_file);
++                      vma_file_update_time(vma);
+       } else {
+               unlock_page(vmf.page);
+               if (anon)
+diff --git a/mm/mmap.c b/mm/mmap.c
+index 20ff0c3..f743033 100644
+--- a/mm/mmap.c
++++ b/mm/mmap.c
+@@ -249,7 +249,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
+       if (vma->vm_ops && vma->vm_ops->close)
+               vma->vm_ops->close(vma);
+       if (vma->vm_file)
+-              fput(vma->vm_file);
++              vma_fput(vma);
+       mpol_put(vma_policy(vma));
+       kmem_cache_free(vm_area_cachep, vma);
+       return next;
+@@ -859,7 +859,7 @@ again:                     remove_next = 1 + (end > next->vm_end);
+       if (remove_next) {
+               if (file) {
+                       uprobe_munmap(next, next->vm_start, next->vm_end);
+-                      fput(file);
++                      vma_fput(vma);
+               }
+               if (next->anon_vma)
+                       anon_vma_merge(vma, next);
+@@ -1639,8 +1639,8 @@ out:
+ unmap_and_free_vma:
+       if (vm_flags & VM_DENYWRITE)
+               allow_write_access(file);
++      vma_fput(vma);
+       vma->vm_file = NULL;
+-      fput(file);
+       /* Undo any partial mapping done by a device driver. */
+       unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
+@@ -2429,7 +2429,7 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
+               goto out_free_mpol;
+       if (new->vm_file)
+-              get_file(new->vm_file);
++              vma_get_file(new);
+       if (new->vm_ops && new->vm_ops->open)
+               new->vm_ops->open(new);
+@@ -2448,7 +2448,7 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
+       if (new->vm_ops && new->vm_ops->close)
+               new->vm_ops->close(new);
+       if (new->vm_file)
+-              fput(new->vm_file);
++              vma_fput(new);
+       unlink_anon_vmas(new);
+  out_free_mpol:
+       mpol_put(vma_policy(new));
+@@ -2837,7 +2837,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
+                       if (anon_vma_clone(new_vma, vma))
+                               goto out_free_mempol;
+                       if (new_vma->vm_file)
+-                              get_file(new_vma->vm_file);
++                              vma_get_file(new_vma);
+                       if (new_vma->vm_ops && new_vma->vm_ops->open)
+                               new_vma->vm_ops->open(new_vma);
+                       vma_link(mm, new_vma, prev, rb_link, rb_parent);
+diff --git a/mm/msync.c b/mm/msync.c
+index 632df45..02d770e 100644
+--- a/mm/msync.c
++++ b/mm/msync.c
+@@ -80,10 +80,10 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
+               start = vma->vm_end;
+               if ((flags & MS_SYNC) && file &&
+                               (vma->vm_flags & VM_SHARED)) {
+-                      get_file(file);
++                      vma_get_file(vma);
+                       up_read(&mm->mmap_sem);
+                       error = vfs_fsync(file, 0);
+-                      fput(file);
++                      vma_fput(vma);
+                       if (error || start >= end)
+                               goto out;
+                       down_read(&mm->mmap_sem);
+diff --git a/mm/nommu.c b/mm/nommu.c
+index 8740213..ea7e336 100644
+--- a/mm/nommu.c
++++ b/mm/nommu.c
+@@ -653,7 +653,7 @@ static void __put_nommu_region(struct vm_region *region)
+               up_write(&nommu_region_sem);
+               if (region->vm_file)
+-                      fput(region->vm_file);
++                      vmr_fput(region);
+               /* IO memory and memory shared directly out of the pagecache
+                * from ramfs/tmpfs mustn't be released here */
+@@ -811,7 +811,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
+       if (vma->vm_ops && vma->vm_ops->close)
+               vma->vm_ops->close(vma);
+       if (vma->vm_file)
+-              fput(vma->vm_file);
++              vma_fput(vma);
+       put_nommu_region(vma->vm_region);
+       kmem_cache_free(vm_area_cachep, vma);
+ }
+@@ -1377,7 +1377,7 @@ unsigned long do_mmap_pgoff(struct file *file,
+                                       goto error_just_free;
+                               }
+                       }
+-                      fput(region->vm_file);
++                      vmr_fput(region);
+                       kmem_cache_free(vm_region_jar, region);
+                       region = pregion;
+                       result = start;
+@@ -1453,10 +1453,10 @@ error_just_free:
+       up_write(&nommu_region_sem);
+ error:
+       if (region->vm_file)
+-              fput(region->vm_file);
++              vmr_fput(region);
+       kmem_cache_free(vm_region_jar, region);
+       if (vma->vm_file)
+-              fput(vma->vm_file);
++              vma_fput(vma);
+       kmem_cache_free(vm_area_cachep, vma);
+       kleave(" = %d", ret);
+       return ret;
+aufs3.14 standalone patch
+
 diff --git a/fs/inode.c b/fs/inode.c
-index f324521..bff7670 100644
+index bc83168..6dd1207 100644
 --- a/fs/inode.c
 +++ b/fs/inode.c
-@@ -56,6 +56,7 @@ static struct hlist_head *inode_hashtable __read_mostly;
+@@ -57,6 +57,7 @@ static struct hlist_head *inode_hashtable __read_mostly;
  static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock);
  
  __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_sb_list_lock);
@@ -151,7 +537,7 @@ index f324521..bff7670 100644
  
  /*
   * Empty aops. Can be used for the cases where the user does not
-@@ -1514,6 +1515,7 @@ int update_time(struct inode *inode, struct timespec *time, int flags)
+@@ -1513,6 +1514,7 @@ int update_time(struct inode *inode, struct timespec *time, int flags)
        mark_inode_dirty_sync(inode);
        return 0;
  }
@@ -160,18 +546,10 @@ index f324521..bff7670 100644
  /**
   *    touch_atime     -       update the access time
 diff --git a/fs/namespace.c b/fs/namespace.c
-index 7b1ca9b..51db6ad 100644
+index 2ffc5a2..785a51f 100644
 --- a/fs/namespace.c
 +++ b/fs/namespace.c
-@@ -54,6 +54,7 @@ EXPORT_SYMBOL_GPL(fs_kobj);
-  * tree or hash is modified or when a vfsmount structure is modified.
-  */
- DEFINE_BRLOCK(vfsmount_lock);
-+EXPORT_SYMBOL(vfsmount_lock);
- static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
- {
-@@ -427,6 +428,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
+@@ -455,6 +455,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
        mnt_dec_writers(real_mount(mnt));
        preempt_enable();
  }
@@ -179,7 +557,7 @@ index 7b1ca9b..51db6ad 100644
  
  /**
   * mnt_drop_write - give up write access to a mount
-@@ -1456,6 +1458,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
+@@ -1555,6 +1556,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
        }
        return 0;
  }
@@ -188,7 +566,7 @@ index 7b1ca9b..51db6ad 100644
  static void cleanup_group_ids(struct mount *mnt, struct mount *end)
  {
 diff --git a/fs/notify/group.c b/fs/notify/group.c
-index bd2625b..2ff2a0f 100644
+index ad19959..adf290d 100644
 --- a/fs/notify/group.c
 +++ b/fs/notify/group.c
 @@ -22,6 +22,7 @@
@@ -199,7 +577,7 @@ index bd2625b..2ff2a0f 100644
  
  #include <linux/fsnotify_backend.h>
  #include "fsnotify.h"
-@@ -65,6 +66,7 @@ void fsnotify_get_group(struct fsnotify_group *group)
+@@ -72,6 +73,7 @@ void fsnotify_get_group(struct fsnotify_group *group)
  {
        atomic_inc(&group->refcnt);
  }
@@ -207,7 +585,7 @@ index bd2625b..2ff2a0f 100644
  
  /*
   * Drop a reference to a group.  Free it if it's through.
-@@ -74,6 +76,7 @@ void fsnotify_put_group(struct fsnotify_group *group)
+@@ -81,6 +83,7 @@ void fsnotify_put_group(struct fsnotify_group *group)
        if (atomic_dec_and_test(&group->refcnt))
                fsnotify_final_destroy_group(group);
  }
@@ -215,7 +593,7 @@ index bd2625b..2ff2a0f 100644
  
  /*
   * Create a new fsnotify_group and hold a reference for the group returned.
-@@ -102,6 +105,7 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
+@@ -109,6 +112,7 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
  
        return group;
  }
@@ -224,10 +602,10 @@ index bd2625b..2ff2a0f 100644
  int fsnotify_fasync(int fd, struct file *file, int on)
  {
 diff --git a/fs/notify/mark.c b/fs/notify/mark.c
-index fc6b49b..a6bb87d 100644
+index 923fe4a..176b435 100644
 --- a/fs/notify/mark.c
 +++ b/fs/notify/mark.c
-@@ -115,6 +115,7 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
+@@ -109,6 +109,7 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
                mark->free_mark(mark);
        }
  }
@@ -235,7 +613,7 @@ index fc6b49b..a6bb87d 100644
  
  /*
   * Any time a mark is getting freed we end up here.
-@@ -197,6 +198,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark,
+@@ -191,6 +192,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark,
        fsnotify_destroy_mark_locked(mark, group);
        mutex_unlock(&group->mark_mutex);
  }
@@ -243,7 +621,7 @@ index fc6b49b..a6bb87d 100644
  
  void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask)
  {
-@@ -281,6 +283,7 @@ err:
+@@ -275,6 +277,7 @@ err:
  
        return ret;
  }
@@ -251,7 +629,7 @@ index fc6b49b..a6bb87d 100644
  
  int fsnotify_add_mark(struct fsnotify_mark *mark, struct fsnotify_group *group,
                      struct inode *inode, struct vfsmount *mnt, int allow_dups)
-@@ -342,6 +345,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
+@@ -336,6 +339,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
        atomic_set(&mark->refcnt, 1);
        mark->free_mark = free_mark;
  }
@@ -260,10 +638,10 @@ index fc6b49b..a6bb87d 100644
  static int fsnotify_mark_destroy(void *ignored)
  {
 diff --git a/fs/open.c b/fs/open.c
-index 8c74100..be563cd 100644
+index b9ed8b2..3ea66972 100644
 --- a/fs/open.c
 +++ b/fs/open.c
-@@ -61,6 +61,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
+@@ -62,6 +62,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
        mutex_unlock(&dentry->d_inode->i_mutex);
        return ret;
  }
@@ -272,18 +650,18 @@ index 8c74100..be563cd 100644
  long vfs_truncate(struct path *path, loff_t length)
  {
 diff --git a/fs/splice.c b/fs/splice.c
-index 4ba1844..2370d0b 100644
+index f26cbaf..ac02366 100644
 --- a/fs/splice.c
 +++ b/fs/splice.c
-@@ -1120,6 +1120,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-       file_end_write(out);
-       return ret;
+@@ -1124,6 +1124,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+       return splice_write(pipe, out, ppos, len, flags);
  }
 +EXPORT_SYMBOL(do_splice_from);
  
  /*
   * Attempt to initiate a splice from a file to a pipe.
-@@ -1146,6 +1147,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
+@@ -1150,6 +1151,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
  
        return splice_read(in, ppos, pipe, len, flags);
  }
@@ -292,7 +670,7 @@ index 4ba1844..2370d0b 100644
  /**
   * splice_direct_to_actor - splices data directly between two non-pipes
 diff --git a/security/commoncap.c b/security/commoncap.c
-index c44b6fe..d78b003 100644
+index b9d613e..ba3b618 100644
 --- a/security/commoncap.c
 +++ b/security/commoncap.c
 @@ -988,9 +988,11 @@ int cap_mmap_addr(unsigned long addr)
@@ -308,7 +686,7 @@ index c44b6fe..d78b003 100644
  }
 +EXPORT_SYMBOL(cap_mmap_file);
 diff --git a/security/device_cgroup.c b/security/device_cgroup.c
-index dd0dc57..9760ecb6 100644
+index d3b6d2c..5076912 100644
 --- a/security/device_cgroup.c
 +++ b/security/device_cgroup.c
 @@ -7,6 +7,7 @@
@@ -319,7 +697,7 @@ index dd0dc57..9760ecb6 100644
  #include <linux/list.h>
  #include <linux/uaccess.h>
  #include <linux/seq_file.h>
-@@ -789,6 +790,7 @@ int __devcgroup_inode_permission(struct inode *inode, int mask)
+@@ -744,6 +745,7 @@ int __devcgroup_inode_permission(struct inode *inode, int mask)
        return __devcgroup_check_permission(type, imajor(inode), iminor(inode),
                        access);
  }
@@ -328,10 +706,10 @@ index dd0dc57..9760ecb6 100644
  int devcgroup_inode_mknod(int mode, dev_t dev)
  {
 diff --git a/security/security.c b/security/security.c
-index a3dce87..06a6ea6 100644
+index 919cad9..f9e9e17 100644
 --- a/security/security.c
 +++ b/security/security.c
-@@ -396,6 +396,7 @@ int security_path_rmdir(struct path *dir, struct dentry *dentry)
+@@ -407,6 +407,7 @@ int security_path_rmdir(struct path *dir, struct dentry *dentry)
                return 0;
        return security_ops->path_rmdir(dir, dentry);
  }
@@ -339,7 +717,7 @@ index a3dce87..06a6ea6 100644
  
  int security_path_unlink(struct path *dir, struct dentry *dentry)
  {
-@@ -412,6 +413,7 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
+@@ -423,6 +424,7 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
                return 0;
        return security_ops->path_symlink(dir, dentry, old_name);
  }
@@ -347,7 +725,7 @@ index a3dce87..06a6ea6 100644
  
  int security_path_link(struct dentry *old_dentry, struct path *new_dir,
                       struct dentry *new_dentry)
-@@ -420,6 +422,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
+@@ -431,6 +433,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
                return 0;
        return security_ops->path_link(old_dentry, new_dir, new_dentry);
  }
@@ -355,7 +733,7 @@ index a3dce87..06a6ea6 100644
  
  int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
                         struct path *new_dir, struct dentry *new_dentry)
-@@ -438,6 +441,7 @@ int security_path_truncate(struct path *path)
+@@ -449,6 +452,7 @@ int security_path_truncate(struct path *path)
                return 0;
        return security_ops->path_truncate(path);
  }
@@ -363,7 +741,7 @@ index a3dce87..06a6ea6 100644
  
  int security_path_chmod(struct path *path, umode_t mode)
  {
-@@ -445,6 +449,7 @@ int security_path_chmod(struct path *path, umode_t mode)
+@@ -456,6 +460,7 @@ int security_path_chmod(struct path *path, umode_t mode)
                return 0;
        return security_ops->path_chmod(path, mode);
  }
@@ -371,7 +749,7 @@ index a3dce87..06a6ea6 100644
  
  int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
  {
-@@ -452,6 +457,7 @@ int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
+@@ -463,6 +468,7 @@ int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
                return 0;
        return security_ops->path_chown(path, uid, gid);
  }
@@ -379,7 +757,7 @@ index a3dce87..06a6ea6 100644
  
  int security_path_chroot(struct path *path)
  {
-@@ -528,6 +534,7 @@ int security_inode_readlink(struct dentry *dentry)
+@@ -539,6 +545,7 @@ int security_inode_readlink(struct dentry *dentry)
                return 0;
        return security_ops->inode_readlink(dentry);
  }
@@ -387,7 +765,7 @@ index a3dce87..06a6ea6 100644
  
  int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd)
  {
-@@ -542,6 +549,7 @@ int security_inode_permission(struct inode *inode, int mask)
+@@ -553,6 +560,7 @@ int security_inode_permission(struct inode *inode, int mask)
                return 0;
        return security_ops->inode_permission(inode, mask);
  }
@@ -395,7 +773,7 @@ index a3dce87..06a6ea6 100644
  
  int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
  {
-@@ -663,6 +671,7 @@ int security_file_permission(struct file *file, int mask)
+@@ -675,6 +683,7 @@ int security_file_permission(struct file *file, int mask)
  
        return fsnotify_perm(file, mask);
  }
@@ -403,7 +781,7 @@ index a3dce87..06a6ea6 100644
  
  int security_file_alloc(struct file *file)
  {
-@@ -723,6 +732,7 @@ int security_mmap_file(struct file *file, unsigned long prot,
+@@ -735,6 +744,7 @@ int security_mmap_file(struct file *file, unsigned long prot,
                return ret;
        return ima_file_mmap(file, prot);
  }
@@ -413,11 +791,11 @@ index a3dce87..06a6ea6 100644
  {
 diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Documentation/ABI/testing/debugfs-aufs
 --- /usr/share/empty/Documentation/ABI/testing/debugfs-aufs    1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/ABI/testing/debugfs-aufs       2013-07-06 13:20:47.716863966 +0200
++++ linux/Documentation/ABI/testing/debugfs-aufs       2014-04-24 22:11:10.471931783 +0200
 @@ -0,0 +1,50 @@
 +What:         /debug/aufs/si_<id>/
 +Date:         March 2009
-+Contact:      J. R. Okajima <hooanon05@yahoo.co.jp>
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
 +Description:
 +              Under /debug/aufs, a directory named si_<id> is created
 +              per aufs mount, where <id> is a unique id generated
@@ -425,7 +803,7 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Document
 +
 +What:         /debug/aufs/si_<id>/plink
 +Date:         Apr 2013
-+Contact:      J. R. Okajima <hooanon05@yahoo.co.jp>
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
 +Description:
 +              It has three lines and shows the information about the
 +              pseudo-link. The first line is a single number
@@ -438,7 +816,7 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Document
 +
 +What:         /debug/aufs/si_<id>/xib
 +Date:         March 2009
-+Contact:      J. R. Okajima <hooanon05@yahoo.co.jp>
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
 +Description:
 +              It shows the consumed blocks by xib (External Inode Number
 +              Bitmap), its block size and file size.
@@ -447,7 +825,7 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Document
 +
 +What:         /debug/aufs/si_<id>/xino0, xino1 ... xinoN
 +Date:         March 2009
-+Contact:      J. R. Okajima <hooanon05@yahoo.co.jp>
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
 +Description:
 +              It shows the consumed blocks by xino (External Inode Number
 +              Translation Table), its link count, block size and file
@@ -457,7 +835,7 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Document
 +
 +What:         /debug/aufs/si_<id>/xigen
 +Date:         March 2009
-+Contact:      J. R. Okajima <hooanon05@yahoo.co.jp>
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
 +Description:
 +              It shows the consumed blocks by xigen (External Inode
 +              Generation Table), its block size and file size.
@@ -467,11 +845,11 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Document
 +              will be empty. About XINO files, see the aufs manual.
 diff -urN /usr/share/empty/Documentation/ABI/testing/sysfs-aufs linux/Documentation/ABI/testing/sysfs-aufs
 --- /usr/share/empty/Documentation/ABI/testing/sysfs-aufs      1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/ABI/testing/sysfs-aufs 2013-07-06 13:20:47.730197761 +0200
-@@ -0,0 +1,24 @@
++++ linux/Documentation/ABI/testing/sysfs-aufs 2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,31 @@
 +What:         /sys/fs/aufs/si_<id>/
 +Date:         March 2009
-+Contact:      J. R. Okajima <hooanon05@yahoo.co.jp>
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
 +Description:
 +              Under /sys/fs/aufs, a directory named si_<id> is created
 +              per aufs mount, where <id> is a unique id generated
@@ -479,14 +857,21 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/sysfs-aufs linux/Documentat
 +
 +What:         /sys/fs/aufs/si_<id>/br0, br1 ... brN
 +Date:         March 2009
-+Contact:      J. R. Okajima <hooanon05@yahoo.co.jp>
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
 +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>/brid0, brid1 ... bridN
++Date:         July 2013
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
++Description:
++              It shows the id of a member directory (which is called
++              branch) in aufs.
++
 +What:         /sys/fs/aufs/si_<id>/xi_path
 +Date:         March 2009
-+Contact:      J. R. Okajima <hooanon05@yahoo.co.jp>
++Contact:      J. R. Okajima <hooanon05g@gmail.com>
 +Description:
 +              It shows the abolute path of XINO (External Inode Number
 +              Bitmap, Translation Table and Generation Table) file
@@ -495,10 +880,10 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/sysfs-aufs linux/Documentat
 +              will be empty. About XINO files, see the aufs manual.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt linux/Documentation/filesystems/aufs/design/01intro.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/01intro.txt    2013-07-06 13:20:47.730197761 +0200
-@@ -0,0 +1,162 @@
++++ linux/Documentation/filesystems/aufs/design/01intro.txt    2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,161 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -511,8 +896,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt lin
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Introduction
 +----------------------------------------
@@ -661,10 +1045,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt lin
 +about it. But currently I have implemented it in kernel space.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt linux/Documentation/filesystems/aufs/design/02struct.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt        1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/02struct.txt   2013-07-06 13:20:47.730197761 +0200
-@@ -0,0 +1,226 @@
++++ linux/Documentation/filesystems/aufs/design/02struct.txt   2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,242 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -677,8 +1061,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Basic Aufs Internal Structure
 +
@@ -889,12 +1272,29 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +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.
++
++
++Move-down (aufs3.9 and later)
++----------------------------------------------------------------------
++"Copy-up" is one of the essential feature in aufs. It copies a file from
++the lower readonly branch to the upper writable branch when a user
++changes something about the file.
++"Move-down" is an opposite action of copy-up. Basically this action is
++ran manually instead of automatically and internally.
++
++Sometimes users want to move-down a file from the upper writable branch
++to the lower readonly or writable branch. For instance,
++- the free space of the upper writable branch is going to run out.
++- create a new intermediate branch between the upper and lower branch.
++- etc.
++
++For this purpose, use "aumvdown" command in aufs-util.git.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt linux/Documentation/filesystems/aufs/design/03lookup.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt        1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/03lookup.txt   2013-07-06 13:20:47.730197761 +0200
-@@ -0,0 +1,106 @@
++++ linux/Documentation/filesystems/aufs/design/03lookup.txt   2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,105 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -907,8 +1307,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt li
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Lookup in a Branch
 +----------------------------------------------------------------------
@@ -1001,10 +1400,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt li
 +   by over-mounting something (or another method).
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt linux/Documentation/filesystems/aufs/design/04branch.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt        1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/04branch.txt   2013-07-06 13:20:47.730197761 +0200
-@@ -0,0 +1,76 @@
++++ linux/Documentation/filesystems/aufs/design/04branch.txt   2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,75 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -1017,8 +1416,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt li
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Branch Manipulation
 +
@@ -1081,10 +1479,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt li
 +    same named entry on the upper branch.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.txt linux/Documentation/filesystems/aufs/design/05wbr_policy.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.txt    1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/05wbr_policy.txt       2013-07-06 13:20:47.730197761 +0200
-@@ -0,0 +1,65 @@
++++ linux/Documentation/filesystems/aufs/design/05wbr_policy.txt       2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,64 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -1097,8 +1495,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.tx
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Policies to Select One among Multiple Writable Branches
 +----------------------------------------------------------------------
@@ -1150,10 +1547,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.tx
 +  copyup policy.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt linux/Documentation/filesystems/aufs/design/06mmap.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt  1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/06mmap.txt     2013-07-06 13:20:47.730197761 +0200
-@@ -0,0 +1,47 @@
++++ linux/Documentation/filesystems/aufs/design/06mmap.txt     2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,46 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -1166,8 +1563,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt linu
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +mmap(2) -- File Memory Mapping
 +----------------------------------------------------------------------
@@ -1201,10 +1597,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt linu
 +switching the approach.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt linux/Documentation/filesystems/aufs/design/07export.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt        1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/07export.txt   2013-07-06 13:20:47.736864659 +0200
-@@ -0,0 +1,59 @@
++++ linux/Documentation/filesystems/aufs/design/07export.txt   2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,58 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -1217,8 +1613,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt li
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Export Aufs via NFS
 +----------------------------------------------------------------------
@@ -1264,10 +1659,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt li
 +  lookup_one_len(), vfs_getattr(), encode_fh() and others.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt linux/Documentation/filesystems/aufs/design/08shwh.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt  1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/08shwh.txt     2013-07-06 13:20:47.736864659 +0200
-@@ -0,0 +1,53 @@
++++ linux/Documentation/filesystems/aufs/design/08shwh.txt     2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,52 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -1280,8 +1675,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt linu
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Show Whiteout Mode (shwh)
 +----------------------------------------------------------------------
@@ -1321,10 +1715,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt linu
 +initramfs will use it to replace the old one at the next boot.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt linux/Documentation/filesystems/aufs/design/10dynop.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/10dynop.txt    2013-07-06 13:20:47.736864659 +0200
-@@ -0,0 +1,47 @@
++++ linux/Documentation/filesystems/aufs/design/10dynop.txt    2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,46 @@
 +
-+# Copyright (C) 2010-2013 Junjiro R. Okajima
++# Copyright (C) 2010-2014 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
@@ -1337,8 +1731,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt lin
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Dynamically customizable FS operations
 +----------------------------------------------------------------------
@@ -1372,10 +1765,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt lin
 +vm_operations_struct for regular files only.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt linux/Documentation/filesystems/aufs/design/99plan.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt  1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/99plan.txt     2013-07-06 13:20:47.736864659 +0200
-@@ -0,0 +1,96 @@
++++ linux/Documentation/filesystems/aufs/design/99plan.txt     2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,95 @@
 +
-+# Copyright (C) 2005-2013 Junjiro R. Okajima
++# Copyright (C) 2005-2014 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
@@ -1388,8 +1781,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt linu
 +# 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
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +Plan
 +
@@ -1472,8 +1864,8 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt linu
 +Otherwise from /new.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documentation/filesystems/aufs/README
 --- /usr/share/empty/Documentation/filesystems/aufs/README     1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/README        2013-07-06 13:20:47.730197761 +0200
-@@ -0,0 +1,345 @@
++++ linux/Documentation/filesystems/aufs/README        2014-04-24 22:11:10.471931783 +0200
+@@ -0,0 +1,344 @@
 +
 +Aufs3 -- advanced multi layered unification filesystem version 3.x
 +http://aufs.sf.net
@@ -1644,9 +2036,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +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-mmap.patch too.
 +- 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
@@ -1666,9 +2056,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +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-mmap.patch too.
 +- 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.
@@ -1802,6 +2190,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +POIRETTE Marc made a donation (2013/4).
 +Alessandro Gorreta made a donation (2013/4).
 +lauri kasvandik made a donation (2013/5).
++"pemasu from Finland" made a donation (2013/7).
++The Parted Magic Project made a donation (2013/9 and 11).
++Pavel Barta made a donation (2013/10).
 +
 +Thank you very much.
 +Donations are always, including future donations, very important and
@@ -1821,10 +2212,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +# End: ;
 diff -urN /usr/share/empty/fs/aufs/aufs.h linux/fs/aufs/aufs.h
 --- /usr/share/empty/fs/aufs/aufs.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/aufs.h       2013-07-06 13:20:47.736864659 +0200
-@@ -0,0 +1,60 @@
++++ linux/fs/aufs/aufs.h       2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,59 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -1837,8 +2228,7 @@ diff -urN /usr/share/empty/fs/aufs/aufs.h linux/fs/aufs/aufs.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -1885,10 +2275,10 @@ diff -urN /usr/share/empty/fs/aufs/aufs.h linux/fs/aufs/aufs.h
 +#endif /* __AUFS_H__ */
 diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 --- /usr/share/empty/fs/aufs/branch.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/branch.c     2013-07-06 13:20:47.736864659 +0200
-@@ -0,0 +1,1213 @@
++++ linux/fs/aufs/branch.c     2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,1219 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -1901,8 +2291,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -2254,7 +2643,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +
 +      /*
 +       * a limit for rmdir/rename a dir
-+       * cf. AUFS_MAX_NAMELEN in include/linux/aufs_type.h
++       * cf. AUFS_MAX_NAMELEN in include/uapi/linux/aufs_type.h
 +       */
 +      err = vfs_statfs(&br->br_path, &kst);
 +      if (unlikely(err))
@@ -2263,8 +2652,8 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      if (kst.f_namelen >= NAME_MAX)
 +              err = au_br_init_wh(sb, br, perm);
 +      else
-+              pr_err("%.*s(%s), unsupported namelen %ld\n",
-+                     AuDLNPair(au_br_dentry(br)),
++              pr_err("%pd(%s), unsupported namelen %ld\n",
++                     au_br_dentry(br),
 +                     au_sbtype(au_br_dentry(br)->d_sb), kst.f_namelen);
 +
 +out:
@@ -2288,7 +2677,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      spin_lock_init(&br->br_dykey_lock);
 +      memset(br->br_dykey, 0, sizeof(br->br_dykey));
 +      atomic_set(&br->br_count, 0);
-+      br->br_xino_upper = AUFS_XINO_TRUNC_INIT;
 +      atomic_set(&br->br_xino_running, 0);
 +      br->br_id = au_new_br_id(sb);
 +      AuDebugOn(br->br_id < 0);
@@ -2500,7 +2888,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              ndentry = dpage->ndentry;
 +              for (j = 0; !err && j < ndentry; j++) {
 +                      d = dpage->dentries[j];
-+                      AuDebugOn(!d->d_count);
++                      AuDebugOn(!d_count(d));
 +                      if (!au_digen_test(d, sigen)) {
 +                              di_read_lock_child(d, AuLock_IR);
 +                              if (unlikely(au_dbrange_test(d))) {
@@ -2530,7 +2918,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +                          && au_h_dptr(d, bindex)
 +                          && au_test_dbusy(d, bstart, bend)) {
 +                              err = -EBUSY;
-+                              AuVerbose(verbose, "busy %.*s\n", AuDLNPair(d));
++                              AuVerbose(verbose, "busy %pd\n", d);
 +                              AuDbgDentry(d);
 +                      }
 +                      di_read_unlock(d, AuLock_IR);
@@ -2894,22 +3282,25 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +{
 +      unsigned long long n;
 +      struct file **p, *f;
++      struct au_sphlhead *files;
++      struct au_finfo *finfo;
 +      struct super_block *sb = arg;
 +
 +      n = 0;
 +      p = a;
-+      lg_global_lock(&files_lglock);
-+      do_file_list_for_each_entry(sb, f) {
-+              if (au_fi(f)
-+                  && file_count(f)
++      files = &au_sbi(sb)->si_files;
++      spin_lock(&files->spin);
++      hlist_for_each_entry(finfo, &files->head, fi_hlist) {
++              f = finfo->fi_file;
++              if (file_count(f)
 +                  && !special_file(file_inode(f)->i_mode)) {
 +                      get_file(f);
 +                      *p++ = f;
 +                      n++;
 +                      AuDebugOn(n > max);
 +              }
-+      } while_file_list_for_each_entry;
-+      lg_global_unlock(&files_lglock);
++      }
++      spin_unlock(&files->spin);
 +
 +      return n;
 +}
@@ -2955,12 +3346,11 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      for (ull = 0; ull < max; ull++) {
 +              file = array[ull];
 +
-+              /* AuDbg("%.*s\n", AuDLNPair(file->f_dentry)); */
++              /* AuDbg("%pD\n", file); */
 +              fi_read_lock(file);
 +              if (unlikely(au_test_mmapped(file))) {
 +                      err = -EBUSY;
-+                      AuVerbose(verbose, "mmapped %.*s\n",
-+                                AuDLNPair(file->f_dentry));
++                      AuVerbose(verbose, "mmapped %pD\n", file);
 +                      AuDbgFile(file);
 +                      FiMustNoWaiters(file);
 +                      fi_read_unlock(file);
@@ -2995,7 +3385,13 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +                      continue;
 +
 +              /* todo: already flushed? */
-+              /* cf. fs/super.c:mark_files_ro() */
++              /*
++               * fs/super.c:mark_files_ro() is gone, but aufs keeps its
++               * approach which resets f_mode and calls mnt_drop_write() and
++               * file_release_write() for each file, because the branch
++               * attribute in aufs world is totally different from the native
++               * fs rw/ro mode.
++              */
 +              /* fi_read_lock(file); */
 +              hfile = &au_fi(file)->fi_htop;
 +              hf = hfile->hf_file;
@@ -3102,10 +3498,10 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +}
 diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 --- /usr/share/empty/fs/aufs/branch.h  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/branch.h     2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,255 @@
++++ linux/fs/aufs/branch.h     2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,264 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -3118,8 +3514,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -3174,6 +3569,18 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 +};
 +#endif
 +
++/* sysfs entries */
++struct au_brsysfs {
++      char                    name[16];
++      struct attribute        attr;
++};
++
++enum {
++      AuBrSysfs_BR,
++      AuBrSysfs_BRID,
++      AuBrSysfs_Last
++};
++
 +/* protected by superblock rwsem */
 +struct au_branch {
 +      struct au_xino_file     br_xino;
@@ -3190,7 +3597,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 +      struct au_wbr           *br_wbr;
 +
 +      /* xino truncation */
-+      blkcnt_t                br_xino_upper;  /* watermark in blocks */
 +      atomic_t                br_xino_running;
 +
 +#ifdef CONFIG_AUFS_HFSNOTIFY
@@ -3198,9 +3604,8 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 +#endif
 +
 +#ifdef CONFIG_SYSFS
-+      /* an entry under sysfs per mount-point */
-+      char                    br_name[8];
-+      struct attribute        br_attr;
++      /* entries under sysfs per mount-point */
++      struct au_brsysfs       br_sysfs[AuBrSysfs_Last];
 +#endif
 +};
 +
@@ -3361,8 +3766,8 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 +#endif /* __AUFS_BRANCH_H__ */
 diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
 --- /usr/share/empty/fs/aufs/conf.mk   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/conf.mk      2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,38 @@
++++ linux/fs/aufs/conf.mk      2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,37 @@
 +
 +AuConfStr = CONFIG_AUFS_FS=${CONFIG_AUFS_FS}
 +
@@ -3377,7 +3782,6 @@ diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
 +      HNOTIFY HFSNOTIFY \
 +      EXPORT INO_T_64 \
 +      RDU \
-+      PROC_MAP \
 +      SP_IATTR \
 +      SHWH \
 +      BR_RAMFS \
@@ -3403,10 +3807,10 @@ diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
 +-include ${srctree}/${src}/conf_priv.mk
 diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 --- /usr/share/empty/fs/aufs/cpup.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/cpup.c       2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,1228 @@
++++ linux/fs/aufs/cpup.c       2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,1277 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -3419,8 +3823,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -3434,7 +3837,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +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;
++              | S_NOATIME | S_NOCMTIME | S_AUTOMOUNT;
 +
 +      BUILD_BUG_ON(sizeof(iflags) != sizeof(dst->i_flags));
 +
@@ -3551,7 +3954,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      attr.ia_valid = ATTR_FORCE | ATTR_MTIME | ATTR_MTIME_SET
 +              | ATTR_ATIME | ATTR_ATIME_SET;
 +
-+      err = vfsub_notify_change(&dt->dt_h_path, &attr);
++      /* no delegation since this is a directory */
++      err = vfsub_notify_change(&dt->dt_h_path, &attr, /*delegated*/NULL);
 +      if (unlikely(err))
 +              pr_warn("restoring timestamps failed(%d). ignored\n", err);
 +}
@@ -3608,13 +4012,14 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              sbits = !!(h_isrc->i_mode & (S_ISUID | S_ISGID));
 +              au_cpup_attr_flags(h_idst, h_isrc->i_flags);
 +      }
-+      err = vfsub_notify_change(&h_path, &ia);
++      /* no delegation since it is just created */
++      err = vfsub_notify_change(&h_path, &ia, /*delegated*/NULL);
 +
 +      /* is this nfs only? */
 +      if (!err && sbits && au_test_nfs(h_path.dentry->d_sb)) {
 +              ia.ia_valid = ATTR_FORCE | ATTR_MODE;
 +              ia.ia_mode = h_isrc->i_mode;
-+              err = vfsub_notify_change(&h_path, &ia);
++              err = vfsub_notify_change(&h_path, &ia, /*delegated*/NULL);
 +      }
 +
 +      return err;
@@ -3673,6 +4078,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +                              wbytes -= b;
 +                              p += b;
 +                      }
++                      if (unlikely(err < 0))
++                              break;
 +              } else {
 +                      loff_t res;
 +
@@ -3709,7 +4116,9 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +                      ia->ia_file = dst;
 +                      h_mtx = &file_inode(dst)->i_mutex;
 +                      mutex_lock_nested(h_mtx, AuLsc_I_CHILD2);
-+                      err = vfsub_notify_change(&dst->f_path, ia);
++                      /* no delegation since it is just created */
++                      err = vfsub_notify_change(&dst->f_path, ia,
++                                                /*delegated*/NULL);
 +                      mutex_unlock(h_mtx);
 +              }
 +      }
@@ -3752,18 +4161,11 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      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 au_cpup_basic *basic)
++static int au_cp_regular(struct au_cp_generic *cpg)
 +{
 +      int err, i;
 +      enum { SRC, DST };
@@ -3771,48 +4173,43 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              aufs_bindex_t bindex;
 +              unsigned int flags;
 +              struct dentry *dentry;
++              int force_wr;
 +              struct file *file;
-+              void *label, *label_file;
++              void *label;
 +      } *f, file[] = {
 +              {
-+                      .bindex = basic->bsrc,
++                      .bindex = cpg->bsrc,
 +                      .flags = O_RDONLY | O_NOATIME | O_LARGEFILE,
-+                      .file = NULL,
-+                      .label = &&out,
-+                      .label_file = &&out_src
++                      .label = &&out
 +              },
 +              {
-+                      .bindex = basic->bdst,
++                      .bindex = cpg->bdst,
 +                      .flags = O_WRONLY | O_NOATIME | O_LARGEFILE,
-+                      .file = NULL,
-+                      .label = &&out_src,
-+                      .label_file = &&out_dst
++                      .force_wr = !!au_ftest_cpup(cpg->flags, RWDST),
++                      .label = &&out_src
 +              }
 +      };
 +      struct super_block *sb;
 +
 +      /* bsrc branch can be ro/rw. */
-+      sb = basic->dentry->d_sb;
++      sb = cpg->dentry->d_sb;
 +      f = file;
 +      for (i = 0; i < 2; i++, f++) {
-+              f->dentry = au_h_dptr(basic->dentry, f->bindex);
-+              f->file = au_h_open(basic->dentry, f->bindex, f->flags,
-+                                  /*file*/NULL);
++              f->dentry = au_h_dptr(cpg->dentry, f->bindex);
++              f->file = au_h_open(cpg->dentry, f->bindex, f->flags,
++                                  /*file*/NULL, f->force_wr);
 +              err = PTR_ERR(f->file);
 +              if (IS_ERR(f->file))
 +                      goto *f->label;
-+              err = -EINVAL;
-+              if (unlikely(!f->file->f_op))
-+                      goto *f->label_file;
 +      }
 +
 +      /* try stopping to update while we copyup */
 +      IMustLock(file[SRC].dentry->d_inode);
-+      err = au_copy_file(file[DST].file, file[SRC].file, basic->len);
++      err = au_copy_file(file[DST].file, file[SRC].file, cpg->len);
 +
-+out_dst:
 +      fput(file[DST].file);
 +      au_sbr_put(sb, file[DST].bindex);
++
 +out_src:
 +      fput(file[SRC].file);
 +      au_sbr_put(sb, file[SRC].bindex);
@@ -3820,7 +4217,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      return err;
 +}
 +
-+static int au_do_cpup_regular(struct au_cpup_basic *basic, struct au_pin *pin,
++static int au_do_cpup_regular(struct au_cp_generic *cpg,
 +                            struct au_cpup_reg_attr *h_src_attr)
 +{
 +      int err, rerr;
@@ -3829,17 +4226,17 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      struct inode *h_src_inode;
 +
 +      err = 0;
-+      h_src_inode = au_h_iptr(basic->dentry->d_inode, basic->bsrc);
++      h_src_inode = au_h_iptr(cpg->dentry->d_inode, cpg->bsrc);
 +      l = i_size_read(h_src_inode);
-+      if (basic->len == -1 || l < basic->len)
-+              basic->len = l;
-+      if (basic->len) {
++      if (cpg->len == -1 || l < cpg->len)
++              cpg->len = l;
++      if (cpg->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);
++              au_pin_hdir_unlock(cpg->pin);
 +
-+              h_path.dentry = au_h_dptr(basic->dentry, basic->bsrc);
-+              h_path.mnt = au_sbr_mnt(basic->dentry->d_sb, basic->bsrc);
++              h_path.dentry = au_h_dptr(cpg->dentry, cpg->bsrc);
++              h_path.mnt = au_sbr_mnt(cpg->dentry->d_sb, cpg->bsrc);
 +              h_src_attr->iflags = h_src_inode->i_flags;
 +              err = vfs_getattr(&h_path, &h_src_attr->st);
 +              if (unlikely(err)) {
@@ -3847,9 +4244,9 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +                      goto out;
 +              }
 +              h_src_attr->valid = 1;
-+              err = au_cp_regular(basic);
++              err = au_cp_regular(cpg);
 +              mutex_unlock(&h_src_inode->i_mutex);
-+              rerr = au_pin_hdir_relock(pin);
++              rerr = au_pin_hdir_relock(cpg->pin);
 +              if (!err && rerr)
 +                      err = rerr;
 +      }
@@ -3895,15 +4292,14 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +}
 +
 +static noinline_for_stack
-+int cpup_entry(struct au_cpup_basic *basic, unsigned int flags,
-+             struct dentry *dst_parent, struct au_pin *pin,
++int cpup_entry(struct au_cp_generic *cpg, struct dentry *dst_parent,
 +             struct au_cpup_reg_attr *h_src_attr)
 +{
 +      int err;
 +      umode_t mode;
 +      unsigned int mnt_flags;
 +      unsigned char isdir;
-+      const unsigned char do_dt = !!au_ftest_cpup(flags, DTIME);
++      const unsigned char do_dt = !!au_ftest_cpup(cpg->flags, DTIME);
 +      struct au_dtime dt;
 +      struct path h_path;
 +      struct dentry *h_src, *h_dst, *h_parent;
@@ -3911,13 +4307,13 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      struct super_block *sb;
 +
 +      /* bsrc branch can be ro/rw. */
-+      h_src = au_h_dptr(basic->dentry, basic->bsrc);
++      h_src = au_h_dptr(cpg->dentry, cpg->bsrc);
 +      h_inode = h_src->d_inode;
-+      AuDebugOn(h_inode != au_h_iptr(basic->dentry->d_inode, basic->bsrc));
++      AuDebugOn(h_inode != au_h_iptr(cpg->dentry->d_inode, cpg->bsrc));
 +
 +      /* try stopping to be referenced while we are creating */
-+      h_dst = au_h_dptr(basic->dentry, basic->bdst);
-+      if (au_ftest_cpup(flags, RENAME))
++      h_dst = au_h_dptr(cpg->dentry, cpg->bdst);
++      if (au_ftest_cpup(cpg->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 */
@@ -3925,8 +4321,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      IMustLock(h_dir);
 +      AuDebugOn(h_parent != h_dst->d_parent);
 +
-+      sb = basic->dentry->d_sb;
-+      h_path.mnt = au_sbr_mnt(sb, basic->bdst);
++      sb = cpg->dentry->d_sb;
++      h_path.mnt = au_sbr_mnt(sb, cpg->bdst);
 +      if (do_dt) {
 +              h_path.dentry = h_parent;
 +              au_dtime_store(&dt, dst_parent, &h_path);
@@ -3940,7 +4336,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              err = vfsub_create(h_dir, &h_path, mode | S_IWUSR,
 +                                 /*want_excl*/true);
 +              if (!err)
-+                      err = au_do_cpup_regular(basic, pin, h_src_attr);
++                      err = au_do_cpup_regular(cpg, h_src_attr);
 +              break;
 +      case S_IFDIR:
 +              isdir = 1;
@@ -3950,10 +4346,10 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +                       * strange behaviour from the users view,
 +                       * particularry setattr case
 +                       */
-+                      if (au_ibstart(dst_parent->d_inode) == basic->bdst)
++                      if (au_ibstart(dst_parent->d_inode) == cpg->bdst)
 +                              au_cpup_attr_nlink(dst_parent->d_inode,
 +                                                 /*force*/1);
-+                      au_cpup_attr_nlink(basic->dentry->d_inode, /*force*/1);
++                      au_cpup_attr_nlink(cpg->dentry->d_inode, /*force*/1);
 +              }
 +              break;
 +      case S_IFLNK:
@@ -3978,10 +4374,10 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +          && au_opt_test(mnt_flags, XINO)
 +          && h_inode->i_nlink == 1
 +          /* todo: unnecessary? */
-+          /* && basic->dentry->d_inode->i_nlink == 1 */
-+          && basic->bdst < basic->bsrc
-+          && !au_ftest_cpup(flags, KEEPLINO))
-+              au_xino_write(sb, basic->bsrc, h_inode->i_ino, /*ino*/0);
++          /* && cpg->dentry->d_inode->i_nlink == 1 */
++          && cpg->bdst < cpg->bsrc
++          && !au_ftest_cpup(cpg->flags, KEEPLINO))
++              au_xino_write(sb, cpg->bsrc, h_inode->i_ino, /*ino*/0);
 +              /* ignore this error */
 +
 +      if (do_dt)
@@ -3989,28 +4385,41 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      return err;
 +}
 +
-+static int au_do_ren_after_cpup(struct dentry *dentry, aufs_bindex_t bdst,
-+                              struct path *h_path)
++static int au_do_ren_after_cpup(struct au_cp_generic *cpg, struct path *h_path)
 +{
 +      int err;
-+      struct dentry *h_dentry, *h_parent;
++      struct dentry *dentry, *h_dentry, *h_parent, *parent;
 +      struct inode *h_dir;
++      aufs_bindex_t bdst;
 +
-+      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)) {
++      dentry = cpg->dentry;
++      bdst = cpg->bdst;
++      h_dentry = au_h_dptr(dentry, bdst);
++      if (!au_ftest_cpup(cpg->flags, OVERWRITE)) {
++              dget(h_dentry);
++              au_set_h_dptr(dentry, bdst, NULL);
++              err = au_lkup_neg(dentry, bdst, /*wh*/0);
++              if (!err)
++                      h_path->dentry = dget(au_h_dptr(dentry, bdst));
 +              au_set_h_dptr(dentry, bdst, h_dentry);
-+              goto out;
++      } else {
++              err = 0;
++              parent = dget_parent(dentry);
++              h_parent = au_h_dptr(parent, bdst);
++              dput(parent);
++              h_path->dentry = vfsub_lkup_one(&dentry->d_name, h_parent);
++              if (IS_ERR(h_path->dentry))
++                      err = PTR_ERR(h_path->dentry);
 +      }
++      if (unlikely(err))
++              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);
++      AuDbg("%pd %pd\n", h_dentry, h_path->dentry);
++      /* no delegation since it is just created */
++      err = vfsub_rename(h_dir, h_dentry, h_dir, h_path, /*delegated*/NULL);
 +      dput(h_path->dentry);
 +
 +out:
@@ -4022,82 +4431,92 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 + * 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.
++ * basic->bsrc can be larger than basic->bdst.
 + */
-+static int au_cpup_single(struct au_cpup_basic *basic, unsigned int flags,
-+                        struct dentry *dst_parent, struct au_pin *pin)
++static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent)
 +{
 +      int err, rerr;
 +      aufs_bindex_t old_ibstart;
 +      unsigned char isdir, plink;
-+      struct au_dtime dt;
-+      struct path h_path;
 +      struct dentry *h_src, *h_dst, *h_parent;
-+      struct inode *dst_inode, *h_dir, *inode;
++      struct inode *dst_inode, *h_dir, *inode, *delegated;
 +      struct super_block *sb;
 +      struct au_branch *br;
-+      struct au_cpup_reg_attr h_src_attr = {
-+              .valid = 0
-+      };
++      /* to reuduce stack size */
++      struct {
++              struct au_dtime dt;
++              struct path h_path;
++              struct au_cpup_reg_attr h_src_attr;
++      } *a;
 +
-+      AuDebugOn(basic->bsrc <= basic->bdst);
++      err = -ENOMEM;
++      a = kmalloc(sizeof(*a), GFP_NOFS);
++      if (unlikely(!a))
++              goto out;
++      a->h_src_attr.valid = 0;
 +
-+      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);
++      sb = cpg->dentry->d_sb;
++      br = au_sbr(sb, cpg->bdst);
++      a->h_path.mnt = au_br_mnt(br);
++      h_dst = au_h_dptr(cpg->dentry, cpg->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(basic->dentry, basic->bsrc);
-+      inode = basic->dentry->d_inode;
++      h_src = au_h_dptr(cpg->dentry, cpg->bsrc);
++      inode = cpg->dentry->d_inode;
 +
 +      if (!dst_parent)
-+              dst_parent = dget_parent(basic->dentry);
++              dst_parent = dget_parent(cpg->dentry);
 +      else
 +              dget(dst_parent);
 +
 +      plink = !!au_opt_test(au_mntflags(sb), PLINK);
-+      dst_inode = au_h_iptr(inode, basic->bdst);
++      dst_inode = au_h_iptr(inode, cpg->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, basic->bdst);
-+                      goto out;
++                              dst_inode->i_ino, inode->i_ino, cpg->bdst);
++                      goto out_parent;
 +              }
 +
 +              if (dst_inode->i_nlink) {
-+                      const int do_dt = au_ftest_cpup(flags, DTIME);
++                      const int do_dt = au_ftest_cpup(cpg->flags, DTIME);
 +
-+                      h_src = au_plink_lkup(inode, basic->bdst);
++                      h_src = au_plink_lkup(inode, cpg->bdst);
 +                      err = PTR_ERR(h_src);
 +                      if (IS_ERR(h_src))
-+                              goto out;
++                              goto out_parent;
 +                      if (unlikely(!h_src->d_inode)) {
 +                              err = -EIO;
 +                              AuIOErr("i%lu exists on a upper branch "
 +                                      "but not pseudo-linked\n",
 +                                      inode->i_ino);
 +                              dput(h_src);
-+                              goto out;
++                              goto out_parent;
 +                      }
 +
 +                      if (do_dt) {
-+                              h_path.dentry = h_parent;
-+                              au_dtime_store(&dt, dst_parent, &h_path);
++                              a->h_path.dentry = h_parent;
++                              au_dtime_store(&a->dt, dst_parent, &a->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);
++                      a->h_path.dentry = h_dst;
++                      delegated = NULL;
++                      err = vfsub_link(h_src, h_dir, &a->h_path, &delegated);
++                      if (!err && au_ftest_cpup(cpg->flags, RENAME))
++                              err = au_do_ren_after_cpup(cpg, &a->h_path);
 +                      if (do_dt)
-+                              au_dtime_revert(&dt);
++                              au_dtime_revert(&a->dt);
++                      if (unlikely(err == -EWOULDBLOCK)) {
++                              pr_warn("cannot retry for NFSv4 delegation"
++                                      " for an internal link\n");
++                              iput(delegated);
++                      }
 +                      dput(h_src);
-+                      goto out;
++                      goto out_parent;
 +              } else
 +                      /* todo: cpup_wh_file? */
 +                      /* udba work */
@@ -4106,38 +4525,40 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +
 +      isdir = S_ISDIR(inode->i_mode);
 +      old_ibstart = au_ibstart(inode);
-+      err = cpup_entry(basic, flags, dst_parent, pin, &h_src_attr);
++      err = cpup_entry(cpg, dst_parent, &a->h_src_attr);
 +      if (unlikely(err))
 +              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); */
++      /* au_pin_hdir_unlock(cpg->pin); */
 +
-+      err = cpup_iattr(basic->dentry, basic->bdst, h_src, &h_src_attr);
++      err = cpup_iattr(cpg->dentry, cpg->bdst, h_src, &a->h_src_attr);
 +      if (unlikely(err)) {
 +              /* todo: necessary? */
-+              /* au_pin_hdir_relock(pin); */ /* ignore an error */
++              /* au_pin_hdir_relock(cpg->pin); */ /* ignore an error */
 +              mutex_unlock(&dst_inode->i_mutex);
 +              goto out_rev;
 +      }
 +
-+      if (basic->bdst < old_ibstart) {
++      if (cpg->bdst < old_ibstart) {
 +              if (S_ISREG(inode->i_mode)) {
-+                      err = au_dy_iaop(inode, basic->bdst, dst_inode);
++                      err = au_dy_iaop(inode, cpg->bdst, dst_inode);
 +                      if (unlikely(err)) {
-+                              /* au_pin_hdir_relock(pin); ignore an error */
++                              /* ignore an error */
++                              /* au_pin_hdir_relock(cpg->pin); */
 +                              mutex_unlock(&dst_inode->i_mutex);
 +                              goto out_rev;
 +                      }
 +              }
-+              au_set_ibstart(inode, basic->bdst);
-+      }
-+      au_set_h_iptr(inode, basic->bdst, au_igrab(dst_inode),
++              au_set_ibstart(inode, cpg->bdst);
++      } else
++              au_set_ibend(inode, cpg->bdst);
++      au_set_h_iptr(inode, cpg->bdst, au_igrab(dst_inode),
 +                    au_hi_flags(inode, isdir));
 +
 +      /* todo: necessary? */
-+      /* err = au_pin_hdir_relock(pin); */
++      /* err = au_pin_hdir_relock(cpg->pin); */
 +      mutex_unlock(&dst_inode->i_mutex);
 +      if (unlikely(err))
 +              goto out_rev;
@@ -4145,53 +4566,57 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      if (!isdir
 +          && h_src->d_inode->i_nlink > 1
 +          && plink)
-+              au_plink_append(inode, basic->bdst, h_dst);
++              au_plink_append(inode, cpg->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 (au_ftest_cpup(cpg->flags, RENAME)) {
++              a->h_path.dentry = h_dst;
++              err = au_do_ren_after_cpup(cpg, &a->h_path);
 +      }
 +      if (!err)
-+              goto out; /* success */
++              goto out_parent; /* success */
 +
 +      /* revert */
 +out_rev:
-+      h_path.dentry = h_parent;
-+      au_dtime_store(&dt, dst_parent, &h_path);
-+      h_path.dentry = h_dst;
++      a->h_path.dentry = h_parent;
++      au_dtime_store(&a->dt, dst_parent, &a->h_path);
++      a->h_path.dentry = h_dst;
 +      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);
++              if (!isdir) {
++                      /* no delegation since it is just created */
++                      rerr = vfsub_unlink(h_dir, &a->h_path,
++                                          /*delegated*/NULL, /*force*/0);
++              } else
++                      rerr = vfsub_rmdir(h_dir, &a->h_path);
 +      }
-+      au_dtime_revert(&dt);
++      au_dtime_revert(&a->dt);
 +      if (rerr) {
 +              AuIOErr("failed removing broken entry(%d, %d)\n", err, rerr);
 +              err = -EIO;
 +      }
-+out:
++out_parent:
 +      dput(dst_parent);
++      kfree(a);
++out:
 +      return err;
 +}
 +
++#if 0 /* unused */
 +struct au_cpup_single_args {
 +      int *errp;
-+      struct au_cpup_basic *basic;
-+      unsigned int flags;
++      struct au_cp_generic *cpg;
 +      struct dentry *dst_parent;
-+      struct au_pin *pin;
 +};
 +
 +static void au_call_cpup_single(void *args)
 +{
 +      struct au_cpup_single_args *a = args;
 +
-+      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);
++      au_pin_hdir_acquire_nest(a->cpg->pin);
++      *a->errp = au_cpup_single(a->cpg, a->dst_parent);
++      au_pin_hdir_release(a->cpg->pin);
 +}
++#endif
 +
 +/*
 + * prevent SIGXFSZ in copy-up.
@@ -4232,29 +4657,20 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      return do_sio;
 +}
 +
-+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 au_pin *pin)
++#if 0 /* unused */
++int au_sio_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent)
 +{
 +      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);
++      h_dentry = au_h_dptr(cpg->dentry, cpg->bsrc);
 +      if (!au_cpup_sio_test(pin, h_dentry->d_inode->i_mode))
-+              err = au_cpup_single(&basic, flags, dst_parent, pin);
++              err = au_cpup_single(cpg, dst_parent);
 +      else {
 +              struct au_cpup_single_args args = {
 +                      .errp           = &err,
-+                      .basic          = &basic,
-+                      .flags          = flags,
-+                      .dst_parent     = dst_parent,
-+                      .pin            = pin
++                      .cpg            = cpg,
++                      .dst_parent     = dst_parent
 +              };
 +              wkq_err = au_wkq_wait(au_call_cpup_single, &args);
 +              if (unlikely(wkq_err))
@@ -4263,44 +4679,35 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +
 +      return err;
 +}
++#endif
 +
 +/*
 + * copyup the @dentry from the first active lower branch to @bdst,
 + * using au_cpup_single().
 + */
-+static int au_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+                        unsigned int flags, struct au_pin *pin)
++static int au_cpup_simple(struct au_cp_generic *cpg)
 +{
 +      int err;
-+      aufs_bindex_t bsrc, bend;
-+      struct dentry *h_dentry;
++      unsigned int flags_orig;
++      struct dentry *dentry;
++
++      AuDebugOn(cpg->bsrc < 0);
 +
++      dentry = cpg->dentry;
 +      DiMustWriteLock(dentry);
-+      bend = au_dbend(dentry);
-+      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, /*wh*/1);
++      err = au_lkup_neg(dentry, cpg->bdst, /*wh*/1);
 +      if (!err) {
-+              struct au_cpup_basic basic = {
-+                      .dentry = dentry,
-+                      .bdst   = bdst,
-+                      .bsrc   = bsrc,
-+                      .len    = len
-+              };
-+              err = au_cpup_single(&basic, flags | AuCpup_RENAME, NULL, pin);
++              flags_orig = cpg->flags;
++              au_fset_cpup(cpg->flags, RENAME);
++              err = au_cpup_single(cpg, NULL);
++              cpg->flags = flags_orig;
 +              if (!err)
 +                      return 0; /* success */
 +
 +              /* revert */
-+              au_set_h_dptr(dentry, bdst, NULL);
-+              au_set_dbstart(dentry, bsrc);
++              au_set_h_dptr(dentry, cpg->bdst, NULL);
++              au_set_dbstart(dentry, cpg->bsrc);
 +      }
 +
 +      return err;
@@ -4308,42 +4715,44 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +
 +struct au_cpup_simple_args {
 +      int *errp;
-+      struct dentry *dentry;
-+      aufs_bindex_t bdst;
-+      loff_t len;
-+      unsigned int flags;
-+      struct au_pin *pin;
++      struct au_cp_generic *cpg;
 +};
 +
 +static void au_call_cpup_simple(void *args)
 +{
 +      struct au_cpup_simple_args *a = args;
 +
-+      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);
++      au_pin_hdir_acquire_nest(a->cpg->pin);
++      *a->errp = au_cpup_simple(a->cpg);
++      au_pin_hdir_release(a->cpg->pin);
 +}
 +
-+int au_sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+                     unsigned int flags, struct au_pin *pin)
++static int au_do_sio_cpup_simple(struct au_cp_generic *cpg)
 +{
 +      int err, wkq_err;
-+      struct dentry *parent;
++      struct dentry *dentry, *parent;
++      struct file *h_file;
 +      struct inode *h_dir;
 +
++      dentry = cpg->dentry;
++      h_file = NULL;
++      if (au_ftest_cpup(cpg->flags, HOPEN)) {
++              AuDebugOn(cpg->bsrc < 0);
++              h_file = au_h_open_pre(dentry, cpg->bsrc, /*force_wr*/0);
++              err = PTR_ERR(h_file);
++              if (IS_ERR(h_file))
++                      goto out;
++      }
++
 +      parent = dget_parent(dentry);
-+      h_dir = au_h_iptr(parent->d_inode, bdst);
++      h_dir = au_h_iptr(parent->d_inode, cpg->bdst);
 +      if (!au_test_h_perm_sio(h_dir, MAY_EXEC | MAY_WRITE)
-+          && !au_cpup_sio_test(pin, dentry->d_inode->i_mode))
-+              err = au_cpup_simple(dentry, bdst, len, flags, pin);
++          && !au_cpup_sio_test(cpg->pin, dentry->d_inode->i_mode))
++              err = au_cpup_simple(cpg);
 +      else {
 +              struct au_cpup_simple_args args = {
 +                      .errp           = &err,
-+                      .dentry         = dentry,
-+                      .bdst           = bdst,
-+                      .len            = len,
-+                      .flags          = flags,
-+                      .pin            = pin
++                      .cpg            = cpg
 +              };
 +              wkq_err = au_wkq_wait(au_call_cpup_simple, &args);
 +              if (unlikely(wkq_err))
@@ -4351,63 +4760,97 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      }
 +
 +      dput(parent);
++      if (h_file)
++              au_h_open_post(dentry, cpg->bsrc, h_file);
++
++out:
 +      return err;
 +}
 +
++int au_sio_cpup_simple(struct au_cp_generic *cpg)
++{
++      aufs_bindex_t bsrc, bend;
++      struct dentry *dentry, *h_dentry;
++
++      if (cpg->bsrc < 0) {
++              dentry = cpg->dentry;
++              bend = au_dbend(dentry);
++              for (bsrc = cpg->bdst + 1; bsrc <= bend; bsrc++) {
++                      h_dentry = au_h_dptr(dentry, bsrc);
++                      if (h_dentry) {
++                              AuDebugOn(!h_dentry->d_inode);
++                              break;
++                      }
++              }
++              AuDebugOn(bsrc > bend);
++              cpg->bsrc = bsrc;
++      }
++      AuDebugOn(cpg->bsrc <= cpg->bdst);
++      return au_do_sio_cpup_simple(cpg);
++}
++
++int au_sio_cpdown_simple(struct au_cp_generic *cpg)
++{
++      AuDebugOn(cpg->bdst <= cpg->bsrc);
++      return au_do_sio_cpup_simple(cpg);
++}
++
 +/* ---------------------------------------------------------------------- */
 +
 +/*
 + * copyup the deleted file for writing.
 + */
-+static int au_do_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst,
-+                       struct dentry *wh_dentry, struct file *file,
-+                       loff_t len, struct au_pin *pin)
++static int au_do_cpup_wh(struct au_cp_generic *cpg, struct dentry *wh_dentry,
++                       struct file *file)
 +{
 +      int err;
-+      struct au_cpup_basic basic = {
-+              .dentry = dentry,
-+              .bdst   = bdst,
-+              .bsrc   = -1,
-+              .len    = len
-+      };
-+      struct au_dinfo *dinfo;
++      unsigned int flags_orig;
++      aufs_bindex_t bsrc_orig;
 +      struct dentry *h_d_dst, *h_d_start;
++      struct au_dinfo *dinfo;
 +      struct au_hdentry *hdp;
 +
-+      dinfo = au_di(dentry);
++      dinfo = au_di(cpg->dentry);
 +      AuRwMustWriteLock(&dinfo->di_rwsem);
 +
-+      basic.bsrc = dinfo->di_bstart;
++      bsrc_orig = cpg->bsrc;
++      cpg->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_dst = hdp[0 + cpg->bdst].hd_dentry;
++      dinfo->di_bstart = cpg->bdst;
++      hdp[0 + cpg->bdst].hd_dentry = wh_dentry;
 +      h_d_start = NULL;
 +      if (file) {
-+              h_d_start = hdp[0 + basic.bsrc].hd_dentry;
-+              hdp[0 + basic.bsrc].hd_dentry = au_hf_top(file)->f_dentry;
++              h_d_start = hdp[0 + cpg->bsrc].hd_dentry;
++              hdp[0 + cpg->bsrc].hd_dentry = au_hf_top(file)->f_dentry;
 +      }
-+      err = au_cpup_single(&basic, !AuCpup_DTIME, /*h_parent*/NULL, pin);
++      flags_orig = cpg->flags;
++      cpg->flags = !AuCpup_DTIME;
++      err = au_cpup_single(cpg, /*h_parent*/NULL);
++      cpg->flags = flags_orig;
 +      if (file) {
 +              if (!err)
 +                      err = au_reopen_nondir(file);
-+              hdp[0 + basic.bsrc].hd_dentry = h_d_start;
++              hdp[0 + cpg->bsrc].hd_dentry = h_d_start;
 +      }
-+      hdp[0 + bdst].hd_dentry = h_d_dst;
-+      dinfo->di_bstart = basic.bsrc;
++      hdp[0 + cpg->bdst].hd_dentry = h_d_dst;
++      dinfo->di_bstart = cpg->bsrc;
++      cpg->bsrc = bsrc_orig;
 +
 +      return err;
 +}
 +
-+static int au_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+                    struct file *file, struct au_pin *pin)
++static int au_cpup_wh(struct au_cp_generic *cpg, struct file *file)
 +{
 +      int err;
++      aufs_bindex_t bdst;
 +      struct au_dtime dt;
-+      struct dentry *parent, *h_parent, *wh_dentry;
++      struct dentry *dentry, *parent, *h_parent, *wh_dentry;
 +      struct au_branch *br;
 +      struct path h_path;
 +
++      dentry = cpg->dentry;
++      bdst = cpg->bdst;
 +      br = au_sbr(dentry->d_sb, bdst);
 +      parent = dget_parent(dentry);
 +      h_parent = au_h_dptr(parent, bdst);
@@ -4419,19 +4862,21 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      h_path.dentry = h_parent;
 +      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, pin);
++      err = au_do_cpup_wh(cpg, wh_dentry, file);
 +      if (unlikely(err))
 +              goto out_wh;
 +
 +      dget(wh_dentry);
 +      h_path.dentry = wh_dentry;
-+      if (!S_ISDIR(wh_dentry->d_inode->i_mode))
-+              err = vfsub_unlink(h_parent->d_inode, &h_path, /*force*/0);
-+      else
++      if (!S_ISDIR(wh_dentry->d_inode->i_mode)) {
++              /* no delegation since it is just created */
++              err = vfsub_unlink(h_parent->d_inode, &h_path,
++                                 /*delegated*/NULL, /*force*/0);
++      } else
 +              err = vfsub_rmdir(h_parent->d_inode, &h_path);
 +      if (unlikely(err)) {
-+              AuIOErr("failed remove copied-up tmp file %.*s(%d)\n",
-+                      AuDLNPair(wh_dentry), err);
++              AuIOErr("failed remove copied-up tmp file %pd(%d)\n",
++                      wh_dentry, err);
 +              err = -EIO;
 +      }
 +      au_dtime_revert(&dt);
@@ -4446,37 +4891,37 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +
 +struct au_cpup_wh_args {
 +      int *errp;
-+      struct dentry *dentry;
-+      aufs_bindex_t bdst;
-+      loff_t len;
++      struct au_cp_generic *cpg;
 +      struct file *file;
-+      struct au_pin *pin;
 +};
 +
 +static void au_call_cpup_wh(void *args)
 +{
 +      struct au_cpup_wh_args *a = args;
 +
-+      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);
++      au_pin_hdir_acquire_nest(a->cpg->pin);
++      *a->errp = au_cpup_wh(a->cpg, a->file);
++      au_pin_hdir_release(a->cpg->pin);
 +}
 +
-+int au_sio_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+                 struct file *file, struct au_pin *pin)
++int au_sio_cpup_wh(struct au_cp_generic *cpg, struct file *file)
 +{
 +      int err, wkq_err;
-+      struct dentry *parent, *h_orph, *h_parent, *h_dentry;
++      aufs_bindex_t bdst;
++      struct dentry *dentry, *parent, *h_orph, *h_parent, *h_dentry;
 +      struct inode *dir, *h_dir, *h_tmpdir;
 +      struct au_wbr *wbr;
-+      struct au_pin wh_pin;
++      struct au_pin wh_pin, *pin_orig;
 +
++      dentry = cpg->dentry;
++      bdst = cpg->bdst;
 +      parent = dget_parent(dentry);
 +      dir = parent->d_inode;
 +      h_orph = NULL;
 +      h_parent = NULL;
 +      h_dir = au_igrab(au_h_iptr(dir, bdst));
 +      h_tmpdir = h_dir;
++      pin_orig = NULL;
 +      if (!h_dir->i_nlink) {
 +              wbr = au_sbr(dentry->d_sb, bdst)->br_wbr;
 +              h_orph = wbr->wbr_orph;
@@ -4493,22 +4938,20 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              mutex_lock_nested(&h_tmpdir->i_mutex, AuLsc_I_PARENT3);
 +              /* todo: au_h_open_pre()? */
 +
++              pin_orig = cpg->pin;
 +              au_pin_init(&wh_pin, dentry, bdst, AuLsc_DI_PARENT,
-+                          AuLsc_I_PARENT3, pin->udba, AuPin_DI_LOCKED);
-+              pin = &wh_pin;
++                          AuLsc_I_PARENT3, cpg->pin->udba, AuPin_DI_LOCKED);
++              cpg->pin = &wh_pin;
 +      }
 +
 +      if (!au_test_h_perm_sio(h_tmpdir, MAY_EXEC | MAY_WRITE)
-+          && !au_cpup_sio_test(pin, dentry->d_inode->i_mode))
-+              err = au_cpup_wh(dentry, bdst, len, file, pin);
++          && !au_cpup_sio_test(cpg->pin, dentry->d_inode->i_mode))
++              err = au_cpup_wh(cpg, file);
 +      else {
 +              struct au_cpup_wh_args args = {
 +                      .errp   = &err,
-+                      .dentry = dentry,
-+                      .bdst   = bdst,
-+                      .len    = len,
-+                      .file   = file,
-+                      .pin    = pin
++                      .cpg    = cpg,
++                      .file   = file
 +              };
 +              wkq_err = au_wkq_wait(au_call_cpup_wh, &args);
 +              if (unlikely(wkq_err))
@@ -4520,6 +4963,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              /* todo: au_h_open_post()? */
 +              au_set_h_iptr(dir, bdst, au_igrab(h_dir), /*flags*/0);
 +              au_set_h_dptr(parent, bdst, h_parent);
++              AuDebugOn(!pin_orig);
++              cpg->pin = pin_orig;
 +      }
 +      iput(h_dir);
 +      dput(parent);
@@ -4602,7 +5047,15 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +                     struct dentry *h_parent __maybe_unused ,
 +                     void *arg __maybe_unused)
 +{
-+      return au_sio_cpup_simple(dentry, bdst, -1, AuCpup_DTIME, pin);
++      struct au_cp_generic cpg = {
++              .dentry = dentry,
++              .bdst   = bdst,
++              .bsrc   = -1,
++              .len    = 0,
++              .pin    = pin,
++              .flags  = AuCpup_DTIME
++      };
++      return au_sio_cpup_simple(&cpg);
 +}
 +
 +int au_cpup_dirs(struct dentry *dentry, aufs_bindex_t bdst)
@@ -4635,10 +5088,10 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +}
 diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
 --- /usr/share/empty/fs/aufs/cpup.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/cpup.h       2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,84 @@
++++ linux/fs/aufs/cpup.h       2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,94 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -4651,8 +5104,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -4679,11 +5131,26 @@ diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
 +
 +/* ---------------------------------------------------------------------- */
 +
++struct au_cp_generic {
++      struct dentry   *dentry;
++      aufs_bindex_t   bdst, bsrc;
++      loff_t          len;
++      struct au_pin   *pin;
++      unsigned int    flags;
++};
++
 +/* cpup flags */
-+#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 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 AuCpup_HOPEN          (1 << 3)        /* call h_open_pre/post() in
++                                                 cpup */
++#define AuCpup_OVERWRITE      (1 << 4)        /* allow overwriting the
++                                                 existing entry */
++#define AuCpup_RWDST          (1 << 5)        /* force write target even if
++                                                 the branch is marked as RO */
++
 +#define au_ftest_cpup(flags, name)    ((flags) & AuCpup_##name)
 +#define au_fset_cpup(flags, name) \
 +      do { (flags) |= AuCpup_##name; } while (0)
@@ -4691,13 +5158,9 @@ diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
 +      do { (flags) &= ~AuCpup_##name; } while (0)
 +
 +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 au_pin *pin);
-+int au_sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+                     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 au_pin *pin);
++int au_sio_cpup_simple(struct au_cp_generic *cpg);
++int au_sio_cpdown_simple(struct au_cp_generic *cpg);
++int au_sio_cpup_wh(struct au_cp_generic *cpg, struct file *file);
 +
 +int au_cp_dirs(struct dentry *dentry, aufs_bindex_t bdst,
 +             int (*cp)(struct dentry *dentry, aufs_bindex_t bdst,
@@ -4723,10 +5186,10 @@ diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
 +#endif /* __AUFS_CPUP_H__ */
 diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 --- /usr/share/empty/fs/aufs/dbgaufs.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dbgaufs.c    2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,433 @@
++++ linux/fs/aufs/dbgaufs.c    2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,432 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -4739,8 +5202,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -5160,10 +5622,10 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +}
 diff -urN /usr/share/empty/fs/aufs/dbgaufs.h linux/fs/aufs/dbgaufs.h
 --- /usr/share/empty/fs/aufs/dbgaufs.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dbgaufs.h    2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,49 @@
++++ linux/fs/aufs/dbgaufs.h    2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,48 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -5176,8 +5638,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.h linux/fs/aufs/dbgaufs.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -5213,10 +5674,10 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.h linux/fs/aufs/dbgaufs.h
 +#endif /* __DBGAUFS_H__ */
 diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 --- /usr/share/empty/fs/aufs/dcsub.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dcsub.c      2013-07-06 13:20:47.740198107 +0200
++++ linux/fs/aufs/dcsub.c      2014-04-24 22:11:10.848602379 +0200
 @@ -0,0 +1,243 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -5229,8 +5690,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -5315,7 +5775,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +              dpages->ndpage++;
 +      }
 +
-+      AuDebugOn(!dentry->d_count);
++      AuDebugOn(!d_count(dentry));
 +      dpage->dentries[dpage->ndentry++] = dget_dlock(dentry);
 +      return 0; /* success */
 +
@@ -5323,6 +5783,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      return err;
 +}
 +
++/* try d_walk() in linux/fs/dcache.c */
 +int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
 +                 au_dpages_test test, void *arg)
 +{
@@ -5341,7 +5802,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      if (this_parent->d_sb == sb
 +          && !IS_ROOT(this_parent)
 +          && au_di(this_parent)
-+          && this_parent->d_count
++          && d_count(this_parent)
 +          && (!test || test(this_parent, arg))) {
 +              err = au_dpages_append(dpages, this_parent, GFP_ATOMIC);
 +              if (unlikely(err))
@@ -5355,7 +5816,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +
 +              next = tmp->next;
 +              spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
-+              if (dentry->d_count) {
++              if (d_count(dentry)) {
 +                      if (!list_empty(&dentry->d_subdirs)) {
 +                              spin_unlock(&this_parent->d_lock);
 +                              spin_release(&dentry->d_lock.dep_map, 1,
@@ -5406,7 +5867,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      write_seqlock(&rename_lock);
 +      spin_lock(&dentry->d_lock);
 +      if (do_include
-+          && dentry->d_count
++          && d_count(dentry)
 +          && (!test || test(dentry, arg)))
 +              err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
 +      spin_unlock(&dentry->d_lock);
@@ -5414,13 +5875,13 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +              goto out;
 +
 +      /*
-+       * vfsmount_lock is unnecessary since this is a traverse in a single
++       * RCU for vfsmount is unnecessary since this is a traverse in a single
 +       * mount
 +       */
 +      while (!IS_ROOT(dentry)) {
 +              dentry = dentry->d_parent; /* rename_lock is locked */
 +              spin_lock(&dentry->d_lock);
-+              if (dentry->d_count
++              if (d_count(dentry)
 +                  && (!test || test(dentry, arg)))
 +                      err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
 +              spin_unlock(&dentry->d_lock);
@@ -5460,10 +5921,10 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +}
 diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
 --- /usr/share/empty/fs/aufs/dcsub.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dcsub.h      2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,94 @@
++++ linux/fs/aufs/dcsub.h      2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,98 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -5476,8 +5937,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -5520,6 +5980,11 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
 +
 +/* ---------------------------------------------------------------------- */
 +
++/*
++ * todo: in linux-3.13, several similar (but faster) helpers are added to
++ * include/linux/dcache.h. Try them (in the future).
++ */
++
 +static inline int au_d_hashed_positive(struct dentry *d)
 +{
 +      int err;
@@ -5558,10 +6023,10 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
 +#endif /* __AUFS_DCSUB_H__ */
 diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 --- /usr/share/empty/fs/aufs/debug.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/debug.c      2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,491 @@
++++ linux/fs/aufs/debug.c      2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,517 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -5574,8 +6039,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -5585,9 +6049,39 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +#include <linux/vt_kern.h>
 +#include "aufs.h"
 +
-+int aufs_debug;
++/* Returns 0, or -errno.  arg is in kp->arg. */
++static int param_atomic_t_set(const char *val, const struct kernel_param *kp)
++{
++      int err, n;
++
++      err = kstrtoint(val, 0, &n);
++      if (!err) {
++              if (n > 0)
++                      au_debug_on();
++              else
++                      au_debug_off();
++      }
++      return err;
++}
++
++/* Returns length written or -errno.  Buffer is 4k (ie. be short!) */
++static int param_atomic_t_get(char *buffer, const struct kernel_param *kp)
++{
++      atomic_t *a;
++
++      a = kp->arg;
++      return sprintf(buffer, "%d", atomic_read(a));
++}
++
++static struct kernel_param_ops param_ops_atomic_t = {
++      .set = param_atomic_t_set,
++      .get = param_atomic_t_get
++      /* void (*free)(void *arg) */
++};
++
++atomic_t aufs_debug = ATOMIC_INIT(0);
 +MODULE_PARM_DESC(debug, "debug print");
-+module_param_named(debug, aufs_debug, int, S_IRUGO | S_IWUSR | S_IWGRP);
++module_param_named(debug, aufs_debug, atomic_t, S_IRUGO | S_IWUSR | S_IWGRP);
 +
 +char *au_plevel = KERN_DEBUG;
 +#define dpri(fmt, ...) do {                                   \
@@ -5649,7 +6143,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +              return -1;
 +      }
 +
-+      /* the type of i_blocks depends upon CONFIG_LSF */
++      /* the type of i_blocks depends upon CONFIG_LBDAF */
 +      BUILD_BUG_ON(sizeof(inode->i_blocks) != sizeof(unsigned long)
 +                   && sizeof(inode->i_blocks) != sizeof(u64));
 +      if (wh) {
@@ -5717,11 +6211,11 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      }
 +      /* do not call dget_parent() here */
 +      /* note: access d_xxx without d_lock */
-+      dpri("d%d: %.*s?/%.*s, %s, cnt %d, flags 0x%x\n",
-+           bindex,
-+           AuDLNPair(dentry->d_parent), AuDLNPair(dentry),
++      dpri("d%d: %p, %pd2?, %s, cnt %d, flags 0x%x, %shashed\n",
++           bindex, dentry, dentry,
 +           dentry->d_sb ? au_sbtype(dentry->d_sb) : "??",
-+           dentry->d_count, dentry->d_flags);
++           d_count(dentry), dentry->d_flags,
++           d_unhashed(dentry) ? "un" : "");
 +      hn = -1;
 +      if (bindex >= 0 && dentry->d_inode && au_test_aufs(dentry->d_sb)) {
 +              struct au_iinfo *iinfo = au_ii(dentry->d_inode);
@@ -5940,14 +6434,11 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +                      continue;
 +              h_inode = au_h_iptr(inode, bindex);
 +              if (unlikely(h_inode != h_dentry->d_inode)) {
-+                      int old = au_debug_test();
-+                      if (!old)
-+                              au_debug(1);
++                      au_debug_on();
 +                      AuDbg("b%d, %s:%d\n", bindex, func, line);
 +                      AuDbgDentry(dentry);
 +                      AuDbgInode(inode);
-+                      if (!old)
-+                              au_debug(0);
++                      au_debug_off();
 +                      BUG();
 +              }
 +      }
@@ -6053,10 +6544,10 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +}
 diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 --- /usr/share/empty/fs/aufs/debug.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/debug.h      2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,242 @@
++++ linux/fs/aufs/debug.h      2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,247 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -6069,8 +6560,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -6082,6 +6572,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +
 +#ifdef __KERNEL__
 +
++#include <linux/atomic.h>
 +#include <linux/module.h>
 +#include <linux/kallsyms.h>
 +#include <linux/sysrq.h>
@@ -6090,23 +6581,29 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +#define AuDebugOn(a)          BUG_ON(a)
 +
 +/* module parameter */
-+extern int aufs_debug;
-+static inline void au_debug(int n)
++extern atomic_t aufs_debug;
++static inline void au_debug_on(void)
++{
++      atomic_inc(&aufs_debug);
++}
++static inline void au_debug_off(void)
 +{
-+      aufs_debug = n;
-+      smp_mb();
++      atomic_dec_if_positive(&aufs_debug);
 +}
 +
 +static inline int au_debug_test(void)
 +{
-+      return aufs_debug;
++      return atomic_read(&aufs_debug) > 0;
 +}
 +#else
 +#define AuDebugOn(a)          do {} while (0)
-+AuStubVoid(au_debug, int n)
++AuStubVoid(au_debug_on, void)
++AuStubVoid(au_debug_off, void)
 +AuStubInt0(au_debug_test, void)
 +#endif /* CONFIG_AUFS_DEBUG */
 +
++#define param_check_atomic_t(name, p) __param_check(name, p, atomic_t)
++
 +/* ---------------------------------------------------------------------- */
 +
 +/* debug print */
@@ -6154,7 +6651,6 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +
 +/* dirty macros for debug print, use with "%.*s" and caution */
 +#define AuLNPair(qstr)                (qstr)->len, (qstr)->name
-+#define AuDLNPair(d)          AuLNPair(&(d)->d_name)
 +
 +/* ---------------------------------------------------------------------- */
 +
@@ -6299,10 +6795,10 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +#endif /* __AUFS_DEBUG_H__ */
 diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 --- /usr/share/empty/fs/aufs/dentry.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dentry.c     2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,1065 @@
++++ linux/fs/aufs/dentry.c     2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,1081 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -6315,8 +6811,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -6512,8 +7007,8 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      if (unlikely(!au_opt_test(au_mntflags(dentry->d_sb), UDBA_NONE)
 +                   && au_dbstart(dentry) < 0)) {
 +              err = -EIO;
-+              AuIOErr("both of real entry and whiteout found, %.*s, err %d\n",
-+                      AuDLNPair(dentry), err);
++              AuIOErr("both of real entry and whiteout found, %pd, err %d\n",
++                      dentry, err);
 +      }
 +
 +out_parent:
@@ -6567,8 +7062,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              goto out;
 +      if (unlikely(h_dentry->d_inode)) {
 +              err = -EIO;
-+              AuIOErr("%.*s should be negative on b%d.\n",
-+                      AuDLNPair(h_dentry), bindex);
++              AuIOErr("%pd should be negative on b%d.\n", h_dentry, bindex);
 +              dput(h_dentry);
 +              goto out;
 +      }
@@ -6825,8 +7319,8 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              /* shrink_dcache_parent(dentry); */
 +              err = au_hide_children(dentry);
 +              if (unlikely(err))
-+                      AuIOErr("%.*s, failed hiding children, ignored %d\n",
-+                              AuDLNPair(dentry), err);
++                      AuIOErr("%pd, failed hiding children, ignored %d\n",
++                              dentry, err);
 +      }
 +      au_do_hide(dentry);
 +}
@@ -7057,8 +7551,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      au_update_digen(dentry);
 +out:
 +      if (unlikely(err && !(dentry->d_flags & DCACHE_NFSFS_RENAMED))) {
-+              AuIOErr("failed refreshing %.*s, %d\n",
-+                      AuDLNPair(dentry), err);
++              AuIOErr("failed refreshing %pd, %d\n", dentry, err);
 +              AuDbgDentry(dentry);
 +      }
 +      AuTraceErr(err);
@@ -7101,7 +7594,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      int err;
 +      umode_t mode, h_mode;
 +      aufs_bindex_t bindex, btail, bstart, ibs, ibe;
-+      unsigned char plus, unhashed, is_root, h_plus;
++      unsigned char plus, unhashed, is_root, h_plus, h_nfs;
 +      struct inode *h_inode, *h_cached_inode;
 +      struct dentry *h_dentry;
 +      struct qstr *name, *h_name;
@@ -7139,18 +7632,25 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              if (!h_dentry)
 +                      continue;
 +
-+              AuDbg("b%d, %.*s\n", bindex, AuDLNPair(h_dentry));
++              AuDbg("b%d, %pd\n", bindex, h_dentry);
++              h_nfs = !!au_test_nfs(h_dentry->d_sb);
 +              spin_lock(&h_dentry->d_lock);
 +              h_name = &h_dentry->d_name;
 +              if (unlikely(do_udba
 +                           && !is_root
-+                           && (unhashed != !!d_unhashed(h_dentry)
-+                               || name->len != h_name->len
-+                               || memcmp(name->name, h_name->name, name->len))
++                           && ((!h_nfs
++                                && (unhashed != !!d_unhashed(h_dentry)
++                                    || name->len != h_name->len
++                                    || memcmp(name->name, h_name->name,
++                                              name->len)))
++                               || (h_nfs
++                                   && !(flags & LOOKUP_OPEN)
++                                   && (h_dentry->d_flags
++                                       & DCACHE_NFSFS_RENAMED)))
 +                          )) {
-+                      AuDbg("unhash 0x%x 0x%x, %.*s %.*s\n",
-+                                unhashed, d_unhashed(h_dentry),
-+                                AuDLNPair(dentry), AuDLNPair(h_dentry));
++                      AuDbg("unhash 0x%x 0x%x, %pd %pd\n",
++                            unhashed, d_unhashed(h_dentry),
++                            dentry, h_dentry);
 +                      spin_unlock(&h_dentry->d_lock);
 +                      goto err;
 +              }
@@ -7180,17 +7680,27 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              if (inode && ibs <= bindex && bindex <= ibe)
 +                      h_cached_inode = au_h_iptr(inode, bindex);
 +
-+              if (unlikely(plus != h_plus
-+                           || mode != h_mode
++              if (!h_nfs) {
++                      if (unlikely(plus != h_plus))
++                              goto err;
++              } else {
++                      if (unlikely(!(h_dentry->d_flags & DCACHE_NFSFS_RENAMED)
++                                   && !is_root
++                                   && !IS_ROOT(h_dentry)
++                                   && unhashed != d_unhashed(h_dentry)))
++                              goto err;
++              }
++              if (unlikely(mode != h_mode
 +                           || h_cached_inode != h_inode))
 +                      goto err;
 +              continue;
 +
-+      err:
++err:
 +              err = -EINVAL;
 +              break;
 +      }
 +
++      AuTraceErr(err);
 +      return err;
 +}
 +
@@ -7316,7 +7826,9 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      di_downgrade_lock(dentry, AuLock_IR);
 +
 +      err = -EINVAL;
-+      if (inode && (IS_DEADDIR(inode) || !inode->i_nlink))
++      if (!(flags & LOOKUP_OPEN)
++          && inode
++          && (IS_DEADDIR(inode) || !inode->i_nlink))
 +              goto out_inval;
 +
 +      do_udba = !au_opt_test(au_mntflags(sb), UDBA_NONE);
@@ -7334,8 +7846,8 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      err = h_d_revalidate(dentry, inode, flags, do_udba);
 +      if (unlikely(!err && do_udba && au_dbstart(dentry) < 0)) {
 +              err = -EIO;
-+              AuDbg("both of real entry and whiteout found, %.*s, err %d\n",
-+                    AuDLNPair(dentry), err);
++              AuDbg("both of real entry and whiteout found, %p, err %d\n",
++                    dentry, err);
 +      }
 +      goto out_inval;
 +
@@ -7347,7 +7859,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      valid = !err;
 +out:
 +      if (!valid) {
-+              AuDbg("%.*s invalid, %d\n", AuDLNPair(dentry), valid);
++              AuDbg("%pd invalid, %d\n", dentry, valid);
 +              d_drop(dentry);
 +      }
 +      return valid;
@@ -7368,10 +7880,10 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +};
 diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
 --- /usr/share/empty/fs/aufs/dentry.h  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dentry.h     2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,234 @@
++++ linux/fs/aufs/dentry.h     2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,233 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -7384,8 +7896,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -7606,10 +8117,10 @@ diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
 +#endif /* __AUFS_DENTRY_H__ */
 diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 --- /usr/share/empty/fs/aufs/dinfo.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dinfo.c      2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,543 @@
++++ linux/fs/aufs/dinfo.c      2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,542 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -7622,8 +8133,7 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -7928,7 +8438,7 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 +              return NULL;
 +      AuDebugOn(bindex < 0);
 +      d = au_di(dentry)->di_hdentry[0 + bindex].hd_dentry;
-+      AuDebugOn(d && d->d_count <= 0);
++      AuDebugOn(d && d_count(d) <= 0);
 +      return d;
 +}
 +
@@ -8153,10 +8663,10 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 +}
 diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 --- /usr/share/empty/fs/aufs/dir.c     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dir.c        2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,632 @@
++++ linux/fs/aufs/dir.c        2014-04-24 22:11:10.848602379 +0200
+@@ -0,0 +1,639 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -8169,8 +8679,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -8190,7 +8699,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      nlink += h_dir->i_nlink - 2;
 +      if (h_dir->i_nlink < 2)
 +              nlink += 2;
-+      smp_mb();
++      smp_mb(); /* for i_nlink */
 +      /* 0 can happen in revaliding */
 +      set_nlink(dir, nlink);
 +}
@@ -8205,7 +8714,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      nlink -= h_dir->i_nlink - 2;
 +      if (h_dir->i_nlink < 2)
 +              nlink -= 2;
-+      smp_mb();
++      smp_mb(); /* for i_nlink */
 +      /* nlink == 0 means the branch-fs is broken */
 +      set_nlink(dir, nlink);
 +}
@@ -8286,7 +8795,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +              if (h_file)
 +                      continue;
 +
-+              h_file = au_h_open(dentry, bindex, flags, file);
++              h_file = au_h_open(dentry, bindex, flags, file, /*force_wr*/0);
 +              err = PTR_ERR(h_file);
 +              if (IS_ERR(h_file))
 +                      goto out; /* close all? */
@@ -8310,11 +8819,8 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +
 +      FiMustWriteLock(file);
 +
++      err = 0;
 +      dentry = file->f_dentry;
-+      err = au_alive_dir(dentry);
-+      if (unlikely(err))
-+              goto out;
-+
 +      file->f_version = dentry->d_inode->i_version;
 +      bindex = au_dbstart(dentry);
 +      au_set_fbstart(file, bindex);
@@ -8325,7 +8831,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +              if (!h_dentry)
 +                      continue;
 +
-+              h_file = au_h_open(dentry, bindex, flags, file);
++              h_file = au_h_open(dentry, bindex, flags, file, /*force_wr*/0);
 +              if (IS_ERR(h_file)) {
 +                      err = PTR_ERR(h_file);
 +                      break;
@@ -8344,7 +8850,6 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      au_set_fbstart(file, -1);
 +      au_set_fbend_dir(file, -1);
 +
-+out:
 +      return err;
 +}
 +
@@ -8515,13 +9020,15 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +
 +/* ---------------------------------------------------------------------- */
 +
-+static int aufs_readdir(struct file *file, void *dirent, filldir_t filldir)
++static int aufs_iterate(struct file *file, struct dir_context *ctx)
 +{
 +      int err;
 +      struct dentry *dentry;
 +      struct inode *inode, *h_inode;
 +      struct super_block *sb;
 +
++      AuDbg("%pD, ctx{%pf, %llu}\n", file, ctx->actor, ctx->pos);
++
 +      dentry = file->f_dentry;
 +      inode = dentry->d_inode;
 +      IMustLock(inode);
@@ -8540,7 +9047,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +
 +      h_inode = au_h_iptr(inode, au_ibstart(inode));
 +      if (!au_test_nfsd()) {
-+              err = au_vdir_fill_de(file, dirent, filldir);
++              err = au_vdir_fill_de(file, ctx);
 +              fsstack_copy_attr_atime(inode, h_inode);
 +      } else {
 +              /*
@@ -8550,7 +9057,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +              atomic_inc(&h_inode->i_count);
 +              di_read_unlock(dentry, AuLock_IR);
 +              si_read_unlock(sb);
-+              err = au_vdir_fill_de(file, dirent, filldir);
++              err = au_vdir_fill_de(file, ctx);
 +              fsstack_copy_attr_atime(inode, h_inode);
 +              fi_write_unlock(file);
 +              iput(h_inode);
@@ -8584,17 +9091,19 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +#endif
 +
 +struct test_empty_arg {
++      struct dir_context ctx;
 +      struct au_nhash *whlist;
 +      unsigned int flags;
 +      int err;
 +      aufs_bindex_t bindex;
 +};
 +
-+static int test_empty_cb(void *__arg, const char *__name, int namelen,
-+                       loff_t offset __maybe_unused, u64 ino,
++static int test_empty_cb(struct dir_context *ctx, const char *__name,
++                       int namelen, loff_t offset __maybe_unused, u64 ino,
 +                       unsigned int d_type)
 +{
-+      struct test_empty_arg *arg = __arg;
++      struct test_empty_arg *arg = container_of(ctx, struct test_empty_arg,
++                                                ctx);
 +      char *name = (void *)__name;
 +
 +      arg->err = 0;
@@ -8632,7 +9141,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +
 +      h_file = au_h_open(dentry, arg->bindex,
 +                         O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_LARGEFILE,
-+                         /*file*/NULL);
++                         /*file*/NULL, /*force_wr*/0);
 +      err = PTR_ERR(h_file);
 +      if (IS_ERR(h_file))
 +              goto out;
@@ -8646,7 +9155,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +              arg->err = 0;
 +              au_fclr_testempty(arg->flags, CALLED);
 +              /* smp_mb(); */
-+              err = vfsub_readdir(h_file, test_empty_cb, arg);
++              err = vfsub_iterate_dir(h_file, &arg->ctx);
 +              if (err >= 0)
 +                      err = arg->err;
 +      } while (!err && au_ftest_testempty(arg->flags, CALLED));
@@ -8707,8 +9216,12 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      unsigned int rdhash;
 +      aufs_bindex_t bindex, bstart, btail;
 +      struct au_nhash whlist;
-+      struct test_empty_arg arg;
-+
++      struct test_empty_arg arg = {
++              .ctx = {
++                      .actor = au_diractor(test_empty_cb)
++              }
++      };
++
 +      SiMustAnyLock(dentry->d_sb);
 +
 +      rdhash = au_sbi(dentry->d_sb)->si_rdhash;
@@ -8749,7 +9262,11 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +int au_test_empty(struct dentry *dentry, struct au_nhash *whlist)
 +{
 +      int err;
-+      struct test_empty_arg arg;
++      struct test_empty_arg arg = {
++              .ctx = {
++                      .actor = au_diractor(test_empty_cb)
++              }
++      };
 +      aufs_bindex_t bindex, btail;
 +
 +      err = 0;
@@ -8777,7 +9294,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      .owner          = THIS_MODULE,
 +      .llseek         = default_llseek,
 +      .read           = generic_read_dir,
-+      .readdir        = aufs_readdir,
++      .iterate        = aufs_iterate,
 +      .unlocked_ioctl = aufs_ioctl_dir,
 +#ifdef CONFIG_COMPAT
 +      .compat_ioctl   = aufs_compat_ioctl_dir,
@@ -8789,10 +9306,10 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +};
 diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 --- /usr/share/empty/fs/aufs/dir.h     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dir.h        2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,137 @@
++++ linux/fs/aufs/dir.h        2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,136 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -8805,8 +9322,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -8899,7 +9415,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 +                     unsigned char shwh);
 +void au_vdir_free(struct au_vdir *vdir);
 +int au_vdir_init(struct file *file);
-+int au_vdir_fill_de(struct file *file, void *dirent, filldir_t filldir);
++int au_vdir_fill_de(struct file *file, struct dir_context *ctx);
 +
 +/* ioctl.c */
 +long aufs_ioctl_dir(struct file *file, unsigned int cmd, unsigned long arg);
@@ -8930,10 +9446,10 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 +#endif /* __AUFS_DIR_H__ */
 diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 --- /usr/share/empty/fs/aufs/dynop.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dynop.c      2013-07-06 13:20:47.740198107 +0200
++++ linux/fs/aufs/dynop.c      2014-04-24 22:11:10.851935747 +0200
 @@ -0,0 +1,379 @@
 +/*
-+ * Copyright (C) 2010-2013 Junjiro R. Okajima
++ * Copyright (C) 2010-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -8946,8 +9462,7 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -9127,6 +9642,7 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +      DySetAop(migratepage);
 +      DySetAop(launder_page);
 +      DySetAop(is_partially_uptodate);
++      DySetAop(is_dirty_writeback);
 +      DySetAop(error_remove_page);
 +      DySetAop(swap_activate);
 +      DySetAop(swap_deactivate);
@@ -9313,10 +9829,10 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +}
 diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h
 --- /usr/share/empty/fs/aufs/dynop.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dynop.h      2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,76 @@
++++ linux/fs/aufs/dynop.h      2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,75 @@
 +/*
-+ * Copyright (C) 2010-2013 Junjiro R. Okajima
++ * Copyright (C) 2010-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -9329,8 +9845,7 @@ diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -9393,10 +9908,10 @@ diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h
 +#endif /* __AUFS_DYNOP_H__ */
 diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 --- /usr/share/empty/fs/aufs/export.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/export.c     2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,826 @@
++++ linux/fs/aufs/export.c     2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,831 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -9409,8 +9924,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -9698,9 +10212,9 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +      };
 +
 +      get_fs_root(current->fs, &root);
-+      br_read_lock(&vfsmount_lock);
++      rcu_read_lock();
 +      err = iterate_mounts(au_compare_mnt, &args, root.mnt);
-+      br_read_unlock(&vfsmount_lock);
++      rcu_read_unlock();
 +      path_put(&root);
 +      AuDebugOn(!err);
 +      AuDebugOn(!args.mnt);
@@ -9738,6 +10252,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +}
 +
 +struct find_name_by_ino {
++      struct dir_context ctx;
 +      int called, found;
 +      ino_t ino;
 +      char *name;
@@ -9745,10 +10260,11 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +};
 +
 +static int
-+find_name_by_ino(void *arg, const char *name, int namelen, loff_t offset,
-+               u64 ino, unsigned int d_type)
++find_name_by_ino(struct dir_context *ctx, const char *name, int namelen,
++               loff_t offset, u64 ino, unsigned int d_type)
 +{
-+      struct find_name_by_ino *a = arg;
++      struct find_name_by_ino *a = container_of(ctx, struct find_name_by_ino,
++                                                ctx);
 +
 +      a->called++;
 +      if (a->ino != ino)
@@ -9766,7 +10282,11 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +      struct dentry *dentry, *parent;
 +      struct file *file;
 +      struct inode *dir;
-+      struct find_name_by_ino arg;
++      struct find_name_by_ino arg = {
++              .ctx = {
++                      .actor = au_diractor(find_name_by_ino)
++              }
++      };
 +      int err;
 +
 +      parent = path->dentry;
@@ -9786,7 +10306,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +      do {
 +              arg.called = 0;
 +              /* smp_mb(); */
-+              err = vfsub_readdir(file, find_name_by_ino, &arg);
++              err = vfsub_iterate_dir(file, &arg.ctx);
 +      } while (!err && !arg.found && arg.called);
 +      dentry = ERR_PTR(err);
 +      if (unlikely(err))
@@ -10223,10 +10743,10 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +}
 diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 --- /usr/share/empty/fs/aufs/file.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/file.c       2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,688 @@
++++ linux/fs/aufs/file.c       2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,724 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -10239,8 +10759,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -10263,7 +10782,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +
 +/* common functions to regular file and dir */
 +struct file *au_h_open(struct dentry *dentry, aufs_bindex_t bindex, int flags,
-+                     struct file *file)
++                     struct file *file, int force_wr)
 +{
 +      struct file *h_file;
 +      struct dentry *h_dentry;
@@ -10298,8 +10817,20 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +              goto out;
 +
 +      /* drop flags for writing */
-+      if (au_test_ro(sb, bindex, dentry->d_inode))
++      if (au_test_ro(sb, bindex, dentry->d_inode)) {
++              if (force_wr && !(flags & O_WRONLY))
++                      force_wr = 0;
 +              flags = au_file_roflags(flags);
++              if (force_wr) {
++                      h_file = ERR_PTR(-EROFS);
++                      flags = au_file_roflags(flags);
++                      if (unlikely(vfsub_native_ro(h_inode)
++                                   || IS_APPEND(h_inode)))
++                              goto out;
++                      flags &= ~O_ACCMODE;
++                      flags |= O_WRONLY;
++              }
++      }
 +      flags &= ~O_CREAT;
 +      atomic_inc(&br->br_count);
 +      h_path.dentry = h_dentry;
@@ -10394,7 +10925,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      /* AuDebugOn(au_fbstart(file) < bstart); */
 +
 +      h_file = au_h_open(dentry, bstart, vfsub_file_flags(file) & ~O_TRUNC,
-+                         file);
++                         file, /*force_wr*/0);
 +      err = PTR_ERR(h_file);
 +      if (IS_ERR(h_file)) {
 +              if (h_file_tmp) {
@@ -10449,28 +10980,35 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +{
 +      int err;
 +      struct inode *inode, *h_inode;
-+      struct dentry *dentry, *h_dentry, *hi_wh;
++      struct dentry *h_dentry, *hi_wh;
++      struct au_cp_generic cpg = {
++              .dentry = file->f_dentry,
++              .bdst   = bcpup,
++              .bsrc   = -1,
++              .len    = len,
++              .pin    = pin
++      };
 +
-+      dentry = file->f_dentry;
-+      au_update_dbstart(dentry);
-+      inode = dentry->d_inode;
++      au_update_dbstart(cpg.dentry);
++      inode = cpg.dentry->d_inode;
 +      h_inode = NULL;
-+      if (au_dbstart(dentry) <= bcpup && au_dbend(dentry) >= bcpup) {
-+              h_dentry = au_h_dptr(dentry, bcpup);
++      if (au_dbstart(cpg.dentry) <= bcpup
++          && au_dbend(cpg.dentry) >= bcpup) {
++              h_dentry = au_h_dptr(cpg.dentry, bcpup);
 +              if (h_dentry)
 +                      h_inode = h_dentry->d_inode;
 +      }
 +      hi_wh = au_hi_wh(inode, bcpup);
 +      if (!hi_wh && !h_inode)
-+              err = au_sio_cpup_wh(dentry, bcpup, len, file, pin);
++              err = au_sio_cpup_wh(&cpg, file);
 +      else
 +              /* already copied-up after unlink */
 +              err = au_reopen_wh(file, bcpup, hi_wh);
 +
 +      if (!err
 +          && inode->i_nlink > 1
-+          && au_opt_test(au_mntflags(dentry->d_sb), PLINK))
-+              au_plink_append(inode, bcpup, au_h_dptr(dentry, bcpup));
++          && au_opt_test(au_mntflags(cpg.dentry->d_sb), PLINK))
++              au_plink_append(inode, bcpup, au_h_dptr(cpg.dentry, bcpup));
 +
 +      return err;
 +}
@@ -10481,72 +11019,79 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +int au_ready_to_write(struct file *file, loff_t len, struct au_pin *pin)
 +{
 +      int err;
-+      aufs_bindex_t bstart, bcpup, dbstart;
-+      struct dentry *dentry, *parent, *h_dentry;
++      aufs_bindex_t dbstart;
++      struct dentry *parent, *h_dentry;
 +      struct inode *inode;
 +      struct super_block *sb;
 +      struct file *h_file;
++      struct au_cp_generic cpg = {
++              .dentry = file->f_dentry,
++              .bdst   = -1,
++              .bsrc   = -1,
++              .len    = len,
++              .pin    = pin,
++              .flags  = AuCpup_DTIME
++      };
 +
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
-+      inode = dentry->d_inode;
++      sb = cpg.dentry->d_sb;
++      inode = cpg.dentry->d_inode;
 +      AuDebugOn(au_special_file(inode->i_mode));
-+      bstart = au_fbstart(file);
-+      err = au_test_ro(sb, bstart, inode);
++      cpg.bsrc = au_fbstart(file);
++      err = au_test_ro(sb, cpg.bsrc, inode);
 +      if (!err && (au_hf_top(file)->f_mode & FMODE_WRITE)) {
-+              err = au_pin(pin, dentry, bstart, AuOpt_UDBA_NONE, /*flags*/0);
++              err = au_pin(pin, cpg.dentry, cpg.bsrc, AuOpt_UDBA_NONE,
++                           /*flags*/0);
 +              goto out;
 +      }
 +
 +      /* need to cpup or reopen */
-+      parent = dget_parent(dentry);
++      parent = dget_parent(cpg.dentry);
 +      di_write_lock_parent(parent);
-+      err = AuWbrCopyup(au_sbi(sb), dentry);
-+      bcpup = err;
++      err = AuWbrCopyup(au_sbi(sb), cpg.dentry);
++      cpg.bdst = err;
 +      if (unlikely(err < 0))
 +              goto out_dgrade;
 +      err = 0;
 +
-+      if (!d_unhashed(dentry) && !au_h_dptr(parent, bcpup)) {
-+              err = au_cpup_dirs(dentry, bcpup);
++      if (!d_unhashed(cpg.dentry) && !au_h_dptr(parent, cpg.bdst)) {
++              err = au_cpup_dirs(cpg.dentry, cpg.bdst);
 +              if (unlikely(err))
 +                      goto out_dgrade;
 +      }
 +
-+      err = au_pin(pin, dentry, bcpup, AuOpt_UDBA_NONE,
++      err = au_pin(pin, cpg.dentry, cpg.bdst, AuOpt_UDBA_NONE,
 +                   AuPin_DI_LOCKED | AuPin_MNT_WRITE);
 +      if (unlikely(err))
 +              goto out_dgrade;
 +
 +      h_dentry = au_hf_top(file)->f_dentry;
-+      dbstart = au_dbstart(dentry);
-+      if (dbstart <= bcpup) {
-+              h_dentry = au_h_dptr(dentry, bcpup);
++      dbstart = au_dbstart(cpg.dentry);
++      if (dbstart <= cpg.bdst) {
++              h_dentry = au_h_dptr(cpg.dentry, cpg.bdst);
 +              AuDebugOn(!h_dentry);
-+              bstart = bcpup;
++              cpg.bsrc = cpg.bdst;
 +      }
 +
-+      if (dbstart <= bcpup            /* just reopen */
-+          || !d_unhashed(dentry)      /* copyup and reopen */
++      if (dbstart <= cpg.bdst         /* just reopen */
++          || !d_unhashed(cpg.dentry)  /* copyup and reopen */
 +              ) {
-+              h_file = au_h_open_pre(dentry, bstart);
++              h_file = au_h_open_pre(cpg.dentry, cpg.bsrc, /*force_wr*/0);
 +              if (IS_ERR(h_file))
 +                      err = PTR_ERR(h_file);
 +              else {
 +                      di_downgrade_lock(parent, AuLock_IR);
-+                      if (dbstart > bcpup)
-+                              err = au_sio_cpup_simple(dentry, bcpup, len,
-+                                                       AuCpup_DTIME, pin);
++                      if (dbstart > cpg.bdst)
++                              err = au_sio_cpup_simple(&cpg);
 +                      if (!err)
 +                              err = au_reopen_nondir(file);
-+                      au_h_open_post(dentry, bstart, h_file);
++                      au_h_open_post(cpg.dentry, cpg.bsrc, h_file);
 +              }
 +      } else {                        /* copyup as wh and reopen */
 +              /*
 +               * since writable hfsplus branch is not supported,
 +               * h_open_pre/post() are unnecessary.
 +               */
-+              err = au_ready_to_write_wh(file, len, bcpup, pin);
++              err = au_ready_to_write_wh(file, len, cpg.bdst, pin);
 +              di_downgrade_lock(parent, AuLock_IR);
 +      }
 +
@@ -10596,29 +11141,35 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +static int au_file_refresh_by_inode(struct file *file, int *need_reopen)
 +{
 +      int err;
-+      aufs_bindex_t bstart;
 +      struct au_pin pin;
 +      struct au_finfo *finfo;
-+      struct dentry *dentry, *parent, *hi_wh;
++      struct dentry *parent, *hi_wh;
 +      struct inode *inode;
 +      struct super_block *sb;
++      struct au_cp_generic cpg = {
++              .dentry = file->f_dentry,
++              .bdst   = -1,
++              .bsrc   = -1,
++              .len    = -1,
++              .pin    = &pin,
++              .flags  = AuCpup_DTIME
++      };
 +
 +      FiMustWriteLock(file);
 +
 +      err = 0;
 +      finfo = au_fi(file);
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
-+      inode = dentry->d_inode;
-+      bstart = au_ibstart(inode);
-+      if (bstart == finfo->fi_btop || IS_ROOT(dentry))
++      sb = cpg.dentry->d_sb;
++      inode = cpg.dentry->d_inode;
++      cpg.bdst = au_ibstart(inode);
++      if (cpg.bdst == finfo->fi_btop || IS_ROOT(cpg.dentry))
 +              goto out;
 +
-+      parent = dget_parent(dentry);
-+      if (au_test_ro(sb, bstart, inode)) {
++      parent = dget_parent(cpg.dentry);
++      if (au_test_ro(sb, cpg.bdst, inode)) {
 +              di_read_lock_parent(parent, !AuLock_IR);
-+              err = AuWbrCopyup(au_sbi(sb), dentry);
-+              bstart = err;
++              err = AuWbrCopyup(au_sbi(sb), cpg.dentry);
++              cpg.bdst = err;
 +              di_read_unlock(parent, !AuLock_IR);
 +              if (unlikely(err < 0))
 +                      goto out_parent;
@@ -10626,26 +11177,26 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      }
 +
 +      di_read_lock_parent(parent, AuLock_IR);
-+      hi_wh = au_hi_wh(inode, bstart);
++      hi_wh = au_hi_wh(inode, cpg.bdst);
 +      if (!S_ISDIR(inode->i_mode)
 +          && au_opt_test(au_mntflags(sb), PLINK)
 +          && au_plink_test(inode)
-+          && !d_unhashed(dentry)
-+          && bstart < au_dbstart(dentry)) {
-+              err = au_test_and_cpup_dirs(dentry, bstart);
++          && !d_unhashed(cpg.dentry)
++          && cpg.bdst < au_dbstart(cpg.dentry)) {
++              err = au_test_and_cpup_dirs(cpg.dentry, cpg.bdst);
 +              if (unlikely(err))
 +                      goto out_unlock;
 +
 +              /* always superio. */
-+              err = au_pin(&pin, dentry, bstart, AuOpt_UDBA_NONE,
++              err = au_pin(&pin, cpg.dentry, cpg.bdst, AuOpt_UDBA_NONE,
 +                           AuPin_DI_LOCKED | AuPin_MNT_WRITE);
-+              if (!err)
-+                      err = au_sio_cpup_simple(dentry, bstart, -1,
-+                                               AuCpup_DTIME, &pin);
-+              au_unpin(&pin);
++              if (!err) {
++                      err = au_sio_cpup_simple(&cpg);
++                      au_unpin(&pin);
++              }
 +      } else if (hi_wh) {
 +              /* already copied-up after unlink */
-+              err = au_reopen_wh(file, bstart, hi_wh);
++              err = au_reopen_wh(file, cpg.bdst, hi_wh);
 +              *need_reopen = 0;
 +      }
 +
@@ -10868,7 +11419,8 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +
 +static int aufs_set_page_dirty(struct page *page)
 +{ AuUnsupport(); return 0; }
-+static void aufs_invalidatepage(struct page *page, unsigned long offset)
++static void aufs_invalidatepage(struct page *page, unsigned int offset,
++                              unsigned int length)
 +{ AuUnsupport(); }
 +static int aufs_releasepage(struct page *page, gfp_t gfp)
 +{ AuUnsupport(); return 0; }
@@ -10881,6 +11433,9 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +                                    read_descriptor_t *desc,
 +                                    unsigned long from)
 +{ AuUnsupport(); return 0; }
++static void aufs_is_dirty_writeback(struct page *page, bool *dirty,
++                                  bool *writeback)
++{ AuUnsupport(); }
 +static int aufs_error_remove_page(struct address_space *mapping,
 +                                struct page *page)
 +{ AuUnsupport(); return 0; }
@@ -10908,6 +11463,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      .migratepage            = aufs_migratepage,
 +      .launder_page           = aufs_launder_page,
 +      .is_partially_uptodate  = aufs_is_partially_uptodate,
++      .is_dirty_writeback     = aufs_is_dirty_writeback,
 +      .error_remove_page      = aufs_error_remove_page,
 +      .swap_activate          = aufs_swap_activate,
 +      .swap_deactivate        = aufs_swap_deactivate
@@ -10915,10 +11471,10 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +};
 diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 --- /usr/share/empty/fs/aufs/file.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/file.h       2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,308 @@
++++ linux/fs/aufs/file.h       2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,312 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -10931,8 +11487,7 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -10981,6 +11536,9 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +              atomic_t                        fi_mmapped;
 +      };
 +      struct au_fidir         *fi_hdir;       /* for dir only */
++
++      struct hlist_node       fi_hlist;
++      struct file             *fi_file;       /* very ugly */
 +} ____cacheline_aligned_in_smp;
 +
 +/* ---------------------------------------------------------------------- */
@@ -10989,7 +11547,7 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +extern const struct address_space_operations aufs_aop;
 +unsigned int au_file_roflags(unsigned int flags);
 +struct file *au_h_open(struct dentry *dentry, aufs_bindex_t bindex, int flags,
-+                     struct file *file);
++                     struct file *file, int force_wr);
 +int au_do_open(struct file *file, int (*open)(struct file *file, int flags),
 +             struct au_fidir *fidir);
 +int au_reopen_nondir(struct file *file);
@@ -11007,12 +11565,14 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +
 +#ifdef CONFIG_AUFS_BR_HFSPLUS
 +/* hfsplus.c */
-+struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex);
++struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex,
++                         int force_wr);
 +void au_h_open_post(struct dentry *dentry, aufs_bindex_t bindex,
 +                  struct file *h_file);
 +#else
 +static inline
-+struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex)
++struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex,
++                         int force_wr)
 +{
 +      return NULL;
 +}
@@ -11062,6 +11622,8 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +#ifdef CONFIG_COMPAT
 +long aufs_compat_ioctl_dir(struct file *file, unsigned int cmd,
 +                         unsigned long arg);
++long aufs_compat_ioctl_nondir(struct file *file, unsigned int cmd,
++                            unsigned long arg);
 +#endif
 +
 +/* ---------------------------------------------------------------------- */
@@ -11213,24 +11775,22 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +static inline void au_vm_prfile_set(struct vm_area_struct *vma,
 +                                  struct file *file)
 +{
-+#ifdef CONFIG_AUFS_PROC_MAP
 +      get_file(file);
 +      vma->vm_prfile = file;
 +#ifndef CONFIG_MMU
 +      get_file(file);
 +      vma->vm_region->vm_prfile = file;
 +#endif
-+#endif
 +}
 +
 +#endif /* __KERNEL__ */
 +#endif /* __AUFS_FILE_H__ */
 diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 --- /usr/share/empty/fs/aufs/finfo.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/finfo.c      2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,157 @@
++++ linux/fs/aufs/finfo.c      2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,156 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -11243,8 +11803,7 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -11388,10 +11947,10 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +}
 diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 --- /usr/share/empty/fs/aufs/f_op.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/f_op.c       2013-07-06 13:20:47.740198107 +0200
-@@ -0,0 +1,721 @@
++++ linux/fs/aufs/f_op.c       2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,718 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -11404,8 +11963,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -11428,27 +11986,25 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +
 +      FiMustWriteLock(file);
 +
++      err = 0;
 +      dentry = file->f_dentry;
-+      err = au_d_alive(dentry);
-+      if (unlikely(err))
-+              goto out;
-+
 +      finfo = au_fi(file);
 +      memset(&finfo->fi_htop, 0, sizeof(finfo->fi_htop));
 +      atomic_set(&finfo->fi_mmapped, 0);
 +      bindex = au_dbstart(dentry);
-+      h_file = au_h_open(dentry, bindex, flags, file);
++      h_file = au_h_open(dentry, bindex, flags, file, /*force_wr*/0);
 +      if (IS_ERR(h_file))
 +              err = PTR_ERR(h_file);
 +      else {
 +              au_set_fbstart(file, bindex);
 +              au_set_h_fptr(file, bindex, h_file);
 +              au_update_figen(file);
++              finfo->fi_file = file;
++              au_sphl_add(&finfo->fi_hlist, &au_sbi(dentry->d_sb)->si_files);
 +              /* todo: necessary? */
 +              /* file->f_ra = h_file->f_ra; */
 +      }
 +
-+out:
 +      return err;
 +}
 +
@@ -11458,9 +12014,8 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +      int err;
 +      struct super_block *sb;
 +
-+      AuDbg("%.*s, f_flags 0x%x, f_mode 0x%x\n",
-+            AuDLNPair(file->f_dentry), vfsub_file_flags(file),
-+            file->f_mode);
++      AuDbg("%pD, f_flags 0x%x, f_mode 0x%x\n",
++            file, vfsub_file_flags(file), file->f_mode);
 +
 +      sb = file->f_dentry->d_sb;
 +      si_read_lock(sb, AuLock_FLUSH);
@@ -11475,6 +12030,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +      aufs_bindex_t bindex;
 +
 +      finfo = au_fi(file);
++      au_sphl_del(&finfo->fi_hlist, &au_sbi(file->f_dentry->d_sb)->si_files);
 +      bindex = finfo->fi_btop;
 +      if (bindex >= 0)
 +              au_set_h_fptr(file, bindex, NULL);
@@ -11830,7 +12386,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 + * It means that when aufs acquires si_rwsem for write, the process should never
 + * acquire mmap_sem.
 + *
-+ * Actually aufs_readdir() holds [fdi]i_rwsem before mmap_sem, but this is not a
++ * Actually aufs_iterate() holds [fdi]i_rwsem before mmap_sem, but this is not a
 + * problem either since any directory is not able to be mmap-ed.
 + * The similar scenario is applied to aufs_readlink() too.
 + */
@@ -12014,7 +12570,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +
 +      err = -ENOSYS;
 +      h_file = au_hf_top(file);
-+      if (h_file->f_op && h_file->f_op->aio_fsync) {
++      if (h_file->f_op->aio_fsync) {
 +              struct mutex *h_mtx;
 +
 +              h_mtx = &file_inode(h_file)->i_mutex;
@@ -12057,7 +12613,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +              goto out;
 +
 +      h_file = au_hf_top(file);
-+      if (h_file->f_op && h_file->f_op->fasync)
++      if (h_file->f_op->fasync)
 +              err = h_file->f_op->fasync(fd, h_file, flag);
 +
 +      di_read_unlock(dentry, AuLock_IR);
@@ -12094,7 +12650,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +#endif
 +      .unlocked_ioctl = aufs_ioctl_nondir,
 +#ifdef CONFIG_COMPAT
-+      .compat_ioctl   = aufs_ioctl_nondir, /* same */
++      .compat_ioctl   = aufs_compat_ioctl_nondir,
 +#endif
 +      .mmap           = aufs_mmap,
 +      .open           = aufs_open_nondir,
@@ -12113,10 +12669,10 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +};
 diff -urN /usr/share/empty/fs/aufs/f_op_sp.c linux/fs/aufs/f_op_sp.c
 --- /usr/share/empty/fs/aufs/f_op_sp.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/f_op_sp.c    2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,376 @@
++++ linux/fs/aufs/f_op_sp.c    2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,382 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -12129,8 +12685,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op_sp.c linux/fs/aufs/f_op_sp.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -12154,7 +12709,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op_sp.c linux/fs/aufs/f_op_sp.c
 +
 +struct au_finfo_sp {
 +      struct hlist_node       hlist;
-+      struct file             *file;
++      struct file             *file;
 +      struct au_finfo         *finfo;
 +};
 +
@@ -12364,29 +12919,36 @@ diff -urN /usr/share/empty/fs/aufs/f_op_sp.c linux/fs/aufs/f_op_sp.c
 +static int au_cpup_sp(struct dentry *dentry)
 +{
 +      int err;
-+      aufs_bindex_t bcpup;
 +      struct au_pin pin;
 +      struct au_wr_dir_args wr_dir_args = {
 +              .force_btgt     = -1,
 +              .flags          = 0
 +      };
++      struct au_cp_generic cpg = {
++              .dentry = dentry,
++              .bdst   = -1,
++              .bsrc   = -1,
++              .len    = -1,
++              .pin    = &pin,
++              .flags  = AuCpup_DTIME
++      };
 +
-+      AuDbg("%.*s\n", AuDLNPair(dentry));
++      AuDbg("%pd\n", dentry);
 +
 +      di_read_unlock(dentry, AuLock_IR);
 +      di_write_lock_child(dentry);
 +      err = au_wr_dir(dentry, /*src_dentry*/NULL, &wr_dir_args);
 +      if (unlikely(err < 0))
 +              goto out;
-+      bcpup = err;
++      cpg.bdst = err;
 +      err = 0;
-+      if (bcpup == au_dbstart(dentry))
++      if (cpg.bdst == au_dbstart(dentry))
 +              goto out; /* success */
 +
-+      err = au_pin(&pin, dentry, bcpup, au_opt_udba(dentry->d_sb),
++      err = au_pin(&pin, dentry, cpg.bdst, au_opt_udba(dentry->d_sb),
 +                   AuPin_MNT_WRITE);
 +      if (!err) {
-+              err = au_sio_cpup_simple(dentry, bcpup, -1, AuCpup_DTIME, &pin);
++              err = au_sio_cpup_simple(&cpg);
 +              au_unpin(&pin);
 +      }
 +
@@ -12408,7 +12970,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op_sp.c linux/fs/aufs/f_op_sp.c
 +              goto out;
 +
 +      dentry = file->f_dentry;
-+      AuDbg("%.*s\n", AuDLNPair(dentry));
++      AuDbg("%pd\n", dentry);
 +
 +      /*
 +       * try copying-up.
@@ -12493,10 +13055,10 @@ diff -urN /usr/share/empty/fs/aufs/f_op_sp.c linux/fs/aufs/f_op_sp.c
 +}
 diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 --- /usr/share/empty/fs/aufs/fstype.h  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/fstype.h     2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,480 @@
++++ linux/fs/aufs/fstype.h     2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,469 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -12509,8 +13071,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -12607,15 +13168,6 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +#endif
 +}
 +
-+static inline int au_test_smbfs(struct super_block *sb __maybe_unused)
-+{
-+#if defined(CONFIG_SMB_FS) || defined(CONFIG_SMB_FS_MODULE)
-+      return sb->s_magic == SMB_SUPER_MAGIC;
-+#else
-+      return 0;
-+#endif
-+}
-+
 +static inline int au_test_ocfs2(struct super_block *sb __maybe_unused)
 +{
 +#if defined(CONFIG_OCFS2_FS) || defined(CONFIG_OCFS2_FS_MODULE)
@@ -12654,7 +13206,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_ext4(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_EXT4DEV_FS) || defined(CONFIG_EXT4DEV_FS_MODULE)
++#if defined(CONFIG_EXT4_FS) || defined(CONFIG_EXT4_FS_MODULE)
 +      return sb->s_magic == EXT4_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -12862,7 +13414,6 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +{
 +      return au_test_nfs(sb)
 +              || au_test_fuse(sb)
-+              /* || au_test_smbfs(sb) */      /* untested */
 +              /* || au_test_ocfs2(sb) */      /* untested */
 +              /* || au_test_btrfs(sb) */      /* untested */
 +              /* || au_test_coda(sb) */       /* untested */
@@ -12977,10 +13528,10 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +#endif /* __AUFS_FSTYPE_H__ */
 diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 --- /usr/share/empty/fs/aufs/hfsnotify.c       1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/hfsnotify.c  2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,296 @@
++++ linux/fs/aufs/hfsnotify.c  2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,281 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -12993,8 +13544,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -13139,29 +13689,29 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +}
 +
 +static int au_hfsn_handle_event(struct fsnotify_group *group,
++                              struct inode *inode,
 +                              struct fsnotify_mark *inode_mark,
 +                              struct fsnotify_mark *vfsmount_mark,
-+                              struct fsnotify_event *event)
++                              u32 mask, void *data, int data_type,
++                              const unsigned char *file_name, u32 cookie)
 +{
 +      int err;
 +      struct au_hnotify *hnotify;
 +      struct inode *h_dir, *h_inode;
-+      __u32 mask;
-+      struct qstr h_child_qstr = QSTR_INIT(event->file_name, event->name_len);
++      struct qstr h_child_qstr = QSTR_INIT(file_name, strlen(file_name));
 +
-+      AuDebugOn(event->data_type != FSNOTIFY_EVENT_INODE);
++      AuDebugOn(data_type != FSNOTIFY_EVENT_INODE);
 +
 +      err = 0;
 +      /* if FS_UNMOUNT happens, there must be another bug */
-+      mask = event->mask;
 +      AuDebugOn(mask & FS_UNMOUNT);
 +      if (mask & (FS_IN_IGNORED | FS_UNMOUNT))
 +              goto out;
 +
-+      h_dir = event->to_tell;
-+      h_inode = event->inode;
++      h_dir = inode;
++      h_inode = NULL;
 +#ifdef AuDbgHnotify
-+      au_debug(1);
++      au_debug_on();
 +      if (1 || h_child_qstr.len != sizeof(AUFS_XINO_FNAME) - 1
 +          || strncmp(h_child_qstr.name, AUFS_XINO_FNAME, h_child_qstr.len)) {
 +              AuDbg("i%lu, mask 0x%x %s, hcname %.*s, hi%lu\n",
@@ -13169,7 +13719,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +                    AuLNPair(&h_child_qstr), h_inode ? h_inode->i_ino : 0);
 +              /* WARN_ON(1); */
 +      }
-+      au_debug(0);
++      au_debug_off();
 +#endif
 +
 +      AuDebugOn(!inode_mark);
@@ -13180,21 +13730,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +      return err;
 +}
 +
-+/* isn't it waste to ask every registered 'group'? */
-+/* copied from linux/fs/notify/inotify/inotify_fsnotiry.c */
-+/* it should be exported to modules */
-+static bool au_hfsn_should_send_event(struct fsnotify_group *group,
-+                                    struct inode *h_inode,
-+                                    struct fsnotify_mark *inode_mark,
-+                                    struct fsnotify_mark *vfsmount_mark,
-+                                    __u32 mask, void *data, int data_type)
-+{
-+      mask = (mask & ~FS_EVENT_ON_CHILD);
-+      return inode_mark->mask & mask;
-+}
-+
 +static struct fsnotify_ops au_hfsn_ops = {
-+      .should_send_event      = au_hfsn_should_send_event,
 +      .handle_event           = au_hfsn_handle_event,
 +      .free_group_priv        = au_hfsn_free_group
 +};
@@ -13277,10 +13813,10 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +};
 diff -urN /usr/share/empty/fs/aufs/hfsplus.c linux/fs/aufs/hfsplus.c
 --- /usr/share/empty/fs/aufs/hfsplus.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/hfsplus.c    2013-07-06 13:20:47.750198454 +0200
++++ linux/fs/aufs/hfsplus.c    2014-04-24 22:11:10.851935747 +0200
 @@ -0,0 +1,56 @@
 +/*
-+ * Copyright (C) 2010-2013 Junjiro R. Okajima
++ * Copyright (C) 2010-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -13293,8 +13829,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsplus.c linux/fs/aufs/hfsplus.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -13309,7 +13844,8 @@ diff -urN /usr/share/empty/fs/aufs/hfsplus.c linux/fs/aufs/hfsplus.c
 +
 +#include "aufs.h"
 +
-+struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex)
++struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex,
++                         int force_wr)
 +{
 +      struct file *h_file;
 +      struct dentry *h_dentry;
@@ -13323,7 +13859,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsplus.c linux/fs/aufs/hfsplus.c
 +          && S_ISREG(h_dentry->d_inode->i_mode))
 +              h_file = au_h_open(dentry, bindex,
 +                                 O_RDONLY | O_NOATIME | O_LARGEFILE,
-+                                 /*file*/NULL);
++                                 /*file*/NULL, force_wr);
 +      return h_file;
 +}
 +
@@ -13337,10 +13873,10 @@ diff -urN /usr/share/empty/fs/aufs/hfsplus.c linux/fs/aufs/hfsplus.c
 +}
 diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 --- /usr/share/empty/fs/aufs/hnotify.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/hnotify.c    2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,712 @@
++++ linux/fs/aufs/hnotify.c    2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,710 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -13353,8 +13889,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -13699,8 +14234,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +      if (au_ftest_hnjob(a->flags, MNTPNT)
 +          && a->dentry
 +          && d_mountpoint(a->dentry))
-+              pr_warn("mount-point %.*s is removed or renamed\n",
-+                      AuDLNPair(a->dentry));
++              pr_warn("mount-point %pd is removed or renamed\n", a->dentry);
 +
 +      return 0;
 +}
@@ -13720,7 +14254,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +      dentry = NULL;
 +      spin_lock(&parent->d_lock);
 +      list_for_each_entry(d, &parent->d_subdirs, d_u.d_child) {
-+              /* AuDbg("%.*s\n", AuDLNPair(d)); */
++              /* AuDbg("%pd\n", d); */
 +              spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED);
 +              dname = &d->d_name;
 +              if (dname->len != nlen || memcmp(dname->name, name, nlen))
@@ -13729,13 +14263,13 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +                      au_digen_dec(d);
 +              else
 +                      goto cont_unlock;
-+              if (d->d_count) {
++              if (d_count(d)) {
 +                      dentry = dget_dlock(d);
 +                      spin_unlock(&d->d_lock);
 +                      break;
 +              }
 +
-+      cont_unlock:
++cont_unlock:
 +              spin_unlock(&d->d_lock);
 +      }
 +      spin_unlock(&parent->d_lock);
@@ -13927,7 +14461,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +              au_fset_hnjob(flags[AuHn_CHILD], MNTPNT);
 +              /*FALLTHROUGH*/
 +      case FS_CREATE:
-+              AuDebugOn(!h_child_name || !h_child_inode);
++              AuDebugOn(!h_child_name);
 +              break;
 +
 +      case FS_DELETE:
@@ -14053,10 +14587,10 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +}
 diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 --- /usr/share/empty/fs/aufs/iinfo.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/iinfo.c      2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,276 @@
++++ linux/fs/aufs/iinfo.c      2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,275 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -14069,8 +14603,7 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -14333,10 +14866,10 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 +}
 diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 --- /usr/share/empty/fs/aufs/inode.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/inode.c      2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,492 @@
++++ linux/fs/aufs/inode.c      2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,491 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -14349,8 +14882,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -14765,8 +15297,8 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +
 +      if (unlikely(au_test_fs_unique_ino(h_dentry->d_inode)))
 +              AuWarn1("Warning: Un-notified UDBA or repeatedly renamed dir,"
-+                      " b%d, %s, %.*s, hi%lu, i%lu.\n",
-+                      bstart, au_sbtype(h_dentry->d_sb), AuDLNPair(dentry),
++                      " b%d, %s, %pd, hi%lu, i%lu.\n",
++                      bstart, au_sbtype(h_dentry->d_sb), dentry,
 +                      (unsigned long)h_ino, (unsigned long)ino);
 +      ino = 0;
 +      err = au_xino_write(sb, bstart, h_ino, /*ino*/0);
@@ -14829,10 +15361,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +}
 diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 --- /usr/share/empty/fs/aufs/inode.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/inode.h      2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,600 @@
++++ linux/fs/aufs/inode.h      2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,599 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -14845,8 +15377,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -15433,10 +15964,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +#endif /* __AUFS_INODE_H__ */
 diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 --- /usr/share/empty/fs/aufs/ioctl.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/ioctl.c      2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,196 @@
++++ linux/fs/aufs/ioctl.c      2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,201 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -15449,16 +15980,18 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
 + * ioctl
 + * plink-management and readdir in userspace.
 + * assist the pathconf(3) wrapper library.
++ * move-down
 + */
 +
++#include <linux/compat.h>
++#include <linux/file.h>
 +#include "aufs.h"
 +
 +static int au_wbr_fd(struct path *path, struct aufs_wbr_fd __user *arg)
@@ -15530,7 +16063,8 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 +      }
 +      AuDbg("wbi %d\n", wbi);
 +      if (wbi >= 0)
-+              h_file = au_h_open(root, wbi, wbrfd.oflags, NULL);
++              h_file = au_h_open(root, wbi, wbrfd.oflags, NULL,
++                                 /*force_wr*/0);
 +
 +out_unlock:
 +      aufs_read_unlock(root, AuLock_IR);
@@ -15585,6 +16119,10 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 +      long err;
 +
 +      switch (cmd) {
++      case AUFS_CTL_MVDOWN:
++              err = au_mvdown(file->f_dentry, (void __user *)arg);
++              break;
++
 +      case AUFS_CTL_WBR_FD:
 +              err = au_wbr_fd(&file->f_path, (void __user *)arg);
 +              break;
@@ -15623,20 +16161,18 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 +      return err;
 +}
 +
-+#if 0 /* unused yet */
 +long aufs_compat_ioctl_nondir(struct file *file, unsigned int cmd,
 +                            unsigned long arg)
 +{
 +      return aufs_ioctl_nondir(file, cmd, (unsigned long)compat_ptr(arg));
 +}
 +#endif
-+#endif
 diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 --- /usr/share/empty/fs/aufs/i_op_add.c        1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/i_op_add.c   2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,722 @@
++++ linux/fs/aufs/i_op_add.c   2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,762 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -15649,8 +16185,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -15708,8 +16243,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      wh = au_wh_create(dentry, bwh, wh_dentry->d_parent);
 +      rerr = PTR_ERR(wh);
 +      if (IS_ERR(wh)) {
-+              AuIOErr("%.*s reverting whiteout failed(%d, %d)\n",
-+                      AuDLNPair(dentry), err, rerr);
++              AuIOErr("%pd reverting whiteout failed(%d, %d)\n",
++                      dentry, err, rerr);
 +              err = -EIO;
 +      } else
 +              dput(wh);
@@ -15796,7 +16331,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      unsigned int udba;
 +      aufs_bindex_t bcpup;
 +
-+      AuDbg("%.*s\n", AuDLNPair(dentry));
++      AuDbg("%pd\n", dentry);
 +
 +      err = au_wr_dir(dentry, src_dentry, wr_dir_args);
 +      bcpup = err;
@@ -15871,47 +16406,55 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      int err;
 +      aufs_bindex_t bstart;
 +      unsigned char created;
-+      struct au_dtime dt;
-+      struct au_pin pin;
-+      struct path h_path;
 +      struct dentry *wh_dentry, *parent;
 +      struct inode *h_dir;
-+      struct au_wr_dir_args wr_dir_args = {
-+              .force_btgt     = -1,
-+              .flags          = AuWrDir_ADD_ENTRY
-+      };
++      /* to reuduce stack size */
++      struct {
++              struct au_dtime dt;
++              struct au_pin pin;
++              struct path h_path;
++              struct au_wr_dir_args wr_dir_args;
++      } *a;
 +
-+      AuDbg("%.*s\n", AuDLNPair(dentry));
++      AuDbg("%pd\n", dentry);
 +      IMustLock(dir);
 +
++      err = -ENOMEM;
++      a = kmalloc(sizeof(*a), GFP_NOFS);
++      if (unlikely(!a))
++              goto out;
++      a->wr_dir_args.force_btgt = -1;
++      a->wr_dir_args.flags = AuWrDir_ADD_ENTRY;
++
 +      parent = dentry->d_parent; /* dir inode is locked */
 +      err = aufs_read_lock(dentry, AuLock_DW | AuLock_GEN);
 +      if (unlikely(err))
-+              goto out;
++              goto out_free;
 +      err = au_d_may_add(dentry);
 +      if (unlikely(err))
 +              goto out_unlock;
 +      di_write_lock_parent(parent);
-+      wh_dentry = lock_hdir_lkup_wh(dentry, &dt, /*src_dentry*/NULL, &pin,
-+                                    &wr_dir_args);
++      wh_dentry = lock_hdir_lkup_wh(dentry, &a->dt, /*src_dentry*/NULL,
++                                    &a->pin, &a->wr_dir_args);
 +      err = PTR_ERR(wh_dentry);
 +      if (IS_ERR(wh_dentry))
 +              goto out_parent;
 +
 +      bstart = au_dbstart(dentry);
-+      h_path.dentry = au_h_dptr(dentry, bstart);
-+      h_path.mnt = au_sbr_mnt(dentry->d_sb, bstart);
-+      h_dir = au_pinned_h_dir(&pin);
++      a->h_path.dentry = au_h_dptr(dentry, bstart);
++      a->h_path.mnt = au_sbr_mnt(dentry->d_sb, bstart);
++      h_dir = au_pinned_h_dir(&a->pin);
 +      switch (arg->type) {
 +      case Creat:
-+              err = vfsub_create(h_dir, &h_path, arg->u.c.mode,
++              err = vfsub_create(h_dir, &a->h_path, arg->u.c.mode,
 +                                 arg->u.c.want_excl);
 +              break;
 +      case Symlink:
-+              err = vfsub_symlink(h_dir, &h_path, arg->u.s.symname);
++              err = vfsub_symlink(h_dir, &a->h_path, arg->u.s.symname);
 +              break;
 +      case Mknod:
-+              err = vfsub_mknod(h_dir, &h_path, arg->u.m.mode, arg->u.m.dev);
++              err = vfsub_mknod(h_dir, &a->h_path, arg->u.m.mode,
++                                arg->u.m.dev);
 +              break;
 +      default:
 +              BUG();
@@ -15921,18 +16464,20 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              err = epilog(dir, bstart, wh_dentry, dentry);
 +
 +      /* revert */
-+      if (unlikely(created && err && h_path.dentry->d_inode)) {
++      if (unlikely(created && err && a->h_path.dentry->d_inode)) {
 +              int rerr;
-+              rerr = vfsub_unlink(h_dir, &h_path, /*force*/0);
++              /* no delegation since it is just created */
++              rerr = vfsub_unlink(h_dir, &a->h_path, /*delegated*/NULL,
++                                  /*force*/0);
 +              if (rerr) {
-+                      AuIOErr("%.*s revert failure(%d, %d)\n",
-+                              AuDLNPair(dentry), err, rerr);
++                      AuIOErr("%pd revert failure(%d, %d)\n",
++                              dentry, err, rerr);
 +                      err = -EIO;
 +              }
-+              au_dtime_revert(&dt);
++              au_dtime_revert(&a->dt);
 +      }
 +
-+      au_unpin(&pin);
++      au_unpin(&a->pin);
 +      dput(wh_dentry);
 +
 +out_parent:
@@ -15943,6 +16488,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              d_drop(dentry);
 +      }
 +      aufs_read_unlock(dentry, AuLock_DW);
++out_free:
++      kfree(a);
 +out:
 +      return err;
 +}
@@ -15996,7 +16543,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +{
 +      int err;
 +      struct dentry *h_src_dentry;
-+      struct file *h_file;
++      struct au_cp_generic cpg = {
++              .dentry = src_dentry,
++              .bdst   = a->bdst,
++              .bsrc   = a->bsrc,
++              .len    = -1,
++              .pin    = &a->pin,
++              .flags  = AuCpup_DTIME | AuCpup_HOPEN /* | AuCpup_KEEPLINO */
++      };
 +
 +      di_read_lock_parent(a->src_parent, AuLock_IR);
 +      err = au_test_and_cpup_dirs(src_dentry, a->bdst);
@@ -16009,15 +16563,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +                   AuPin_DI_LOCKED | AuPin_MNT_WRITE);
 +      if (unlikely(err))
 +              goto out;
-+      h_file = au_h_open_pre(src_dentry, a->bsrc);
-+      if (IS_ERR(h_file))
-+              err = PTR_ERR(h_file);
-+      else {
-+              err = au_sio_cpup_simple(src_dentry, a->bdst, -1,
-+                                       AuCpup_DTIME /* | AuCpup_KEEPLINO */,
-+                                       &a->pin);
-+              au_h_open_post(src_dentry, a->bsrc, h_file);
-+      }
++
++      err = au_sio_cpup_simple(&cpg);
 +      au_unpin(&a->pin);
 +
 +out:
@@ -16032,7 +16579,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      unsigned char plink;
 +      aufs_bindex_t bend;
 +      struct dentry *h_src_dentry;
-+      struct inode *h_inode, *inode;
++      struct inode *h_inode, *inode, *delegated;
 +      struct super_block *sb;
 +      struct file *h_file;
 +
@@ -16052,12 +16599,19 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              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);
++              h_file = au_h_open_pre(dentry, a->bsrc, /*force_wr*/0);
 +              if (IS_ERR(h_file))
 +                      err = PTR_ERR(h_file);
 +              else {
-+                      err = au_sio_cpup_simple(dentry, a->bdst, -1,
-+                                               AuCpup_KEEPLINO, &a->pin);
++                      struct au_cp_generic cpg = {
++                              .dentry = dentry,
++                              .bdst   = a->bdst,
++                              .bsrc   = -1,
++                              .len    = -1,
++                              .pin    = &a->pin,
++                              .flags  = AuCpup_KEEPLINO
++                      };
++                      err = au_sio_cpup_simple(&cpg);
 +                      au_h_open_post(dentry, a->bsrc, h_file);
 +                      if (!err) {
 +                              dput(a->h_path.dentry);
@@ -16086,8 +16640,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +
 +              }
 +              if (h_src_dentry) {
++                      delegated = NULL;
 +                      err = vfsub_link(h_src_dentry, au_pinned_h_dir(&a->pin),
-+                                       &a->h_path);
++                                       &a->h_path, &delegated);
++                      if (unlikely(err == -EWOULDBLOCK)) {
++                              pr_warn("cannot retry for NFSv4 delegation"
++                                      " for an internal link\n");
++                              iput(delegated);
++                      }
 +                      dput(h_src_dentry);
 +              } else {
 +                      AuIOErr("no dentry found for hi%lu on b%d\n",
@@ -16111,7 +16671,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      struct au_dtime dt;
 +      struct au_link_args *a;
 +      struct dentry *wh_dentry, *h_src_dentry;
-+      struct inode *inode;
++      struct inode *inode, *delegated;
 +      struct super_block *sb;
 +      struct au_wr_dir_args wr_dir_args = {
 +              /* .force_btgt  = -1, */
@@ -16168,9 +16728,16 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              if (a->bdst < a->bsrc
 +                  /* && h_src_dentry->d_sb != a->h_path.dentry->d_sb */)
 +                      err = au_cpup_or_link(src_dentry, dentry, a);
-+              else
++              else {
++                      delegated = NULL;
 +                      err = vfsub_link(h_src_dentry, au_pinned_h_dir(&a->pin),
-+                                       &a->h_path);
++                                       &a->h_path, &delegated);
++                      if (unlikely(err == -EWOULDBLOCK)) {
++                              pr_warn("cannot retry for NFSv4 delegation"
++                                      " for an internal link\n");
++                              iput(delegated);
++                      }
++              }
 +              dput(h_src_dentry);
 +      } else {
 +              /*
@@ -16194,10 +16761,18 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              if (!err) {
 +                      h_src_dentry = au_h_dptr(src_dentry, a->bdst);
 +                      err = -ENOENT;
-+                      if (h_src_dentry && h_src_dentry->d_inode)
++                      if (h_src_dentry && h_src_dentry->d_inode) {
++                              delegated = NULL;
 +                              err = vfsub_link(h_src_dentry,
 +                                               au_pinned_h_dir(&a->pin),
-+                                               &a->h_path);
++                                               &a->h_path, &delegated);
++                              if (unlikely(err == -EWOULDBLOCK)) {
++                                      pr_warn("cannot retry"
++                                              " for NFSv4 delegation"
++                                              " for an internal link\n");
++                                      iput(delegated);
++                              }
++                      }
 +              }
 +      }
 +      if (unlikely(err))
@@ -16223,10 +16798,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      goto out_unpin; /* success */
 +
 +out_revert:
-+      rerr = vfsub_unlink(au_pinned_h_dir(&a->pin), &a->h_path, /*force*/0);
++      /* no delegation since it is just created */
++      rerr = vfsub_unlink(au_pinned_h_dir(&a->pin), &a->h_path,
++                          /*delegated*/NULL, /*force*/0);
 +      if (unlikely(rerr)) {
-+              AuIOErr("%.*s reverting failed(%d, %d)\n",
-+                      AuDLNPair(dentry), err, rerr);
++              AuIOErr("%pd reverting failed(%d, %d)\n", dentry, err, rerr);
 +              err = -EIO;
 +      }
 +      au_dtime_revert(&dt);
@@ -16326,8 +16902,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              rerr = au_diropq_remove(dentry, bindex);
 +              mutex_unlock(h_mtx);
 +              if (rerr) {
-+                      AuIOErr("%.*s reverting diropq failed(%d, %d)\n",
-+                              AuDLNPair(dentry), err, rerr);
++                      AuIOErr("%pd reverting diropq failed(%d, %d)\n",
++                              dentry, err, rerr);
 +                      err = -EIO;
 +              }
 +      }
@@ -16336,8 +16912,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      AuLabel(revert dir);
 +      rerr = vfsub_rmdir(au_pinned_h_dir(&a->pin), &h_path);
 +      if (rerr) {
-+              AuIOErr("%.*s reverting dir failed(%d, %d)\n",
-+                      AuDLNPair(dentry), err, rerr);
++              AuIOErr("%pd reverting dir failed(%d, %d)\n",
++                      dentry, err, rerr);
 +              err = -EIO;
 +      }
 +      au_dtime_revert(&a->dt);
@@ -16359,10 +16935,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +}
 diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 --- /usr/share/empty/fs/aufs/i_op.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/i_op.c       2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,1108 @@
++++ linux/fs/aufs/i_op.c       2014-04-24 22:11:10.851935747 +0200
+@@ -0,0 +1,1127 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -16375,8 +16951,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -16623,10 +17198,12 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +
 +      err = 0;
 +      if (!au_h_dptr(parent, bcpup)) {
-+              if (bstart < bcpup)
++              if (bstart > bcpup)
++                      err = au_cpup_dirs(dentry, bcpup);
++              else if (bstart < bcpup)
 +                      err = au_cpdown_dirs(dentry, bcpup);
 +              else
-+                      err = au_cpup_dirs(dentry, bcpup);
++                      BUG();
 +      }
 +      if (!err && add_entry) {
 +              h_parent = au_h_dptr(parent, bcpup);
@@ -16663,6 +17240,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +            struct au_wr_dir_args *args)
 +{
 +      int err;
++      unsigned int flags;
 +      aufs_bindex_t bcpup, bstart, src_bstart;
 +      const unsigned char add_entry
 +              = au_ftest_wrdir(args->flags, ADD_ENTRY)
@@ -16682,8 +17260,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +                      if (src_bstart < bstart)
 +                              bcpup = src_bstart;
 +              } else if (add_entry) {
-+                      err = AuWbrCreate(sbinfo, dentry,
-+                                        au_ftest_wrdir(args->flags, ISDIR));
++                      flags = 0;
++                      if (au_ftest_wrdir(args->flags, ISDIR))
++                              au_fset_wbr(flags, DIR);
++                      err = AuWbrCreate(sbinfo, dentry, flags);
 +                      bcpup = err;
 +              }
 +
@@ -16993,7 +17573,6 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      aufs_bindex_t bstart, ibstart;
 +      struct dentry *hi_wh, *parent;
 +      struct inode *inode;
-+      struct file *h_file;
 +      struct au_wr_dir_args wr_dir_args = {
 +              .force_btgt     = -1,
 +              .flags          = 0
@@ -17035,13 +17614,18 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              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,
-+                                           &a->pin);
++                      struct au_cp_generic cpg = {
++                              .dentry = dentry,
++                              .bdst   = a->btgt,
++                              .bsrc   = -1,
++                              .len    = sz,
++                              .pin    = &a->pin
++                      };
++                      err = au_sio_cpup_wh(&cpg, /*file*/NULL);
 +                      if (unlikely(err))
 +                              goto out_unlock;
 +                      hi_wh = au_hi_wh(inode, a->btgt);
@@ -17059,14 +17643,15 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              goto out; /* success */
 +
 +      if (!d_unhashed(dentry)) {
-+              h_file = au_h_open_pre(dentry, bstart);
-+              if (IS_ERR(h_file))
-+                      err = PTR_ERR(h_file);
-+              else {
-+                      err = au_sio_cpup_simple(dentry, a->btgt, sz,
-+                                               AuCpup_DTIME, &a->pin);
-+                      au_h_open_post(dentry, bstart, h_file);
-+              }
++              struct au_cp_generic cpg = {
++                      .dentry = dentry,
++                      .bdst   = a->btgt,
++                      .bsrc   = bstart,
++                      .len    = sz,
++                      .pin    = &a->pin,
++                      .flags  = AuCpup_DTIME | AuCpup_HOPEN
++              };
++              err = au_sio_cpup_simple(&cpg);
 +              if (!err)
 +                      a->h_path.dentry = au_h_dptr(dentry, a->btgt);
 +      } else if (!hi_wh)
@@ -17093,7 +17678,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +static int aufs_setattr(struct dentry *dentry, struct iattr *ia)
 +{
 +      int err;
-+      struct inode *inode;
++      struct inode *inode, *delegated;
 +      struct super_block *sb;
 +      struct file *file;
 +      struct au_icpup_args *a;
@@ -17173,8 +17758,18 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              mutex_unlock(&a->h_inode->i_mutex);
 +              err = vfsub_trunc(&a->h_path, ia->ia_size, ia->ia_valid, f);
 +              mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
-+      } else
-+              err = vfsub_notify_change(&a->h_path, ia);
++      } else {
++              delegated = NULL;
++              while (1) {
++                      err = vfsub_notify_change(&a->h_path, ia, &delegated);
++                      if (delegated) {
++                              err = break_deleg_wait(&delegated);
++                              if (!err)
++                                      continue;
++                      }
++                      break;
++              }
++      }
 +      if (!err)
 +              au_cpup_attr_changeable(inode);
 +
@@ -17217,7 +17812,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              n = inode->i_nlink;
 +              n -= nlink;
 +              n += st->nlink;
-+              smp_mb();
++              smp_mb(); /* for i_nlink */
 +              /* 0 can happen */
 +              set_nlink(inode, n);
 +      }
@@ -17471,10 +18066,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +};
 diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 --- /usr/share/empty/fs/aufs/i_op_del.c        1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/i_op_del.c   2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,477 @@
++++ linux/fs/aufs/i_op_del.c   2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,506 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -17487,8 +18082,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -17715,8 +18309,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +
 +      err = au_whtmp_rmdir(dir, bindex, h_dentry, whlist);
 +      if (unlikely(err)) {
-+              AuIOErr("rmdir %.*s, b%d failed, %d. ignored\n",
-+                      AuDLNPair(h_dentry), bindex, err);
++              AuIOErr("rmdir %pd, b%d failed, %d. ignored\n",
++                      h_dentry, bindex, err);
 +              err = 0;
 +      }
 +
@@ -17763,8 +18357,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +              return 0;
 +      }
 +
-+      AuIOErr("%.*s reverting whiteout failed(%d, %d)\n",
-+              AuDLNPair(dentry), err, rerr);
++      AuIOErr("%pd reverting whiteout failed(%d, %d)\n", dentry, err, rerr);
 +      return -EIO;
 +}
 +
@@ -17774,17 +18367,25 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +{
 +      int err;
 +      aufs_bindex_t bwh, bindex, bstart;
-+      struct au_dtime dt;
-+      struct au_pin pin;
-+      struct path h_path;
-+      struct inode *inode, *h_dir;
++      struct inode *inode, *h_dir, *delegated;
 +      struct dentry *parent, *wh_dentry;
++      /* to reuduce stack size */
++      struct {
++              struct au_dtime dt;
++              struct au_pin pin;
++              struct path h_path;
++      } *a;
 +
 +      IMustLock(dir);
 +
++      err = -ENOMEM;
++      a = kmalloc(sizeof(*a), GFP_NOFS);
++      if (unlikely(!a))
++              goto out;
++
 +      err = aufs_read_lock(dentry, AuLock_DW | AuLock_GEN);
 +      if (unlikely(err))
-+              goto out;
++              goto out_free;
 +      err = au_d_hashed_positive(dentry);
 +      if (unlikely(err))
 +              goto out_unlock;
@@ -17799,17 +18400,24 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +      bindex = -1;
 +      parent = dentry->d_parent; /* dir inode is locked */
 +      di_write_lock_parent(parent);
-+      wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/0, &bindex, &dt, &pin);
++      wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/0, &bindex, &a->dt,
++                                      &a->pin);
 +      err = PTR_ERR(wh_dentry);
 +      if (IS_ERR(wh_dentry))
 +              goto out_parent;
 +
-+      h_path.mnt = au_sbr_mnt(dentry->d_sb, bstart);
-+      h_path.dentry = au_h_dptr(dentry, bstart);
-+      dget(h_path.dentry);
++      a->h_path.mnt = au_sbr_mnt(dentry->d_sb, bstart);
++      a->h_path.dentry = au_h_dptr(dentry, bstart);
++      dget(a->h_path.dentry);
 +      if (bindex == bstart) {
-+              h_dir = au_pinned_h_dir(&pin);
-+              err = vfsub_unlink(h_dir, &h_path, /*force*/0);
++              h_dir = au_pinned_h_dir(&a->pin);
++              delegated = NULL;
++              err = vfsub_unlink(h_dir, &a->h_path, &delegated, /*force*/0);
++              if (unlikely(err == -EWOULDBLOCK)) {
++                      pr_warn("cannot retry for NFSv4 delegation"
++                              " for an internal unlink\n");
++                      iput(delegated);
++              }
 +      } else {
 +              /* dir inode is locked */
 +              h_dir = wh_dentry->d_parent->d_inode;
@@ -17823,8 +18431,9 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +
 +              /* update target timestamps */
 +              if (bindex == bstart) {
-+                      vfsub_update_h_iattr(&h_path, /*did*/NULL); /*ignore*/
-+                      inode->i_ctime = h_path.dentry->d_inode->i_ctime;
++                      vfsub_update_h_iattr(&a->h_path, /*did*/NULL);
++                      /*ignore*/
++                      inode->i_ctime = a->h_path.dentry->d_inode->i_ctime;
 +              } else
 +                      /* todo: this timestamp may be reverted later */
 +                      inode->i_ctime = h_dir->i_ctime;
@@ -17835,19 +18444,22 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +      if (wh_dentry) {
 +              int rerr;
 +
-+              rerr = do_revert(err, dir, bindex, bwh, wh_dentry, dentry, &dt);
++              rerr = do_revert(err, dir, bindex, bwh, wh_dentry, dentry,
++                               &a->dt);
 +              if (rerr)
 +                      err = rerr;
 +      }
 +
 +out_unpin:
-+      au_unpin(&pin);
++      au_unpin(&a->pin);
 +      dput(wh_dentry);
-+      dput(h_path.dentry);
++      dput(a->h_path.dentry);
 +out_parent:
 +      di_write_unlock(parent);
 +out_unlock:
 +      aufs_read_unlock(dentry, AuLock_DW);
++out_free:
++      kfree(a);
 +out:
 +      return err;
 +}
@@ -17856,17 +18468,25 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +{
 +      int err, rmdir_later;
 +      aufs_bindex_t bwh, bindex, bstart;
-+      struct au_dtime dt;
-+      struct au_pin pin;
 +      struct inode *inode;
 +      struct dentry *parent, *wh_dentry, *h_dentry;
 +      struct au_whtmp_rmdir *args;
++      /* to reuduce stack size */
++      struct {
++              struct au_dtime dt;
++              struct au_pin pin;
++      } *a;
 +
 +      IMustLock(dir);
 +
++      err = -ENOMEM;
++      a = kmalloc(sizeof(*a), GFP_NOFS);
++      if (unlikely(!a))
++              goto out;
++
 +      err = aufs_read_lock(dentry, AuLock_DW | AuLock_FLUSH | AuLock_GEN);
 +      if (unlikely(err))
-+              goto out;
++              goto out_free;
 +      err = au_alive_dir(dentry);
 +      if (unlikely(err))
 +              goto out_unlock;
@@ -17890,7 +18510,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +      bstart = au_dbstart(dentry);
 +      bwh = au_dbwh(dentry);
 +      bindex = -1;
-+      wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/1, &bindex, &dt, &pin);
++      wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/1, &bindex, &a->dt,
++                                      &a->pin);
 +      err = PTR_ERR(wh_dentry);
 +      if (IS_ERR(wh_dentry))
 +              goto out_parent;
@@ -17931,13 +18552,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +      if (wh_dentry) {
 +              int rerr;
 +
-+              rerr = do_revert(err, dir, bindex, bwh, wh_dentry, dentry, &dt);
++              rerr = do_revert(err, dir, bindex, bwh, wh_dentry, dentry,
++                               &a->dt);
 +              if (rerr)
 +                      err = rerr;
 +      }
 +
 +out_unpin:
-+      au_unpin(&pin);
++      au_unpin(&a->pin);
 +      dput(wh_dentry);
 +      dput(h_dentry);
 +out_parent:
@@ -17946,16 +18568,18 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +              au_whtmp_rmdir_free(args);
 +out_unlock:
 +      aufs_read_unlock(dentry, AuLock_DW);
++out_free:
++      kfree(a);
 +out:
 +      AuTraceErr(err);
 +      return err;
 +}
 diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 --- /usr/share/empty/fs/aufs/i_op_ren.c        1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/i_op_ren.c   2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,1053 @@
++++ linux/fs/aufs/i_op_ren.c   2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,1032 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -17968,8 +18592,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -18068,29 +18691,36 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      au_hn_imtx_unlock(a->src_hinode);
 +      au_set_dbdiropq(a->src_dentry, a->src_bdiropq);
 +      if (rerr)
-+              RevertFailure("remove diropq %.*s", AuDLNPair(a->src_dentry));
++              RevertFailure("remove diropq %pd", a->src_dentry);
 +}
 +
 +static void au_ren_rev_rename(int err, struct au_ren_args *a)
 +{
 +      int rerr;
++      struct inode *delegated;
 +
 +      a->h_path.dentry = vfsub_lkup_one(&a->src_dentry->d_name,
 +                                        a->src_h_parent);
 +      rerr = PTR_ERR(a->h_path.dentry);
 +      if (IS_ERR(a->h_path.dentry)) {
-+              RevertFailure("lkup one %.*s", AuDLNPair(a->src_dentry));
++              RevertFailure("lkup one %pd", a->src_dentry);
 +              return;
 +      }
 +
++      delegated = NULL;
 +      rerr = vfsub_rename(a->dst_h_dir,
 +                          au_h_dptr(a->src_dentry, a->btgt),
-+                          a->src_h_dir, &a->h_path);
++                          a->src_h_dir, &a->h_path, &delegated);
++      if (unlikely(rerr == -EWOULDBLOCK)) {
++              pr_warn("cannot retry for NFSv4 delegation"
++                      " for an internal rename\n");
++              iput(delegated);
++      }
 +      d_drop(a->h_path.dentry);
 +      dput(a->h_path.dentry);
 +      /* au_set_h_dptr(a->src_dentry, a->btgt, NULL); */
 +      if (rerr)
-+              RevertFailure("rename %.*s", AuDLNPair(a->src_dentry));
++              RevertFailure("rename %pd", a->src_dentry);
 +}
 +
 +static void au_ren_rev_cpup(int err, struct au_ren_args *a)
@@ -18098,22 +18728,25 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      int rerr;
 +
 +      a->h_path.dentry = a->dst_h_dentry;
-+      rerr = vfsub_unlink(a->dst_h_dir, &a->h_path, /*force*/0);
++      /* no delegation since it is just created */
++      rerr = vfsub_unlink(a->dst_h_dir, &a->h_path, /*delegated*/NULL,
++                          /*force*/0);
 +      au_set_h_dptr(a->src_dentry, a->btgt, NULL);
 +      au_set_dbstart(a->src_dentry, a->src_bstart);
 +      if (rerr)
-+              RevertFailure("unlink %.*s", AuDLNPair(a->dst_h_dentry));
++              RevertFailure("unlink %pd", a->dst_h_dentry);
 +}
 +
 +static void au_ren_rev_whtmp(int err, struct au_ren_args *a)
 +{
 +      int rerr;
++      struct inode *delegated;
 +
 +      a->h_path.dentry = vfsub_lkup_one(&a->dst_dentry->d_name,
 +                                        a->dst_h_parent);
 +      rerr = PTR_ERR(a->h_path.dentry);
 +      if (IS_ERR(a->h_path.dentry)) {
-+              RevertFailure("lkup one %.*s", AuDLNPair(a->dst_dentry));
++              RevertFailure("lkup one %pd", a->dst_dentry);
 +              return;
 +      }
 +      if (a->h_path.dentry->d_inode) {
@@ -18122,13 +18755,20 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              return;
 +      }
 +
-+      rerr = vfsub_rename(a->dst_h_dir, a->h_dst, a->dst_h_dir, &a->h_path);
++      delegated = NULL;
++      rerr = vfsub_rename(a->dst_h_dir, a->h_dst, a->dst_h_dir, &a->h_path,
++                          &delegated);
++      if (unlikely(rerr == -EWOULDBLOCK)) {
++              pr_warn("cannot retry for NFSv4 delegation"
++                      " for an internal rename\n");
++              iput(delegated);
++      }
 +      d_drop(a->h_path.dentry);
 +      dput(a->h_path.dentry);
 +      if (!rerr)
 +              au_set_h_dptr(a->dst_dentry, a->btgt, dget(a->h_dst));
 +      else
-+              RevertFailure("rename %.*s", AuDLNPair(a->h_dst));
++              RevertFailure("rename %pd", a->h_dst);
 +}
 +
 +static void au_ren_rev_whsrc(int err, struct au_ren_args *a)
@@ -18139,7 +18779,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      rerr = au_wh_unlink_dentry(a->src_h_dir, &a->h_path, a->src_dentry);
 +      au_set_dbwh(a->src_dentry, a->src_bwh);
 +      if (rerr)
-+              RevertFailure("unlink %.*s", AuDLNPair(a->src_wh_dentry));
++              RevertFailure("unlink %pd", a->src_wh_dentry);
 +}
 +#undef RevertFailure
 +
@@ -18154,6 +18794,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +{
 +      int err;
 +      struct dentry *d;
++      struct inode *delegated;
 +
 +      d = a->src_dentry;
 +      if (au_dbstart(d) == a->btgt) {
@@ -18162,35 +18803,17 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +                  && au_dbdiropq(d) == a->btgt)
 +                      au_fclr_ren(a->flags, DIROPQ);
 +              AuDebugOn(au_dbstart(d) != a->btgt);
++              delegated = NULL;
 +              err = vfsub_rename(a->src_h_dir, au_h_dptr(d, a->btgt),
-+                                 a->dst_h_dir, &a->h_path);
-+      } else {
-+#if 1
++                                 a->dst_h_dir, &a->h_path, &delegated);
++              if (unlikely(err == -EWOULDBLOCK)) {
++                      pr_warn("cannot retry for NFSv4 delegation"
++                              " for an internal rename\n");
++                      iput(delegated);
++              }
++      } else
 +              BUG();
-+#else
-+              struct file *h_file;
 +
-+              au_fset_ren(a->flags, CPUP);
-+              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))
-+                      err = PTR_ERR(h_file);
-+              else {
-+                      err = au_sio_cpup_single(d, a->btgt, a->src_bstart, -1,
-+                                               !AuCpup_DTIME, a->dst_parent);
-+                      au_h_open_post(d, a->src_bstart, h_file);
-+              }
-+              if (!err) {
-+                      d = a->dst_dentry;
-+                      au_set_h_dptr(d, a->btgt, NULL);
-+                      au_update_dbstart(d);
-+              } else {
-+                      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 */
 +              dget(a->h_dst);
@@ -18211,8 +18834,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +          || au_test_fs_remote(a->h_dst->d_sb)) {
 +              err = au_whtmp_rmdir(dir, a->btgt, a->h_dst, &a->whlist);
 +              if (unlikely(err))
-+                      pr_warn("failed removing whtmp dir %.*s (%d), "
-+                              "ignored.\n", AuDLNPair(a->h_dst), err);
++                      pr_warn("failed removing whtmp dir %pd (%d), "
++                              "ignored.\n", a->h_dst, err);
 +      } else {
 +              au_nhash_wh_free(&a->thargs->whlist);
 +              a->thargs->whlist = a->whlist;
@@ -18297,25 +18920,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              a->dst_h_dentry = au_h_dptr(d, a->btgt);
 +      }
 +
-+      /* cpup src */
-+      if (a->dst_h_dentry->d_inode && a->src_bstart != a->btgt) {
-+#if 1
-+              BUG();
-+#else
-+              struct file *h_file;
-+
-+              h_file = au_h_open_pre(a->src_dentry, a->src_bstart);
-+              if (IS_ERR(h_file))
-+                      err = PTR_ERR(h_file);
-+              else {
-+                      err = au_sio_cpup_simple(a->src_dentry, a->btgt, -1,
-+                                               !AuCpup_DTIME);
-+                      au_h_open_post(a->src_dentry, a->src_bstart, h_file);
-+              }
-+              if (unlikely(err))
-+                      goto out_whtmp;
-+#endif
-+      }
++      BUG_ON(a->dst_h_dentry->d_inode && a->src_bstart != a->btgt);
 +
 +      /* rename by vfs_rename or cpup */
 +      d = a->dst_dentry;
@@ -18803,7 +19408,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      /* reduce stack space */
 +      struct au_ren_args *a;
 +
-+      AuDbg("%.*s, %.*s\n", AuDLNPair(_src_dentry), AuDLNPair(_dst_dentry));
++      AuDbg("%pd, %pd\n", _src_dentry, _dst_dentry);
 +      IMustLock(_src_dir);
 +      IMustLock(_dst_dir);
 +
@@ -18917,26 +19522,24 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      /* 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);
++              if (!err) {
++                      struct au_cp_generic cpg = {
++                              .dentry = a->src_dentry,
++                              .bdst   = a->btgt,
++                              .bsrc   = a->src_bstart,
++                              .len    = -1,
++                              .pin    = &pin,
++                              .flags  = AuCpup_DTIME | AuCpup_HOPEN
++                      };
++                      AuDebugOn(au_dbstart(a->src_dentry) != a->src_bstart);
++                      err = au_sio_cpup_simple(&cpg);
++                      au_unpin(&pin);
 +              }
-+              au_unpin(&pin);
 +              if (unlikely(err))
 +                      goto out_children;
 +              a->src_bstart = a->btgt;
@@ -19009,8 +19612,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +}
 diff -urN /usr/share/empty/fs/aufs/Kconfig linux/fs/aufs/Kconfig
 --- /usr/share/empty/fs/aufs/Kconfig   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/Kconfig      2013-07-06 13:20:47.736864659 +0200
-@@ -0,0 +1,202 @@
++++ linux/fs/aufs/Kconfig      2014-04-24 22:11:10.835268907 +0200
+@@ -0,0 +1,179 @@
 +config AUFS_FS
 +      tristate "Aufs (Advanced multi layered unification filesystem) support"
 +      help
@@ -19112,29 +19715,6 @@ diff -urN /usr/share/empty/fs/aufs/Kconfig linux/fs/aufs/Kconfig
 +      shows better performance in most cases.
 +      See detail in aufs.5.
 +
-+config AUFS_PROC_MAP
-+      bool "support for /proc/maps and lsof(1)"
-+      depends on PROC_FS
-+      help
-+      When you issue mmap(2) in aufs, it is actually a direct mmap(2)
-+      call to the file on the branch fs since the file in aufs is
-+      purely virtual. And the file path printed in /proc/maps (and
-+      others) will be the path on the branch fs. In most cases, it
-+      does no harm. But some utilities like lsof(1) may confuse since
-+      the utility or user may expect the file path in aufs to be
-+      printed.
-+      To address this issue, aufs provides a patch which introduces a
-+      new member called vm_prfile into struct vm_are_struct. The patch
-+      is meaningless without enabling this configuration since nobody
-+      sets the new vm_prfile member.
-+      If you don't apply the patch, then enabling this configuration
-+      will cause a compile error.
-+      This approach is fragile since if someone else make some changes
-+      around vm_file, then vm_prfile may not work anymore. As a
-+      workaround such case, aufs provides this configuration. If you
-+      disable it, then lsof(1) may produce incorrect result but the
-+      problem will be gone even if the aufs patch is applied (I hope).
-+
 +config AUFS_SP_IATTR
 +      bool "Respect the attributes (mtime/ctime mainly) of special files"
 +      help
@@ -19215,10 +19795,10 @@ diff -urN /usr/share/empty/fs/aufs/Kconfig linux/fs/aufs/Kconfig
 +endif
 diff -urN /usr/share/empty/fs/aufs/loop.c linux/fs/aufs/loop.c
 --- /usr/share/empty/fs/aufs/loop.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/loop.c       2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,135 @@
++++ linux/fs/aufs/loop.c       2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,145 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -19231,31 +19811,40 @@ diff -urN /usr/share/empty/fs/aufs/loop.c linux/fs/aufs/loop.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
 + * support for loopback block device as a branch
 + */
 +
-+#include <linux/loop.h>
 +#include "aufs.h"
 +
++/* added into drivers/block/loop.c */
++static struct file *(*backing_file_func)(struct super_block *sb);
++
 +/*
 + * test if two lower dentries have overlapping branches.
 + */
 +int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_adding)
 +{
 +      struct super_block *h_sb;
-+      struct loop_device *l;
++      struct file *backing_file;
++
++      if (unlikely(!backing_file_func)) {
++              /* don't load "loop" module here */
++              backing_file_func = symbol_get(loop_backing_file);
++              if (unlikely(!backing_file_func))
++                      /* "loop" module is not loaded */
++                      return 0;
++      }
 +
 +      h_sb = h_adding->d_sb;
-+      if (MAJOR(h_sb->s_dev) != LOOP_MAJOR)
++      backing_file = backing_file_func(h_sb);
++      if (!backing_file)
 +              return 0;
 +
-+      l = h_sb->s_bdev->bd_disk->private_data;
-+      h_adding = l->lo_backing_file->f_dentry;
++      h_adding = backing_file->f_dentry;
 +      /*
 +       * h_adding can be local NFS.
 +       * in this case aufs cannot detect the loop.
@@ -19350,14 +19939,15 @@ diff -urN /usr/share/empty/fs/aufs/loop.c linux/fs/aufs/loop.c
 +
 +void au_loopback_fin(void)
 +{
++      symbol_put(loop_backing_file);
 +      kfree(au_warn_loopback_array);
 +}
 diff -urN /usr/share/empty/fs/aufs/loop.h linux/fs/aufs/loop.h
 --- /usr/share/empty/fs/aufs/loop.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/loop.h       2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,50 @@
++++ linux/fs/aufs/loop.h       2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,52 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -19370,8 +19960,7 @@ diff -urN /usr/share/empty/fs/aufs/loop.h linux/fs/aufs/loop.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -19387,6 +19976,9 @@ diff -urN /usr/share/empty/fs/aufs/loop.h linux/fs/aufs/loop.h
 +struct super_block;
 +
 +#ifdef CONFIG_AUFS_BDEV_LOOP
++/* drivers/block/loop.c */
++struct file *loop_backing_file(struct super_block *sb);
++
 +/* loop.c */
 +int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_adding);
 +int au_test_loopback_kthread(void);
@@ -19408,7 +20000,7 @@ diff -urN /usr/share/empty/fs/aufs/loop.h linux/fs/aufs/loop.h
 +#endif /* __AUFS_LOOP_H__ */
 diff -urN /usr/share/empty/fs/aufs/magic.mk linux/fs/aufs/magic.mk
 --- /usr/share/empty/fs/aufs/magic.mk  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/magic.mk     2013-07-06 13:20:47.750198454 +0200
++++ linux/fs/aufs/magic.mk     2012-10-05 20:40:23.980965955 +0200
 @@ -0,0 +1,54 @@
 +
 +# defined in ${srctree}/fs/fuse/inode.c
@@ -19466,7 +20058,7 @@ diff -urN /usr/share/empty/fs/aufs/magic.mk linux/fs/aufs/magic.mk
 +endif
 diff -urN /usr/share/empty/fs/aufs/Makefile linux/fs/aufs/Makefile
 --- /usr/share/empty/fs/aufs/Makefile  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/Makefile     2013-07-06 13:20:47.736864659 +0200
++++ linux/fs/aufs/Makefile     2014-04-24 22:11:10.845269011 +0200
 @@ -0,0 +1,42 @@
 +
 +include ${src}/magic.mk
@@ -19480,9 +20072,9 @@ diff -urN /usr/share/empty/fs/aufs/Makefile linux/fs/aufs/Makefile
 +ccflags-y += -DDEBUG
 +# sparse requires the full pathname
 +ifdef M
-+ccflags-y += -include ${M}/../../include/linux/aufs_type.h
++ccflags-y += -include ${M}/../../include/uapi/linux/aufs_type.h
 +else
-+ccflags-y += -include ${srctree}/include/linux/aufs_type.h
++ccflags-y += -include ${srctree}/include/uapi/linux/aufs_type.h
 +endif
 +
 +obj-$(CONFIG_AUFS_FS) += aufs.o
@@ -19494,7 +20086,7 @@ diff -urN /usr/share/empty/fs/aufs/Makefile linux/fs/aufs/Makefile
 +      finfo.o file.o f_op.o \
 +      dir.o vdir.o \
 +      iinfo.o inode.o i_op.o i_op_add.o i_op_del.o i_op_ren.o \
-+      ioctl.o
++      mvdown.o ioctl.o
 +
 +# all are boolean
 +aufs-$(CONFIG_PROC_FS) += procfs.o plink.o
@@ -19512,10 +20104,10 @@ diff -urN /usr/share/empty/fs/aufs/Makefile linux/fs/aufs/Makefile
 +aufs-$(CONFIG_AUFS_MAGIC_SYSRQ) += sysrq.o
 diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 --- /usr/share/empty/fs/aufs/module.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/module.c     2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,203 @@
++++ linux/fs/aufs/module.c     2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,202 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -19528,8 +20120,7 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -19719,10 +20310,10 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 +module_exit(aufs_exit);
 diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 --- /usr/share/empty/fs/aufs/module.h  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/module.h     2013-07-06 13:20:47.750198454 +0200
-@@ -0,0 +1,105 @@
++++ linux/fs/aufs/module.h     2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,104 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -19735,8 +20326,7 @@ diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -19826,12 +20416,12 @@ diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 +
 +#endif /* __KERNEL__ */
 +#endif /* __AUFS_MODULE_H__ */
-diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
---- /usr/share/empty/fs/aufs/opts.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/opts.c       2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,1697 @@
+diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
+--- /usr/share/empty/fs/aufs/mvdown.c  1970-01-01 01:00:00.000000000 +0100
++++ linux/fs/aufs/mvdown.c     2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,627 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2011-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -19844,40 +20434,670 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
-+ * mount options/flags
++ * move-down, opposite of copy-up
 + */
 +
-+#include <linux/namei.h>
-+#include <linux/types.h> /* a distribution requires */
-+#include <linux/parser.h>
 +#include "aufs.h"
 +
-+/* ---------------------------------------------------------------------- */
++struct au_mvd_args {
++      struct {
++              struct super_block *h_sb;
++              struct dentry *h_parent;
++              struct au_hinode *hdir;
++              struct inode *h_dir, *h_inode;
++      } info[AUFS_MVDOWN_NARRAY];
 +
-+enum {
-+      Opt_br,
-+      Opt_add, Opt_del, Opt_mod, Opt_reorder, Opt_append, Opt_prepend,
-+      Opt_idel, Opt_imod, Opt_ireorder,
-+      Opt_dirwh, Opt_rdcache, Opt_rdblk, Opt_rdhash, Opt_rendir,
-+      Opt_rdblk_def, Opt_rdhash_def,
-+      Opt_xino, Opt_zxino, Opt_noxino,
-+      Opt_trunc_xino, Opt_trunc_xino_v, Opt_notrunc_xino,
-+      Opt_trunc_xino_path, Opt_itrunc_xino,
-+      Opt_trunc_xib, Opt_notrunc_xib,
-+      Opt_shwh, Opt_noshwh,
-+      Opt_plink, Opt_noplink, Opt_list_plink,
-+      Opt_udba,
-+      Opt_dio, Opt_nodio,
-+      /* Opt_lock, Opt_unlock, */
-+      Opt_cmd, Opt_cmd_args,
-+      Opt_diropq_a, Opt_diropq_w,
-+      Opt_warn_perm, Opt_nowarn_perm,
-+      Opt_wbr_copyup, Opt_wbr_create,
++      struct aufs_mvdown mvdown;
++      struct dentry *dentry, *parent;
++      struct inode *inode, *dir;
++      struct super_block *sb;
++      aufs_bindex_t bopq, bwh, bfound;
++      unsigned char rename_lock;
++      struct au_pin pin;
++};
++
++#define mvd_errno             mvdown.au_errno
++#define mvd_bsrc              mvdown.a[AUFS_MVDOWN_UPPER].bindex
++#define mvd_src_brid          mvdown.a[AUFS_MVDOWN_UPPER].brid
++#define mvd_bdst              mvdown.a[AUFS_MVDOWN_LOWER].bindex
++#define mvd_dst_brid          mvdown.a[AUFS_MVDOWN_LOWER].brid
++
++#define mvd_h_src_sb          info[AUFS_MVDOWN_UPPER].h_sb
++#define mvd_h_src_parent      info[AUFS_MVDOWN_UPPER].h_parent
++#define mvd_hdir_src          info[AUFS_MVDOWN_UPPER].hdir
++#define mvd_h_src_dir         info[AUFS_MVDOWN_UPPER].h_dir
++#define mvd_h_src_inode               info[AUFS_MVDOWN_UPPER].h_inode
++
++#define mvd_h_dst_sb          info[AUFS_MVDOWN_LOWER].h_sb
++#define mvd_h_dst_parent      info[AUFS_MVDOWN_LOWER].h_parent
++#define mvd_hdir_dst          info[AUFS_MVDOWN_LOWER].hdir
++#define mvd_h_dst_dir         info[AUFS_MVDOWN_LOWER].h_dir
++#define mvd_h_dst_inode               info[AUFS_MVDOWN_LOWER].h_inode
++
++#define AU_MVD_PR(flag, ...) do {                     \
++              if (flag)                               \
++                      pr_err(__VA_ARGS__);            \
++      } while (0)
++
++/* make the parent dir on bdst */
++static int au_do_mkdir(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err;
++
++      err = 0;
++      a->mvd_hdir_src = au_hi(a->dir, a->mvd_bsrc);
++      a->mvd_hdir_dst = au_hi(a->dir, a->mvd_bdst);
++      a->mvd_h_src_parent = au_h_dptr(a->parent, a->mvd_bsrc);
++      a->mvd_h_dst_parent = NULL;
++      if (au_dbend(a->parent) >= a->mvd_bdst)
++              a->mvd_h_dst_parent = au_h_dptr(a->parent, a->mvd_bdst);
++      if (!a->mvd_h_dst_parent) {
++              err = au_cpdown_dirs(a->dentry, a->mvd_bdst);
++              if (unlikely(err)) {
++                      AU_MVD_PR(dmsg, "cpdown_dirs failed\n");
++                      goto out;
++              }
++              a->mvd_h_dst_parent = au_h_dptr(a->parent, a->mvd_bdst);
++      }
++
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++/* lock them all */
++static int au_do_lock(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err;
++      struct dentry *h_trap;
++
++      a->mvd_h_src_sb = au_sbr_sb(a->sb, a->mvd_bsrc);
++      a->mvd_h_dst_sb = au_sbr_sb(a->sb, a->mvd_bdst);
++      if (a->mvd_h_src_sb != a->mvd_h_dst_sb) {
++              a->rename_lock = 0;
++              err = au_pin(&a->pin, a->dentry, a->mvd_bdst,
++                           au_opt_udba(a->sb),
++                           AuPin_MNT_WRITE | AuPin_DI_LOCKED);
++              if (!err) {
++                      a->mvd_h_src_dir = a->mvd_h_src_parent->d_inode;
++                      mutex_lock_nested(&a->mvd_h_src_dir->i_mutex,
++                                        AuLsc_I_PARENT3);
++              } else
++                      AU_MVD_PR(dmsg, "pin failed\n");
++              goto out;
++      }
++
++      err = 0;
++      a->rename_lock = 1;
++      h_trap = vfsub_lock_rename(a->mvd_h_src_parent, a->mvd_hdir_src,
++                                 a->mvd_h_dst_parent, a->mvd_hdir_dst);
++      if (h_trap) {
++              err = (h_trap != a->mvd_h_src_parent);
++              if (err)
++                      err = (h_trap != a->mvd_h_dst_parent);
++      }
++      BUG_ON(err); /* it should never happen */
++
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++static void au_do_unlock(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      if (!a->rename_lock) {
++              mutex_unlock(&a->mvd_h_src_dir->i_mutex);
++              au_unpin(&a->pin);
++      } else
++              vfsub_unlock_rename(a->mvd_h_src_parent, a->mvd_hdir_src,
++                                  a->mvd_h_dst_parent, a->mvd_hdir_dst);
++}
++
++/* copy-down the file */
++static int au_do_cpdown(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err;
++      struct au_cp_generic cpg = {
++              .dentry = a->dentry,
++              .bdst   = a->mvd_bdst,
++              .bsrc   = a->mvd_bsrc,
++              .len    = -1,
++              .pin    = &a->pin,
++              .flags  = AuCpup_DTIME | AuCpup_HOPEN
++      };
++
++      AuDbg("b%d, b%d\n", cpg.bsrc, cpg.bdst);
++      if (a->mvdown.flags & AUFS_MVDOWN_OWLOWER)
++              au_fset_cpup(cpg.flags, OVERWRITE);
++      if (a->mvdown.flags & AUFS_MVDOWN_ROLOWER)
++              au_fset_cpup(cpg.flags, RWDST);
++      err = au_sio_cpdown_simple(&cpg);
++      if (unlikely(err))
++              AU_MVD_PR(dmsg, "cpdown failed\n");
++
++      AuTraceErr(err);
++      return err;
++}
++
++/*
++ * unlink the whiteout on bdst if exist which may be created by UDBA while we
++ * were sleeping
++ */
++static int au_do_unlink_wh(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err;
++      struct path h_path;
++      struct au_branch *br;
++      struct inode *delegated;
++
++      br = au_sbr(a->sb, a->mvd_bdst);
++      h_path.dentry = au_wh_lkup(a->mvd_h_dst_parent, &a->dentry->d_name, br);
++      err = PTR_ERR(h_path.dentry);
++      if (IS_ERR(h_path.dentry)) {
++              AU_MVD_PR(dmsg, "wh_lkup failed\n");
++              goto out;
++      }
++
++      err = 0;
++      if (h_path.dentry->d_inode) {
++              h_path.mnt = au_br_mnt(br);
++              delegated = NULL;
++              err = vfsub_unlink(a->mvd_h_dst_parent->d_inode, &h_path,
++                                 &delegated, /*force*/0);
++              if (unlikely(err == -EWOULDBLOCK)) {
++                      pr_warn("cannot retry for NFSv4 delegation"
++                              " for an internal unlink\n");
++                      iput(delegated);
++              }
++              if (unlikely(err))
++                      AU_MVD_PR(dmsg, "wh_unlink failed\n");
++      }
++      dput(h_path.dentry);
++
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++/*
++ * unlink the topmost h_dentry
++ * Note: the target file MAY be modified by UDBA between this mutex_unlock() and
++ *    mutex_lock() in vfs_unlink(). in this case, such changes may be lost.
++ */
++static int au_do_unlink(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err;
++      struct path h_path;
++      struct inode *delegated;
++
++      h_path.mnt = au_sbr_mnt(a->sb, a->mvd_bsrc);
++      h_path.dentry = au_h_dptr(a->dentry, a->mvd_bsrc);
++      delegated = NULL;
++      err = vfsub_unlink(a->mvd_h_src_dir, &h_path, &delegated, /*force*/0);
++      if (unlikely(err == -EWOULDBLOCK)) {
++              pr_warn("cannot retry for NFSv4 delegation"
++                      " for an internal unlink\n");
++              iput(delegated);
++      }
++      if (unlikely(err))
++              AU_MVD_PR(dmsg, "unlink failed\n");
++
++      AuTraceErr(err);
++      return err;
++}
++
++/*
++ * copy-down the file and unlink the bsrc file.
++ * - unlink the bdst whout if exist
++ * - copy-down the file (with whtmp name and rename)
++ * - unlink the bsrc file
++ */
++static int au_do_mvdown(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err;
++
++      err = au_do_mkdir(dmsg, a);
++      if (!err)
++              err = au_do_lock(dmsg, a);
++      if (unlikely(err))
++              goto out;
++
++      /*
++       * do not revert the activities we made on bdst since they should be
++       * harmless in aufs.
++       */
++
++      err = au_do_cpdown(dmsg, a);
++      if (!err)
++              err = au_do_unlink_wh(dmsg, a);
++      if (!err && !(a->mvdown.flags & AUFS_MVDOWN_KUPPER))
++              err = au_do_unlink(dmsg, a);
++      if (unlikely(err))
++              goto out_unlock;
++
++      /* maintain internal array */
++      if (!(a->mvdown.flags & AUFS_MVDOWN_KUPPER)) {
++              au_set_h_dptr(a->dentry, a->mvd_bsrc, NULL);
++              au_set_dbstart(a->dentry, a->mvd_bdst);
++              au_set_h_iptr(a->inode, a->mvd_bsrc, NULL, /*flags*/0);
++              au_set_ibstart(a->inode, a->mvd_bdst);
++      }
++      if (au_dbend(a->dentry) < a->mvd_bdst)
++              au_set_dbend(a->dentry, a->mvd_bdst);
++      if (au_ibend(a->inode) < a->mvd_bdst)
++              au_set_ibend(a->inode, a->mvd_bdst);
++
++out_unlock:
++      au_do_unlock(dmsg, a);
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int find_lower_writable(struct au_mvd_args *a)
++{
++      struct super_block *sb;
++      aufs_bindex_t bindex, bend;
++      struct au_branch *br;
++
++      sb = a->sb;
++      bindex = a->mvd_bsrc;
++      bend = au_sbend(sb);
++      if (!(a->mvdown.flags & AUFS_MVDOWN_ROLOWER)) {
++              for (bindex++; bindex <= bend; bindex++) {
++                      br = au_sbr(sb, bindex);
++                      if (!au_br_rdonly(br))
++                              return bindex;
++              }
++      } else {
++              for (bindex++; bindex <= bend; bindex++) {
++                      br = au_sbr(sb, bindex);
++                      if (!(au_br_sb(br)->s_flags & MS_RDONLY)) {
++                              if (au_br_rdonly(br))
++                                      a->mvdown.flags
++                                              |= AUFS_MVDOWN_ROLOWER_R;
++                              return bindex;
++                      }
++              }
++      }
++
++      return -1;
++}
++
++/* make sure the file is idle */
++static int au_mvd_args_busy(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err, plinked;
++
++      err = 0;
++      plinked = !!au_opt_test(au_mntflags(a->sb), PLINK);
++      if (au_dbstart(a->dentry) == a->mvd_bsrc
++          && d_count(a->dentry) == 1
++          && atomic_read(&a->inode->i_count) == 1
++          /* && a->mvd_h_src_inode->i_nlink == 1 */
++          && (!plinked || !au_plink_test(a->inode))
++          && a->inode->i_nlink == 1)
++              goto out;
++
++      err = -EBUSY;
++      AU_MVD_PR(dmsg,
++                "b%d, d{b%d, c%u?}, i{c%d?, l%u}, hi{l%u}, p{%d, %d}\n",
++                a->mvd_bsrc, au_dbstart(a->dentry), d_count(a->dentry),
++                atomic_read(&a->inode->i_count), a->inode->i_nlink,
++                a->mvd_h_src_inode->i_nlink,
++                plinked, plinked ? au_plink_test(a->inode) : 0);
++
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++/* make sure the parent dir is fine */
++static int au_mvd_args_parent(const unsigned char dmsg,
++                            struct au_mvd_args *a)
++{
++      int err;
++      aufs_bindex_t bindex;
++
++      err = 0;
++      if (unlikely(au_alive_dir(a->parent))) {
++              err = -ENOENT;
++              AU_MVD_PR(dmsg, "parent dir is dead\n");
++              goto out;
++      }
++
++      a->bopq = au_dbdiropq(a->parent);
++      bindex = au_wbr_nonopq(a->dentry, a->mvd_bdst);
++      AuDbg("b%d\n", bindex);
++      if (unlikely((bindex >= 0 && bindex < a->mvd_bdst)
++                   || (a->bopq != -1 && a->bopq < a->mvd_bdst))) {
++              err = -EINVAL;
++              a->mvd_errno = EAU_MVDOWN_OPAQUE;
++              AU_MVD_PR(dmsg, "ancestor is opaque b%d, b%d\n",
++                        a->bopq, a->mvd_bdst);
++      }
++
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++static int au_mvd_args_intermediate(const unsigned char dmsg,
++                                  struct au_mvd_args *a)
++{
++      int err;
++      struct au_dinfo *dinfo, *tmp;
++
++      /* lookup the next lower positive entry */
++      err = -ENOMEM;
++      tmp = au_di_alloc(a->sb, AuLsc_DI_TMP);
++      if (unlikely(!tmp))
++              goto out;
++
++      a->bfound = -1;
++      a->bwh = -1;
++      dinfo = au_di(a->dentry);
++      au_di_cp(tmp, dinfo);
++      au_di_swap(tmp, dinfo);
++
++      /* returns the number of positive dentries */
++      err = au_lkup_dentry(a->dentry, a->mvd_bsrc + 1, /*type*/0);
++      if (!err)
++              a->bwh = au_dbwh(a->dentry);
++      else if (err > 0)
++              a->bfound = au_dbstart(a->dentry);
++
++      au_di_swap(tmp, dinfo);
++      au_rw_write_unlock(&tmp->di_rwsem);
++      au_di_free(tmp);
++      if (unlikely(err < 0))
++              AU_MVD_PR(dmsg, "failed look-up lower\n");
++
++      /*
++       * here, we have these cases.
++       * bfound == -1
++       *      no positive dentry under bsrc. there are more sub-cases.
++       *      bwh < 0
++       *              there no whiteout, we can safely move-down.
++       *      bwh <= bsrc
++       *              impossible
++       *      bsrc < bwh && bwh < bdst
++       *              there is a whiteout on RO branch. cannot proceed.
++       *      bwh == bdst
++       *              there is a whiteout on the RW target branch. it should
++       *              be removed.
++       *      bdst < bwh
++       *              there is a whiteout somewhere unrelated branch.
++       * -1 < bfound && bfound <= bsrc
++       *      impossible.
++       * bfound < bdst
++       *      found, but it is on RO branch between bsrc and bdst. cannot
++       *      proceed.
++       * bfound == bdst
++       *      found, replace it if AUFS_MVDOWN_FORCE is set. otherwise return
++       *      error.
++       * bdst < bfound
++       *      found, after we create the file on bdst, it will be hidden.
++       */
++
++      AuDebugOn(a->bfound == -1
++                && a->bwh != -1
++                && a->bwh <= a->mvd_bsrc);
++      AuDebugOn(-1 < a->bfound
++                && a->bfound <= a->mvd_bsrc);
++
++      err = -EINVAL;
++      if (a->bfound == -1
++          && a->mvd_bsrc < a->bwh
++          && a->bwh != -1
++          && a->bwh < a->mvd_bdst) {
++              a->mvd_errno = EAU_MVDOWN_WHITEOUT;
++              AU_MVD_PR(dmsg, "bsrc %d, bdst %d, bfound %d, bwh %d\n",
++                        a->mvd_bsrc, a->mvd_bdst, a->bfound, a->bwh);
++              goto out;
++      } else if (a->bfound != -1 && a->bfound < a->mvd_bdst) {
++              a->mvd_errno = EAU_MVDOWN_UPPER;
++              AU_MVD_PR(dmsg, "bdst %d, bfound %d\n",
++                        a->mvd_bdst, a->bfound);
++              goto out;
++      }
++
++      err = 0; /* success */
++
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++static int au_mvd_args_exist(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err;
++
++      err = 0;
++      if (!(a->mvdown.flags & AUFS_MVDOWN_OWLOWER)
++          && a->bfound == a->mvd_bdst)
++              err = -EEXIST;
++      AuTraceErr(err);
++      return err;
++}
++
++static int au_mvd_args(const unsigned char dmsg, struct au_mvd_args *a)
++{
++      int err;
++      struct au_branch *br;
++
++      err = -EISDIR;
++      if (unlikely(S_ISDIR(a->inode->i_mode)))
++              goto out;
++
++      err = -EINVAL;
++      if (!(a->mvdown.flags & AUFS_MVDOWN_BRID_UPPER))
++              a->mvd_bsrc = au_ibstart(a->inode);
++      else {
++              a->mvd_bsrc = au_br_index(a->sb, a->mvd_src_brid);
++              if (unlikely(a->mvd_bsrc < 0
++                           || (a->mvd_bsrc < au_dbstart(a->dentry)
++                               || au_dbend(a->dentry) < a->mvd_bsrc
++                               || !au_h_dptr(a->dentry, a->mvd_bsrc))
++                           || (a->mvd_bsrc < au_ibstart(a->inode)
++                               || au_ibend(a->inode) < a->mvd_bsrc
++                               || !au_h_iptr(a->inode, a->mvd_bsrc)))) {
++                      a->mvd_errno = EAU_MVDOWN_NOUPPER;
++                      AU_MVD_PR(dmsg, "no upper\n");
++                      goto out;
++              }
++      }
++      if (unlikely(a->mvd_bsrc == au_sbend(a->sb))) {
++              a->mvd_errno = EAU_MVDOWN_BOTTOM;
++              AU_MVD_PR(dmsg, "on the bottom\n");
++              goto out;
++      }
++      a->mvd_h_src_inode = au_h_iptr(a->inode, a->mvd_bsrc);
++      br = au_sbr(a->sb, a->mvd_bsrc);
++      err = au_br_rdonly(br);
++      if (!(a->mvdown.flags & AUFS_MVDOWN_ROUPPER)) {
++              if (unlikely(err))
++                      goto out;
++      } else if (!(vfsub_native_ro(a->mvd_h_src_inode)
++                   || IS_APPEND(a->mvd_h_src_inode))) {
++              if (err)
++                      a->mvdown.flags |= AUFS_MVDOWN_ROUPPER_R;
++              /* go on */
++      } else
++              goto out;
++
++      err = -EINVAL;
++      if (!(a->mvdown.flags & AUFS_MVDOWN_BRID_LOWER)) {
++              a->mvd_bdst = find_lower_writable(a);
++              if (unlikely(a->mvd_bdst < 0)) {
++                      a->mvd_errno = EAU_MVDOWN_BOTTOM;
++                      AU_MVD_PR(dmsg, "no writable lower branch\n");
++                      goto out;
++              }
++      } else {
++              a->mvd_bdst = au_br_index(a->sb, a->mvd_dst_brid);
++              if (unlikely(a->mvd_bdst < 0
++                           || au_sbend(a->sb) < a->mvd_bdst)) {
++                      a->mvd_errno = EAU_MVDOWN_NOLOWERBR;
++                      AU_MVD_PR(dmsg, "no lower brid\n");
++                      goto out;
++              }
++      }
++
++      err = au_mvd_args_busy(dmsg, a);
++      if (!err)
++              err = au_mvd_args_parent(dmsg, a);
++      if (!err)
++              err = au_mvd_args_intermediate(dmsg, a);
++      if (!err)
++              err = au_mvd_args_exist(dmsg, a);
++      if (!err)
++              AuDbg("b%d, b%d\n", a->mvd_bsrc, a->mvd_bdst);
++
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++int au_mvdown(struct dentry *dentry, struct aufs_mvdown __user *uarg)
++{
++      int err, e;
++      unsigned char dmsg;
++      struct au_mvd_args *args;
++
++      err = -EPERM;
++      if (unlikely(!capable(CAP_SYS_ADMIN)))
++              goto out;
++
++      WARN_ONCE(1, "move-down is still testing...\n");
++
++      err = -ENOMEM;
++      args = kmalloc(sizeof(*args), GFP_NOFS);
++      if (unlikely(!args))
++              goto out;
++
++      err = copy_from_user(&args->mvdown, uarg, sizeof(args->mvdown));
++      if (!err)
++              err = !access_ok(VERIFY_WRITE, uarg, sizeof(*uarg));
++      if (unlikely(err)) {
++              err = -EFAULT;
++              AuTraceErr(err);
++              goto out_free;
++      }
++      AuDbg("flags 0x%x\n", args->mvdown.flags);
++      args->mvdown.flags &= ~(AUFS_MVDOWN_ROLOWER_R | AUFS_MVDOWN_ROUPPER_R);
++      args->mvdown.au_errno = 0;
++      args->dentry = dentry;
++      args->inode = dentry->d_inode;
++      args->sb = dentry->d_sb;
++
++      err = -ENOENT;
++      dmsg = !!(args->mvdown.flags & AUFS_MVDOWN_DMSG);
++      args->parent = dget_parent(dentry);
++      args->dir = args->parent->d_inode;
++      mutex_lock_nested(&args->dir->i_mutex, I_MUTEX_PARENT);
++      dput(args->parent);
++      if (unlikely(args->parent != dentry->d_parent)) {
++              AU_MVD_PR(dmsg, "parent dir is moved\n");
++              goto out_dir;
++      }
++
++      mutex_lock_nested(&args->inode->i_mutex, I_MUTEX_CHILD);
++      err = aufs_read_lock(dentry, AuLock_DW | AuLock_FLUSH);
++      if (unlikely(err))
++              goto out_inode;
++
++      di_write_lock_parent(args->parent);
++      err = au_mvd_args(dmsg, args);
++      if (unlikely(err))
++              goto out_parent;
++
++      AuDbgDentry(dentry);
++      AuDbgInode(args->inode);
++      err = au_do_mvdown(dmsg, args);
++      if (unlikely(err))
++              goto out_parent;
++      AuDbgDentry(dentry);
++      AuDbgInode(args->inode);
++
++      au_cpup_attr_timesizes(args->dir);
++      au_cpup_attr_timesizes(args->inode);
++      au_cpup_igen(args->inode, au_h_iptr(args->inode, args->mvd_bdst));
++      /* au_digen_dec(dentry); */
++
++out_parent:
++      di_write_unlock(args->parent);
++      aufs_read_unlock(dentry, AuLock_DW);
++out_inode:
++      mutex_unlock(&args->inode->i_mutex);
++out_dir:
++      mutex_unlock(&args->dir->i_mutex);
++out_free:
++      e = copy_to_user(uarg, &args->mvdown, sizeof(args->mvdown));
++      if (unlikely(e))
++              err = -EFAULT;
++      kfree(args);
++out:
++      AuTraceErr(err);
++      return err;
++}
+diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
+--- /usr/share/empty/fs/aufs/opts.c    1970-01-01 01:00:00.000000000 +0100
++++ linux/fs/aufs/opts.c       2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,1701 @@
++/*
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ *
++ * This program, aufs 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, see <http://www.gnu.org/licenses/>.
++ */
++
++/*
++ * mount options/flags
++ */
++
++#include <linux/namei.h>
++#include <linux/types.h> /* a distribution requires */
++#include <linux/parser.h>
++#include "aufs.h"
++
++/* ---------------------------------------------------------------------- */
++
++enum {
++      Opt_br,
++      Opt_add, Opt_del, Opt_mod, Opt_reorder, Opt_append, Opt_prepend,
++      Opt_idel, Opt_imod, Opt_ireorder,
++      Opt_dirwh, Opt_rdcache, Opt_rdblk, Opt_rdhash, Opt_rendir,
++      Opt_rdblk_def, Opt_rdhash_def,
++      Opt_xino, Opt_zxino, Opt_noxino,
++      Opt_trunc_xino, Opt_trunc_xino_v, Opt_notrunc_xino,
++      Opt_trunc_xino_path, Opt_itrunc_xino,
++      Opt_trunc_xib, Opt_notrunc_xib,
++      Opt_shwh, Opt_noshwh,
++      Opt_plink, Opt_noplink, Opt_list_plink,
++      Opt_udba,
++      Opt_dio, Opt_nodio,
++      /* Opt_lock, Opt_unlock, */
++      Opt_cmd, Opt_cmd_args,
++      Opt_diropq_a, Opt_diropq_w,
++      Opt_warn_perm, Opt_nowarn_perm,
++      Opt_wbr_copyup, Opt_wbr_create,
 +      Opt_refrof, Opt_norefrof,
 +      Opt_verbose, Opt_noverbose,
 +      Opt_sum, Opt_nosum, Opt_wsum,
@@ -20196,6 +21416,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      {AuWbrCreate_MFSRRV, "mfsrr:%d:%d"},
 +      {AuWbrCreate_PMFS, "pmfs"},
 +      {AuWbrCreate_PMFSV, "pmfs:%d"},
++      {AuWbrCreate_PMFSRR, "pmfsrr:%d"},
++      {AuWbrCreate_PMFSRRV, "pmfsrr:%d:%d"},
 +
 +      {-1, NULL}
 +};
@@ -20265,6 +21487,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      create->wbr_create = err;
 +      switch (err) {
 +      case AuWbrCreate_MFSRRV:
++      case AuWbrCreate_PMFSRRV:
 +              e = au_wbr_mfs_wmark(&args[0], str, create);
 +              if (!e)
 +                      e = au_wbr_mfs_sec(&args[1], str, create);
@@ -20272,6 +21495,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +                      err = e;
 +              break;
 +      case AuWbrCreate_MFSRR:
++      case AuWbrCreate_PMFSRR:
 +              e = au_wbr_mfs_wmark(&args[0], str, create);
 +              if (unlikely(e)) {
 +                      err = e;
@@ -20391,9 +21615,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +                      break;
 +              case Opt_xino:
 +                      u.xino = &opt->xino;
-+                      AuDbg("xino {%s %.*s}\n",
-+                                u.xino->path,
-+                                AuDLNPair(u.xino->file->f_dentry));
++                      AuDbg("xino {%s %pD}\n", u.xino->path, u.xino->file);
 +                      break;
 +              case Opt_trunc_xino:
 +                      AuLabel(trunc_xino);
@@ -20488,6 +21710,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +                                        u.create->mfsrr_watermark);
 +                              break;
 +                      case AuWbrCreate_MFSRRV:
++                      case AuWbrCreate_PMFSRRV:
 +                              AuDbg("%llu watermark, %d sec\n",
 +                                        u.create->mfsrr_watermark,
 +                                        u.create->mfs_second);
@@ -21027,6 +22250,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      switch (create->wbr_create) {
 +      case AuWbrCreate_MFSRRV:
 +      case AuWbrCreate_MFSRR:
++      case AuWbrCreate_PMFSRR:
++      case AuWbrCreate_PMFSRRV:
 +              sbinfo->si_wbr_mfs.mfsrr_watermark = create->mfsrr_watermark;
 +              /*FALLTHROUGH*/
 +      case AuWbrCreate_MFS:
@@ -21212,7 +22437,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              goto add;
 +      case Opt_prepend:
 +              opt->add.bindex = 0;
-+      add:
++      add: /* indented label */
 +      case Opt_add:
 +              err = au_br_add(sb, &opt->add,
 +                              au_ftest_opts(opts->flags, REMOUNT));
@@ -21529,10 +22754,10 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +}
 diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 --- /usr/share/empty/fs/aufs/opts.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/opts.h       2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,209 @@
++++ linux/fs/aufs/opts.h       2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,210 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -21545,8 +22770,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -21635,6 +22859,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 +      AuWbrCreate_MFSRRV,     /* mfs then rr with seconds */
 +      AuWbrCreate_PMFS,       /* parent and mfs */
 +      AuWbrCreate_PMFSV,      /* parent and mfs with seconds */
++      AuWbrCreate_PMFSRR,     /* parent, mfs and round-robin */
++      AuWbrCreate_PMFSRRV,    /* plus seconds */
 +
 +      AuWbrCreate_Def = AuWbrCreate_TDP
 +};
@@ -21742,10 +22968,10 @@ diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 +#endif /* __AUFS_OPTS_H__ */
 diff -urN /usr/share/empty/fs/aufs/plink.c linux/fs/aufs/plink.c
 --- /usr/share/empty/fs/aufs/plink.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/plink.c      2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,520 @@
++++ linux/fs/aufs/plink.c      2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,532 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -21758,8 +22984,7 @@ diff -urN /usr/share/empty/fs/aufs/plink.c linux/fs/aufs/plink.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -22004,7 +23229,7 @@ diff -urN /usr/share/empty/fs/aufs/plink.c linux/fs/aufs/plink.c
 +      struct path h_path = {
 +              .mnt = au_br_mnt(br)
 +      };
-+      struct inode *h_dir;
++      struct inode *h_dir, *delegated;
 +
 +      h_dir = h_parent->d_inode;
 +      mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_CHILD2);
@@ -22019,14 +23244,27 @@ diff -urN /usr/share/empty/fs/aufs/plink.c linux/fs/aufs/plink.c
 +      /* todo: is it really safe? */
 +      if (h_path.dentry->d_inode
 +          && h_path.dentry->d_inode != h_dentry->d_inode) {
-+              err = vfsub_unlink(h_dir, &h_path, /*force*/0);
++              delegated = NULL;
++              err = vfsub_unlink(h_dir, &h_path, &delegated, /*force*/0);
++              if (unlikely(err == -EWOULDBLOCK)) {
++                      pr_warn("cannot retry for NFSv4 delegation"
++                              " for an internal unlink\n");
++                      iput(delegated);
++              }
 +              dput(h_path.dentry);
 +              h_path.dentry = NULL;
 +              if (!err)
 +                      goto again;
 +      }
-+      if (!err && !h_path.dentry->d_inode)
-+              err = vfsub_link(h_dentry, h_dir, &h_path);
++      if (!err && !h_path.dentry->d_inode) {
++              delegated = NULL;
++              err = vfsub_link(h_dentry, h_dir, &h_path, &delegated);
++              if (unlikely(err == -EWOULDBLOCK)) {
++                      pr_warn("cannot retry for NFSv4 delegation"
++                              " for an internal link\n");
++                      iput(delegated);
++              }
++      }
 +      dput(h_path.dentry);
 +
 +out:
@@ -22266,10 +23504,10 @@ diff -urN /usr/share/empty/fs/aufs/plink.c linux/fs/aufs/plink.c
 +}
 diff -urN /usr/share/empty/fs/aufs/poll.c linux/fs/aufs/poll.c
 --- /usr/share/empty/fs/aufs/poll.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/poll.c       2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,56 @@
++++ linux/fs/aufs/poll.c       2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,55 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -22282,8 +23520,7 @@ diff -urN /usr/share/empty/fs/aufs/poll.c linux/fs/aufs/poll.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -22313,7 +23550,7 @@ diff -urN /usr/share/empty/fs/aufs/poll.c linux/fs/aufs/poll.c
 +      /* it is not an error if h_file has no operation */
 +      mask = DEFAULT_POLLMASK;
 +      h_file = au_hf_top(file);
-+      if (h_file->f_op && h_file->f_op->poll)
++      if (h_file->f_op->poll)
 +              mask = h_file->f_op->poll(h_file, wait);
 +
 +      di_read_unlock(dentry, AuLock_IR);
@@ -22326,10 +23563,10 @@ diff -urN /usr/share/empty/fs/aufs/poll.c linux/fs/aufs/poll.c
 +}
 diff -urN /usr/share/empty/fs/aufs/procfs.c linux/fs/aufs/procfs.c
 --- /usr/share/empty/fs/aufs/procfs.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/procfs.c     2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,170 @@
++++ linux/fs/aufs/procfs.c     2014-04-24 22:11:10.855269116 +0200
+@@ -0,0 +1,169 @@
 +/*
-+ * Copyright (C) 2010-2013 Junjiro R. Okajima
++ * Copyright (C) 2010-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -22342,8 +23579,7 @@ diff -urN /usr/share/empty/fs/aufs/procfs.c linux/fs/aufs/procfs.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -22500,10 +23736,10 @@ diff -urN /usr/share/empty/fs/aufs/procfs.c linux/fs/aufs/procfs.c
 +}
 diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 --- /usr/share/empty/fs/aufs/rdu.c     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/rdu.c        2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,384 @@
++++ linux/fs/aufs/rdu.c        2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,388 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -22516,8 +23752,7 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -22540,6 +23775,7 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +      do { (flags) &= ~AuRdu_##name; } while (0)
 +
 +struct au_rdu_arg {
++      struct dir_context              ctx;
 +      struct aufs_rdu                 *rdu;
 +      union au_rdu_ent_ul             ent;
 +      unsigned long                   end;
@@ -22548,11 +23784,11 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +      int                             err;
 +};
 +
-+static int au_rdu_fill(void *__arg, const char *name, int nlen,
++static int au_rdu_fill(struct dir_context *ctx, const char *name, int nlen,
 +                     loff_t offset, u64 h_ino, unsigned int d_type)
 +{
 +      int err, len;
-+      struct au_rdu_arg *arg = __arg;
++      struct au_rdu_arg *arg = container_of(ctx, struct au_rdu_arg, ctx);
 +      struct aufs_rdu *rdu = arg->rdu;
 +      struct au_rdu_ent ent;
 +
@@ -22610,7 +23846,7 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +              arg->err = 0;
 +              au_fclr_rdu(cookie->flags, CALLED);
 +              /* smp_mb(); */
-+              err = vfsub_readdir(h_file, au_rdu_fill, arg);
++              err = vfsub_iterate_dir(h_file, &arg->ctx);
 +              if (err >= 0)
 +                      err = arg->err;
 +      } while (!err
@@ -22627,7 +23863,11 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +{
 +      int err;
 +      aufs_bindex_t bend;
-+      struct au_rdu_arg arg;
++      struct au_rdu_arg arg = {
++              .ctx = {
++                      .actor = au_diractor(au_rdu_fill)
++              }
++      };
 +      struct dentry *dentry;
 +      struct inode *inode;
 +      struct file *h_file;
@@ -22648,7 +23888,7 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +      arg.end += rdu->sz;
 +
 +      err = -ENOTDIR;
-+      if (unlikely(!file->f_op || !file->f_op->readdir))
++      if (unlikely(!file->f_op->iterate))
 +              goto out;
 +
 +      err = security_file_permission(file, MAY_READ);
@@ -22888,10 +24128,10 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +#endif
 diff -urN /usr/share/empty/fs/aufs/rwsem.h linux/fs/aufs/rwsem.h
 --- /usr/share/empty/fs/aufs/rwsem.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/rwsem.h      2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,188 @@
++++ linux/fs/aufs/rwsem.h      2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,187 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -22904,8 +24144,7 @@ diff -urN /usr/share/empty/fs/aufs/rwsem.h linux/fs/aufs/rwsem.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -23080,10 +24319,10 @@ diff -urN /usr/share/empty/fs/aufs/rwsem.h linux/fs/aufs/rwsem.h
 +#endif /* __AUFS_RWSEM_H__ */
 diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 --- /usr/share/empty/fs/aufs/sbinfo.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sbinfo.c     2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,346 @@
++++ linux/fs/aufs/sbinfo.c     2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,351 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -23096,8 +24335,7 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -23175,6 +24413,7 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +      atomic_long_set(&sbinfo->si_nfiles, 0);
 +
 +      sbinfo->si_bend = -1;
++      sbinfo->si_last_br_id = AUFS_BRANCH_MAX / 2;
 +
 +      sbinfo->si_wbr_copyup = AuWbrCopyup_Def;
 +      sbinfo->si_wbr_create = AuWbrCreate_Def;
@@ -23183,6 +24422,9 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +
 +      sbinfo->si_mntflags = au_opts_plink(AuOpt_Def);
 +
++      sbinfo->si_xino_jiffy = jiffies;
++      sbinfo->si_xino_expire
++              = msecs_to_jiffies(AUFS_XINO_DEF_SEC * MSEC_PER_SEC);
 +      mutex_init(&sbinfo->si_xib_mtx);
 +      sbinfo->si_xino_brid = -1;
 +      /* leave si_xib_last_pindex and si_xib_next_bit */
@@ -23197,6 +24439,8 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +      init_waitqueue_head(&sbinfo->si_plink_wq);
 +      spin_lock_init(&sbinfo->si_plink_maint_lock);
 +
++      au_sphl_init(&sbinfo->si_files);
++
 +      /* leave other members for sysaufs and si_mnt. */
 +      sbinfo->si_sb = sb;
 +      sb->s_fs_info = sbinfo;
@@ -23430,10 +24674,10 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +}
 diff -urN /usr/share/empty/fs/aufs/spl.h linux/fs/aufs/spl.h
 --- /usr/share/empty/fs/aufs/spl.h     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/spl.h        2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,112 @@
++++ linux/fs/aufs/spl.h        2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,111 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -23446,8 +24690,7 @@ diff -urN /usr/share/empty/fs/aufs/spl.h linux/fs/aufs/spl.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -23546,10 +24789,10 @@ diff -urN /usr/share/empty/fs/aufs/spl.h linux/fs/aufs/spl.h
 +#endif /* __AUFS_SPL_H__ */
 diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 --- /usr/share/empty/fs/aufs/super.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/super.c      2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,992 @@
++++ linux/fs/aufs/super.c      2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,1001 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -23562,8 +24805,7 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -23681,14 +24923,14 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +
 +      AuRwMustAnyLock(&sbinfo->si_rwsem);
 +
-+      seq_printf(m, ",create=");
++      seq_puts(m, ",create=");
 +      pat = au_optstr_wbr_create(v);
 +      switch (v) {
 +      case AuWbrCreate_TDP:
 +      case AuWbrCreate_RR:
 +      case AuWbrCreate_MFS:
 +      case AuWbrCreate_PMFS:
-+              seq_printf(m, pat);
++              seq_puts(m, pat);
 +              break;
 +      case AuWbrCreate_MFSV:
 +              seq_printf(m, /*pat*/"mfs:%lu",
@@ -23710,6 +24952,16 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +                         jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire)
 +                         / MSEC_PER_SEC);
 +              break;
++      case AuWbrCreate_PMFSRR:
++              seq_printf(m, /*pat*/"pmfsrr:%llu",
++                         sbinfo->si_wbr_mfs.mfsrr_watermark);
++              break;
++      case AuWbrCreate_PMFSRRV:
++              seq_printf(m, /*pat*/"pmfsrr:%llu:%lu",
++                         sbinfo->si_wbr_mfs.mfsrr_watermark,
++                         jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire)
++                         / MSEC_PER_SEC);
++              break;
 +      }
 +}
 +
@@ -24528,7 +25780,7 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +              aufs_write_unlock(sb->s_root);
 +              au_nwt_flush(&sbinfo->si_nowait);
 +      }
-+      generic_shutdown_super(sb);
++      kill_anon_super(sb);
 +}
 +
 +struct file_system_type aufs_fs_type = {
@@ -24542,10 +25794,10 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +};
 diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 --- /usr/share/empty/fs/aufs/super.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/super.h      2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,555 @@
++++ linux/fs/aufs/super.h      2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,571 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -24558,8 +25810,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -24585,8 +25836,15 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      int (*copyup)(struct dentry *dentry);
 +};
 +
++#define AuWbr_DIR     1               /* target is a dir */
++#define AuWbr_PARENT  (1 << 1)        /* always require a parent */
++
++#define au_ftest_wbr(flags, name)     ((flags) & AuWbr_##name)
++#define au_fset_wbr(flags, name)      { (flags) |= AuWbr_##name; }
++#define au_fclr_wbr(flags, name)      { (flags) &= ~AuWbr_##name; }
++
 +struct au_wbr_create_operations {
-+      int (*create)(struct dentry *dentry, int isdir);
++      int (*create)(struct dentry *dentry, unsigned int flags);
 +      int (*init)(struct super_block *sb);
 +      int (*fin)(struct super_block *sb);
 +};
@@ -24634,7 +25892,8 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      } au_si_pid;
 +
 +      /*
-+       * dirty approach to protect sb->sb_inodes and ->s_files from remount.
++       * dirty approach to protect sb->sb_inodes and ->s_files (gone) from
++       * remount.
 +       */
 +      atomic_long_t           si_ninodes, si_nfiles;
 +
@@ -24676,6 +25935,8 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      unsigned long           si_xib_last_pindex;
 +      int                     si_xib_next_bit;
 +      aufs_bindex_t           si_xino_brid;
++      unsigned long           si_xino_jiffy;
++      unsigned long           si_xino_expire;
 +      /* reserved for future use */
 +      /* unsigned long long   si_xib_limit; */        /* Max xib file size */
 +
@@ -24710,6 +25971,9 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      spinlock_t              si_plink_maint_lock;
 +      pid_t                   si_plink_maint_pid;
 +
++      /* file list */
++      struct au_sphlhead      si_files;
++
 +      /*
 +       * sysfs and lifetime management.
 +       * this is not a small structure and it may be a waste of memory in case
@@ -24817,6 +26081,10 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +extern struct au_wbr_copyup_operations au_wbr_copyup_ops[];
 +extern struct au_wbr_create_operations au_wbr_create_ops[];
 +int au_cpdown_dirs(struct dentry *dentry, aufs_bindex_t bdst);
++int au_wbr_nonopq(struct dentry *dentry, aufs_bindex_t bindex);
++
++/* mvdown.c */
++int au_mvdown(struct dentry *dentry, struct aufs_mvdown __user *arg);
 +
 +/* ---------------------------------------------------------------------- */
 +
@@ -25101,10 +26369,10 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +#endif /* __AUFS_SUPER_H__ */
 diff -urN /usr/share/empty/fs/aufs/sysaufs.c linux/fs/aufs/sysaufs.c
 --- /usr/share/empty/fs/aufs/sysaufs.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sysaufs.c    2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,105 @@
++++ linux/fs/aufs/sysaufs.c    2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,104 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25117,8 +26385,7 @@ diff -urN /usr/share/empty/fs/aufs/sysaufs.c linux/fs/aufs/sysaufs.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -25210,10 +26477,10 @@ diff -urN /usr/share/empty/fs/aufs/sysaufs.c linux/fs/aufs/sysaufs.c
 +}
 diff -urN /usr/share/empty/fs/aufs/sysaufs.h linux/fs/aufs/sysaufs.h
 --- /usr/share/empty/fs/aufs/sysaufs.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sysaufs.h    2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,104 @@
++++ linux/fs/aufs/sysaufs.h    2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,103 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25226,8 +26493,7 @@ diff -urN /usr/share/empty/fs/aufs/sysaufs.h linux/fs/aufs/sysaufs.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -25318,10 +26584,10 @@ diff -urN /usr/share/empty/fs/aufs/sysaufs.h linux/fs/aufs/sysaufs.h
 +#endif /* __SYSAUFS_H__ */
 diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 --- /usr/share/empty/fs/aufs/sysfs.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sysfs.c      2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,257 @@
++++ linux/fs/aufs/sysfs.c      2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,296 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25334,8 +26600,7 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -25400,7 +26665,7 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 + * unlinked.
 + */
 +static int sysaufs_si_br(struct seq_file *seq, struct super_block *sb,
-+                       aufs_bindex_t bindex)
++                       aufs_bindex_t bindex, int idx)
 +{
 +      int err;
 +      struct path path;
@@ -25414,18 +26679,30 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +      root = sb->s_root;
 +      di_read_lock_parent(root, !AuLock_IR);
 +      br = au_sbr(sb, bindex);
-+      path.mnt = au_br_mnt(br);
-+      path.dentry = au_h_dptr(root, bindex);
-+      au_seq_path(seq, &path);
-+      di_read_unlock(root, !AuLock_IR);
-+      perm = au_optstr_br_perm(br->br_perm);
-+      if (perm) {
-+              err = seq_printf(seq, "=%s\n", perm);
-+              kfree(perm);
++
++      switch (idx) {
++      case AuBrSysfs_BR:
++              path.mnt = au_br_mnt(br);
++              path.dentry = au_h_dptr(root, bindex);
++              au_seq_path(seq, &path);
++              di_read_unlock(root, !AuLock_IR);
++              perm = au_optstr_br_perm(br->br_perm);
++              if (perm) {
++                      err = seq_printf(seq, "=%s\n", perm);
++                      kfree(perm);
++                      if (err == -1)
++                              err = -E2BIG;
++              } else
++                      err = -ENOMEM;
++              break;
++      case AuBrSysfs_BRID:
++              err = seq_printf(seq, "%d\n", br->br_id);
++              di_read_unlock(root, !AuLock_IR);
 +              if (err == -1)
 +                      err = -E2BIG;
-+      } else
-+              err = -ENOMEM;
++              break;
++      }
++
 +      return err;
 +}
 +
@@ -25447,13 +26724,15 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +      return seq;
 +}
 +
-+#define SysaufsBr_PREFIX "br"
++#define SysaufsBr_PREFIX      "br"
++#define SysaufsBrid_PREFIX    "brid"
 +
 +/* todo: file size may exceed PAGE_SIZE */
 +ssize_t sysaufs_si_show(struct kobject *kobj, struct attribute *attr,
 +                      char *buf)
 +{
 +      ssize_t err;
++      int idx;
 +      long l;
 +      aufs_bindex_t bend;
 +      struct au_sbinfo *sbinfo;
@@ -25495,19 +26774,25 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +              cattr++;
 +      }
 +
-+      bend = au_sbend(sb);
-+      if (!strncmp(name, SysaufsBr_PREFIX, sizeof(SysaufsBr_PREFIX) - 1)) {
++      if (!strncmp(name, SysaufsBrid_PREFIX,
++                   sizeof(SysaufsBrid_PREFIX) - 1)) {
++              idx = AuBrSysfs_BRID;
++              name += sizeof(SysaufsBrid_PREFIX) - 1;
++      } else if (!strncmp(name, SysaufsBr_PREFIX,
++                          sizeof(SysaufsBr_PREFIX) - 1)) {
++              idx = AuBrSysfs_BR;
 +              name += sizeof(SysaufsBr_PREFIX) - 1;
-+              err = kstrtol(name, 10, &l);
-+              if (!err) {
-+                      if (l <= bend)
-+                              err = sysaufs_si_br(seq, sb, (aufs_bindex_t)l);
-+                      else
-+                              err = -ENOENT;
-+              }
-+              goto out_seq;
++      } else
++                BUG();
++
++      err = kstrtol(name, 10, &l);
++      if (!err) {
++              bend = au_sbend(sb);
++              if (l <= bend)
++                      err = sysaufs_si_br(seq, sb, (aufs_bindex_t)l, idx);
++              else
++                      err = -ENOENT;
 +      }
-+      BUG();
 +
 +out_seq:
 +      if (!err) {
@@ -25527,17 +26812,26 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +
 +void sysaufs_br_init(struct au_branch *br)
 +{
-+      struct attribute *attr = &br->br_attr;
++      int i;
++      struct au_brsysfs *br_sysfs;
++      struct attribute *attr;
 +
-+      sysfs_attr_init(attr);
-+      attr->name = br->br_name;
-+      attr->mode = S_IRUGO;
++      br_sysfs = br->br_sysfs;
++      for (i = 0; i < ARRAY_SIZE(br->br_sysfs); i++) {
++              attr = &br_sysfs->attr;
++              sysfs_attr_init(attr);
++              attr->name = br_sysfs->name;
++              attr->mode = S_IRUGO;
++              br_sysfs++;
++      }
 +}
 +
 +void sysaufs_brs_del(struct super_block *sb, aufs_bindex_t bindex)
 +{
 +      struct au_branch *br;
 +      struct kobject *kobj;
++      struct au_brsysfs *br_sysfs;
++      int i;
 +      aufs_bindex_t bend;
 +
 +      dbgaufs_brs_del(sb, bindex);
@@ -25549,16 +26843,21 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +      bend = au_sbend(sb);
 +      for (; bindex <= bend; bindex++) {
 +              br = au_sbr(sb, bindex);
-+              sysfs_remove_file(kobj, &br->br_attr);
++              br_sysfs = br->br_sysfs;
++              for (i = 0; i < ARRAY_SIZE(br->br_sysfs); i++) {
++                      sysfs_remove_file(kobj, &br_sysfs->attr);
++                      br_sysfs++;
++              }
 +      }
 +}
 +
 +void sysaufs_brs_add(struct super_block *sb, aufs_bindex_t bindex)
 +{
-+      int err;
++      int err, i;
 +      aufs_bindex_t bend;
 +      struct kobject *kobj;
 +      struct au_branch *br;
++      struct au_brsysfs *br_sysfs;
 +
 +      dbgaufs_brs_add(sb, bindex);
 +
@@ -25569,20 +26868,26 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +      bend = au_sbend(sb);
 +      for (; bindex <= bend; bindex++) {
 +              br = au_sbr(sb, bindex);
-+              snprintf(br->br_name, sizeof(br->br_name), SysaufsBr_PREFIX
-+                       "%d", bindex);
-+              err = sysfs_create_file(kobj, &br->br_attr);
-+              if (unlikely(err))
-+                      pr_warn("failed %s under sysfs(%d)\n",
-+                              br->br_name, err);
++              br_sysfs = br->br_sysfs;
++              snprintf(br_sysfs[AuBrSysfs_BR].name, sizeof(br_sysfs->name),
++                       SysaufsBr_PREFIX "%d", bindex);
++              snprintf(br_sysfs[AuBrSysfs_BRID].name, sizeof(br_sysfs->name),
++                       SysaufsBrid_PREFIX "%d", bindex);
++              for (i = 0; i < ARRAY_SIZE(br->br_sysfs); i++) {
++                      err = sysfs_create_file(kobj, &br_sysfs->attr);
++                      if (unlikely(err))
++                              pr_warn("failed %s under sysfs(%d)\n",
++                                      br_sysfs->name, err);
++                      br_sysfs++;
++              }
 +      }
 +}
 diff -urN /usr/share/empty/fs/aufs/sysrq.c linux/fs/aufs/sysrq.c
 --- /usr/share/empty/fs/aufs/sysrq.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sysrq.c      2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,151 @@
++++ linux/fs/aufs/sysrq.c      2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,154 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25595,8 +26900,7 @@ diff -urN /usr/share/empty/fs/aufs/sysrq.c linux/fs/aufs/sysrq.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -25614,6 +26918,8 @@ diff -urN /usr/share/empty/fs/aufs/sysrq.c linux/fs/aufs/sysrq.c
 +      char *plevel;
 +      struct au_sbinfo *sbinfo;
 +      struct file *file;
++      struct au_sphlhead *files;
++      struct au_finfo *finfo;
 +
 +      plevel = au_plevel;
 +      au_plevel = KERN_WARNING;
@@ -25669,14 +26975,16 @@ diff -urN /usr/share/empty/fs/aufs/sysrq.c linux/fs/aufs/sysrq.c
 +      }
 +#endif
 +      pr("files\n");
-+      lg_global_lock(&files_lglock);
-+      do_file_list_for_each_entry(sb, file) {
++      files = &au_sbi(sb)->si_files;
++      spin_lock(&files->spin);
++      hlist_for_each_entry(finfo, &files->head, fi_hlist) {
 +              umode_t mode;
++              file = finfo->fi_file;
 +              mode = file_inode(file)->i_mode;
 +              if (!special_file(mode) || au_special_file(mode))
 +                      au_dpri_file(file);
-+      } while_file_list_for_each_entry;
-+      lg_global_unlock(&files_lglock);
++      }
++      spin_unlock(&files->spin);
 +      pr("done\n");
 +
 +#undef pr
@@ -25734,10 +27042,10 @@ diff -urN /usr/share/empty/fs/aufs/sysrq.c linux/fs/aufs/sysrq.c
 +}
 diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 --- /usr/share/empty/fs/aufs/vdir.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/vdir.c       2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,878 @@
++++ linux/fs/aufs/vdir.c       2014-04-24 22:11:10.858602483 +0200
+@@ -0,0 +1,887 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25750,8 +27058,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -26175,6 +27482,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +#endif
 +
 +struct fillvdir_arg {
++      struct dir_context      ctx;
 +      struct file             *file;
 +      struct au_vdir          *vdir;
 +      struct au_nhash         delist;
@@ -26184,11 +27492,11 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      int                     err;
 +};
 +
-+static int fillvdir(void *__arg, const char *__name, int nlen,
++static int fillvdir(struct dir_context *ctx, const char *__name, int nlen,
 +                  loff_t offset __maybe_unused, u64 h_ino,
 +                  unsigned int d_type)
 +{
-+      struct fillvdir_arg *arg = __arg;
++      struct fillvdir_arg *arg = container_of(ctx, struct fillvdir_arg, ctx);
 +      char *name = (void *)__name;
 +      struct super_block *sb;
 +      ino_t ino;
@@ -26336,10 +27644,15 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +                      arg->err = 0;
 +                      au_fclr_fillvdir(arg->flags, CALLED);
 +                      /* smp_mb(); */
-+                      err = vfsub_readdir(hf, fillvdir, arg);
++                      err = vfsub_iterate_dir(hf, &arg->ctx);
 +                      if (err >= 0)
 +                              err = arg->err;
 +              } while (!err && au_ftest_fillvdir(arg->flags, CALLED));
++
++              /*
++               * dir_relax() may be good for concurrency, but aufs should not
++               * use it since it will cause a lockdep problem.
++               */
 +      }
 +
 +      if (!err && shwh)
@@ -26358,7 +27671,11 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      int err;
 +      unsigned long expire;
 +      unsigned char do_read;
-+      struct fillvdir_arg arg;
++      struct fillvdir_arg arg = {
++              .ctx = {
++                      .actor = au_diractor(fillvdir)
++              }
++      };
 +      struct inode *inode;
 +      struct au_vdir *vdir, *allocated;
 +
@@ -26395,7 +27712,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      arg.vdir = vdir;
 +      err = au_do_read_vdir(&arg);
 +      if (!err) {
-+              /* file->f_pos = 0; */
++              /* file->f_pos = 0; */ /* todo: ctx->pos? */
 +              vdir->vd_version = inode->i_version;
 +              vdir->vd_last.ul = 0;
 +              vdir->vd_last.p.deblk = vdir->vd_deblk[0];
@@ -26468,6 +27785,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      struct inode *inode;
 +      struct au_vdir *vdir_cache, *allocated;
 +
++      /* test file->f_pos here instead of ctx->pos */
 +      err = read_vdir(file, !file->f_pos);
 +      if (unlikely(err))
 +              goto out;
@@ -26481,6 +27799,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +                      goto out;
 +              allocated = vdir_cache;
 +      } else if (!file->f_pos && vdir_cache->vd_version != file->f_version) {
++              /* test file->f_pos here instead of ctx->pos */
 +              err = reinit_vdir(vdir_cache);
 +              if (unlikely(err))
 +                      goto out;
@@ -26512,7 +27831,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +}
 +
 +/* returns true or false */
-+static int seek_vdir(struct file *file)
++static int seek_vdir(struct file *file, struct dir_context *ctx)
 +{
 +      int valid;
 +      unsigned int deblk_sz;
@@ -26525,17 +27844,17 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      vdir_cache = au_fvdir_cache(file);
 +      offset = calc_offset(vdir_cache);
 +      AuDbg("offset %lld\n", offset);
-+      if (file->f_pos == offset)
++      if (ctx->pos == offset)
 +              goto out;
 +
 +      vdir_cache->vd_last.ul = 0;
 +      vdir_cache->vd_last.p.deblk = vdir_cache->vd_deblk[0];
-+      if (!file->f_pos)
++      if (!ctx->pos)
 +              goto out;
 +
 +      valid = 0;
 +      deblk_sz = vdir_cache->vd_deblk_sz;
-+      ul = div64_u64(file->f_pos, deblk_sz);
++      ul = div64_u64(ctx->pos, deblk_sz);
 +      AuDbg("ul %lu\n", ul);
 +      if (ul >= vdir_cache->vd_nblk)
 +              goto out;
@@ -26546,7 +27865,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +              deblk_end.deblk = p.deblk + deblk_sz;
 +              offset = ul;
 +              offset *= deblk_sz;
-+              while (!is_deblk_end(&p, &deblk_end) && offset < file->f_pos) {
++              while (!is_deblk_end(&p, &deblk_end) && offset < ctx->pos) {
 +                      unsigned int l;
 +
 +                      l = calc_size(p.de->de_str.len);
@@ -26567,16 +27886,15 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      return valid;
 +}
 +
-+int au_vdir_fill_de(struct file *file, void *dirent, filldir_t filldir)
++int au_vdir_fill_de(struct file *file, struct dir_context *ctx)
 +{
-+      int err;
 +      unsigned int l, deblk_sz;
 +      union au_vdir_deblk_p deblk_end;
 +      struct au_vdir *vdir_cache;
 +      struct au_vdir_de *de;
 +
 +      vdir_cache = au_fvdir_cache(file);
-+      if (!seek_vdir(file))
++      if (!seek_vdir(file, ctx))
 +              return 0;
 +
 +      deblk_sz = vdir_cache->vd_deblk_sz;
@@ -26586,12 +27904,11 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +              while (!is_deblk_end(&vdir_cache->vd_last.p, &deblk_end)) {
 +                      de = vdir_cache->vd_last.p.de;
 +                      AuDbg("%.*s, off%lld, i%lu, dt%d\n",
-+                            de->de_str.len, de->de_str.name, file->f_pos,
++                            de->de_str.len, de->de_str.name, ctx->pos,
 +                            (unsigned long)de->de_ino, de->de_type);
-+                      err = filldir(dirent, de->de_str.name, de->de_str.len,
-+                                    file->f_pos, de->de_ino, de->de_type);
-+                      if (unlikely(err)) {
-+                              AuTraceErr(err);
++                      if (unlikely(!dir_emit(ctx, de->de_str.name,
++                                             de->de_str.len, de->de_ino,
++                                             de->de_type))) {
 +                              /* todo: ignore the error caused by udba? */
 +                              /* return err; */
 +                              return 0;
@@ -26599,13 +27916,13 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +
 +                      l = calc_size(de->de_str.len);
 +                      vdir_cache->vd_last.p.deblk += l;
-+                      file->f_pos += l;
++                      ctx->pos += l;
 +              }
 +              if (vdir_cache->vd_last.ul < vdir_cache->vd_nblk - 1) {
 +                      vdir_cache->vd_last.ul++;
 +                      vdir_cache->vd_last.p.deblk
 +                              = vdir_cache->vd_deblk[vdir_cache->vd_last.ul];
-+                      file->f_pos = deblk_sz * vdir_cache->vd_last.ul;
++                      ctx->pos = deblk_sz * vdir_cache->vd_last.ul;
 +                      continue;
 +              }
 +              break;
@@ -26616,10 +27933,10 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +}
 diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 --- /usr/share/empty/fs/aufs/vfsub.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/vfsub.c      2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,769 @@
++++ linux/fs/aufs/vfsub.c      2014-04-24 22:11:10.861935852 +0200
+@@ -0,0 +1,782 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -26632,8 +27949,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -26868,7 +28184,8 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      return -EMLINK;
 +}
 +
-+int vfsub_link(struct dentry *src_dentry, struct inode *dir, struct path *path)
++int vfsub_link(struct dentry *src_dentry, struct inode *dir, struct path *path,
++             struct inode **delegated_inode)
 +{
 +      int err;
 +      struct dentry *d;
@@ -26888,7 +28205,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +              goto out;
 +
 +      lockdep_off();
-+      err = vfs_link(src_dentry, dir, path->dentry);
++      err = vfs_link(src_dentry, dir, path->dentry, delegated_inode);
 +      lockdep_on();
 +      if (!err) {
 +              struct path tmp = *path;
@@ -26910,7 +28227,8 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +}
 +
 +int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
-+               struct inode *dir, struct path *path)
++               struct inode *dir, struct path *path,
++               struct inode **delegated_inode)
 +{
 +      int err;
 +      struct path tmp = {
@@ -26930,7 +28248,8 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +              goto out;
 +
 +      lockdep_off();
-+      err = vfs_rename(src_dir, src_dentry, dir, path->dentry);
++      err = vfs_rename(src_dir, src_dentry, dir, path->dentry,
++                       delegated_inode);
 +      lockdep_on();
 +      if (!err) {
 +              int did;
@@ -27081,7 +28400,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      int err;
 +
 +      err = 0;
-+      if (file->f_op && file->f_op->flush) {
++      if (file->f_op->flush) {
 +              if (!au_test_nfs(file->f_dentry->d_sb))
 +                      err = file->f_op->flush(file, id);
 +              else {
@@ -27096,12 +28415,14 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      return err;
 +}
 +
-+int vfsub_readdir(struct file *file, filldir_t filldir, void *arg)
++int vfsub_iterate_dir(struct file *file, struct dir_context *ctx)
 +{
 +      int err;
 +
++      AuDbg("%pD, ctx{%pf, %llu}\n", file, ctx->actor, ctx->pos);
++
 +      lockdep_off();
-+      err = vfs_readdir(file, filldir, arg);
++      err = iterate_dir(file, ctx);
 +      lockdep_on();
 +      if (err >= 0)
 +              vfsub_update_h_iattr(&file->f_path, /*did*/NULL); /*ignore*/
@@ -27264,6 +28585,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      int *errp;
 +      struct path *path;
 +      struct iattr *ia;
++      struct inode **delegated_inode;
 +};
 +
 +static void call_notify_change(void *args)
@@ -27276,20 +28598,23 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +
 +      *a->errp = -EPERM;
 +      if (!IS_IMMUTABLE(h_inode) && !IS_APPEND(h_inode)) {
-+              *a->errp = notify_change(a->path->dentry, a->ia);
++              *a->errp = notify_change(a->path->dentry, a->ia,
++                                       a->delegated_inode);
 +              if (!*a->errp)
 +                      vfsub_update_h_iattr(a->path, /*did*/NULL); /*ignore*/
 +      }
 +      AuTraceErr(*a->errp);
 +}
 +
-+int vfsub_notify_change(struct path *path, struct iattr *ia)
++int vfsub_notify_change(struct path *path, struct iattr *ia,
++                      struct inode **delegated_inode)
 +{
 +      int err;
 +      struct notify_change_args args = {
-+              .errp   = &err,
-+              .path   = path,
-+              .ia     = ia
++              .errp                   = &err,
++              .path                   = path,
++              .ia                     = ia,
++              .delegated_inode        = delegated_inode
 +      };
 +
 +      call_notify_change(&args);
@@ -27297,13 +28622,15 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      return err;
 +}
 +
-+int vfsub_sio_notify_change(struct path *path, struct iattr *ia)
++int vfsub_sio_notify_change(struct path *path, struct iattr *ia,
++                          struct inode **delegated_inode)
 +{
 +      int err, wkq_err;
 +      struct notify_change_args args = {
-+              .errp   = &err,
-+              .path   = path,
-+              .ia     = ia
++              .errp                   = &err,
++              .path                   = path,
++              .ia                     = ia,
++              .delegated_inode        = delegated_inode
 +      };
 +
 +      wkq_err = au_wkq_wait(call_notify_change, &args);
@@ -27319,6 +28646,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      int *errp;
 +      struct inode *dir;
 +      struct path *path;
++      struct inode **delegated_inode;
 +};
 +
 +static void call_unlink(void *args)
@@ -27327,7 +28655,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      struct dentry *d = a->path->dentry;
 +      struct inode *h_inode;
 +      const int stop_sillyrename = (au_test_nfs(d->d_sb)
-+                                    && d->d_count == 1);
++                                    && d_count(d) == 1);
 +
 +      IMustLock(a->dir);
 +
@@ -27344,7 +28672,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +              ihold(h_inode);
 +
 +      lockdep_off();
-+      *a->errp = vfs_unlink(a->dir, d);
++      *a->errp = vfs_unlink(a->dir, d, a->delegated_inode);
 +      lockdep_on();
 +      if (!*a->errp) {
 +              struct path tmp = {
@@ -27366,13 +28694,15 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 + * @dir: must be locked.
 + * @dentry: target dentry.
 + */
-+int vfsub_unlink(struct inode *dir, struct path *path, int force)
++int vfsub_unlink(struct inode *dir, struct path *path,
++               struct inode **delegated_inode, int force)
 +{
 +      int err;
 +      struct unlink_args args = {
-+              .errp   = &err,
-+              .dir    = dir,
-+              .path   = path
++              .errp                   = &err,
++              .dir                    = dir,
++              .path                   = path,
++              .delegated_inode        = delegated_inode
 +      };
 +
 +      if (!force)
@@ -27389,10 +28719,10 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +}
 diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 --- /usr/share/empty/fs/aufs/vfsub.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/vfsub.h      2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,294 @@
++++ linux/fs/aufs/vfsub.h      2014-04-24 22:11:10.861935852 +0200
+@@ -0,0 +1,282 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -27405,8 +28735,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -27425,48 +28754,16 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +
 +/* copied from linux/fs/internal.h */
 +/* todo: BAD approach!! */
-+extern struct lglock vfsmount_lock;
 +extern void __mnt_drop_write(struct vfsmount *);
 +extern spinlock_t inode_sb_list_lock;
 +
-+/* copied from linux/fs/file_table.c */
-+extern struct lglock files_lglock;
-+#ifdef CONFIG_SMP
-+/*
-+ * These macros iterate all files on all CPUs for a given superblock.
-+ * files_lglock must be held globally.
-+ */
-+#define do_file_list_for_each_entry(__sb, __file)             \
-+{                                                             \
-+      int i;                                                  \
-+      for_each_possible_cpu(i) {                              \
-+              struct list_head *list;                         \
-+              list = per_cpu_ptr((__sb)->s_files, i);         \
-+              list_for_each_entry((__file), list, f_u.fu_list)
-+
-+#define while_file_list_for_each_entry                                \
-+      }                                                       \
-+}
-+
-+#else
-+
-+#define do_file_list_for_each_entry(__sb, __file)             \
-+{                                                             \
-+      struct list_head *list;                                 \
-+      list = &(sb)->s_files;                                  \
-+      list_for_each_entry((__file), list, f_u.fu_list)
-+
-+#define while_file_list_for_each_entry                                \
-+}
-+#endif
-+
 +/* ---------------------------------------------------------------------- */
 +
 +/* lock subclass for lower inode */
 +/* default MAX_LOCKDEP_SUBCLASSES(8) is not enough */
 +/* reduce? gave up. */
 +enum {
-+      AuLsc_I_Begin = I_MUTEX_QUOTA, /* 4 */
++      AuLsc_I_Begin = I_MUTEX_NONDIR2, /* 4 */
 +      AuLsc_I_PARENT,         /* lower inode, parent first */
 +      AuLsc_I_PARENT2,        /* copyup dirs */
 +      AuLsc_I_PARENT3,        /* copyup wh */
@@ -27494,6 +28791,14 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +      clear_nlink(inode);
 +}
 +
++static inline int vfsub_native_ro(struct inode *inode)
++{
++      return (inode->i_sb->s_flags & MS_RDONLY)
++              || IS_RDONLY(inode)
++              /* || IS_APPEND(inode) */
++              || IS_IMMUTABLE(inode);
++}
++
 +/* ---------------------------------------------------------------------- */
 +
 +int vfsub_update_h_iattr(struct path *h_path, int *did);
@@ -27557,9 +28862,10 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +                const char *symname);
 +int vfsub_mknod(struct inode *dir, struct path *path, int mode, dev_t dev);
 +int vfsub_link(struct dentry *src_dentry, struct inode *dir,
-+             struct path *path);
++             struct path *path, struct inode **delegated_inode);
 +int vfsub_rename(struct inode *src_hdir, struct dentry *src_dentry,
-+               struct inode *hdir, struct path *path);
++               struct inode *hdir, struct path *path,
++               struct inode **delegated_inode);
 +int vfsub_mkdir(struct inode *dir, struct path *path, int mode);
 +int vfsub_rmdir(struct inode *dir, struct path *path);
 +
@@ -27574,7 +28880,16 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count,
 +                    loff_t *ppos);
 +int vfsub_flush(struct file *file, fl_owner_t id);
-+int vfsub_readdir(struct file *file, filldir_t filldir, void *arg);
++int vfsub_iterate_dir(struct file *file, struct dir_context *ctx);
++
++/* just for type-check */
++static inline filldir_t au_diractor(int (*func)(struct dir_context *,
++                                              const char *, int, loff_t, u64,
++                                              unsigned))
++{
++      return (filldir_t)func;
++}
++
 +
 +static inline loff_t vfsub_f_size_read(struct file *file)
 +{
@@ -27679,18 +28994,21 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +
 +int vfsub_sio_mkdir(struct inode *dir, struct path *path, int mode);
 +int vfsub_sio_rmdir(struct inode *dir, struct path *path);
-+int vfsub_sio_notify_change(struct path *path, struct iattr *ia);
-+int vfsub_notify_change(struct path *path, struct iattr *ia);
-+int vfsub_unlink(struct inode *dir, struct path *path, int force);
++int vfsub_sio_notify_change(struct path *path, struct iattr *ia,
++                          struct inode **delegated_inode);
++int vfsub_notify_change(struct path *path, struct iattr *ia,
++                      struct inode **delegated_inode);
++int vfsub_unlink(struct inode *dir, struct path *path,
++               struct inode **delegated_inode, int force);
 +
 +#endif /* __KERNEL__ */
 +#endif /* __AUFS_VFSUB_H__ */
 diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 --- /usr/share/empty/fs/aufs/wbr_policy.c      1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/wbr_policy.c 2013-07-06 13:20:47.753531903 +0200
-@@ -0,0 +1,701 @@
++++ linux/fs/aufs/wbr_policy.c 2014-04-24 22:11:10.861935852 +0200
+@@ -0,0 +1,756 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -27703,8 +29021,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -27729,13 +29046,14 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      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->i_flags);
-+      err = vfsub_sio_notify_change(h_path, &ia);
++      /* no delegation since it is just created */
++      err = vfsub_sio_notify_change(h_path, &ia, /*delegated*/NULL);
 +
 +      /* is this nfs only? */
 +      if (!err && sbits && au_test_nfs(h_path->dentry->d_sb)) {
 +              ia.ia_valid = ATTR_FORCE | ATTR_MODE;
 +              ia.ia_mode = h_isrc->i_mode;
-+              err = vfsub_sio_notify_change(h_path, &ia);
++              err = vfsub_sio_notify_change(h_path, &ia, /*delegated*/NULL);
 +      }
 +
 +      return err;
@@ -27751,13 +29069,8 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +#define au_fclr_cpdown(flags, name) \
 +      do { (flags) &= ~AuCpdown_##name; } while (0)
 +
-+struct au_cpdown_dir_args {
-+      struct dentry *parent;
-+      unsigned int flags;
-+};
-+
 +static int au_cpdown_dir_opq(struct dentry *dentry, aufs_bindex_t bdst,
-+                           struct au_cpdown_dir_args *a)
++                           unsigned int *flags)
 +{
 +      int err;
 +      struct dentry *opq_dentry;
@@ -27767,7 +29080,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      if (IS_ERR(opq_dentry))
 +              goto out;
 +      dput(opq_dentry);
-+      au_fset_cpdown(a->flags, DIROPQ);
++      au_fset_cpdown(*flags, DIROPQ);
 +
 +out:
 +      return err;
@@ -27807,7 +29120,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      struct path h_path;
 +      struct dentry *parent;
 +      struct inode *h_dir, *h_inode, *inode, *dir;
-+      struct au_cpdown_dir_args *args = arg;
++      unsigned int *flags = arg;
 +
 +      bstart = au_dbstart(dentry);
 +      /* dentry is di-locked */
@@ -27826,19 +29139,19 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +                            S_IRWXU | S_IRUGO | S_IXUGO);
 +      if (unlikely(err))
 +              goto out_put;
-+      au_fset_cpdown(args->flags, MADE_DIR);
++      au_fset_cpdown(*flags, MADE_DIR);
 +
 +      bopq = au_dbdiropq(dentry);
-+      au_fclr_cpdown(args->flags, WHED);
-+      au_fclr_cpdown(args->flags, DIROPQ);
++      au_fclr_cpdown(*flags, WHED);
++      au_fclr_cpdown(*flags, DIROPQ);
 +      if (au_dbwh(dentry) == bdst)
-+              au_fset_cpdown(args->flags, WHED);
-+      if (!au_ftest_cpdown(args->flags, PARENT_OPQ) && bopq <= bdst)
-+              au_fset_cpdown(args->flags, PARENT_OPQ);
++              au_fset_cpdown(*flags, WHED);
++      if (!au_ftest_cpdown(*flags, PARENT_OPQ) && bopq <= bdst)
++              au_fset_cpdown(*flags, PARENT_OPQ);
 +      h_inode = h_path.dentry->d_inode;
 +      mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
-+      if (au_ftest_cpdown(args->flags, WHED)) {
-+              err = au_cpdown_dir_opq(dentry, bdst, args);
++      if (au_ftest_cpdown(*flags, WHED)) {
++              err = au_cpdown_dir_opq(dentry, bdst, flags);
 +              if (unlikely(err)) {
 +                      mutex_unlock(&h_inode->i_mutex);
 +                      goto out_dir;
@@ -27850,7 +29163,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      if (unlikely(err))
 +              goto out_opq;
 +
-+      if (au_ftest_cpdown(args->flags, WHED)) {
++      if (au_ftest_cpdown(*flags, WHED)) {
 +              err = au_cpdown_dir_wh(dentry, h_parent, dir, bdst);
 +              if (unlikely(err))
 +                      goto out_opq;
@@ -27865,23 +29178,23 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +
 +      /* revert */
 +out_opq:
-+      if (au_ftest_cpdown(args->flags, DIROPQ)) {
++      if (au_ftest_cpdown(*flags, DIROPQ)) {
 +              mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
 +              rerr = au_diropq_remove(dentry, bdst);
 +              mutex_unlock(&h_inode->i_mutex);
 +              if (unlikely(rerr)) {
-+                      AuIOErr("failed removing diropq for %.*s b%d (%d)\n",
-+                              AuDLNPair(dentry), bdst, rerr);
++                      AuIOErr("failed removing diropq for %pd b%d (%d)\n",
++                              dentry, bdst, rerr);
 +                      err = -EIO;
 +                      goto out;
 +              }
 +      }
 +out_dir:
-+      if (au_ftest_cpdown(args->flags, MADE_DIR)) {
++      if (au_ftest_cpdown(*flags, MADE_DIR)) {
 +              rerr = vfsub_sio_rmdir(au_h_iptr(dir, bdst), &h_path);
 +              if (unlikely(rerr)) {
-+                      AuIOErr("failed removing %.*s b%d (%d)\n",
-+                              AuDLNPair(dentry), bdst, rerr);
++                      AuIOErr("failed removing %pd b%d (%d)\n",
++                              dentry, bdst, rerr);
 +                      err = -EIO;
 +              }
 +      }
@@ -27897,13 +29210,10 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +int au_cpdown_dirs(struct dentry *dentry, aufs_bindex_t bdst)
 +{
 +      int err;
-+      struct au_cpdown_dir_args args = {
-+              .parent = dget_parent(dentry),
-+              .flags  = 0
-+      };
++      unsigned int flags;
 +
-+      err = au_cp_dirs(dentry, bdst, au_cpdown_dir, &args);
-+      dput(args.parent);
++      flags = 0;
++      err = au_cp_dirs(dentry, bdst, au_cpdown_dir, &flags);
 +
 +      return err;
 +}
@@ -27912,7 +29222,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +
 +/* policies for create */
 +
-+static int au_wbr_nonopq(struct dentry *dentry, aufs_bindex_t bindex)
++int au_wbr_nonopq(struct dentry *dentry, aufs_bindex_t bindex)
 +{
 +      int err, i, j, ndentry;
 +      aufs_bindex_t bopq;
@@ -27959,7 +29269,8 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +}
 +
 +/* top down parent */
-+static int au_wbr_create_tdp(struct dentry *dentry, int isdir __maybe_unused)
++static int au_wbr_create_tdp(struct dentry *dentry,
++                           unsigned int flags __maybe_unused)
 +{
 +      int err;
 +      aufs_bindex_t bstart, bindex;
@@ -28048,7 +29359,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      return err;
 +}
 +
-+static int au_wbr_create_rr(struct dentry *dentry, int isdir)
++static int au_wbr_create_rr(struct dentry *dentry, unsigned int flags)
 +{
 +      int err, nbr;
 +      unsigned int u;
@@ -28065,7 +29376,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      bend = au_sbend(sb);
 +      nbr = bend + 1;
 +      for (bindex = 0; bindex <= bend; bindex++) {
-+              if (!isdir) {
++              if (!au_ftest_wbr(flags, DIR)) {
 +                      err = atomic_dec_return(next) + 1;
 +                      /* modulo for 0 is meaningless */
 +                      if (unlikely(!err))
@@ -28092,11 +29403,12 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +/* ---------------------------------------------------------------------- */
 +
 +/* most free space */
-+static void au_mfs(struct dentry *dentry)
++static void au_mfs(struct dentry *dentry, struct dentry *parent)
 +{
 +      struct super_block *sb;
 +      struct au_branch *br;
 +      struct au_wbr_mfs *mfs;
++      struct dentry *h_parent;
 +      aufs_bindex_t bindex, bend;
 +      int err;
 +      unsigned long long b, bavail;
@@ -28116,8 +29428,20 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      MtxMustLock(&mfs->mfs_lock);
 +      mfs->mfs_bindex = -EROFS;
 +      mfs->mfsrr_bytes = 0;
-+      bend = au_sbend(sb);
-+      for (bindex = 0; bindex <= bend; bindex++) {
++      if (!parent) {
++              bindex = 0;
++              bend = au_sbend(sb);
++      } else {
++              bindex = au_dbstart(parent);
++              bend = au_dbtaildir(parent);
++      }
++
++      for (; bindex <= bend; bindex++) {
++              if (parent) {
++                      h_parent = au_h_dptr(parent, bindex);
++                      if (!h_parent || !h_parent->d_inode)
++                              continue;
++              }
 +              br = au_sbr(sb, bindex);
 +              if (au_br_rdonly(br))
 +                      continue;
@@ -28148,9 +29472,10 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      kfree(st);
 +}
 +
-+static int au_wbr_create_mfs(struct dentry *dentry, int isdir __maybe_unused)
++static int au_wbr_create_mfs(struct dentry *dentry, unsigned int flags)
 +{
 +      int err;
++      struct dentry *parent;
 +      struct super_block *sb;
 +      struct au_wbr_mfs *mfs;
 +
@@ -28159,14 +29484,18 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +              goto out;
 +
 +      sb = dentry->d_sb;
++      parent = NULL;
++      if (au_ftest_wbr(flags, PARENT))
++              parent = dget_parent(dentry);
 +      mfs = &au_sbi(sb)->si_wbr_mfs;
 +      mutex_lock(&mfs->mfs_lock);
 +      if (time_after(jiffies, mfs->mfs_jiffy + mfs->mfs_expire)
 +          || mfs->mfs_bindex < 0
 +          || au_br_rdonly(au_sbr(sb, mfs->mfs_bindex)))
-+              au_mfs(dentry);
++              au_mfs(dentry, parent);
 +      mutex_unlock(&mfs->mfs_lock);
 +      err = mfs->mfs_bindex;
++      dput(parent);
 +
 +      if (err >= 0)
 +              err = au_wbr_nonopq(dentry, err);
@@ -28197,17 +29526,17 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +/* ---------------------------------------------------------------------- */
 +
 +/* most free space and then round robin */
-+static int au_wbr_create_mfsrr(struct dentry *dentry, int isdir)
++static int au_wbr_create_mfsrr(struct dentry *dentry, unsigned int flags)
 +{
 +      int err;
 +      struct au_wbr_mfs *mfs;
 +
-+      err = au_wbr_create_mfs(dentry, isdir);
++      err = au_wbr_create_mfs(dentry, flags);
 +      if (err >= 0) {
 +              mfs = &au_sbi(dentry->d_sb)->si_wbr_mfs;
 +              mutex_lock(&mfs->mfs_lock);
 +              if (mfs->mfsrr_bytes < mfs->mfsrr_watermark)
-+                      err = au_wbr_create_rr(dentry, isdir);
++                      err = au_wbr_create_rr(dentry, flags);
 +              mutex_unlock(&mfs->mfs_lock);
 +      }
 +
@@ -28228,7 +29557,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +/* ---------------------------------------------------------------------- */
 +
 +/* top down parent and most free space */
-+static int au_wbr_create_pmfs(struct dentry *dentry, int isdir)
++static int au_wbr_create_pmfs(struct dentry *dentry, unsigned int flags)
 +{
 +      int err, e2;
 +      unsigned long long b;
@@ -28237,7 +29566,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      struct dentry *parent, *h_parent;
 +      struct au_branch *br;
 +
-+      err = au_wbr_create_tdp(dentry, isdir);
++      err = au_wbr_create_tdp(dentry, flags);
 +      if (unlikely(err < 0))
 +              goto out;
 +      parent = dget_parent(dentry);
@@ -28246,7 +29575,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +      if (bstart == bend)
 +              goto out_parent; /* success */
 +
-+      e2 = au_wbr_create_mfs(dentry, isdir);
++      e2 = au_wbr_create_mfs(dentry, flags);
 +      if (e2 < 0)
 +              goto out_parent; /* success */
 +
@@ -28281,12 +29610,46 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +
 +/* ---------------------------------------------------------------------- */
 +
++/*
++ * - top down parent
++ * - most free space with parent
++ * - most free space round-robin regardless parent
++ */
++static int au_wbr_create_pmfsrr(struct dentry *dentry, unsigned int flags)
++{
++      int err;
++      unsigned long long watermark;
++      struct super_block *sb;
++      struct au_branch *br;
++      struct au_wbr_mfs *mfs;
++
++      err = au_wbr_create_pmfs(dentry, flags | AuWbr_PARENT);
++      if (unlikely(err < 0))
++              goto out;
++
++      sb = dentry->d_sb;
++      br = au_sbr(sb, err);
++      mfs = &au_sbi(sb)->si_wbr_mfs;
++      mutex_lock(&mfs->mfs_lock);
++      watermark = mfs->mfsrr_watermark;
++      mutex_unlock(&mfs->mfs_lock);
++      if (br->br_wbr->wbr_bytes < watermark)
++              /* regardless the parent dir */
++              err = au_wbr_create_mfsrr(dentry, flags);
++
++out:
++      AuDbg("b%d\n", err);
++      return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
 +/* policies for copyup */
 +
 +/* top down parent */
 +static int au_wbr_copyup_tdp(struct dentry *dentry)
 +{
-+      return au_wbr_create_tdp(dentry, /*isdir, anything is ok*/0);
++      return au_wbr_create_tdp(dentry, /*flags, anything is ok*/0);
 +}
 +
 +/* bottom up parent */
@@ -28388,14 +29751,24 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +              .create = au_wbr_create_pmfs,
 +              .init   = au_wbr_create_init_mfs,
 +              .fin    = au_wbr_create_fin_mfs
++      },
++      [AuWbrCreate_PMFSRR] = {
++              .create = au_wbr_create_pmfsrr,
++              .init   = au_wbr_create_init_mfsrr,
++              .fin    = au_wbr_create_fin_mfs
++      },
++      [AuWbrCreate_PMFSRRV] = {
++              .create = au_wbr_create_pmfsrr,
++              .init   = au_wbr_create_init_mfsrr,
++              .fin    = au_wbr_create_fin_mfs
 +      }
 +};
 diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 --- /usr/share/empty/fs/aufs/whout.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/whout.c      2013-07-06 13:20:47.760198800 +0200
-@@ -0,0 +1,1022 @@
++++ linux/fs/aufs/whout.c      2014-04-24 22:11:10.861935852 +0200
+@@ -0,0 +1,1052 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -28408,8 +29781,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -28483,8 +29855,8 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +              goto out_wh; /* success */
 +
 +      err = -EIO;
-+      AuIOErr("%.*s Invalid whiteout entry type 0%o.\n",
-+              AuDLNPair(wh_dentry), wh_dentry->d_inode->i_mode);
++      AuIOErr("%pd Invalid whiteout entry type 0%o.\n",
++              wh_dentry, wh_dentry->d_inode->i_mode);
 +
 +out_wh:
 +      dput(wh_dentry);
@@ -28572,7 +29944,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      struct path h_path = {
 +              .mnt = au_br_mnt(br)
 +      };
-+      struct inode *h_dir;
++      struct inode *h_dir, *delegated;
 +      struct dentry *h_parent;
 +
 +      h_parent = h_dentry->d_parent; /* dir inode is locked */
@@ -28585,8 +29957,14 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +              goto out;
 +
 +      /* under the same dir, no need to lock_rename() */
-+      err = vfsub_rename(h_dir, h_dentry, h_dir, &h_path);
++      delegated = NULL;
++      err = vfsub_rename(h_dir, h_dentry, h_dir, &h_path, &delegated);
 +      AuTraceErr(err);
++      if (unlikely(err == -EWOULDBLOCK)) {
++              pr_warn("cannot retry for NFSv4 delegation"
++                      " for an internal rename\n");
++              iput(delegated);
++      }
 +      dput(h_path.dentry);
 +
 +out:
@@ -28601,7 +29979,8 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +
 +static int do_unlink_wh(struct inode *h_dir, struct path *h_path)
 +{
-+      int force;
++      int err, force;
++      struct inode *delegated;
 +
 +      /*
 +       * forces superio when the dir has a sticky bit.
@@ -28609,7 +29988,14 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +       */
 +      force = (h_dir->i_mode & S_ISVTX)
 +              && !uid_eq(current_fsuid(), h_path->dentry->d_inode->i_uid);
-+      return vfsub_unlink(h_dir, h_path, force);
++      delegated = NULL;
++      err = vfsub_unlink(h_dir, h_path, &delegated, force);
++      if (unlikely(err == -EWOULDBLOCK)) {
++              pr_warn("cannot retry for NFSv4 delegation"
++                      " for an internal unlink\n");
++              iput(delegated);
++      }
++      return err;
 +}
 +
 +int au_wh_unlink_dentry(struct inode *h_dir, struct path *h_path,
@@ -28655,17 +30041,25 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +                      const int isdir)
 +{
 +      int err;
++      struct inode *delegated;
 +
 +      if (!whpath->dentry->d_inode)
 +              return;
 +
 +      if (isdir)
 +              err = vfsub_rmdir(h_dir, whpath);
-+      else
-+              err = vfsub_unlink(h_dir, whpath, /*force*/0);
++      else {
++              delegated = NULL;
++              err = vfsub_unlink(h_dir, whpath, &delegated, /*force*/0);
++              if (unlikely(err == -EWOULDBLOCK)) {
++                      pr_warn("cannot retry for NFSv4 delegation"
++                              " for an internal unlink\n");
++                      iput(delegated);
++              }
++      }
 +      if (unlikely(err))
-+              pr_warn("failed removing %.*s (%d), ignored.\n",
-+                      AuDLNPair(whpath->dentry), err);
++              pr_warn("failed removing %pd (%d), ignored.\n",
++                      whpath->dentry, err);
 +}
 +
 +static int test_linkable(struct dentry *h_root)
@@ -28675,8 +30069,8 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      if (h_dir->i_op->link)
 +              return 0;
 +
-+      pr_err("%.*s (%s) doesn't support link(2), use noplink and rw+nolwh\n",
-+             AuDLNPair(h_root), au_sbtype(h_root->d_sb));
++      pr_err("%pd (%s) doesn't support link(2), use noplink and rw+nolwh\n",
++             h_root, au_sbtype(h_root->d_sb));
 +      return -ENOSYS;
 +}
 +
@@ -28695,7 +30089,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      } else if (S_ISDIR(path->dentry->d_inode->i_mode))
 +              err = 0;
 +      else
-+              pr_err("unknown %.*s exists\n", AuDLNPair(path->dentry));
++              pr_err("unknown %pd exists\n", path->dentry);
 +
 +      return err;
 +}
@@ -28790,8 +30184,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      } else if (S_ISREG(base[AuBrWh_BASE].dentry->d_inode->i_mode))
 +              err = 0;
 +      else
-+              pr_err("unknown %.*s/%.*s exists\n",
-+                     AuDLNPair(h_root), AuDLNPair(base[AuBrWh_BASE].dentry));
++              pr_err("unknown %pd2 exists\n", base[AuBrWh_BASE].dentry);
 +      if (unlikely(err))
 +              goto out;
 +
@@ -28894,8 +30287,8 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      goto out; /* success */
 +
 +out_err:
-+      pr_err("an error(%d) on the writable branch %.*s(%s)\n",
-+             err, AuDLNPair(h_root), au_sbtype(h_root->d_sb));
++      pr_err("an error(%d) on the writable branch %pd(%s)\n",
++             err, h_root, au_sbtype(h_root->d_sb));
 +out:
 +      for (i = 0; i < AuBrWh_Last; i++)
 +              dput(base[i].dentry);
@@ -28921,7 +30314,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      struct path h_path;
 +      struct reinit_br_wh *a = arg;
 +      struct au_wbr *wbr;
-+      struct inode *dir;
++      struct inode *dir, *delegated;
 +      struct dentry *h_root;
 +      struct au_hinode *hdir;
 +
@@ -28948,10 +30341,16 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      if (!err) {
 +              h_path.dentry = wbr->wbr_whbase;
 +              h_path.mnt = au_br_mnt(a->br);
-+              err = vfsub_unlink(hdir->hi_inode, &h_path, /*force*/0);
++              delegated = NULL;
++              err = vfsub_unlink(hdir->hi_inode, &h_path, &delegated,
++                                 /*force*/0);
++              if (unlikely(err == -EWOULDBLOCK)) {
++                      pr_warn("cannot retry for NFSv4 delegation"
++                              " for an internal unlink\n");
++                      iput(delegated);
++              }
 +      } else {
-+              pr_warn("%.*s is moved, ignored\n",
-+                      AuDLNPair(wbr->wbr_whbase));
++              pr_warn("%pd is moved, ignored\n", wbr->wbr_whbase);
 +              err = 0;
 +      }
 +      dput(wbr->wbr_whbase);
@@ -29021,7 +30420,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      struct au_branch *br;
 +      struct au_wbr *wbr;
 +      struct dentry *h_parent;
-+      struct inode *h_dir;
++      struct inode *h_dir, *delegated;
 +
 +      h_parent = wh->d_parent; /* dir inode is locked */
 +      h_dir = h_parent->d_inode;
@@ -29032,7 +30431,13 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      wbr = br->br_wbr;
 +      wbr_wh_read_lock(wbr);
 +      if (wbr->wbr_whbase) {
-+              err = vfsub_link(wbr->wbr_whbase, h_dir, &h_path);
++              delegated = NULL;
++              err = vfsub_link(wbr->wbr_whbase, h_dir, &h_path, &delegated);
++              if (unlikely(err == -EWOULDBLOCK)) {
++                      pr_warn("cannot retry for NFSv4 delegation"
++                              " for an internal link\n");
++                      iput(delegated);
++              }
 +              if (!err || err != -EMLINK)
 +                      goto out;
 +
@@ -29341,8 +30746,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +              return 0; /* success */
 +      }
 +
-+      pr_warn("failed removing %.*s(%d), ignored\n",
-+              AuDLNPair(wh_dentry), err);
++      pr_warn("failed removing %pd(%d), ignored\n", wh_dentry, err);
 +      return err;
 +}
 +
@@ -29411,17 +30815,16 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      args->wh_dentry = dget(wh_dentry);
 +      wkq_err = au_wkq_nowait(call_rmdir_whtmp, args, sb, /*flags*/0);
 +      if (unlikely(wkq_err)) {
-+              pr_warn("rmdir error %.*s (%d), ignored\n",
-+                      AuDLNPair(wh_dentry), wkq_err);
++              pr_warn("rmdir error %pd (%d), ignored\n", wh_dentry, wkq_err);
 +              au_whtmp_rmdir_free(args);
 +      }
 +}
 diff -urN /usr/share/empty/fs/aufs/whout.h linux/fs/aufs/whout.h
 --- /usr/share/empty/fs/aufs/whout.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/whout.h      2013-07-06 13:20:47.760198800 +0200
-@@ -0,0 +1,87 @@
++++ linux/fs/aufs/whout.h      2014-04-24 22:11:10.861935852 +0200
+@@ -0,0 +1,86 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -29434,8 +30837,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.h linux/fs/aufs/whout.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -29509,10 +30911,10 @@ diff -urN /usr/share/empty/fs/aufs/whout.h linux/fs/aufs/whout.h
 +#endif /* __AUFS_WHOUT_H__ */
 diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 --- /usr/share/empty/fs/aufs/wkq.c     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/wkq.c        2013-07-06 13:20:47.760198800 +0200
-@@ -0,0 +1,213 @@
++++ linux/fs/aufs/wkq.c        2014-04-24 22:11:10.861935852 +0200
+@@ -0,0 +1,212 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -29525,8 +30927,7 @@ diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -29575,7 +30976,7 @@ diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 +/*
 + * Since struct completion is large, try allocating it dynamically.
 + */
-+#if defined(CONFIG_4KSTACKS) || defined(AuTest4KSTACKS)
++#if 1 /* defined(CONFIG_4KSTACKS) || defined(AuTest4KSTACKS) */
 +#define AuWkqCompDeclare(name)        struct completion *comp = NULL
 +
 +static int au_wkq_comp_alloc(struct au_wkinfo *wkinfo, struct completion **comp)
@@ -29726,10 +31127,10 @@ diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 +}
 diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h
 --- /usr/share/empty/fs/aufs/wkq.h     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/wkq.h        2013-07-06 13:20:47.760198800 +0200
-@@ -0,0 +1,92 @@
++++ linux/fs/aufs/wkq.h        2014-04-24 22:11:10.861935852 +0200
+@@ -0,0 +1,91 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -29742,8 +31143,7 @@ diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -29822,10 +31222,10 @@ diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h
 +#endif /* __AUFS_WKQ_H__ */
 diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 --- /usr/share/empty/fs/aufs/xino.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/xino.c       2013-07-06 13:20:47.760198800 +0200
-@@ -0,0 +1,1264 @@
++++ linux/fs/aufs/xino.c       2014-04-24 22:11:10.861935852 +0200
+@@ -0,0 +1,1314 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -29838,8 +31238,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +/*
@@ -29847,6 +31246,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 + */
 +
 +#include <linux/seq_file.h>
++#include <linux/statfs.h>
 +#include "aufs.h"
 +
 +/* todo: unnecessary to support mmap_sem since kernel-space? */
@@ -29963,7 +31363,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +{
 +      struct file *file;
 +      struct dentry *base, *parent;
-+      struct inode *dir;
++      struct inode *dir, *delegated;
 +      struct qstr *name;
 +      struct path path;
 +      int err;
@@ -29978,8 +31378,8 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      path.dentry = vfsub_lookup_one_len(name->name, parent, name->len);
 +      if (IS_ERR(path.dentry)) {
 +              file = (void *)path.dentry;
-+              pr_err("%.*s lookup err %ld\n",
-+                     AuLNPair(name), PTR_ERR(path.dentry));
++              pr_err("%pd lookup err %ld\n",
++                     base, PTR_ERR(path.dentry));
 +              goto out;
 +      }
 +
@@ -29987,7 +31387,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      err = vfs_create(dir, path.dentry, S_IRUGO | S_IWUGO, NULL);
 +      if (unlikely(err)) {
 +              file = ERR_PTR(err);
-+              pr_err("%.*s create err %d\n", AuLNPair(name), err);
++              pr_err("%pd create err %d\n", base, err);
 +              goto out_dput;
 +      }
 +
@@ -29996,13 +31396,19 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +                               O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE
 +                               /* | __FMODE_NONOTIFY */);
 +      if (IS_ERR(file)) {
-+              pr_err("%.*s open err %ld\n", AuLNPair(name), PTR_ERR(file));
++              pr_err("%pd open err %ld\n", base, PTR_ERR(file));
 +              goto out_dput;
 +      }
 +
-+      err = vfsub_unlink(dir, &file->f_path, /*force*/0);
++      delegated = NULL;
++      err = vfsub_unlink(dir, &file->f_path, &delegated, /*force*/0);
++      if (unlikely(err == -EWOULDBLOCK)) {
++              pr_warn("cannot retry for NFSv4 delegation"
++                      " for an internal unlink\n");
++              iput(delegated);
++      }
 +      if (unlikely(err)) {
-+              pr_err("%.*s unlink err %d\n", AuLNPair(name), err);
++              pr_err("%pd unlink err %d\n", base, err);
 +              goto out_fput;
 +      }
 +
@@ -30010,7 +31416,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +              /* no one can touch copy_src xino */
 +              err = au_copy_file(file, copy_src, vfsub_f_size_read(copy_src));
 +              if (unlikely(err)) {
-+                      pr_err("%.*s copy err %d\n", AuLNPair(name), err);
++                      pr_err("%pd copy err %d\n", base, err);
 +                      goto out_fput;
 +              }
 +      }
@@ -30068,28 +31474,46 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +int au_xino_trunc(struct super_block *sb, aufs_bindex_t bindex)
 +{
 +      int err;
++      unsigned long jiffy;
++      blkcnt_t blocks;
 +      aufs_bindex_t bi, bend;
++      struct kstatfs *st;
 +      struct au_branch *br;
 +      struct file *new_xino, *file;
 +      struct super_block *h_sb;
 +      struct au_xino_lock_dir ldir;
 +
++      err = -ENOMEM;
++      st = kzalloc(sizeof(*st), GFP_NOFS);
++      if (unlikely(!st))
++              goto out;
++
 +      err = -EINVAL;
 +      bend = au_sbend(sb);
 +      if (unlikely(bindex < 0 || bend < bindex))
-+              goto out;
++              goto out_st;
 +      br = au_sbr(sb, bindex);
 +      file = br->br_xino.xi_file;
 +      if (!file)
-+              goto out;
++              goto out_st;
++
++      err = vfs_statfs(&file->f_path, st);
++      if (unlikely(err))
++              AuErr1("statfs err %d, ignored\n", err);
++      jiffy = jiffies;
++      blocks = file_inode(file)->i_blocks;
++      pr_info("begin truncating xino(b%d), ib%llu, %llu/%llu free blks\n",
++              bindex, (u64)blocks, st->f_bfree, st->f_blocks);
 +
 +      au_xino_lock_dir(sb, file, &ldir);
 +      /* mnt_want_write() is unnecessary here */
 +      new_xino = au_xino_create2(file, file);
 +      au_xino_unlock_dir(&ldir);
 +      err = PTR_ERR(new_xino);
-+      if (IS_ERR(new_xino))
-+              goto out;
++      if (IS_ERR(new_xino)) {
++              pr_err("err %d, ignored\n", err);
++              goto out_st;
++      }
 +      err = 0;
 +      fput(file);
 +      br->br_xino.xi_file = new_xino;
@@ -30107,6 +31531,18 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +              get_file(new_xino);
 +      }
 +
++      err = vfs_statfs(&new_xino->f_path, st);
++      if (!err) {
++              pr_info("end truncating xino(b%d), ib%llu, %llu/%llu free blks\n",
++                      bindex, (u64)file_inode(new_xino)->i_blocks,
++                      st->f_bfree, st->f_blocks);
++              if (file_inode(new_xino)->i_blocks < blocks)
++                      au_sbi(sb)->si_xino_jiffy = jiffy;
++      } else
++              AuErr1("statfs err %d, ignored\n", err);
++
++out_st:
++      kfree(st);
 +out:
 +      return err;
 +}
@@ -30134,15 +31570,9 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      ii_read_lock_parent(dir);
 +      bindex = au_br_index(sb, br->br_id);
 +      err = au_xino_trunc(sb, bindex);
-+      if (!err
-+          && file_inode(br->br_xino.xi_file)->i_blocks
-+          >= br->br_xino_upper)
-+              br->br_xino_upper += AUFS_XINO_TRUNC_STEP;
-+
 +      ii_read_unlock(dir);
 +      if (unlikely(err))
-+              pr_warn("err b%d, upper %llu, (%d)\n",
-+                      bindex, (unsigned long long)br->br_xino_upper, err);
++              pr_warn("err b%d, (%d)\n", bindex, err);
 +      atomic_dec(&br->br_xino_running);
 +      atomic_dec(&br->br_count);
 +      si_write_unlock(sb);
@@ -30150,13 +31580,36 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      kfree(args);
 +}
 +
++static int xino_trunc_test(struct super_block *sb, struct au_branch *br)
++{
++      int err;
++      struct kstatfs st;
++      struct au_sbinfo *sbinfo;
++
++      /* todo: si_xino_expire and the ratio should be customizable */
++      sbinfo = au_sbi(sb);
++      if (time_before(jiffies,
++                      sbinfo->si_xino_jiffy + sbinfo->si_xino_expire))
++              return 0;
++
++      /* truncation border */
++      err = vfs_statfs(&br->br_xino.xi_file->f_path, &st);
++      if (unlikely(err)) {
++              AuErr1("statfs err %d, ignored\n", err);
++              return 0;
++      }
++      if (div64_u64(st.f_bfree * 100, st.f_blocks) >= AUFS_XINO_DEF_TRUNC)
++              return 0;
++
++      return 1;
++}
++
 +static void xino_try_trunc(struct super_block *sb, struct au_branch *br)
 +{
 +      struct xino_do_trunc_args *args;
 +      int wkq_err;
 +
-+      if (file_inode(br->br_xino.xi_file)->i_blocks
-+          < br->br_xino_upper)
++      if (!xino_trunc_test(sb, br))
 +              return;
 +
 +      if (atomic_inc_return(&br->br_xino_running) > 1)
@@ -30524,7 +31977,8 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      h_dir = h_parent->d_inode;
 +      mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
 +      /* mnt_want_write() is unnecessary here */
-+      err = vfsub_unlink(h_dir, &file->f_path, /*force*/0);
++      /* no delegation since it is just created */
++      err = vfsub_unlink(h_dir, &file->f_path, /*delegated*/NULL, /*force*/0);
 +      mutex_unlock(&h_dir->i_mutex);
 +      dput(h_parent);
 +      if (unlikely(err)) {
@@ -30766,12 +32220,10 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +{
 +      const struct file_operations *fop = h_file->f_op;
 +
-+      if (fop) {
-+              if (fop->read)
-+                      return fop->read;
-+              if (fop->aio_read)
-+                      return do_sync_read;
-+      }
++      if (fop->read)
++              return fop->read;
++      if (fop->aio_read)
++              return do_sync_read;
 +      return ERR_PTR(-ENOSYS);
 +}
 +
@@ -30779,12 +32231,10 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +{
 +      const struct file_operations *fop = h_file->f_op;
 +
-+      if (fop) {
-+              if (fop->write)
-+                      return fop->write;
-+              if (fop->aio_write)
-+                      return do_sync_write;
-+      }
++      if (fop->write)
++              return fop->write;
++      if (fop->aio_write)
++              return do_sync_write;
 +      return ERR_PTR(-ENOSYS);
 +}
 +
@@ -31088,35 +32538,12 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +out:
 +      return err;
 +}
-diff -urN /usr/share/empty/include/linux/aufs_type.h linux/include/linux/aufs_type.h
---- /usr/share/empty/include/linux/aufs_type.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/include/linux/aufs_type.h    2013-07-06 13:20:47.760198800 +0200
-@@ -0,0 +1,19 @@
-+/*
-+ * Copyright (C) 2012-2013 Junjiro R. Okajima
-+ *
-+ * This program, aufs 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
-+ */
-+
-+#include <uapi/linux/aufs_type.h>
 diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/linux/aufs_type.h
 --- /usr/share/empty/include/uapi/linux/aufs_type.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/include/uapi/linux/aufs_type.h       2013-07-06 13:20:47.760198800 +0200
-@@ -0,0 +1,235 @@
++++ linux/include/uapi/linux/aufs_type.h       2014-04-24 22:11:10.935269950 +0200
+@@ -0,0 +1,281 @@
 +/*
-+ * Copyright (C) 2005-2013 Junjiro R. Okajima
++ * Copyright (C) 2005-2014 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -31129,8 +32556,7 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 + * 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
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + */
 +
 +#ifndef __AUFS_TYPE_H__
@@ -31157,7 +32583,7 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +
 +#include <linux/limits.h>
 +
-+#define AUFS_VERSION  "3.x-rcN-20130701"
++#define AUFS_VERSION  "3.14-20140407"
 +
 +/* todo? move this to linux-2.6.19/include/magic.h */
 +#define AUFS_SUPER_MAGIC      ('a' << 24 | 'u' << 16 | 'f' << 8 | 's')
@@ -31201,8 +32627,8 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +                              - AUFS_WH_TMP_LEN)      /* hex */
 +#define AUFS_XINO_FNAME               "." AUFS_NAME ".xino"
 +#define AUFS_XINO_DEFPATH     "/tmp/" AUFS_XINO_FNAME
-+#define AUFS_XINO_TRUNC_INIT  64 /* blocks */
-+#define AUFS_XINO_TRUNC_STEP  4  /* blocks */
++#define AUFS_XINO_DEF_SEC     30 /* seconds */
++#define AUFS_XINO_DEF_TRUNC   45 /* percentage */
 +#define AUFS_DIRWH_DEF                3
 +#define AUFS_RDCACHE_DEF      10 /* seconds */
 +#define AUFS_RDCACHE_MAX      3600 /* seconds */
@@ -31250,7 +32676,10 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +      AuCtl_WBR_FD,
 +
 +      /* busy inode */
-+      AuCtl_IBUSY
++      AuCtl_IBUSY,
++
++      /* move-down */
++      AuCtl_MVDOWN
 +};
 +
 +/* borrowed from linux/include/linux/kernel.h */
@@ -31342,11 +32771,345 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +
 +/* ---------------------------------------------------------------------- */
 +
++/* error code for move-down */
++/* the actual message strings are implemented in aufs-util.git */
++enum {
++      EAU_MVDOWN_OPAQUE = 1,
++      EAU_MVDOWN_WHITEOUT,
++      EAU_MVDOWN_UPPER,
++      EAU_MVDOWN_BOTTOM,
++      EAU_MVDOWN_NOUPPER,
++      EAU_MVDOWN_NOLOWERBR,
++      EAU_Last
++};
++
++/* flags for move-down */
++#define AUFS_MVDOWN_DMSG      1
++#define AUFS_MVDOWN_OWLOWER   (1 << 1)        /* overwrite lower */
++#define AUFS_MVDOWN_KUPPER    (1 << 2)        /* keep upper */
++#define AUFS_MVDOWN_ROLOWER   (1 << 3)        /* do even if lower is RO */
++#define AUFS_MVDOWN_ROLOWER_R (1 << 4)        /* did on lower RO */
++#define AUFS_MVDOWN_ROUPPER   (1 << 5)        /* do even if upper is RO */
++#define AUFS_MVDOWN_ROUPPER_R (1 << 6)        /* did on upper RO */
++#define AUFS_MVDOWN_BRID_UPPER        (1 << 7)        /* upper brid */
++#define AUFS_MVDOWN_BRID_LOWER        (1 << 8)        /* lower brid */
++/* will be added more */
++
++enum {
++      AUFS_MVDOWN_UPPER,
++      AUFS_MVDOWN_LOWER,
++      AUFS_MVDOWN_NARRAY
++};
++
++struct aufs_mvdown {
++      uint32_t        flags;
++      struct {
++              int16_t         bindex;
++              int16_t         brid;
++      } a[AUFS_MVDOWN_NARRAY];
++      int8_t          au_errno;
++      /* will be added more */
++} __aligned(8);
++
++/* ---------------------------------------------------------------------- */
++
 +#define AuCtlType             'A'
 +#define AUFS_CTL_RDU          _IOWR(AuCtlType, AuCtl_RDU, struct aufs_rdu)
 +#define AUFS_CTL_RDU_INO      _IOWR(AuCtlType, AuCtl_RDU_INO, struct aufs_rdu)
 +#define AUFS_CTL_WBR_FD               _IOW(AuCtlType, AuCtl_WBR_FD, \
 +                                   struct aufs_wbr_fd)
 +#define AUFS_CTL_IBUSY                _IOWR(AuCtlType, AuCtl_IBUSY, struct aufs_ibusy)
++#define AUFS_CTL_MVDOWN               _IOWR(AuCtlType, AuCtl_MVDOWN, \
++                                    struct aufs_mvdown)
 +
 +#endif /* __AUFS_TYPE_H__ */
+aufs3.14 loopback patch
+
+diff --git a/drivers/block/loop.c b/drivers/block/loop.c
+index ec278ac..1894990 100644
+--- a/drivers/block/loop.c
++++ b/drivers/block/loop.c
+@@ -514,7 +514,7 @@ out:
+ }
+ struct switch_request {
+-      struct file *file;
++      struct file *file, *virt_file;
+       struct completion wait;
+ };
+@@ -576,7 +576,8 @@ static int loop_thread(void *data)
+  * First it needs to flush existing IO, it does this by sending a magic
+  * BIO down the pipe. The completion of this BIO does the actual switch.
+  */
+-static int loop_switch(struct loop_device *lo, struct file *file)
++static int loop_switch(struct loop_device *lo, struct file *file,
++                     struct file *virt_file)
+ {
+       struct switch_request w;
+       struct bio *bio = bio_alloc(GFP_KERNEL, 0);
+@@ -584,6 +585,7 @@ static int loop_switch(struct loop_device *lo, struct file *file)
+               return -ENOMEM;
+       init_completion(&w.wait);
+       w.file = file;
++      w.virt_file = virt_file;
+       bio->bi_private = &w;
+       bio->bi_bdev = NULL;
+       loop_make_request(lo->lo_queue, bio);
+@@ -600,7 +602,7 @@ static int loop_flush(struct loop_device *lo)
+       if (!lo->lo_thread)
+               return 0;
+-      return loop_switch(lo, NULL);
++      return loop_switch(lo, NULL, NULL);
+ }
+ /*
+@@ -619,6 +621,7 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
+       mapping = file->f_mapping;
+       mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
+       lo->lo_backing_file = file;
++      lo->lo_backing_virt_file = p->virt_file;
+       lo->lo_blocksize = S_ISBLK(mapping->host->i_mode) ?
+               mapping->host->i_bdev->bd_block_size : PAGE_SIZE;
+       lo->old_gfp_mask = mapping_gfp_mask(mapping);
+@@ -627,6 +630,13 @@ out:
+       complete(&p->wait);
+ }
++static struct file *loop_real_file(struct file *file)
++{
++      struct file *f = NULL;
++      if (file->f_dentry->d_sb->s_op->real_loop)
++              f = file->f_dentry->d_sb->s_op->real_loop(file);
++      return f;
++}
+ /*
+  * loop_change_fd switched the backing store of a loopback device to
+@@ -640,6 +650,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+                         unsigned int arg)
+ {
+       struct file     *file, *old_file;
++      struct file     *f, *virt_file = NULL, *old_virt_file;
+       struct inode    *inode;
+       int             error;
+@@ -656,9 +667,16 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+       file = fget(arg);
+       if (!file)
+               goto out;
++      f = loop_real_file(file);
++      if (f) {
++              virt_file = file;
++              file = f;
++              get_file(file);
++      }
+       inode = file->f_mapping->host;
+       old_file = lo->lo_backing_file;
++      old_virt_file = lo->lo_backing_virt_file;
+       error = -EINVAL;
+@@ -670,17 +688,21 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+               goto out_putf;
+       /* and ... switch */
+-      error = loop_switch(lo, file);
++      error = loop_switch(lo, file, virt_file);
+       if (error)
+               goto out_putf;
+       fput(old_file);
++      if (old_virt_file)
++              fput(old_virt_file);
+       if (lo->lo_flags & LO_FLAGS_PARTSCAN)
+               ioctl_by_bdev(bdev, BLKRRPART, 0);
+       return 0;
+  out_putf:
+       fput(file);
++      if (virt_file)
++              fput(virt_file);
+  out:
+       return error;
+ }
+@@ -841,7 +863,7 @@ static void loop_config_discard(struct loop_device *lo)
+ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+                      struct block_device *bdev, unsigned int arg)
+ {
+-      struct file     *file, *f;
++      struct file     *file, *f, *virt_file = NULL;
+       struct inode    *inode;
+       struct address_space *mapping;
+       unsigned lo_blocksize;
+@@ -856,6 +878,12 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+       file = fget(arg);
+       if (!file)
+               goto out;
++      f = loop_real_file(file);
++      if (f) {
++              virt_file = file;
++              file = f;
++              get_file(file);
++      }
+       error = -EBUSY;
+       if (lo->lo_state != Lo_unbound)
+@@ -904,6 +932,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+       lo->lo_device = bdev;
+       lo->lo_flags = lo_flags;
+       lo->lo_backing_file = file;
++      lo->lo_backing_virt_file = virt_file;
+       lo->transfer = transfer_none;
+       lo->ioctl = NULL;
+       lo->lo_sizelimit = 0;
+@@ -948,6 +977,7 @@ out_clr:
+       lo->lo_thread = NULL;
+       lo->lo_device = NULL;
+       lo->lo_backing_file = NULL;
++      lo->lo_backing_virt_file = NULL;
+       lo->lo_flags = 0;
+       set_capacity(lo->lo_disk, 0);
+       invalidate_bdev(bdev);
+@@ -957,6 +987,8 @@ out_clr:
+       lo->lo_state = Lo_unbound;
+  out_putf:
+       fput(file);
++      if (virt_file)
++              fput(virt_file);
+  out:
+       /* This is safe: open() is still holding a reference. */
+       module_put(THIS_MODULE);
+@@ -1003,6 +1035,7 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
+ static int loop_clr_fd(struct loop_device *lo)
+ {
+       struct file *filp = lo->lo_backing_file;
++      struct file *virt_filp = lo->lo_backing_virt_file;
+       gfp_t gfp = lo->old_gfp_mask;
+       struct block_device *bdev = lo->lo_device;
+@@ -1036,6 +1069,7 @@ static int loop_clr_fd(struct loop_device *lo)
+       spin_lock_irq(&lo->lo_lock);
+       lo->lo_backing_file = NULL;
++      lo->lo_backing_virt_file = NULL;
+       spin_unlock_irq(&lo->lo_lock);
+       loop_release_xfer(lo);
+@@ -1078,6 +1112,8 @@ static int loop_clr_fd(struct loop_device *lo)
+        * bd_mutex which is usually taken before lo_ctl_mutex.
+        */
+       fput(filp);
++      if (virt_filp)
++              fput(virt_filp);
+       return 0;
+ }
+diff --git a/drivers/block/loop.h b/drivers/block/loop.h
+index 90df5d6..cb91822 100644
+--- a/drivers/block/loop.h
++++ b/drivers/block/loop.h
+@@ -44,7 +44,7 @@ struct loop_device {
+       int             (*ioctl)(struct loop_device *, int cmd, 
+                                unsigned long arg); 
+-      struct file *   lo_backing_file;
++      struct file *   lo_backing_file, *lo_backing_virt_file;
+       struct block_device *lo_device;
+       unsigned        lo_blocksize;
+       void            *key_data; 
+diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c
+index 2e0302d..b35af58 100644
+--- a/fs/aufs/f_op.c
++++ b/fs/aufs/f_op.c
+@@ -337,7 +337,7 @@ static ssize_t aufs_splice_read(struct file *file, loff_t *ppos,
+       err = -EINVAL;
+       h_file = au_hf_top(file);
+       get_file(h_file);
+-      if (au_test_loopback_kthread()) {
++      if (0 && au_test_loopback_kthread()) {
+               au_warn_loopback(h_file->f_dentry->d_sb);
+               if (file->f_mapping != h_file->f_mapping) {
+                       file->f_mapping = h_file->f_mapping;
+diff --git a/fs/aufs/loop.c b/fs/aufs/loop.c
+index 3b03b52..4ab749d 100644
+--- a/fs/aufs/loop.c
++++ b/fs/aufs/loop.c
+@@ -130,3 +130,19 @@ void au_loopback_fin(void)
+       symbol_put(loop_backing_file);
+       kfree(au_warn_loopback_array);
+ }
++
++/* ---------------------------------------------------------------------- */
++
++/* support the loopback block device insude aufs */
++
++struct file *aufs_real_loop(struct file *file)
++{
++      struct file *f;
++
++      BUG_ON(!au_test_aufs(file->f_dentry->d_sb));
++      fi_read_lock(file);
++      f = au_hf_top(file);
++      fi_read_unlock(file);
++      AuDebugOn(!f);
++      return f;
++}
+diff --git a/fs/aufs/loop.h b/fs/aufs/loop.h
+index da8b756..28cb7ea 100644
+--- a/fs/aufs/loop.h
++++ b/fs/aufs/loop.h
+@@ -25,7 +25,11 @@ void au_warn_loopback(struct super_block *h_sb);
+ int au_loopback_init(void);
+ void au_loopback_fin(void);
++
++struct file *aufs_real_loop(struct file *file);
+ #else
++AuStub(struct file *, loop_backing_file, return NULL)
++
+ AuStubInt0(au_test_loopback_overlap, struct super_block *sb,
+          struct dentry *h_adding)
+ AuStubInt0(au_test_loopback_kthread, void)
+@@ -33,6 +37,8 @@ AuStubVoid(au_warn_loopback, struct super_block *h_sb)
+ AuStubInt0(au_loopback_init, void)
+ AuStubVoid(au_loopback_fin, void)
++
++AuStub(struct file *, aufs_real_loop, return NULL, struct file *file)
+ #endif /* BLK_DEV_LOOP */
+ #endif /* __KERNEL__ */
+diff --git a/fs/aufs/super.c b/fs/aufs/super.c
+index b609e5a..e3909ed 100644
+--- a/fs/aufs/super.c
++++ b/fs/aufs/super.c
+@@ -807,7 +807,10 @@ static const struct super_operations aufs_sop = {
+       .statfs         = aufs_statfs,
+       .put_super      = aufs_put_super,
+       .sync_fs        = aufs_sync_fs,
+-      .remount_fs     = aufs_remount_fs
++      .remount_fs     = aufs_remount_fs,
++#ifdef CONFIG_AUFS_BDEV_LOOP
++      .real_loop      = aufs_real_loop
++#endif
+ };
+ /* ---------------------------------------------------------------------- */
+diff --git a/include/linux/fs.h b/include/linux/fs.h
+index f3f635c..c4308ca 100644
+--- a/include/linux/fs.h
++++ b/include/linux/fs.h
+@@ -1626,6 +1626,10 @@ struct super_operations {
+       int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
+       long (*nr_cached_objects)(struct super_block *, int);
+       long (*free_cached_objects)(struct super_block *, long, int);
++#if defined(CONFIG_BLK_DEV_LOOP) ||  defined(CONFIG_BLK_DEV_LOOP_MODULE)
++      /* and aufs */
++      struct file *(*real_loop)(struct file *);
++#endif
+ };
+ /*
This page took 0.87283 seconds and 4 git commands to generate.