]> git.pld-linux.org Git - packages/kernel.git/blobdiff - kernel-aufs4.patch
- up to 4.9.81; vserver up to 2.3.9.7
[packages/kernel.git] / kernel-aufs4.patch
index 64ad03c7eb7187c23a1581c5de02f9df6bd34847..16f65cba11a7c76dd1d7cc62a77312fd9fa04d0a 100644 (file)
@@ -1,10 +1,10 @@
-aufs4.x-rcN kbuild patch
+aufs4.9 kbuild patch
 
 diff --git a/fs/Kconfig b/fs/Kconfig
-index b8fcb41..78adefb 100644
+index 4bd03a2..620e01b 100644
 --- a/fs/Kconfig
 +++ b/fs/Kconfig
-@@ -236,6 +236,7 @@ source "fs/pstore/Kconfig"
+@@ -249,6 +249,7 @@ source "fs/pstore/Kconfig"
  source "fs/sysv/Kconfig"
  source "fs/ufs/Kconfig"
  source "fs/exofs/Kconfig"
@@ -13,16 +13,16 @@ index b8fcb41..78adefb 100644
  endif # MISC_FILESYSTEMS
  
 diff --git a/fs/Makefile b/fs/Makefile
-index 85b6e13..e7bb164 100644
+index ed2b632..aa6d14b 100644
 --- a/fs/Makefile
 +++ b/fs/Makefile
-@@ -128,3 +128,4 @@ obj-y                              += exofs/ # Multiple modules
+@@ -129,3 +129,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 8bdae34..65dbd5f 100644
+index cd2be1c..78f3c68 100644
 --- a/include/uapi/linux/Kbuild
 +++ b/include/uapi/linux/Kbuild
 @@ -59,6 +59,7 @@ header-y += atmsvc.h
@@ -33,13 +33,13 @@ index 8bdae34..65dbd5f 100644
  header-y += auto_fs4.h
  header-y += auto_fs.h
  header-y += auxvec.h
-aufs4.x-rcN base patch
+aufs4.9 base patch
 
 diff --git a/MAINTAINERS b/MAINTAINERS
-index 952fd2a..6a8f0f8 100644
+index 63cefa6..d78b954 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
-@@ -2210,6 +2210,19 @@ F:      include/linux/audit.h
+@@ -2293,6 +2293,19 @@ F:      include/linux/audit.h
  F:    include/uapi/linux/audit.h
  F:    kernel/audit*
  
@@ -60,10 +60,10 @@ index 952fd2a..6a8f0f8 100644
  M:    Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
  W:    http://miguelojeda.es/auxdisplay.htm
 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
-index 1fa8cc2..7339e65 100644
+index fa1b7a9..6ee9235 100644
 --- a/drivers/block/loop.c
 +++ b/drivers/block/loop.c
-@@ -712,6 +712,24 @@ static inline int is_loop_device(struct file *file)
+@@ -701,6 +701,24 @@ static inline int is_loop_device(struct file *file)
        return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
  }
  
@@ -89,10 +89,10 @@ index 1fa8cc2..7339e65 100644
  
  static ssize_t loop_attr_show(struct device *dev, char *page,
 diff --git a/fs/dcache.c b/fs/dcache.c
-index d6847d7..c3c0b6d 100644
+index 5c7cc95..df0268c 100644
 --- a/fs/dcache.c
 +++ b/fs/dcache.c
-@@ -1202,7 +1202,7 @@ enum d_walk_ret {
+@@ -1164,7 +1164,7 @@ enum d_walk_ret {
   *
   * The @enter() and @finish() callbacks are called with d_lock held.
   */
@@ -124,10 +124,10 @@ index 350a2c8..6f42279 100644
                return error;
  
 diff --git a/fs/inode.c b/fs/inode.c
-index 4ccbc21..aa6d071 100644
+index 88110fd..9a9ba3a 100644
 --- a/fs/inode.c
 +++ b/fs/inode.c
-@@ -1591,7 +1591,7 @@ EXPORT_SYMBOL(generic_update_time);
+@@ -1642,7 +1642,7 @@ int generic_update_time(struct inode *inode, struct timespec *time, int flags)
   * This does the actual work of updating an inodes time or version.  Must have
   * had called mnt_want_write() before calling this.
   */
@@ -137,7 +137,7 @@ index 4ccbc21..aa6d071 100644
        int (*update_time)(struct inode *, struct timespec *, int);
  
 diff --git a/fs/read_write.c b/fs/read_write.c
-index 933b53a..2d13282 100644
+index 190e0d36..4052813 100644
 --- a/fs/read_write.c
 +++ b/fs/read_write.c
 @@ -515,6 +515,28 @@ ssize_t __vfs_write(struct file *file, const char __user *p, size_t count,
@@ -170,10 +170,10 @@ index 933b53a..2d13282 100644
  {
        mm_segment_t old_fs;
 diff --git a/fs/splice.c b/fs/splice.c
-index dd9bf7e..9326c2a 100644
+index 5a7750b..28160a7 100644
 --- a/fs/splice.c
 +++ b/fs/splice.c
-@@ -1111,8 +1111,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
+@@ -855,8 +855,8 @@ ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out,
  /*
   * Attempt to initiate a splice from pipe to file.
   */
@@ -184,7 +184,7 @@ index dd9bf7e..9326c2a 100644
  {
        ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
                                loff_t *, size_t, unsigned int);
-@@ -1128,9 +1128,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+@@ -872,9 +872,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.
   */
@@ -201,7 +201,7 @@ diff --git a/include/linux/file.h b/include/linux/file.h
 index 7444f5f..bdac0be 100644
 --- a/include/linux/file.h
 +++ b/include/linux/file.h
-@@ -19,6 +19,7 @@ struct dentry;
+@@ -19,6 +19,7 @@
  struct path;
  extern struct file *alloc_file(struct path *, fmode_t mode,
        const struct file_operations *fop);
@@ -210,10 +210,10 @@ index 7444f5f..bdac0be 100644
  static inline void fput_light(struct file *file, int fput_needed)
  {
 diff --git a/include/linux/fs.h b/include/linux/fs.h
-index dd28814..b689a48 100644
+index dc0478c..27c05e7 100644
 --- a/include/linux/fs.h
 +++ b/include/linux/fs.h
-@@ -1306,6 +1306,7 @@ extern void fasync_free(struct fasync_struct *);
+@@ -1291,6 +1291,7 @@ struct fasync_struct {
  /* can be called from interrupts */
  extern void kill_fasync(struct fasync_struct **, int, int);
  
@@ -221,7 +221,7 @@ index dd28814..b689a48 100644
  extern void __f_setown(struct file *filp, struct pid *, enum pid_type, int force);
  extern void f_setown(struct file *filp, unsigned long arg, int force);
  extern void f_delown(struct file *filp);
-@@ -1690,6 +1691,7 @@ struct file_operations {
+@@ -1715,6 +1716,7 @@ struct file_operations {
        ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
        unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
        int (*check_flags)(int);
@@ -229,7 +229,7 @@ index dd28814..b689a48 100644
        int (*flock) (struct file *, int, struct file_lock *);
        ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
        ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
-@@ -1750,6 +1752,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
+@@ -1768,6 +1770,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
                              struct iovec *fast_pointer,
                              struct iovec **ret_pointer);
  
@@ -242,7 +242,7 @@ index dd28814..b689a48 100644
  extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *);
  extern ssize_t __vfs_write(struct file *, const char __user *, size_t, loff_t *);
  extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
-@@ -2105,6 +2113,7 @@ extern int current_umask(void);
+@@ -2140,6 +2148,7 @@ extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
  extern void ihold(struct inode * inode);
  extern void iput(struct inode *);
  extern int generic_update_time(struct inode *, struct timespec *, int);
@@ -251,13 +251,13 @@ index dd28814..b689a48 100644
  /* /sys/fs */
  extern struct kobject *fs_kobj;
 diff --git a/include/linux/splice.h b/include/linux/splice.h
-index da2751d..2e0fca6 100644
+index 00a2116..1f0a4a2 100644
 --- a/include/linux/splice.h
 +++ b/include/linux/splice.h
-@@ -83,4 +83,10 @@ extern void splice_shrink_spd(struct splice_pipe_desc *);
- extern void spd_release_page(struct splice_pipe_desc *, unsigned int);
+@@ -86,4 +86,10 @@ extern ssize_t splice_direct_to_actor(struct file *, struct splice_desc *,
  
  extern const struct pipe_buf_operations page_cache_pipe_buf_ops;
+ extern const struct pipe_buf_operations default_pipe_buf_ops;
 +
 +extern long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
 +                         loff_t *ppos, size_t len, unsigned int flags);
@@ -265,13 +265,13 @@ index da2751d..2e0fca6 100644
 +                       struct pipe_inode_info *pipe, size_t len,
 +                       unsigned int flags);
  #endif
-aufs4.x-rcN mmap patch
+aufs4.9 mmap patch
 
 diff --git a/fs/proc/base.c b/fs/proc/base.c
-index a11eb71..8f10865 100644
+index ca651ac..0e8551a 100644
 --- a/fs/proc/base.c
 +++ b/fs/proc/base.c
-@@ -1939,7 +1939,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)
+@@ -1953,7 +1953,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)
        down_read(&mm->mmap_sem);
        vma = find_exact_vma(mm, vm_start, vm_end);
        if (vma && vma->vm_file) {
@@ -297,10 +297,10 @@ index f8595e8..cb8eda0 100644
                ino = inode->i_ino;
        }
 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
-index 4648c7f..061cb85 100644
+index 35b92d8..5b981db 100644
 --- a/fs/proc/task_mmu.c
 +++ b/fs/proc/task_mmu.c
-@@ -298,7 +298,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
+@@ -291,7 +291,10 @@ static int is_stack(struct proc_maps_private *priv,
        const char *name = NULL;
  
        if (file) {
@@ -312,7 +312,7 @@ index 4648c7f..061cb85 100644
                dev = inode->i_sb->s_dev;
                ino = inode->i_ino;
                pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
-@@ -1624,7 +1627,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
+@@ -1627,7 +1630,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
        struct proc_maps_private *proc_priv = &numa_priv->proc_maps;
        struct vm_area_struct *vma = v;
        struct numa_maps *md = &numa_priv->md;
@@ -322,10 +322,10 @@ index 4648c7f..061cb85 100644
        struct mm_walk walk = {
                .hugetlb_entry = gather_hugetlb_stats,
 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
-index faacb0c..17b43be 100644
+index 3717562..6a328f1 100644
 --- a/fs/proc/task_nommu.c
 +++ b/fs/proc/task_nommu.c
-@@ -163,7 +163,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
+@@ -155,7 +155,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
        file = vma->vm_file;
  
        if (file) {
@@ -338,10 +338,10 @@ index faacb0c..17b43be 100644
                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 ece042d..1e24513 100644
+index a92c8d7..1d83a2a 100644
 --- a/include/linux/mm.h
 +++ b/include/linux/mm.h
-@@ -1239,6 +1239,28 @@ static inline int fixup_user_fault(struct task_struct *tsk,
+@@ -1266,6 +1266,28 @@ static inline int fixup_user_fault(struct task_struct *tsk,
  }
  #endif
  
@@ -367,14 +367,14 @@ index ece042d..1e24513 100644
 +#define vmr_fput(region)              vmr_do_fput(region, __func__, __LINE__)
 +#endif /* !CONFIG_MMU */
 +
- extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
+ extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len,
+               unsigned int gup_flags);
  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 ca3e517..10bc491 100644
+index 4a8aced..badd16b 100644
 --- a/include/linux/mm_types.h
 +++ b/include/linux/mm_types.h
-@@ -274,6 +274,7 @@ struct vm_region {
+@@ -275,6 +275,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 */
@@ -382,7 +382,7 @@ index ca3e517..10bc491 100644
  
        int             vm_usage;       /* region usage count (access under nommu_region_sem) */
        bool            vm_icache_flushed : 1; /* true if the icache has been flushed for
-@@ -348,6 +349,7 @@ struct vm_area_struct {
+@@ -349,6 +350,7 @@ struct vm_area_struct {
        unsigned long vm_pgoff;         /* Offset (within vm_file) in PAGE_SIZE
                                           units */
        struct file * vm_file;          /* File we map to (can be NULL). */
@@ -391,10 +391,10 @@ index ca3e517..10bc491 100644
  
  #ifndef CONFIG_MMU
 diff --git a/kernel/fork.c b/kernel/fork.c
-index 4a7ec0c..8c8f7ac 100644
+index 997ac1d..4d0131b 100644
 --- a/kernel/fork.c
 +++ b/kernel/fork.c
-@@ -479,7 +479,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
+@@ -624,7 +624,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
                        struct inode *inode = file_inode(file);
                        struct address_space *mapping = file->f_mapping;
  
@@ -404,7 +404,7 @@ index 4a7ec0c..8c8f7ac 100644
                                atomic_dec(&inode->i_writecount);
                        i_mmap_lock_write(mapping);
 diff --git a/mm/Makefile b/mm/Makefile
-index 78c6f7d..aea4230 100644
+index 295bd7a..14fa1c8 100644
 --- a/mm/Makefile
 +++ b/mm/Makefile
 @@ -37,7 +37,7 @@ obj-y                        := filemap.o mempool.o oom_kill.o \
@@ -417,10 +417,10 @@ index 78c6f7d..aea4230 100644
  obj-y += init-mm.o
  
 diff --git a/mm/filemap.c b/mm/filemap.c
-index 20f3b1f..ee827ce 100644
+index 50b52fe..9e607f9 100644
 --- a/mm/filemap.c
 +++ b/mm/filemap.c
-@@ -2208,7 +2208,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -2304,7 +2304,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);
@@ -430,10 +430,10 @@ index 20f3b1f..ee827ce 100644
        if (page->mapping != inode->i_mapping) {
                unlock_page(page);
 diff --git a/mm/memory.c b/mm/memory.c
-index cd1f29e..f0c204c 100644
+index e18c57b..7be4a39 100644
 --- a/mm/memory.c
 +++ b/mm/memory.c
-@@ -2100,7 +2100,7 @@ static inline int wp_page_reuse(struct mm_struct *mm,
+@@ -2117,7 +2117,7 @@ static inline int wp_page_reuse(struct fault_env *fe, pte_t orig_pte,
                }
  
                if (!page_mkwrite)
@@ -443,10 +443,10 @@ index cd1f29e..f0c204c 100644
  
        return VM_FAULT_WRITE;
 diff --git a/mm/mmap.c b/mm/mmap.c
-index de2c176..b7f391c 100644
+index 1af87c1..95b0ff4 100644
 --- a/mm/mmap.c
 +++ b/mm/mmap.c
-@@ -162,7 +162,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
+@@ -170,7 +170,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)
@@ -455,7 +455,7 @@ index de2c176..b7f391c 100644
        mpol_put(vma_policy(vma));
        kmem_cache_free(vm_area_cachep, vma);
        return next;
-@@ -782,7 +782,7 @@ again:                     remove_next = 1 + (end > next->vm_end);
+@@ -879,7 +879,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
        if (remove_next) {
                if (file) {
                        uprobe_munmap(next, next->vm_start, next->vm_end);
@@ -464,7 +464,7 @@ index de2c176..b7f391c 100644
                }
                if (next->anon_vma)
                        anon_vma_merge(vma, next);
-@@ -1563,8 +1563,8 @@ out:
+@@ -1727,8 +1727,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
        return addr;
  
  unmap_and_free_vma:
@@ -474,7 +474,7 @@ index de2c176..b7f391c 100644
  
        /* Undo any partial mapping done by a device driver. */
        unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
-@@ -2358,7 +2358,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
+@@ -2533,7 +2533,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
                goto out_free_mpol;
  
        if (new->vm_file)
@@ -483,7 +483,7 @@ index de2c176..b7f391c 100644
  
        if (new->vm_ops && new->vm_ops->open)
                new->vm_ops->open(new);
-@@ -2377,7 +2377,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
+@@ -2552,7 +2552,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)
@@ -492,7 +492,7 @@ index de2c176..b7f391c 100644
        unlink_anon_vmas(new);
   out_free_mpol:
        mpol_put(vma_policy(new));
-@@ -2528,7 +2528,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
+@@ -2703,7 +2703,7 @@ int vm_munmap(unsigned long start, size_t len)
        struct vm_area_struct *vma;
        unsigned long populate = 0;
        unsigned long ret = -EINVAL;
@@ -501,7 +501,7 @@ index de2c176..b7f391c 100644
  
        pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. See Documentation/vm/remap_file_pages.txt.\n",
                     current->comm, current->pid);
-@@ -2597,10 +2597,27 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
+@@ -2778,10 +2778,27 @@ int vm_munmap(unsigned long start, size_t len)
                }
        }
  
@@ -530,7 +530,7 @@ index de2c176..b7f391c 100644
  out:
        up_write(&mm->mmap_sem);
        if (populate)
-@@ -2873,7 +2890,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
+@@ -3056,7 +3073,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)
@@ -540,10 +540,10 @@ index de2c176..b7f391c 100644
                        new_vma->vm_ops->open(new_vma);
                vma_link(mm, new_vma, prev, rb_link, rb_parent);
 diff --git a/mm/nommu.c b/mm/nommu.c
-index c2e588802..c39edc4 100644
+index 8b8faaf..5d26ed94 100644
 --- a/mm/nommu.c
 +++ b/mm/nommu.c
-@@ -644,7 +644,7 @@ static void __put_nommu_region(struct vm_region *region)
+@@ -636,7 +636,7 @@ static void __put_nommu_region(struct vm_region *region)
                up_write(&nommu_region_sem);
  
                if (region->vm_file)
@@ -552,7 +552,7 @@ index c2e588802..c39edc4 100644
  
                /* IO memory and memory shared directly out of the pagecache
                 * from ramfs/tmpfs mustn't be released here */
-@@ -802,7 +802,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
+@@ -794,7 +794,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)
@@ -561,7 +561,7 @@ index c2e588802..c39edc4 100644
        put_nommu_region(vma->vm_region);
        kmem_cache_free(vm_area_cachep, vma);
  }
-@@ -1328,7 +1328,7 @@ unsigned long do_mmap(struct file *file,
+@@ -1320,7 +1320,7 @@ unsigned long do_mmap(struct file *file,
                                        goto error_just_free;
                                }
                        }
@@ -570,7 +570,7 @@ index c2e588802..c39edc4 100644
                        kmem_cache_free(vm_region_jar, region);
                        region = pregion;
                        result = start;
-@@ -1403,10 +1403,10 @@ error_just_free:
+@@ -1395,10 +1395,10 @@ unsigned long do_mmap(struct file *file,
        up_write(&nommu_region_sem);
  error:
        if (region->vm_file)
@@ -675,13 +675,13 @@ index 0000000..b323b8a
 +              fput(pr);
 +}
 +#endif /* !CONFIG_MMU */
-aufs4.x-rcN standalone patch
+aufs4.9 standalone patch
 
 diff --git a/fs/dcache.c b/fs/dcache.c
-index c3c0b6d..c99d2d2 100644
+index df0268c..755fea1 100644
 --- a/fs/dcache.c
 +++ b/fs/dcache.c
-@@ -1310,6 +1310,7 @@ rename_retry:
+@@ -1272,6 +1272,7 @@ void d_walk(struct dentry *parent, void *data,
        seq = 1;
        goto again;
  }
@@ -689,8 +689,16 @@ index c3c0b6d..c99d2d2 100644
  
  /*
   * Search for at least 1 mount point in the dentry's subdirs.
+@@ -2855,6 +2856,7 @@ void d_exchange(struct dentry *dentry1, struct dentry *dentry2)
+       write_sequnlock(&rename_lock);
+ }
++EXPORT_SYMBOL_GPL(d_exchange);
+ /**
+  * d_ancestor - search for an ancestor
 diff --git a/fs/exec.c b/fs/exec.c
-index 887c1c9..40e8767 100644
+index 4e497b9..e27d323 100644
 --- a/fs/exec.c
 +++ b/fs/exec.c
 @@ -104,6 +104,7 @@ bool path_noexec(const struct path *path)
@@ -717,7 +725,7 @@ diff --git a/fs/file_table.c b/fs/file_table.c
 index ad17e05..ae9f267 100644
 --- a/fs/file_table.c
 +++ b/fs/file_table.c
-@@ -147,6 +147,7 @@ over:
+@@ -147,6 +147,7 @@ struct file *get_empty_filp(void)
        }
        return ERR_PTR(-ENFILE);
  }
@@ -750,10 +758,10 @@ index ad17e05..ae9f267 100644
  void __init files_init(void)
  { 
 diff --git a/fs/inode.c b/fs/inode.c
-index aa6d071..f336032 100644
+index 9a9ba3a..a3a18d8 100644
 --- a/fs/inode.c
 +++ b/fs/inode.c
-@@ -1600,6 +1600,7 @@ int update_time(struct inode *inode, struct timespec *time, int flags)
+@@ -1651,6 +1651,7 @@ int update_time(struct inode *inode, struct timespec *time, int flags)
  
        return update_time(inode, time, flags);
  }
@@ -762,10 +770,10 @@ index aa6d071..f336032 100644
  /**
   *    touch_atime     -       update the access time
 diff --git a/fs/namespace.c b/fs/namespace.c
-index 783004a..44abb2d 100644
+index e6c234b..8d13f7b 100644
 --- a/fs/namespace.c
 +++ b/fs/namespace.c
-@@ -463,6 +463,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
+@@ -466,6 +466,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
        mnt_dec_writers(real_mount(mnt));
        preempt_enable();
  }
@@ -773,7 +781,7 @@ index 783004a..44abb2d 100644
  
  /**
   * mnt_drop_write - give up write access to a mount
-@@ -1811,6 +1812,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
+@@ -1823,6 +1824,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
        }
        return 0;
  }
@@ -782,7 +790,7 @@ index 783004a..44abb2d 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 3e2dd85..b17cb4b 100644
+index fbe3cbe..bdfc61e 100644
 --- a/fs/notify/group.c
 +++ b/fs/notify/group.c
 @@ -22,6 +22,7 @@
@@ -793,7 +801,7 @@ index 3e2dd85..b17cb4b 100644
  
  #include <linux/fsnotify_backend.h>
  #include "fsnotify.h"
-@@ -81,6 +82,7 @@ void fsnotify_get_group(struct fsnotify_group *group)
+@@ -100,6 +101,7 @@ void fsnotify_get_group(struct fsnotify_group *group)
  {
        atomic_inc(&group->refcnt);
  }
@@ -801,7 +809,7 @@ index 3e2dd85..b17cb4b 100644
  
  /*
   * Drop a reference to a group.  Free it if it's through.
-@@ -90,6 +92,7 @@ void fsnotify_put_group(struct fsnotify_group *group)
+@@ -109,6 +111,7 @@ void fsnotify_put_group(struct fsnotify_group *group)
        if (atomic_dec_and_test(&group->refcnt))
                fsnotify_final_destroy_group(group);
  }
@@ -809,7 +817,7 @@ index 3e2dd85..b17cb4b 100644
  
  /*
   * Create a new fsnotify_group and hold a reference for the group returned.
-@@ -118,6 +121,7 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
+@@ -137,6 +140,7 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
  
        return group;
  }
@@ -837,7 +845,7 @@ index d3fea0b..5fc06ad 100644
  
  void fsnotify_destroy_marks(struct hlist_head *head, spinlock_t *lock)
  {
-@@ -415,6 +417,7 @@ err:
+@@ -415,6 +417,7 @@ int fsnotify_add_mark_locked(struct fsnotify_mark *mark,
  
        return ret;
  }
@@ -854,7 +862,7 @@ index d3fea0b..5fc06ad 100644
  /*
   * Destroy all marks in destroy_list, waits for SRCU period to finish before
 diff --git a/fs/open.c b/fs/open.c
-index 93ae3cd..d25b9bd 100644
+index d3ed817..20d2494 100644
 --- a/fs/open.c
 +++ b/fs/open.c
 @@ -64,6 +64,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
@@ -865,7 +873,7 @@ index 93ae3cd..d25b9bd 100644
  
  long vfs_truncate(const struct path *path, loff_t length)
  {
-@@ -678,6 +679,7 @@ int open_check_o_direct(struct file *f)
+@@ -695,6 +696,7 @@ int open_check_o_direct(struct file *f)
        }
        return 0;
  }
@@ -874,7 +882,7 @@ index 93ae3cd..d25b9bd 100644
  static int do_dentry_open(struct file *f,
                          struct inode *inode,
 diff --git a/fs/read_write.c b/fs/read_write.c
-index 2d13282..260c4a4 100644
+index 4052813..7dfd732 100644
 --- a/fs/read_write.c
 +++ b/fs/read_write.c
 @@ -525,6 +525,7 @@ vfs_readf_t vfs_readf(struct file *file)
@@ -894,10 +902,10 @@ index 2d13282..260c4a4 100644
  ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos)
  {
 diff --git a/fs/splice.c b/fs/splice.c
-index 9326c2a..0606690 100644
+index 28160a7..98c1902 100644
 --- a/fs/splice.c
 +++ b/fs/splice.c
-@@ -1124,6 +1124,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+@@ -868,6 +868,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
  
        return splice_write(pipe, out, ppos, len, flags);
  }
@@ -905,7 +913,7 @@ index 9326c2a..0606690 100644
  
  /*
   * Attempt to initiate a splice from a file to a pipe.
-@@ -1153,6 +1154,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
+@@ -897,6 +898,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
  
        return splice_read(in, ppos, pipe, len, flags);
  }
@@ -914,31 +922,31 @@ index 9326c2a..0606690 100644
  /**
   * splice_direct_to_actor - splices data directly between two non-pipes
 diff --git a/fs/xattr.c b/fs/xattr.c
-index 4beafc4..e118715 100644
+index 2d13b4e..41c2bcd 100644
 --- a/fs/xattr.c
 +++ b/fs/xattr.c
-@@ -207,6 +207,7 @@ vfs_getxattr_alloc(struct dentry *dentry, const char *name, char **xattr_value,
+@@ -296,6 +296,7 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name,
        *xattr_value = value;
        return error;
  }
 +EXPORT_SYMBOL_GPL(vfs_getxattr_alloc);
  
  ssize_t
- vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
+ __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name,
 diff --git a/kernel/task_work.c b/kernel/task_work.c
-index 53fa971..bce3211 100644
+index d513051..e056d54 100644
 --- a/kernel/task_work.c
 +++ b/kernel/task_work.c
-@@ -118,3 +118,4 @@ void task_work_run(void)
+@@ -119,3 +119,4 @@ void task_work_run(void)
                } while (work);
        }
  }
 +EXPORT_SYMBOL_GPL(task_work_run);
 diff --git a/security/commoncap.c b/security/commoncap.c
-index e7fadde..6423e53 100644
+index 8df676f..6b5cc07 100644
 --- a/security/commoncap.c
 +++ b/security/commoncap.c
-@@ -1058,12 +1058,14 @@ int cap_mmap_addr(unsigned long addr)
+@@ -1061,12 +1061,14 @@ int cap_mmap_addr(unsigned long addr)
        }
        return ret;
  }
@@ -974,10 +982,10 @@ index 03c1652..f88c84b 100644
  int devcgroup_inode_mknod(int mode, dev_t dev)
  {
 diff --git a/security/security.c b/security/security.c
-index 7095693..da7fe2c 100644
+index f825304..8dd441d 100644
 --- a/security/security.c
 +++ b/security/security.c
-@@ -434,6 +434,7 @@ int security_path_rmdir(const struct path *dir, struct dentry *dentry)
+@@ -443,6 +443,7 @@ int security_path_rmdir(const struct path *dir, struct dentry *dentry)
                return 0;
        return call_int_hook(path_rmdir, 0, dir, dentry);
  }
@@ -985,7 +993,7 @@ index 7095693..da7fe2c 100644
  
  int security_path_unlink(const struct path *dir, struct dentry *dentry)
  {
-@@ -450,6 +451,7 @@ int security_path_symlink(const struct path *dir, struct dentry *dentry,
+@@ -459,6 +460,7 @@ int security_path_symlink(const struct path *dir, struct dentry *dentry,
                return 0;
        return call_int_hook(path_symlink, 0, dir, dentry, old_name);
  }
@@ -993,7 +1001,7 @@ index 7095693..da7fe2c 100644
  
  int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
                       struct dentry *new_dentry)
-@@ -458,6 +460,7 @@ int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
+@@ -467,6 +469,7 @@ int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
                return 0;
        return call_int_hook(path_link, 0, old_dentry, new_dir, new_dentry);
  }
@@ -1001,7 +1009,7 @@ index 7095693..da7fe2c 100644
  
  int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
                         const struct path *new_dir, struct dentry *new_dentry,
-@@ -485,6 +488,7 @@ int security_path_truncate(const struct path *path)
+@@ -494,6 +497,7 @@ int security_path_truncate(const struct path *path)
                return 0;
        return call_int_hook(path_truncate, 0, path);
  }
@@ -1009,7 +1017,7 @@ index 7095693..da7fe2c 100644
  
  int security_path_chmod(const struct path *path, umode_t mode)
  {
-@@ -492,6 +496,7 @@ int security_path_chmod(const struct path *path, umode_t mode)
+@@ -501,6 +505,7 @@ int security_path_chmod(const struct path *path, umode_t mode)
                return 0;
        return call_int_hook(path_chmod, 0, path, mode);
  }
@@ -1017,7 +1025,7 @@ index 7095693..da7fe2c 100644
  
  int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
  {
-@@ -499,6 +504,7 @@ int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
+@@ -508,6 +513,7 @@ int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
                return 0;
        return call_int_hook(path_chown, 0, path, uid, gid);
  }
@@ -1025,7 +1033,7 @@ index 7095693..da7fe2c 100644
  
  int security_path_chroot(const struct path *path)
  {
-@@ -584,6 +590,7 @@ int security_inode_readlink(struct dentry *dentry)
+@@ -593,6 +599,7 @@ int security_inode_readlink(struct dentry *dentry)
                return 0;
        return call_int_hook(inode_readlink, 0, dentry);
  }
@@ -1033,7 +1041,7 @@ index 7095693..da7fe2c 100644
  
  int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
                               bool rcu)
-@@ -599,6 +606,7 @@ int security_inode_permission(struct inode *inode, int mask)
+@@ -608,6 +615,7 @@ int security_inode_permission(struct inode *inode, int mask)
                return 0;
        return call_int_hook(inode_permission, 0, inode, mask);
  }
@@ -1041,7 +1049,7 @@ index 7095693..da7fe2c 100644
  
  int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
  {
-@@ -737,6 +745,7 @@ int security_file_permission(struct file *file, int mask)
+@@ -779,6 +787,7 @@ int security_file_permission(struct file *file, int mask)
  
        return fsnotify_perm(file, mask);
  }
@@ -1049,7 +1057,7 @@ index 7095693..da7fe2c 100644
  
  int security_file_alloc(struct file *file)
  {
-@@ -796,6 +805,7 @@ int security_mmap_file(struct file *file, unsigned long prot,
+@@ -838,6 +847,7 @@ int security_mmap_file(struct file *file, unsigned long prot,
                return ret;
        return ima_file_mmap(file, prot);
  }
@@ -1059,7 +1067,7 @@ index 7095693..da7fe2c 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       2015-09-24 10:47:58.244719488 +0200
++++ linux/Documentation/ABI/testing/debugfs-aufs       2016-10-09 16:55:36.476034536 +0200
 @@ -0,0 +1,50 @@
 +What:         /debug/aufs/si_<id>/
 +Date:         March 2009
@@ -1113,7 +1121,7 @@ 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 2015-09-24 10:47:58.244719488 +0200
++++ linux/Documentation/ABI/testing/sysfs-aufs 2016-10-09 16:55:36.476034536 +0200
 @@ -0,0 +1,31 @@
 +What:         /sys/fs/aufs/si_<id>/
 +Date:         March 2009
@@ -1148,7 +1156,7 @@ 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    2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/01intro.txt    2016-10-09 16:55:36.479367956 +0200
 @@ -0,0 +1,170 @@
 +
 +# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1322,7 +1330,7 @@ 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   2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/02struct.txt   2016-10-09 16:55:36.479367956 +0200
 @@ -0,0 +1,258 @@
 +
 +# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1584,7 +1592,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +For this purpose, use "aumvdown" command in aufs-util.git.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03atomic_open.txt linux/Documentation/filesystems/aufs/design/03atomic_open.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/03atomic_open.txt   1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/03atomic_open.txt      2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/03atomic_open.txt      2016-10-09 16:55:36.479367956 +0200
 @@ -0,0 +1,85 @@
 +
 +# Copyright (C) 2015-2016 Junjiro R. Okajima
@@ -1673,7 +1681,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03atomic_open.t
 +       be implemented in aufs, but not all I am afraid.
 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   2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/03lookup.txt   2016-10-09 16:55:36.479367956 +0200
 @@ -0,0 +1,113 @@
 +
 +# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1790,7 +1798,7 @@ 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   2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/04branch.txt   2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,74 @@
 +
 +# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1868,7 +1876,7 @@ 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       2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/05wbr_policy.txt       2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,64 @@
 +
 +# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1936,7 +1944,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.tx
 +  copyup policy.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06fhsm.txt linux/Documentation/filesystems/aufs/design/06fhsm.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/06fhsm.txt  1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/06fhsm.txt     2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/06fhsm.txt     2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,120 @@
 +
 +# Copyright (C) 2011-2016 Junjiro R. Okajima
@@ -2060,7 +2068,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06fhsm.txt linu
 +should restore the original file state after an error happens.
 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     2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/06mmap.txt     2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,72 @@
 +
 +# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -2136,7 +2144,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt linu
 +I have to give up this "looks-smater" approach.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt linux/Documentation/filesystems/aufs/design/06xattr.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/06xattr.txt    2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/06xattr.txt    2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,96 @@
 +
 +# Copyright (C) 2014-2016 Junjiro R. Okajima
@@ -2236,7 +2244,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt lin
 +now, aufs implements the branch attributes to ignore the error.
 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   2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/07export.txt   2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,58 @@
 +
 +# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -2298,7 +2306,7 @@ 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     2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/08shwh.txt     2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,52 @@
 +
 +# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -2354,7 +2362,7 @@ 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    2016-07-25 19:05:34.807826401 +0200
++++ linux/Documentation/filesystems/aufs/design/10dynop.txt    2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,47 @@
 +
 +# Copyright (C) 2010-2016 Junjiro R. Okajima
@@ -2405,8 +2413,8 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt lin
 +regular files only.
 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        2016-07-25 19:05:34.807826401 +0200
-@@ -0,0 +1,392 @@
++++ linux/Documentation/filesystems/aufs/README        2016-12-17 12:28:17.595211562 +0100
+@@ -0,0 +1,393 @@
 +
 +Aufs4 -- advanced multi layered unification filesystem version 4.x
 +http://aufs.sf.net
@@ -2782,6 +2790,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +Daniel Epellei made a donation (2015/1).
 +OmegaPhil made a donation (2016/1).
 +Tomasz Szewczyk made a donation (2016/4).
++James Burry made a donation (2016/12).
 +
 +Thank you very much.
 +Donations are always, including future donations, very important and
@@ -2801,7 +2810,7 @@ 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       2016-07-25 19:05:34.811159821 +0200
++++ linux/fs/aufs/aufs.h       2016-10-09 16:55:36.486034798 +0200
 @@ -0,0 +1,59 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -2864,8 +2873,8 @@ 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     2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,1406 @@
++++ linux/fs/aufs/branch.c     2016-10-09 16:55:38.886097714 +0200
+@@ -0,0 +1,1412 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -2919,7 +2928,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +
 +      if (br->br_fhsm) {
 +              au_br_fhsm_fin(br->br_fhsm);
-+              kfree(br->br_fhsm);
++              au_delayed_kfree(br->br_fhsm);
 +      }
 +
 +      key = br->br_dykey;
@@ -2933,8 +2942,9 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      lockdep_off();
 +      path_put(&br->br_path);
 +      lockdep_on();
-+      kfree(wbr);
-+      kfree(br);
++      if (wbr)
++              au_delayed_kfree(wbr);
++      au_delayed_kfree(br);
 +}
 +
 +/*
@@ -3021,22 +3031,23 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +                      goto out_wbr;
 +      }
 +
-+      err = au_sbr_realloc(au_sbi(sb), new_nbranch);
++      err = au_sbr_realloc(au_sbi(sb), new_nbranch, /*may_shrink*/0);
 +      if (!err)
-+              err = au_di_realloc(au_di(root), new_nbranch);
++              err = au_di_realloc(au_di(root), new_nbranch, /*may_shrink*/0);
 +      if (!err) {
 +              inode = d_inode(root);
-+              err = au_hinode_realloc(au_ii(inode), new_nbranch);
++              err = au_hinode_realloc(au_ii(inode), new_nbranch, /*may_shrink*/0);
 +      }
 +      if (!err)
 +              return add_branch; /* success */
 +
 +out_wbr:
-+      kfree(add_branch->br_wbr);
++      if (add_branch->br_wbr)
++              au_delayed_kfree(add_branch->br_wbr);
 +out_hnotify:
 +      au_hnotify_fin_br(add_branch);
 +out_br:
-+      kfree(add_branch);
++      au_delayed_kfree(add_branch);
 +out:
 +      return ERR_PTR(err);
 +}
@@ -3202,7 +3213,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      br->br_perm = old_perm;
 +
 +      if (!err && wbr && !au_br_writable(new_perm)) {
-+              kfree(wbr);
++              au_delayed_kfree(wbr);
 +              br->br_wbr = NULL;
 +      }
 +
@@ -3769,7 +3780,8 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      sbinfo->si_branch[0 + bbot] = NULL;
 +      sbinfo->si_bbot--;
 +
-+      p = krealloc(sbinfo->si_branch, sizeof(*p) * bbot, AuGFP_SBILIST);
++      p = au_krealloc(sbinfo->si_branch, sizeof(*p) * bbot, AuGFP_SBILIST,
++                      /*may_shrink*/1);
 +      if (p)
 +              sbinfo->si_branch = p;
 +      /* harmless error */
@@ -3788,7 +3800,8 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      /* au_h_dentry_init(au_hdentry(dinfo, bbot); */
 +      dinfo->di_bbot--;
 +
-+      p = krealloc(dinfo->di_hdentry, sizeof(*p) * bbot, AuGFP_SBILIST);
++      p = au_krealloc(dinfo->di_hdentry, sizeof(*p) * bbot, AuGFP_SBILIST,
++                      /*may_shrink*/1);
 +      if (p)
 +              dinfo->di_hdentry = p;
 +      /* harmless error */
@@ -3807,7 +3820,8 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      /* au_hinode_init(au_hinode(iinfo, bbot)); */
 +      iinfo->ii_bbot--;
 +
-+      p = krealloc(iinfo->ii_hinode, sizeof(*p) * bbot, AuGFP_SBILIST);
++      p = au_krealloc(iinfo->ii_hinode, sizeof(*p) * bbot, AuGFP_SBILIST,
++                      /*may_shrink*/1);
 +      if (p)
 +              iinfo->ii_hinode = p;
 +      /* harmless error */
@@ -4225,7 +4239,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              if (br->br_wbr) {
 +                      err = au_wbr_init(br, sb, mod->perm);
 +                      if (unlikely(err)) {
-+                              kfree(br->br_wbr);
++                              au_delayed_kfree(br->br_wbr);
 +                              br->br_wbr = NULL;
 +                      }
 +              }
@@ -4237,7 +4251,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              if (!au_br_fhsm(mod->perm)) {
 +                      /* fhsm --> non-fhsm */
 +                      au_br_fhsm_fin(br->br_fhsm);
-+                      kfree(br->br_fhsm);
++                      au_delayed_kfree(br->br_fhsm);
 +                      br->br_fhsm = NULL;
 +              }
 +      } else if (au_br_fhsm(mod->perm))
@@ -4249,7 +4263,8 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      goto out; /* success */
 +
 +out_bf:
-+      kfree(bf);
++      if (bf)
++              au_delayed_kfree(bf);
 +out:
 +      AuTraceErr(err);
 +      return err;
@@ -4274,7 +4289,7 @@ 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     2016-07-25 19:05:34.811159821 +0200
++++ linux/fs/aufs/branch.h     2016-10-09 16:55:36.486034798 +0200
 @@ -0,0 +1,309 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -4587,7 +4602,7 @@ 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      2015-09-24 10:47:58.248052907 +0200
++++ linux/fs/aufs/conf.mk      2016-10-09 16:55:36.486034798 +0200
 @@ -0,0 +1,38 @@
 +
 +AuConfStr = CONFIG_AUFS_FS=${CONFIG_AUFS_FS}
@@ -4629,8 +4644,8 @@ 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       2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,1383 @@
++++ linux/fs/aufs/cpup.c       2016-12-17 12:28:17.595211562 +0100
+@@ -0,0 +1,1394 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -4990,9 +5005,9 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      dst->f_pos = 0;
 +      err = au_do_copy_file(dst, src, len, buf, blksize);
 +      if (do_kfree)
-+              kfree(buf);
++              au_delayed_kfree(buf);
 +      else
-+              free_page((unsigned long)buf);
++              au_delayed_free_page((unsigned long)buf);
 +
 +out:
 +      return err;
@@ -5027,6 +5042,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              }
 +      };
 +      struct super_block *sb;
++      struct inode *h_src_inode;
 +      struct task_struct *tsk = current;
 +
 +      /* bsrc branch can be ro/rw. */
@@ -5042,7 +5058,9 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      }
 +
 +      /* try stopping to update while we copyup */
-+      IMustLock(d_inode(file[SRC].dentry));
++      h_src_inode = d_inode(file[SRC].dentry);
++      if (!au_test_nfs(h_src_inode->i_sb))
++              IMustLock(h_src_inode);
 +      err = au_copy_file(file[DST].file, file[SRC].file, cpg->len);
 +
 +      /* i wonder if we had O_NO_DELAY_FPUT flag */
@@ -5102,8 +5120,13 @@ 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(cpg);
-+              inode_unlock(h_src_inode);
++              if (!au_test_nfs(h_src_inode->i_sb)) {
++                      err = au_cp_regular(cpg);
++                      inode_unlock(h_src_inode);
++              } else {
++                      inode_unlock(h_src_inode);
++                      err = au_cp_regular(cpg);
++              }
 +              rerr = au_pin_hdir_relock(cpg->pin);
 +              if (!err && rerr)
 +                      err = rerr;
@@ -5152,7 +5175,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              sym.k[symlen] = 0;
 +              err = vfsub_symlink(h_dir, h_path, sym.k);
 +      }
-+      free_page((unsigned long)sym.k);
++      au_delayed_free_page((unsigned long)sym.k);
 +
 +out:
 +      return err;
@@ -5344,7 +5367,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      IMustLock(h_dir);
 +      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);
++      err = vfsub_rename(h_dir, h_dentry, h_dir, h_path, /*delegated*/NULL,
++                         /*flags*/0);
 +      dput(h_path->dentry);
 +
 +out:
@@ -5357,6 +5381,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 + * @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.
++ * aufs doesn't touch the credential so
++ * security_inode_copy_up{,_xattr}() are unnecrssary.
 + */
 +static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent)
 +{
@@ -5523,7 +5549,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      }
 +out_parent:
 +      dput(dst_parent);
-+      kfree(a);
++      au_delayed_kfree(a);
 +out:
 +      return err;
 +}
@@ -6016,7 +6042,7 @@ 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       2016-07-25 19:05:34.811159821 +0200
++++ linux/fs/aufs/cpup.h       2016-10-09 16:55:36.486034798 +0200
 @@ -0,0 +1,94 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -6114,8 +6140,8 @@ 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    2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,432 @@
++++ linux/fs/aufs/dbgaufs.c    2016-10-09 16:55:38.886097714 +0200
+@@ -0,0 +1,438 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -6159,7 +6185,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +static int dbgaufs_xi_release(struct inode *inode __maybe_unused,
 +                            struct file *file)
 +{
-+      kfree(file->private_data);
++      au_delayed_kfree(file->private_data);
 +      return 0;
 +}
 +
@@ -6221,7 +6247,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +static int dbgaufs_plink_release(struct inode *inode __maybe_unused,
 +                               struct file *file)
 +{
-+      free_page((unsigned long)file->private_data);
++      au_delayed_free_page((unsigned long)file->private_data);
 +      return 0;
 +}
 +
@@ -6285,7 +6311,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +      goto out; /* success */
 +
 +out_free:
-+      free_page((unsigned long)p);
++      au_delayed_free_page((unsigned long)p);
 +out:
 +      return err;
 +}
@@ -6387,7 +6413,10 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +      for (; bindex <= bbot; bindex++) {
 +              br = au_sbr(sb, bindex);
 +              xi = &br->br_xino;
++              /* debugfs acquires the parent i_mutex */
++              lockdep_off();
 +              debugfs_remove(xi->xi_dbgaufs);
++              lockdep_on();
 +              xi->xi_dbgaufs = NULL;
 +      }
 +}
@@ -6412,8 +6441,11 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +              br = au_sbr(sb, bindex);
 +              xi = &br->br_xino;
 +              AuDebugOn(xi->xi_dbgaufs);
++              /* debugfs acquires the parent i_mutex */
++              lockdep_off();
 +              xi->xi_dbgaufs = debugfs_create_file(name, dbgaufs_mode, parent,
 +                                                   sbinfo, &dbgaufs_xino_fop);
++              lockdep_on();
 +              /* ignore an error */
 +              if (unlikely(!xi->xi_dbgaufs))
 +                      AuWarn1("failed %s under debugfs\n", name);
@@ -6550,7 +6582,7 @@ 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    2016-07-25 19:05:34.811159821 +0200
++++ linux/fs/aufs/dbgaufs.h    2016-10-09 16:55:36.486034798 +0200
 @@ -0,0 +1,48 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -6602,8 +6634,8 @@ 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      2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,224 @@
++++ linux/fs/aufs/dcsub.c      2016-10-09 16:55:38.886097714 +0200
+@@ -0,0 +1,225 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -6635,7 +6667,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      p = dpage->dentries;
 +      for (i = 0; i < dpage->ndentry; i++)
 +              dput(*p++);
-+      free_page((unsigned long)dpage->dentries);
++      au_delayed_free_page((unsigned long)dpage->dentries);
 +}
 +
 +int au_dpages_init(struct au_dcsub_pages *dpages, gfp_t gfp)
@@ -6658,7 +6690,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      return 0; /* success */
 +
 +out_dpages:
-+      kfree(dpages->dpages);
++      au_delayed_kfree(dpages->dpages);
 +out:
 +      return err;
 +}
@@ -6671,7 +6703,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      p = dpages->dpages;
 +      for (i = 0; i < dpages->ndpage; i++)
 +              au_dpage_free(p++);
-+      kfree(dpages->dpages);
++      au_delayed_kfree(dpages->dpages);
 +}
 +
 +static int au_dpages_append(struct au_dcsub_pages *dpages,
@@ -6688,7 +6720,8 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +              err = -ENOMEM;
 +              sz = dpages->ndpage * sizeof(*dpages->dpages);
 +              p = au_kzrealloc(dpages->dpages, sz,
-+                               sz + sizeof(*dpages->dpages), gfp);
++                               sz + sizeof(*dpages->dpages), gfp,
++                               /*may_shrink*/0);
 +              if (unlikely(!p))
 +                      goto out;
 +
@@ -6830,7 +6863,7 @@ 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      2016-07-25 19:05:34.811159821 +0200
++++ linux/fs/aufs/dcsub.h      2016-10-09 16:55:36.486034798 +0200
 @@ -0,0 +1,136 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -6970,8 +7003,8 @@ 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      2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,441 @@
++++ linux/fs/aufs/debug.c      2016-10-09 16:55:36.486034798 +0200
+@@ -0,0 +1,440 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -7310,7 +7343,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      au_br_count_init(&a->fake);
 +      err = do_pri_br(-1, &a->fake);
 +      au_br_count_fin(&a->fake);
-+      kfree(a);
++      au_delayed_kfree(a);
 +      dpri("dev 0x%x\n", sb->s_dev);
 +      if (err || !au_test_aufs(sb))
 +              return;
@@ -7318,9 +7351,8 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      sbinfo = au_sbi(sb);
 +      if (!sbinfo)
 +              return;
-+      dpri("nw %lld, gen %u, kobj %d\n",
-+           percpu_counter_sum(&sbinfo->si_nowait.nw_len),
-+           sbinfo->si_generation,
++      dpri("nw %d, gen %u, kobj %d\n",
++           atomic_read(&sbinfo->si_nowait.nw_len), sbinfo->si_generation,
 +           atomic_read(&sbinfo->si_kobj.kref.refcount));
 +      for (bindex = 0; bindex <= sbinfo->si_bbot; bindex++)
 +              do_pri_br(bindex, sbinfo->si_branch[0 + bindex]);
@@ -7415,7 +7447,7 @@ 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      2016-07-25 19:05:34.811159821 +0200
++++ linux/fs/aufs/debug.h      2016-10-09 16:55:36.486034798 +0200
 @@ -0,0 +1,225 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -7644,8 +7676,8 @@ 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     2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,1128 @@
++++ linux/fs/aufs/dentry.c     2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,1130 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -7697,7 +7729,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      br = au_sbr(dentry->d_sb, bindex);
 +      wh_able = !!au_br_whable(br->br_perm);
 +      if (wh_able)
-+              wh_found = au_wh_test(h_parent, wh_name, /*try_sio*/0);
++              wh_found = au_wh_test(h_parent, wh_name, ignore_perm);
 +      h_dentry = ERR_PTR(wh_found);
 +      if (!wh_found)
 +              goto real_lookup;
@@ -7862,7 +7894,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +
 +out_parent:
 +      dput(parent);
-+      kfree(whname.name);
++      au_delayed_kfree(whname.name);
 +out:
 +      return err;
 +}
@@ -8362,7 +8394,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +
 +int au_refresh_dentry(struct dentry *dentry, struct dentry *parent)
 +{
-+      int err, ebrange;
++      int err, ebrange, nbr;
 +      unsigned int sigen;
 +      struct au_dinfo *dinfo, *tmp;
 +      struct super_block *sb;
@@ -8378,8 +8410,9 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      if (unlikely(err))
 +              goto out;
 +
++      nbr = au_sbbot(sb) + 1;
 +      dinfo = au_di(dentry);
-+      err = au_di_realloc(dinfo, au_sbbot(sb) + 1);
++      err = au_di_realloc(dinfo, nbr, /*may_shrink*/0);
 +      if (unlikely(err))
 +              goto out;
 +      ebrange = au_dbrange_test(dentry);
@@ -8422,6 +8455,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              au_dbg_verify_dinode(dentry);
 +              AuTraceErr(err);
 +      }
++      au_di_realloc(dinfo, nbr, /*may_shrink*/1); /* harmless if err */
 +      au_rw_write_unlock(&tmp->di_rwsem);
 +      au_di_free(tmp);
 +      if (unlikely(err))
@@ -8776,8 +8810,8 @@ 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     2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,252 @@
++++ linux/fs/aufs/dentry.h     2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,255 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -8818,7 +8852,10 @@ diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
 +      struct au_rwsem         di_rwsem;
 +      aufs_bindex_t           di_btop, di_bbot, di_bwh, di_bdiropq;
 +      unsigned char           di_tmpfile; /* to allow the different name */
-+      struct au_hdentry       *di_hdentry;
++      union {
++              struct au_hdentry       *di_hdentry;
++              struct llist_node       di_lnode;       /* delayed free */
++      };
 +} ____cacheline_aligned_in_smp;
 +
 +/* ---------------------------------------------------------------------- */
@@ -8856,7 +8893,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
 +void au_di_cp(struct au_dinfo *dst, struct au_dinfo *src);
 +int au_di_init(struct dentry *dentry);
 +void au_di_fin(struct dentry *dentry);
-+int au_di_realloc(struct au_dinfo *dinfo, int nbr);
++int au_di_realloc(struct au_dinfo *dinfo, int nbr, int may_shrink);
 +
 +void di_read_lock(struct dentry *d, int flags, unsigned int lsc);
 +void di_read_unlock(struct dentry *d, int flags);
@@ -9032,8 +9069,8 @@ 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      2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,552 @@
++++ linux/fs/aufs/dinfo.c      2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,553 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -9089,7 +9126,7 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 +              goto out;
 +      }
 +
-+      au_cache_free_dinfo(dinfo);
++      au_cache_dfree_dinfo(dinfo);
 +      dinfo = NULL;
 +
 +out:
@@ -9109,8 +9146,8 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 +              while (bindex++ <= bbot)
 +                      au_hdput(p++);
 +      }
-+      kfree(dinfo->di_hdentry);
-+      au_cache_free_dinfo(dinfo);
++      au_delayed_kfree(dinfo->di_hdentry);
++      au_cache_dfree_dinfo(dinfo);
 +}
 +
 +void au_di_swap(struct au_dinfo *a, struct au_dinfo *b)
@@ -9178,7 +9215,7 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 +      au_di_free(dinfo);
 +}
 +
-+int au_di_realloc(struct au_dinfo *dinfo, int nbr)
++int au_di_realloc(struct au_dinfo *dinfo, int nbr, int may_shrink)
 +{
 +      int err, sz;
 +      struct au_hdentry *hdp;
@@ -9189,7 +9226,8 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 +      sz = sizeof(*hdp) * (dinfo->di_bbot + 1);
 +      if (!sz)
 +              sz = sizeof(*hdp);
-+      hdp = au_kzrealloc(dinfo->di_hdentry, sz, sizeof(*hdp) * nbr, GFP_NOFS);
++      hdp = au_kzrealloc(dinfo->di_hdentry, sz, sizeof(*hdp) * nbr, GFP_NOFS,
++                         may_shrink);
 +      if (hdp) {
 +              dinfo->di_hdentry = hdp;
 +              err = 0;
@@ -9588,8 +9626,8 @@ 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        2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,756 @@
++++ linux/fs/aufs/dir.c        2016-10-09 16:55:36.489368218 +0200
+@@ -0,0 +1,762 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -9748,7 +9786,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +out:
 +      dput(a->dentry);
 +      au_nwt_done(&au_sbi(sb)->si_nowait);
-+      kfree(arg);
++      au_delayed_kfree(arg);
 +}
 +
 +void au_dir_ts(struct inode *dir, aufs_bindex_t bindex)
@@ -9784,7 +9822,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      if (unlikely(wkq_err)) {
 +              pr_err("wkq %d\n", wkq_err);
 +              dput(dentry);
-+              kfree(arg);
++              au_delayed_kfree(arg);
 +      }
 +
 +out:
@@ -9903,7 +9941,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +              };
 +              err = au_do_open(file, &args);
 +              if (unlikely(err))
-+                      kfree(fidir);
++                      au_delayed_kfree(fidir);
 +      }
 +      si_read_unlock(sb);
 +      return err;
@@ -9915,8 +9953,11 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      struct au_vdir *vdir_cache;
 +      struct au_finfo *finfo;
 +      struct au_fidir *fidir;
++      struct au_hfile *hf;
 +      aufs_bindex_t bindex, bbot;
++      int execed, delayed;
 +
++      delayed = (current->flags & PF_KTHREAD) || in_interrupt();
 +      finfo = au_fi(file);
 +      fidir = finfo->fi_hdir;
 +      if (fidir) {
@@ -9924,22 +9965,25 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +                          &au_sbi(file->f_path.dentry->d_sb)->si_files);
 +              vdir_cache = fidir->fd_vdir_cache; /* lock-free */
 +              if (vdir_cache)
-+                      au_vdir_free(vdir_cache);
++                      au_vdir_free(vdir_cache, delayed);
 +
 +              bindex = finfo->fi_btop;
 +              if (bindex >= 0) {
++                      execed = vfsub_file_execed(file);
++                      hf = fidir->fd_hfile + bindex;
 +                      /*
 +                       * calls fput() instead of filp_close(),
 +                       * since no dnotify or lock for the lower file.
 +                       */
 +                      bbot = fidir->fd_bbot;
-+                      for (; bindex <= bbot; bindex++)
-+                              au_set_h_fptr(file, bindex, NULL);
++                      for (; bindex <= bbot; bindex++, hf++)
++                              if (hf->hf_file)
++                                      au_hfput(hf, execed);
 +              }
-+              kfree(fidir);
++              au_delayed_kfree(fidir);
 +              finfo->fi_hdir = NULL;
 +      }
-+      au_finfo_fin(file);
++      au_finfo_fin(file, delayed);
 +      return 0;
 +}
 +
@@ -10348,8 +10392,8 @@ 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        2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,131 @@
++++ linux/fs/aufs/dir.h        2016-10-09 16:55:36.489368218 +0200
+@@ -0,0 +1,137 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -10394,7 +10438,10 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 +
 +struct au_vdir_dehstr {
 +      struct hlist_node       hash;
-+      struct au_vdir_destr    *str;
++      union {
++              struct au_vdir_destr    *str;
++              struct llist_node       lnode;  /* delayed free */
++      };
 +} ____cacheline_aligned_in_smp;
 +
 +struct au_vdir_de {
@@ -10432,7 +10479,10 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 +
 +      unsigned long   vd_version;
 +      unsigned int    vd_deblk_sz;
-+      unsigned long   vd_jiffy;
++      union {
++              unsigned long           vd_jiffy;
++              struct llist_node       vd_lnode;       /* delayed free */
++      };
 +} ____cacheline_aligned_in_smp;
 +
 +/* ---------------------------------------------------------------------- */
@@ -10456,7 +10506,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 +int au_nhash_append_wh(struct au_nhash *whlist, char *name, int nlen, ino_t ino,
 +                     unsigned int d_type, aufs_bindex_t bindex,
 +                     unsigned char shwh);
-+void au_vdir_free(struct au_vdir *vdir);
++void au_vdir_free(struct au_vdir *vdir, int atonce);
 +int au_vdir_init(struct file *file);
 +int au_vdir_fill_de(struct file *file, struct dir_context *ctx);
 +
@@ -10483,8 +10533,8 @@ 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      2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,369 @@
++++ linux/fs/aufs/dynop.c      2016-10-09 16:55:36.489368218 +0200
+@@ -0,0 +1,371 @@
 +/*
 + * Copyright (C) 2010-2016 Junjiro R. Okajima
 + *
@@ -10514,17 +10564,17 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 + * How large will these lists be?
 + * Usually just a few elements, 20-30 at most for each, I guess.
 + */
-+static struct au_splhead dynop[AuDyLast];
++static struct au_sphlhead dynop[AuDyLast];
 +
-+static struct au_dykey *dy_gfind_get(struct au_splhead *spl, const void *h_op)
++static struct au_dykey *dy_gfind_get(struct au_sphlhead *sphl, const void *h_op)
 +{
 +      struct au_dykey *key, *tmp;
-+      struct list_head *head;
++      struct hlist_head *head;
 +
 +      key = NULL;
-+      head = &spl->head;
++      head = &sphl->head;
 +      rcu_read_lock();
-+      list_for_each_entry_rcu(tmp, head, dk_list)
++      hlist_for_each_entry_rcu(tmp, head, dk_hnode)
 +              if (tmp->dk_op.dy_hop == h_op) {
 +                      key = tmp;
 +                      kref_get(&key->dk_kref);
@@ -10571,24 +10621,24 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +}
 +
 +/* kref_get() if @key is already added */
-+static struct au_dykey *dy_gadd(struct au_splhead *spl, struct au_dykey *key)
++static struct au_dykey *dy_gadd(struct au_sphlhead *sphl, struct au_dykey *key)
 +{
 +      struct au_dykey *tmp, *found;
-+      struct list_head *head;
++      struct hlist_head *head;
 +      const void *h_op = key->dk_op.dy_hop;
 +
 +      found = NULL;
-+      head = &spl->head;
-+      spin_lock(&spl->spin);
-+      list_for_each_entry(tmp, head, dk_list)
++      head = &sphl->head;
++      spin_lock(&sphl->spin);
++      hlist_for_each_entry(tmp, head, dk_hnode)
 +              if (tmp->dk_op.dy_hop == h_op) {
 +                      kref_get(&tmp->dk_kref);
 +                      found = tmp;
 +                      break;
 +              }
 +      if (!found)
-+              list_add_rcu(&key->dk_list, head);
-+      spin_unlock(&spl->spin);
++              hlist_add_head_rcu(&key->dk_hnode, head);
++      spin_unlock(&sphl->spin);
 +
 +      if (!found)
 +              DyPrSym(key);
@@ -10601,17 +10651,17 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +
 +      key = container_of(rcu, struct au_dykey, dk_rcu);
 +      DyPrSym(key);
-+      kfree(key);
++      kfree(key);     /* not delayed */
 +}
 +
 +static void dy_free(struct kref *kref)
 +{
 +      struct au_dykey *key;
-+      struct au_splhead *spl;
++      struct au_sphlhead *sphl;
 +
 +      key = container_of(kref, struct au_dykey, dk_kref);
-+      spl = dynop + key->dk_op.dy_type;
-+      au_spl_del_rcu(&key->dk_list, spl);
++      sphl = dynop + key->dk_op.dy_type;
++      au_sphl_del_rcu(&key->dk_hnode, sphl);
 +      call_rcu(&key->dk_rcu, dy_free_rcu);
 +}
 +
@@ -10676,6 +10726,8 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +      /* this one will be changed according to an aufs mount option */
 +      DySetAop(direct_IO);
 +      DySetAop(migratepage);
++      DySetAop(isolate_page);
++      DySetAop(putback_page);
 +      DySetAop(launder_page);
 +      DySetAop(is_partially_uptodate);
 +      DySetAop(is_dirty_writeback);
@@ -10696,7 +10748,7 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +static struct au_dykey *dy_get(struct au_dynop *op, struct au_branch *br)
 +{
 +      struct au_dykey *key, *old;
-+      struct au_splhead *spl;
++      struct au_sphlhead *sphl;
 +      struct op {
 +              unsigned int sz;
 +              void (*set)(struct au_dykey *key, const void *h_op,
@@ -10710,8 +10762,8 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +      };
 +      const struct op *p;
 +
-+      spl = dynop + op->dy_type;
-+      key = dy_gfind_get(spl, op->dy_hop);
++      sphl = dynop + op->dy_type;
++      key = dy_gfind_get(sphl, op->dy_hop);
 +      if (key)
 +              goto out_add; /* success */
 +
@@ -10725,9 +10777,9 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +      key->dk_op.dy_hop = op->dy_hop;
 +      kref_init(&key->dk_kref);
 +      p->set(key, op->dy_hop, au_br_sb(br));
-+      old = dy_gadd(spl, key);
++      old = dy_gadd(sphl, key);
 +      if (old) {
-+              kfree(key);
++              au_delayed_kfree(key);
 +              key = old;
 +      }
 +
@@ -10822,16 +10874,16 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +
 +void au_dy_arefresh(int do_dx)
 +{
-+      struct au_splhead *spl;
-+      struct list_head *head;
++      struct au_sphlhead *sphl;
++      struct hlist_head *head;
 +      struct au_dykey *key;
 +
-+      spl = dynop + AuDy_AOP;
-+      head = &spl->head;
-+      spin_lock(&spl->spin);
-+      list_for_each_entry(key, head, dk_list)
++      sphl = dynop + AuDy_AOP;
++      head = &sphl->head;
++      spin_lock(&sphl->spin);
++      hlist_for_each_entry(key, head, dk_hnode)
 +              dy_adx((void *)key, do_dx);
-+      spin_unlock(&spl->spin);
++      spin_unlock(&sphl->spin);
 +}
 +
 +/* ---------------------------------------------------------------------- */
@@ -10844,7 +10896,7 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +      BUILD_BUG_ON(offsetof(struct au_dyaop, da_key));
 +
 +      for (i = 0; i < AuDyLast; i++)
-+              au_spl_init(dynop + i);
++              au_sphl_init(dynop + i);
 +}
 +
 +void au_dy_fin(void)
@@ -10852,11 +10904,11 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +      int i;
 +
 +      for (i = 0; i < AuDyLast; i++)
-+              WARN_ON(!list_empty(&dynop[i].head));
++              WARN_ON(!hlist_empty(&dynop[i].head));
 +}
 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      2016-07-25 19:05:34.811159821 +0200
++++ linux/fs/aufs/dynop.h      2016-10-09 16:55:36.489368218 +0200
 @@ -0,0 +1,74 @@
 +/*
 + * Copyright (C) 2010-2016 Junjiro R. Okajima
@@ -10899,7 +10951,7 @@ diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h
 +
 +struct au_dykey {
 +      union {
-+              struct list_head        dk_list;
++              struct hlist_node       dk_hnode;
 +              struct rcu_head         dk_rcu;
 +      };
 +      struct au_dynop         dk_op;
@@ -10934,8 +10986,8 @@ 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     2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,837 @@
++++ linux/fs/aufs/export.c     2016-12-17 12:28:17.595211562 +0100
+@@ -0,0 +1,836 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -10963,7 +11015,6 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +#include <linux/nsproxy.h>
 +#include <linux/random.h>
 +#include <linux/writeback.h>
-+#include "../fs/mount.h"
 +#include "aufs.h"
 +
 +union conv {
@@ -11355,7 +11406,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +      }
 +
 +out_name:
-+      free_page((unsigned long)arg.name);
++      au_delayed_free_page((unsigned long)arg.name);
 +out_file:
 +      fput(file);
 +out:
@@ -11509,7 +11560,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +                      dentry = ERR_PTR(-ESTALE);
 +              }
 +out_pathname:
-+      free_page((unsigned long)pathname);
++      au_delayed_free_page((unsigned long)pathname);
 +out_h_parent:
 +      dput(h_parent);
 +out:
@@ -11775,7 +11826,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +}
 diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.c
 --- /usr/share/empty/fs/aufs/fhsm.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/fhsm.c       2016-07-25 19:05:34.814493242 +0200
++++ linux/fs/aufs/fhsm.c       2016-10-09 16:55:36.489368218 +0200
 @@ -0,0 +1,426 @@
 +/*
 + * Copyright (C) 2011-2016 Junjiro R. Okajima
@@ -12205,8 +12256,8 @@ diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.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       2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,843 @@
++++ linux/fs/aufs/file.c       2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,857 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -12482,7 +12533,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      }
 +      if (unlikely(err)) {
 +              finfo->fi_hdir = NULL;
-+              au_finfo_fin(file);
++              au_finfo_fin(file, /*atonce*/0);
 +      }
 +
 +out:
@@ -12802,6 +12853,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +
 +static void au_do_refresh_dir(struct file *file)
 +{
++      int execed;
 +      aufs_bindex_t bindex, bbot, new_bindex, brid;
 +      struct au_hfile *p, tmp, *q;
 +      struct au_finfo *finfo;
@@ -12840,6 +12892,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +              }
 +      }
 +
++      execed = vfsub_file_execed(file);
 +      p = fidir->fd_hfile;
 +      if (!au_test_mmapped(file) && !d_unlinked(file->f_path.dentry)) {
 +              bbot = au_sbbot(sb);
@@ -12848,14 +12901,14 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +                      if (p->hf_file) {
 +                              if (file_inode(p->hf_file))
 +                                      break;
-+                              au_hfput(p, file);
++                              au_hfput(p, execed);
 +                      }
 +      } else {
 +              bbot = au_br_index(sb, brid);
 +              for (finfo->fi_btop = 0; finfo->fi_btop < bbot;
 +                   finfo->fi_btop++, p++)
 +                      if (p->hf_file)
-+                              au_hfput(p, file);
++                              au_hfput(p, execed);
 +              bbot = au_sbbot(sb);
 +      }
 +
@@ -12865,7 +12918,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +              if (p->hf_file) {
 +                      if (file_inode(p->hf_file))
 +                              break;
-+                      au_hfput(p, file);
++                      au_hfput(p, execed);
 +              }
 +      AuDebugOn(fidir->fd_bbot < finfo->fi_btop);
 +}
@@ -12875,23 +12928,26 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 + */
 +static int refresh_file(struct file *file, int (*reopen)(struct file *file))
 +{
-+      int err, need_reopen;
++      int err, need_reopen, nbr;
 +      aufs_bindex_t bbot, bindex;
 +      struct dentry *dentry;
++      struct super_block *sb;
 +      struct au_finfo *finfo;
 +      struct au_hfile *hfile;
 +
 +      dentry = file->f_path.dentry;
++      sb = dentry->d_sb;
++      nbr = au_sbbot(sb) + 1;
 +      finfo = au_fi(file);
 +      if (!finfo->fi_hdir) {
 +              hfile = &finfo->fi_htop;
 +              AuDebugOn(!hfile->hf_file);
-+              bindex = au_br_index(dentry->d_sb, hfile->hf_br->br_id);
++              bindex = au_br_index(sb, hfile->hf_br->br_id);
 +              AuDebugOn(bindex < 0);
 +              if (bindex != finfo->fi_btop)
 +                      au_set_fbtop(file, bindex);
 +      } else {
-+              err = au_fidir_realloc(finfo, au_sbbot(dentry->d_sb) + 1);
++              err = au_fidir_realloc(finfo, nbr, /*may_shrink*/0);
 +              if (unlikely(err))
 +                      goto out;
 +              au_do_refresh_dir(file);
@@ -12901,6 +12957,9 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      need_reopen = 1;
 +      if (!au_test_mmapped(file))
 +              err = au_file_refresh_by_inode(file, &need_reopen);
++      if (finfo->fi_hdir)
++              /* harmless if err */
++              au_fidir_realloc(finfo, nbr, /*may_shrink*/1);
 +      if (!err && need_reopen && !d_unlinked(dentry))
 +              err = reopen(file);
 +      if (!err) {
@@ -13008,6 +13067,10 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +                          struct page *page, enum migrate_mode mode)
 +{ AuUnsupport(); return 0; }
 +#endif
++static bool aufs_isolate_page(struct page *page, isolate_mode_t mode)
++{ AuUnsupport(); return true; }
++static void aufs_putback_page(struct page *page)
++{ AuUnsupport(); }
 +static int aufs_launder_page(struct page *page)
 +{ AuUnsupport(); return 0; }
 +static int aufs_is_partially_uptodate(struct page *page,
@@ -13042,6 +13105,8 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      .releasepage            = aufs_releasepage,
 +      /* is fallback_migrate_page ok? */
 +      /* .migratepage         = aufs_migratepage, */
++      .isolate_page           = aufs_isolate_page,
++      .putback_page           = aufs_putback_page,
 +      .launder_page           = aufs_launder_page,
 +      .is_partially_uptodate  = aufs_is_partially_uptodate,
 +      .is_dirty_writeback     = aufs_is_dirty_writeback,
@@ -13052,8 +13117,8 @@ 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       2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,291 @@
++++ linux/fs/aufs/file.h       2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,294 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -13119,7 +13184,10 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +      struct au_fidir         *fi_hdir;       /* for dir only */
 +
 +      struct hlist_node       fi_hlist;
-+      struct file             *fi_file;       /* very ugly */
++      union {
++              struct file             *fi_file;       /* very ugly */
++              struct llist_node       fi_lnode;       /* delayed free */
++      };
 +} ____cacheline_aligned_in_smp;
 +
 +/* ---------------------------------------------------------------------- */
@@ -13170,16 +13238,16 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +struct file *au_read_pre(struct file *file, int keep_fi);
 +
 +/* finfo.c */
-+void au_hfput(struct au_hfile *hf, struct file *file);
++void au_hfput(struct au_hfile *hf, int execed);
 +void au_set_h_fptr(struct file *file, aufs_bindex_t bindex,
 +                 struct file *h_file);
 +
 +void au_update_figen(struct file *file);
 +struct au_fidir *au_fidir_alloc(struct super_block *sb);
-+int au_fidir_realloc(struct au_finfo *finfo, int nbr);
++int au_fidir_realloc(struct au_finfo *finfo, int nbr, int may_shrink);
 +
 +void au_fi_init_once(void *_fi);
-+void au_finfo_fin(struct file *file);
++void au_finfo_fin(struct file *file, int atonce);
 +int au_finfo_init(struct file *file, struct au_fidir *fidir);
 +
 +/* ioctl.c */
@@ -13347,8 +13415,8 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +#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      2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,149 @@
++++ linux/fs/aufs/finfo.c      2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,151 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -13372,10 +13440,9 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +
 +#include "aufs.h"
 +
-+void au_hfput(struct au_hfile *hf, struct file *file)
++void au_hfput(struct au_hfile *hf, int execed)
 +{
-+      /* todo: direct access f_flags */
-+      if (vfsub_file_flags(file) & __FMODE_EXEC)
++      if (execed)
 +              allow_write_access(hf->hf_file);
 +      fput(hf->hf_file);
 +      hf->hf_file = NULL;
@@ -13397,7 +13464,7 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +              hf = fidir->fd_hfile + bindex;
 +
 +      if (hf && hf->hf_file)
-+              au_hfput(hf, file);
++              au_hfput(hf, vfsub_file_execed(file));
 +      if (val) {
 +              FiMustWriteLock(file);
 +              AuDebugOn(IS_ERR_OR_NULL(file->f_path.dentry));
@@ -13431,7 +13498,7 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +      return fidir;
 +}
 +
-+int au_fidir_realloc(struct au_finfo *finfo, int nbr)
++int au_fidir_realloc(struct au_finfo *finfo, int nbr, int may_shrink)
 +{
 +      int err;
 +      struct au_fidir *fidir, *p;
@@ -13442,7 +13509,7 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +
 +      err = -ENOMEM;
 +      p = au_kzrealloc(fidir, au_fidir_sz(fidir->fd_nent), au_fidir_sz(nbr),
-+                       GFP_NOFS);
++                       GFP_NOFS, may_shrink);
 +      if (p) {
 +              p->fd_nent = nbr;
 +              finfo->fi_hdir = p;
@@ -13454,7 +13521,7 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +
 +/* ---------------------------------------------------------------------- */
 +
-+void au_finfo_fin(struct file *file)
++void au_finfo_fin(struct file *file, int atonce)
 +{
 +      struct au_finfo *finfo;
 +
@@ -13463,7 +13530,10 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +      finfo = au_fi(file);
 +      AuDebugOn(finfo->fi_hdir);
 +      AuRwDestroy(&finfo->fi_rwsem);
-+      au_cache_free_finfo(finfo);
++      if (!atonce)
++              au_cache_dfree_finfo(finfo);
++      else
++              au_cache_free_finfo(finfo);
 +}
 +
 +void au_fi_init_once(void *_finfo)
@@ -13500,8 +13570,8 @@ 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       2016-07-25 19:05:34.811159821 +0200
-@@ -0,0 +1,770 @@
++++ linux/fs/aufs/f_op.c       2016-12-17 12:28:17.595211562 +0100
+@@ -0,0 +1,723 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -13603,6 +13673,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +{
 +      struct au_finfo *finfo;
 +      aufs_bindex_t bindex;
++      int delayed;
 +
 +      finfo = au_fi(file);
 +      au_sphl_del(&finfo->fi_hlist,
@@ -13611,7 +13682,8 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +      if (bindex >= 0)
 +              au_set_h_fptr(file, bindex, NULL);
 +
-+      au_finfo_fin(file);
++      delayed = (current->flags & PF_KTHREAD) || in_interrupt();
++      au_finfo_fin(file, delayed);
 +      return 0;
 +}
 +
@@ -14132,54 +14204,6 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +      return err;
 +}
 +
-+/* no one supports this operation, currently */
-+#if 0
-+static int aufs_aio_fsync_nondir(struct kiocb *kio, int datasync)
-+{
-+      int err;
-+      struct au_write_pre wpre;
-+      struct inode *inode, *h_inode;
-+      struct file *file, *h_file;
-+
-+      err = 0; /* -EBADF; */ /* posix? */
-+      if (unlikely(!(file->f_mode & FMODE_WRITE)))
-+              goto out;
-+
-+      file = kio->ki_filp;
-+      inode = file_inode(file);
-+      au_mtx_and_read_lock(inode);
-+
-+      h_file = au_write_pre(file, /*do_ready*/1, &wpre);
-+      err = PTR_ERR(h_file);
-+      if (IS_ERR(h_file))
-+              goto out_unlock;
-+
-+      err = -ENOSYS;
-+      h_file = au_hf_top(file);
-+      if (h_file->f_op->aio_fsync) {
-+              h_inode = file_inode(h_file);
-+              if (!is_sync_kiocb(kio)) {
-+                      get_file(h_file);
-+                      fput(file);
-+              }
-+              kio->ki_filp = h_file;
-+              err = h_file->f_op->aio_fsync(kio, datasync);
-+              inode_lock_nested(h_inode, AuLsc_I_CHILD);
-+              if (!err)
-+                      vfsub_update_h_iattr(&h_file->f_path, /*did*/NULL);
-+              /*ignore*/
-+              inode_unlock(h_inode);
-+      }
-+      au_write_post(inode, h_file, &wpre, /*written*/0);
-+
-+out_unlock:
-+      si_read_unlock(inode->sb);
-+      inode_unlock(inode);
-+out:
-+      return err;
-+}
-+#endif
-+
 +static int aufs_fasync(int fd, struct file *file, int flag)
 +{
 +      int err;
@@ -14260,7 +14284,6 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +      .flush          = aufs_flush_nondir,
 +      .release        = aufs_release_nondir,
 +      .fsync          = aufs_fsync_nondir,
-+      /* .aio_fsync   = aufs_aio_fsync_nondir, */
 +      .fasync         = aufs_fasync,
 +      /* .sendpage    = aufs_sendpage, */
 +      .setfl          = aufs_setfl,
@@ -14274,7 +14297,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.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     2016-07-25 19:05:34.814493242 +0200
++++ linux/fs/aufs/fstype.h     2016-10-09 16:55:36.492701639 +0200
 @@ -0,0 +1,400 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -14319,7 +14342,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_iso9660(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_ISO9660_FS) || defined(CONFIG_ISO9660_FS_MODULE)
++#if IS_ENABLED(CONFIG_ISO9660_FS)
 +      return sb->s_magic == ISOFS_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14328,7 +14351,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_romfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_ROMFS_FS) || defined(CONFIG_ROMFS_FS_MODULE)
++#if IS_ENABLED(CONFIG_ROMFS_FS)
 +      return sb->s_magic == ROMFS_MAGIC;
 +#else
 +      return 0;
@@ -14337,7 +14360,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_cramfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_CRAMFS) || defined(CONFIG_CRAMFS_MODULE)
++#if IS_ENABLED(CONFIG_CRAMFS)
 +      return sb->s_magic == CRAMFS_MAGIC;
 +#endif
 +      return 0;
@@ -14345,7 +14368,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_nfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_NFS_FS) || defined(CONFIG_NFS_FS_MODULE)
++#if IS_ENABLED(CONFIG_NFS_FS)
 +      return sb->s_magic == NFS_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14354,7 +14377,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_fuse(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_FUSE_FS) || defined(CONFIG_FUSE_FS_MODULE)
++#if IS_ENABLED(CONFIG_FUSE_FS)
 +      return sb->s_magic == FUSE_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14363,7 +14386,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_xfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_XFS_FS) || defined(CONFIG_XFS_FS_MODULE)
++#if IS_ENABLED(CONFIG_XFS_FS)
 +      return sb->s_magic == XFS_SB_MAGIC;
 +#else
 +      return 0;
@@ -14381,7 +14404,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_ecryptfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_ECRYPT_FS) || defined(CONFIG_ECRYPT_FS_MODULE)
++#if IS_ENABLED(CONFIG_ECRYPT_FS)
 +      return !strcmp(au_sbtype(sb), "ecryptfs");
 +#else
 +      return 0;
@@ -14395,7 +14418,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_ubifs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_UBIFS_FS) || defined(CONFIG_UBIFS_FS_MODULE)
++#if IS_ENABLED(CONFIG_UBIFS_FS)
 +      return sb->s_magic == UBIFS_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14422,7 +14445,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_configfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_CONFIGFS_FS) || defined(CONFIG_CONFIGFS_FS_MODULE)
++#if IS_ENABLED(CONFIG_CONFIGFS_FS)
 +      return sb->s_magic == CONFIGFS_MAGIC;
 +#else
 +      return 0;
@@ -14431,7 +14454,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_minix(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_MINIX_FS) || defined(CONFIG_MINIX_FS_MODULE)
++#if IS_ENABLED(CONFIG_MINIX_FS)
 +      return sb->s_magic == MINIX3_SUPER_MAGIC
 +              || sb->s_magic == MINIX2_SUPER_MAGIC
 +              || sb->s_magic == MINIX2_SUPER_MAGIC2
@@ -14444,7 +14467,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_fat(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_FAT_FS) || defined(CONFIG_FAT_FS_MODULE)
++#if IS_ENABLED(CONFIG_FAT_FS)
 +      return sb->s_magic == MSDOS_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14472,7 +14495,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_squashfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_SQUASHFS) || defined(CONFIG_SQUASHFS_MODULE)
++#if IS_ENABLED(CONFIG_SQUASHFS)
 +      return sb->s_magic == SQUASHFS_MAGIC;
 +#else
 +      return 0;
@@ -14481,7 +14504,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_btrfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
++#if IS_ENABLED(CONFIG_BTRFS_FS)
 +      return sb->s_magic == BTRFS_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14490,7 +14513,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_xenfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_XENFS) || defined(CONFIG_XENFS_MODULE)
++#if IS_ENABLED(CONFIG_XENFS)
 +      return sb->s_magic == XENFS_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14508,7 +14531,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_nilfs(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_NILFS) || defined(CONFIG_NILFS_MODULE)
++#if IS_ENABLED(CONFIG_NILFS)
 +      return sb->s_magic == NILFS_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14517,7 +14540,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +
 +static inline int au_test_hfsplus(struct super_block *sb __maybe_unused)
 +{
-+#if defined(CONFIG_HFSPLUS_FS) || defined(CONFIG_HFSPLUS_FS_MODULE)
++#if IS_ENABLED(CONFIG_HFSPLUS_FS)
 +      return sb->s_magic == HFSPLUS_SUPER_MAGIC;
 +#else
 +      return 0;
@@ -14678,7 +14701,7 @@ 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  2016-07-25 19:05:34.814493242 +0200
++++ linux/fs/aufs/hfsnotify.c  2016-10-09 16:55:36.492701639 +0200
 @@ -0,0 +1,287 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -14714,7 +14737,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +      struct au_hnotify *hn = container_of(mark, struct au_hnotify,
 +                                           hn_mark);
 +      /* AuDbg("here\n"); */
-+      au_cache_free_hnotify(hn);
++      au_cache_dfree_hnotify(hn);
 +      smp_mb__before_atomic();
 +      if (atomic64_dec_and_test(&au_hfsn_ifree))
 +              wake_up(&au_hfsn_wq);
@@ -14838,7 +14861,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +      struct au_br_hfsnotify *hfsn = group->private;
 +
 +      /* AuDbg("here\n"); */
-+      kfree(hfsn);
++      au_delayed_kfree(hfsn);
 +}
 +
 +static int au_hfsn_handle_event(struct fsnotify_group *group,
@@ -14932,7 +14955,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +      goto out; /* success */
 +
 +out_hfsn:
-+      kfree(hfsn);
++      au_delayed_kfree(hfsn);
 +out:
 +      return err;
 +}
@@ -14969,7 +14992,7 @@ 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    2016-07-25 19:05:34.814493242 +0200
++++ linux/fs/aufs/hfsplus.c    2016-10-09 16:55:36.492701639 +0200
 @@ -0,0 +1,56 @@
 +/*
 + * Copyright (C) 2010-2016 Junjiro R. Okajima
@@ -15029,8 +15052,8 @@ 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    2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,710 @@
++++ linux/fs/aufs/hnotify.c    2016-10-09 16:55:36.492701639 +0200
+@@ -0,0 +1,723 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -15068,7 +15091,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +              AuTraceErr(err);
 +              if (unlikely(err)) {
 +                      hinode->hi_notify = NULL;
-+                      au_cache_free_hnotify(hn);
++                      au_cache_dfree_hnotify(hn);
 +                      /*
 +                       * The upper dir was removed by udba, but the same named
 +                       * dir left. In this case, aufs assignes a new inode
@@ -15092,7 +15115,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +      if (hn) {
 +              hinode->hi_notify = NULL;
 +              if (au_hnotify_op.free(hinode, hn))
-+                      au_cache_free_hnotify(hn);
++                      au_cache_dfree_hnotify(hn);
 +      }
 +}
 +
@@ -15526,7 +15549,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +              || au_ftest_hnjob(a->flags[AuHn_CHILD], GEN))) {
 +              inode = lookup_wlock_by_ino(sb, bfound, h_ino);
 +              try_iput = 1;
-+          }
++      }
 +
 +      args.flags = a->flags[AuHn_CHILD];
 +      args.dentry = dentry;
@@ -15565,7 +15588,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +      iput(a->dir);
 +      si_write_unlock(sb);
 +      au_nwt_done(&sbinfo->si_nowait);
-+      kfree(a);
++      au_delayed_kfree(a);
 +}
 +
 +/* ---------------------------------------------------------------------- */
@@ -15671,7 +15694,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +              iput(args->h_child_inode);
 +              iput(args->h_dir);
 +              iput(args->dir);
-+              kfree(args);
++              au_delayed_kfree(args);
 +      }
 +
 +out:
@@ -15712,17 +15735,26 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +
 +static void au_hn_destroy_cache(void)
 +{
-+      kmem_cache_destroy(au_cachep[AuCache_HNOTIFY]);
-+      au_cachep[AuCache_HNOTIFY] = NULL;
++      struct au_cache *cp;
++
++      flush_delayed_work(&au_dfree.dwork);
++      cp = au_dfree.cache + AuCache_HNOTIFY;
++      AuDebugOn(!llist_empty(&cp->llist));
++      kmem_cache_destroy(cp->cache);
++      cp->cache = NULL;
 +}
 +
++AU_CACHE_DFREE_FUNC(hnotify, HNOTIFY, hn_lnode);
++
 +int __init au_hnotify_init(void)
 +{
 +      int err;
++      struct au_cache *cp;
 +
 +      err = -ENOMEM;
-+      au_cachep[AuCache_HNOTIFY] = AuCache(au_hnotify);
-+      if (au_cachep[AuCache_HNOTIFY]) {
++      cp = au_dfree.cache + AuCache_HNOTIFY;
++      cp->cache = AuCache(au_hnotify);
++      if (cp->cache) {
 +              err = 0;
 +              if (au_hnotify_op.init)
 +                      err = au_hnotify_op.init();
@@ -15735,16 +15767,20 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +
 +void au_hnotify_fin(void)
 +{
++      struct au_cache *cp;
++
 +      if (au_hnotify_op.fin)
 +              au_hnotify_op.fin();
++
 +      /* cf. au_cache_fin() */
-+      if (au_cachep[AuCache_HNOTIFY])
++      cp = au_dfree.cache + AuCache_HNOTIFY;
++      if (cp->cache)
 +              au_hn_destroy_cache();
 +}
 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      2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,284 @@
++++ linux/fs/aufs/iinfo.c      2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,285 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -15965,7 +16001,7 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 +      return -ENOMEM;
 +}
 +
-+int au_hinode_realloc(struct au_iinfo *iinfo, int nbr)
++int au_hinode_realloc(struct au_iinfo *iinfo, int nbr, int may_shrink)
 +{
 +      int err, i;
 +      struct au_hinode *hip;
@@ -15973,7 +16009,8 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 +      AuRwMustWriteLock(&iinfo->ii_rwsem);
 +
 +      err = -ENOMEM;
-+      hip = krealloc(iinfo->ii_hinode, sizeof(*hip) * nbr, GFP_NOFS);
++      hip = au_krealloc(iinfo->ii_hinode, sizeof(*hip) * nbr, GFP_NOFS,
++                        may_shrink);
 +      if (hip) {
 +              iinfo->ii_hinode = hip;
 +              i = iinfo->ii_bbot + 1;
@@ -16014,7 +16051,7 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 +
 +      iinfo = au_ii(inode);
 +      if (iinfo->ii_vdir)
-+              au_vdir_free(iinfo->ii_vdir);
++              au_vdir_free(iinfo->ii_vdir, /*atonce*/0);
 +
 +      bindex = iinfo->ii_btop;
 +      if (bindex >= 0) {
@@ -16026,13 +16063,13 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 +                      hi++;
 +              }
 +      }
-+      kfree(iinfo->ii_hinode);
++      au_delayed_kfree(iinfo->ii_hinode);
 +      AuRwDestroy(&iinfo->ii_rwsem);
 +}
 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      2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,517 @@
++++ linux/fs/aufs/inode.c      2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,519 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -16075,7 +16112,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +
 +static int au_ii_refresh(struct inode *inode, int *update)
 +{
-+      int err, e;
++      int err, e, nbr;
 +      umode_t type;
 +      aufs_bindex_t bindex, new_bindex;
 +      struct super_block *sb;
@@ -16087,9 +16124,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +
 +      *update = 0;
 +      sb = inode->i_sb;
++      nbr = au_sbbot(sb) + 1;
 +      type = inode->i_mode & S_IFMT;
 +      iinfo = au_ii(inode);
-+      err = au_hinode_realloc(iinfo, au_sbbot(sb) + 1);
++      err = au_hinode_realloc(iinfo, nbr, /*may_shrink*/0);
 +      if (unlikely(err))
 +              goto out;
 +
@@ -16127,6 +16165,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +              }
 +      }
 +      au_update_ibrange(inode, /*do_put_zero*/0);
++      au_hinode_realloc(iinfo, nbr, /*may_shrink*/1); /* harmless if err */
 +      e = au_dy_irefresh(inode);
 +      if (unlikely(e && !err))
 +              err = e;
@@ -16552,8 +16591,8 @@ 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      2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,694 @@
++++ linux/fs/aufs/inode.h      2016-12-17 12:28:17.595211562 +0100
+@@ -0,0 +1,691 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -16591,7 +16630,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +      /* never use fsnotify_add_vfsmount_mark() */
 +      struct fsnotify_mark            hn_mark;
 +#endif
-+      struct inode                    *hn_aufs_inode; /* no get/put */
++      union {
++              struct inode            *hn_aufs_inode; /* no get/put */
++              struct llist_node       hn_lnode;       /* delayed free */
++      };
 +#endif
 +} ____cacheline_aligned_in_smp;
 +
@@ -16634,7 +16676,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +struct au_icntnr {
 +      struct au_iinfo iinfo;
 +      struct inode vfs_inode;
-+      struct hlist_node plink;
++      union {
++              struct hlist_node       plink;
++              struct llist_node       lnode;  /* delayed free */
++      };
 +} ____cacheline_aligned_in_smp;
 +
 +/* au_pin flags */
@@ -16788,7 +16833,8 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +/* i_op_ren.c */
 +int au_wbr(struct dentry *dentry, aufs_bindex_t btgt);
 +int aufs_rename(struct inode *src_dir, struct dentry *src_dentry,
-+              struct inode *dir, struct dentry *dentry);
++              struct inode *dir, struct dentry *dentry,
++              unsigned int flags);
 +
 +/* iinfo.c */
 +struct inode *au_h_iptr(struct inode *inode, aufs_bindex_t bindex);
@@ -16821,7 +16867,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +void au_hinode_init(struct au_hinode *hinode);
 +int au_iinfo_init(struct inode *inode);
 +void au_iinfo_fin(struct inode *inode);
-+int au_hinode_realloc(struct au_iinfo *iinfo, int nbr);
++int au_hinode_realloc(struct au_iinfo *iinfo, int nbr, int may_shrink);
 +
 +#ifdef CONFIG_PROC_FS
 +/* plink.c */
@@ -16861,17 +16907,11 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +int au_cpup_xattr(struct dentry *h_dst, struct dentry *h_src, int ignore_flags,
 +                unsigned int verbose);
 +ssize_t aufs_listxattr(struct dentry *dentry, char *list, size_t size);
-+ssize_t aufs_getxattr(struct dentry *dentry, struct inode *inode,
-+                    const char *name, void *value, size_t size);
-+int aufs_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
-+                const void *value, size_t size, int flags);
-+int aufs_removexattr(struct dentry *dentry, const char *name);
-+
-+/* void au_xattr_init(struct super_block *sb); */
++void au_xattr_init(struct super_block *sb);
 +#else
 +AuStubInt0(au_cpup_xattr, struct dentry *h_dst, struct dentry *h_src,
 +         int ignore_flags, unsigned int verbose);
-+/* AuStubVoid(au_xattr_init, struct super_block *sb); */
++AuStubVoid(au_xattr_init, struct super_block *sb);
 +#endif
 +
 +#ifdef CONFIG_FS_POSIX_ACL
@@ -16882,11 +16922,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +#if IS_ENABLED(CONFIG_AUFS_XATTR) || IS_ENABLED(CONFIG_FS_POSIX_ACL)
 +enum {
 +      AU_XATTR_SET,
-+      AU_XATTR_REMOVE,
 +      AU_ACL_SET
 +};
 +
-+struct au_srxattr {
++struct au_sxattr {
 +      int type;
 +      union {
 +              struct {
@@ -16896,16 +16935,13 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +                      int             flags;
 +              } set;
 +              struct {
-+                      const char      *name;
-+              } remove;
-+              struct {
 +                      struct posix_acl *acl;
 +                      int             type;
 +              } acl_set;
 +      } u;
 +};
-+ssize_t au_srxattr(struct dentry *dentry, struct inode *inode,
-+                 struct au_srxattr *arg);
++ssize_t au_sxattr(struct dentry *dentry, struct inode *inode,
++                struct au_sxattr *arg);
 +#endif
 +
 +/* ---------------------------------------------------------------------- */
@@ -17250,7 +17286,7 @@ 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      2016-07-25 19:05:34.814493242 +0200
++++ linux/fs/aufs/ioctl.c      2016-10-09 16:55:36.492701639 +0200
 @@ -0,0 +1,219 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -17473,8 +17509,8 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 +#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   2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,924 @@
++++ linux/fs/aufs/i_op_add.c   2016-12-17 12:28:17.595211562 +0100
+@@ -0,0 +1,928 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -17822,7 +17858,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      if (!try_aopen)
 +              aufs_read_unlock(dentry, AuLock_DW);
 +out_free:
-+      kfree(a);
++      au_delayed_kfree(a);
 +out:
 +      return err;
 +}
@@ -18189,6 +18225,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              goto out_parent;
 +      }
 +
++      /*
++       * aufs doesn't touch the credential so
++       * security_dentry_create_files_as() is unnecrssary.
++       */
 +      if (au_opt_test(au_mntflags(sb), PLINK)) {
 +              if (a->bdst < a->bsrc
 +                  /* && h_src_dentry->d_sb != a->h_path.dentry->d_sb */)
@@ -18286,7 +18326,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      }
 +      aufs_read_and_write_unlock2(dentry, src_dentry);
 +out_kfree:
-+      kfree(a);
++      au_delayed_kfree(a);
 +out:
 +      AuTraceErr(err);
 +      return err;
@@ -18395,14 +18435,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      }
 +      aufs_read_unlock(dentry, AuLock_DW);
 +out_free:
-+      kfree(a);
++      au_delayed_kfree(a);
 +out:
 +      return err;
 +}
 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       2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,1414 @@
++++ linux/fs/aufs/i_op.c       2016-12-17 12:28:17.595211562 +0100
+@@ -0,0 +1,1444 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -18436,12 +18476,15 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      int err;
 +      const unsigned char write_mask = !!(mask & (MAY_WRITE | MAY_APPEND));
 +
++      err = -EPERM;
++      if (write_mask && IS_IMMUTABLE(h_inode))
++              goto out;
++
 +      err = -EACCES;
-+      if ((write_mask && IS_IMMUTABLE(h_inode))
-+          || ((mask & MAY_EXEC)
-+              && S_ISREG(h_inode->i_mode)
-+              && (path_noexec(h_path)
-+                  || !(h_inode->i_mode & S_IXUGO))))
++      if (((mask & MAY_EXEC)
++           && S_ISREG(h_inode->i_mode)
++           && (path_noexec(h_path)
++               || !(h_inode->i_mode & S_IXUGO))))
 +              goto out;
 +
 +      /*
@@ -18686,8 +18729,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +{
 +      int err, h_opened = *opened;
 +      unsigned int lkup_flags;
-+      struct dentry *parent;
-+      struct dentry *d;
++      struct dentry *parent, *d;
 +      struct au_sphlhead *aopen;
 +      struct vfsub_aopen_args args = {
 +              .open_flag      = open_flag,
@@ -18782,10 +18824,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      di_write_unlock(parent);
 +      aufs_read_unlock(dentry, AuLock_DW);
 +      AuDbgDentry(dentry);
-+      if (unlikely(err))
++      if (unlikely(err < 0))
 +              goto out;
 +out_no_open:
-+      if (!err && !(*opened & FILE_CREATED)) {
++      if (err >= 0 && !(*opened & FILE_CREATED)) {
 +              AuLabel(out_no_open);
 +              dget(dentry);
 +              err = finish_no_open(file, dentry);
@@ -19291,6 +19333,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      inode = d_inode(dentry);
 +      IMustLock(inode);
 +
++      err = setattr_prepare(dentry, ia);
++      if (unlikely(err))
++              goto out;
++
 +      err = -ENOMEM;
 +      a = kzalloc(sizeof(*a), GFP_NOFS);
 +      if (unlikely(!a))
@@ -19399,7 +19445,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +out_si:
 +      si_read_unlock(sb);
 +out_kfree:
-+      kfree(a);
++      au_delayed_kfree(a);
 +out:
 +      AuTraceErr(err);
 +      return err;
@@ -19434,8 +19480,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      return err;
 +}
 +
-+ssize_t au_srxattr(struct dentry *dentry, struct inode *inode,
-+                 struct au_srxattr *arg)
++ssize_t au_sxattr(struct dentry *dentry, struct inode *inode,
++                struct au_sxattr *arg)
 +{
 +      int err;
 +      struct path h_path;
@@ -19469,13 +19515,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +                                   arg->u.set.name, arg->u.set.value,
 +                                   arg->u.set.size, arg->u.set.flags);
 +              break;
-+      case AU_XATTR_REMOVE:
-+              err = vfsub_removexattr(h_path.dentry, arg->u.remove.name);
-+              break;
 +      case AU_ACL_SET:
 +              err = -EOPNOTSUPP;
 +              h_inode = d_inode(h_path.dentry);
 +              if (h_inode->i_op->set_acl)
++                      /* this will call posix_acl_update_mode */
 +                      err = h_inode->i_op->set_acl(h_inode,
 +                                                   arg->u.acl_set.acl,
 +                                                   arg->u.acl_set.type);
@@ -19492,7 +19536,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      di_write_unlock(dentry);
 +      si_read_unlock(sb);
 +out_kfree:
-+      kfree(a);
++      au_delayed_kfree(a);
 +out:
 +      AuTraceErr(err);
 +      return err;
@@ -19529,7 +19573,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +}
 +
 +/*
-+ * common routine for aufs_getattr() and aufs_getxattr().
++ * common routine for aufs_getattr() and au_getxattr().
 + * returns zero or negative (an error).
 + * @dentry will be read-locked in success.
 + */
@@ -19696,7 +19740,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      err = 0;
 +      AuDbg("%pf\n", h_inode->i_op->get_link);
 +      AuDbgDentry(h_dentry);
-+      ret = h_inode->i_op->get_link(h_dentry, h_inode, done);
++      ret = vfs_get_link(h_dentry, done);
 +      dput(h_dentry);
 +      if (IS_ERR(ret))
 +              err = PTR_ERR(ret);
@@ -19712,20 +19756,55 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +
 +/* ---------------------------------------------------------------------- */
 +
++static int au_is_special(struct inode *inode)
++{
++      return (inode->i_mode & (S_IFBLK | S_IFCHR | S_IFIFO | S_IFSOCK));
++}
++
 +static int aufs_update_time(struct inode *inode, struct timespec *ts, int flags)
 +{
 +      int err;
++      aufs_bindex_t bindex;
 +      struct super_block *sb;
 +      struct inode *h_inode;
++      struct vfsmount *h_mnt;
 +
 +      sb = inode->i_sb;
++      WARN_ONCE((flags & S_ATIME) && !IS_NOATIME(inode),
++                "unexpected s_flags 0x%lx", sb->s_flags);
++
 +      /* mmap_sem might be acquired already, cf. aufs_mmap() */
 +      lockdep_off();
 +      si_read_lock(sb, AuLock_FLUSH);
 +      ii_write_lock_child(inode);
 +      lockdep_on();
-+      h_inode = au_h_iptr(inode, au_ibtop(inode));
-+      err = vfsub_update_time(h_inode, ts, flags);
++
++      err = 0;
++      bindex = au_ibtop(inode);
++      h_inode = au_h_iptr(inode, bindex);
++      if (!au_test_ro(sb, bindex, inode)) {
++              h_mnt = au_sbr_mnt(sb, bindex);
++              err = vfsub_mnt_want_write(h_mnt);
++              if (!err) {
++                      err = vfsub_update_time(h_inode, ts, flags);
++                      vfsub_mnt_drop_write(h_mnt);
++              }
++      } else if (au_is_special(h_inode)) {
++              /*
++               * Never copy-up here.
++               * These special files may already be opened and used for
++               * communicating. If we copied it up, then the communication
++               * would be corrupted.
++               */
++              AuWarn1("timestamps for i%lu are ignored "
++                      "since it is on readonly branch (hi%lu).\n",
++                      inode->i_ino, h_inode->i_ino);
++      } else if (flags & ~S_ATIME) {
++              err = -EIO;
++              AuIOErr1("unexpected flags 0x%x\n", flags);
++              AuDebugOn(1);
++      }
++
 +      lockdep_off();
 +      if (!err)
 +              au_cpup_attr_timesizes(inode);
@@ -19755,10 +19834,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              .getattr        = aufs_getattr,
 +
 +#ifdef CONFIG_AUFS_XATTR
-+              .setxattr       = aufs_setxattr,
-+              .getxattr       = aufs_getxattr,
 +              .listxattr      = aufs_listxattr,
-+              .removexattr    = aufs_removexattr,
 +#endif
 +
 +              .readlink       = generic_readlink,
@@ -19787,10 +19863,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              .getattr        = aufs_getattr,
 +
 +#ifdef CONFIG_AUFS_XATTR
-+              .setxattr       = aufs_setxattr,
-+              .getxattr       = aufs_getxattr,
 +              .listxattr      = aufs_listxattr,
-+              .removexattr    = aufs_removexattr,
 +#endif
 +
 +              .update_time    = aufs_update_time,
@@ -19808,10 +19881,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              .getattr        = aufs_getattr,
 +
 +#ifdef CONFIG_AUFS_XATTR
-+              .setxattr       = aufs_setxattr,
-+              .getxattr       = aufs_getxattr,
 +              .listxattr      = aufs_listxattr,
-+              .removexattr    = aufs_removexattr,
 +#endif
 +
 +              .update_time    = aufs_update_time
@@ -19819,7 +19889,7 @@ 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   2016-07-25 19:05:34.814493242 +0200
++++ linux/fs/aufs/i_op_del.c   2016-10-09 16:55:36.492701639 +0200
 @@ -0,0 +1,511 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -20217,7 +20287,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +out_unlock:
 +      aufs_read_unlock(dentry, AuLock_DW);
 +out_free:
-+      kfree(a);
++      au_delayed_kfree(a);
 +out:
 +      return err;
 +}
@@ -20327,15 +20397,15 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +out_unlock:
 +      aufs_read_unlock(dentry, AuLock_DW);
 +out_free:
-+      kfree(a);
++      au_delayed_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   2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,1015 @@
++++ linux/fs/aufs/i_op_ren.c   2016-12-17 12:28:17.595211562 +0100
+@@ -0,0 +1,1165 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -20363,13 +20433,15 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +enum { AuSRC, AuDST, AuSrcDst };
 +enum { AuPARENT, AuCHILD, AuParentChild };
 +
-+#define AuRen_ISDIR   1
-+#define AuRen_ISSAMEDIR       (1 << 1)
-+#define AuRen_WHSRC   (1 << 2)
-+#define AuRen_WHDST   (1 << 3)
-+#define AuRen_MNT_WRITE       (1 << 4)
-+#define AuRen_DT_DSTDIR       (1 << 5)
-+#define AuRen_DIROPQ  (1 << 6)
++#define AuRen_ISDIR_SRC               1
++#define AuRen_ISDIR_DST               (1 << 1)
++#define AuRen_ISSAMEDIR               (1 << 2)
++#define AuRen_WHSRC           (1 << 3)
++#define AuRen_WHDST           (1 << 4)
++#define AuRen_MNT_WRITE               (1 << 5)
++#define AuRen_DT_DSTDIR               (1 << 6)
++#define AuRen_DIROPQ_SRC      (1 << 7)
++#define AuRen_DIROPQ_DST      (1 << 8)
 +#define au_ftest_ren(flags, name)     ((flags) & AuRen_##name)
 +#define au_fset_ren(flags, name) \
 +      do { (flags) |= AuRen_##name; } while (0)
@@ -20381,9 +20453,9 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              struct dentry *dentry, *h_dentry, *parent, *h_parent,
 +                      *wh_dentry;
 +              struct inode *dir, *inode;
-+              struct au_hinode *hdir;
++              struct au_hinode *hdir, *hinode;
 +              struct au_dtime dt[AuParentChild];
-+              aufs_bindex_t btop;
++              aufs_bindex_t btop, bdiropq;
 +      } sd[AuSrcDst];
 +
 +#define src_dentry    sd[AuSRC].dentry
@@ -20394,9 +20466,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +#define src_h_parent  sd[AuSRC].h_parent
 +#define src_wh_dentry sd[AuSRC].wh_dentry
 +#define src_hdir      sd[AuSRC].hdir
++#define src_hinode    sd[AuSRC].hinode
 +#define src_h_dir     sd[AuSRC].hdir->hi_inode
 +#define src_dt                sd[AuSRC].dt
 +#define src_btop      sd[AuSRC].btop
++#define src_bdiropq   sd[AuSRC].bdiropq
 +
 +#define dst_dentry    sd[AuDST].dentry
 +#define dst_dir               sd[AuDST].dir
@@ -20406,18 +20480,23 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +#define dst_h_parent  sd[AuDST].h_parent
 +#define dst_wh_dentry sd[AuDST].wh_dentry
 +#define dst_hdir      sd[AuDST].hdir
++#define dst_hinode    sd[AuDST].hinode
 +#define dst_h_dir     sd[AuDST].hdir->hi_inode
 +#define dst_dt                sd[AuDST].dt
 +#define dst_btop      sd[AuDST].btop
++#define dst_bdiropq   sd[AuDST].bdiropq
 +
 +      struct dentry *h_trap;
 +      struct au_branch *br;
-+      struct au_hinode *src_hinode;
 +      struct path h_path;
 +      struct au_nhash whlist;
-+      aufs_bindex_t btgt, src_bwh, src_bdiropq;
++      aufs_bindex_t btgt, src_bwh;
 +
-+      unsigned int flags;
++      struct {
++              unsigned short auren_flags;
++              unsigned char flags;    /* syscall parameter */
++              unsigned char exchange;
++      } __packed;
 +
 +      struct au_whtmp_rmdir *thargs;
 +      struct dentry *h_dst;
@@ -20439,16 +20518,29 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      err = -EIO; \
 +} while (0)
 +
-+static void au_ren_rev_diropq(int err, struct au_ren_args *a)
++static void au_ren_do_rev_diropq(int err, struct au_ren_args *a, int idx)
 +{
 +      int rerr;
++      struct dentry *d;
++#define src_or_dst(member) a->sd[idx].member
 +
-+      au_hn_inode_lock_nested(a->src_hinode, AuLsc_I_CHILD);
-+      rerr = au_diropq_remove(a->src_dentry, a->btgt);
-+      au_hn_inode_unlock(a->src_hinode);
-+      au_set_dbdiropq(a->src_dentry, a->src_bdiropq);
++      d = src_or_dst(dentry); /* {src,dst}_dentry */
++      au_hn_inode_lock_nested(src_or_dst(hinode), AuLsc_I_CHILD);
++      rerr = au_diropq_remove(d, a->btgt);
++      au_hn_inode_unlock(src_or_dst(hinode));
++      au_set_dbdiropq(d, src_or_dst(bdiropq));
 +      if (rerr)
-+              RevertFailure("remove diropq %pd", a->src_dentry);
++              RevertFailure("remove diropq %pd", d);
++
++#undef src_or_dst_
++}
++
++static void au_ren_rev_diropq(int err, struct au_ren_args *a)
++{
++      if (au_ftest_ren(a->auren_flags, DIROPQ_SRC))
++              au_ren_do_rev_diropq(err, a, AuSRC);
++      if (au_ftest_ren(a->auren_flags, DIROPQ_DST))
++              au_ren_do_rev_diropq(err, a, AuDST);
 +}
 +
 +static void au_ren_rev_rename(int err, struct au_ren_args *a)
@@ -20467,7 +20559,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      delegated = NULL;
 +      rerr = vfsub_rename(a->dst_h_dir,
 +                          au_h_dptr(a->src_dentry, a->btgt),
-+                          a->src_h_dir, &a->h_path, &delegated);
++                          a->src_h_dir, &a->h_path, &delegated, a->flags);
 +      if (unlikely(rerr == -EWOULDBLOCK)) {
 +              pr_warn("cannot retry for NFSv4 delegation"
 +                      " for an internal rename\n");
@@ -20500,7 +20592,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      delegated = NULL;
 +      rerr = vfsub_rename(a->dst_h_dir, a->h_dst, a->dst_h_dir, &a->h_path,
-+                          &delegated);
++                          &delegated, a->flags);
 +      if (unlikely(rerr == -EWOULDBLOCK)) {
 +              pr_warn("cannot retry for NFSv4 delegation"
 +                      " for an internal rename\n");
@@ -20542,13 +20634,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      d = a->src_dentry;
 +      if (au_dbtop(d) == a->btgt) {
 +              a->h_path.dentry = a->dst_h_dentry;
-+              if (au_ftest_ren(a->flags, DIROPQ)
-+                  && au_dbdiropq(d) == a->btgt)
-+                      au_fclr_ren(a->flags, DIROPQ);
 +              AuDebugOn(au_dbtop(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, &delegated);
++                                 a->dst_h_dir, &a->h_path, &delegated,
++                                 a->flags);
 +              if (unlikely(err == -EWOULDBLOCK)) {
 +                      pr_warn("cannot retry for NFSv4 delegation"
 +                              " for an internal rename\n");
@@ -20592,127 +20682,179 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +}
 +
 +/* make it 'opaque' dir. */
-+static int au_ren_diropq(struct au_ren_args *a)
++static int au_ren_do_diropq(struct au_ren_args *a, int idx)
 +{
 +      int err;
-+      struct dentry *diropq;
++      struct dentry *d, *diropq;
++#define src_or_dst(member) a->sd[idx].member
 +
 +      err = 0;
-+      a->src_bdiropq = au_dbdiropq(a->src_dentry);
-+      a->src_hinode = au_hi(a->src_inode, a->btgt);
-+      au_hn_inode_lock_nested(a->src_hinode, AuLsc_I_CHILD);
-+      diropq = au_diropq_create(a->src_dentry, a->btgt);
-+      au_hn_inode_unlock(a->src_hinode);
++      d = src_or_dst(dentry); /* {src,dst}_dentry */
++      src_or_dst(bdiropq) = au_dbdiropq(d);
++      src_or_dst(hinode) = au_hi(src_or_dst(inode), a->btgt);
++      au_hn_inode_lock_nested(src_or_dst(hinode), AuLsc_I_CHILD);
++      diropq = au_diropq_create(d, a->btgt);
++      au_hn_inode_unlock(src_or_dst(hinode));
 +      if (IS_ERR(diropq))
 +              err = PTR_ERR(diropq);
 +      else
 +              dput(diropq);
 +
++#undef src_or_dst_
 +      return err;
 +}
 +
-+static int do_rename(struct au_ren_args *a)
++static int au_ren_diropq(struct au_ren_args *a)
 +{
 +      int err;
-+      struct dentry *d, *h_d;
++      unsigned char always;
++      struct dentry *d;
 +
-+      /* prepare workqueue args for asynchronous rmdir */
-+      h_d = a->dst_h_dentry;
-+      if (au_ftest_ren(a->flags, ISDIR) && d_is_positive(h_d)) {
-+              err = -ENOMEM;
-+              a->thargs = au_whtmp_rmdir_alloc(a->src_dentry->d_sb, GFP_NOFS);
-+              if (unlikely(!a->thargs))
++      err = 0;
++      d = a->dst_dentry; /* already renamed on the branch */
++      always = !!au_opt_test(au_mntflags(d->d_sb), ALWAYS_DIROPQ);
++      if (au_ftest_ren(a->auren_flags, ISDIR_SRC)
++          && a->btgt != au_dbdiropq(a->src_dentry)
++          && (a->dst_wh_dentry
++              || a->btgt <= au_dbdiropq(d)
++              /* hide the lower to keep xino */
++              /* the lowers may not be a dir, but we hide them anyway */
++              || a->btgt < au_dbbot(d)
++              || always)) {
++              AuDbg("here\n");
++              err = au_ren_do_diropq(a, AuSRC);
++              if (unlikely(err))
 +                      goto out;
-+              a->h_dst = dget(h_d);
-+      }
-+
-+      /* create whiteout for src_dentry */
-+      if (au_ftest_ren(a->flags, WHSRC)) {
-+              a->src_bwh = au_dbwh(a->src_dentry);
-+              AuDebugOn(a->src_bwh >= 0);
-+              a->src_wh_dentry
-+                      = au_wh_create(a->src_dentry, a->btgt, a->src_h_parent);
-+              err = PTR_ERR(a->src_wh_dentry);
-+              if (IS_ERR(a->src_wh_dentry))
-+                      goto out_thargs;
-+      }
-+
-+      /* lookup whiteout for dentry */
-+      if (au_ftest_ren(a->flags, WHDST)) {
-+              h_d = au_wh_lkup(a->dst_h_parent, &a->dst_dentry->d_name,
-+                               a->br);
-+              err = PTR_ERR(h_d);
-+              if (IS_ERR(h_d))
-+                      goto out_whsrc;
-+              if (d_is_negative(h_d))
-+                      dput(h_d);
-+              else
-+                      a->dst_wh_dentry = h_d;
++              au_fset_ren(a->auren_flags, DIROPQ_SRC);
 +      }
++      if (!a->exchange)
++              goto out; /* success */
 +
-+      /* rename dentry to tmpwh */
-+      if (a->thargs) {
-+              err = au_whtmp_ren(a->dst_h_dentry, a->br);
++      d = a->src_dentry; /* already renamed on the branch */
++      if (au_ftest_ren(a->auren_flags, ISDIR_DST)
++          && a->btgt != au_dbdiropq(a->dst_dentry)
++          && (a->btgt < au_dbdiropq(d)
++              || a->btgt < au_dbbot(d)
++              || always)) {
++              AuDbgDentry(a->src_dentry);
++              AuDbgDentry(a->dst_dentry);
++              err = au_ren_do_diropq(a, AuDST);
 +              if (unlikely(err))
-+                      goto out_whdst;
++                      goto out_rev_src;
++              au_fset_ren(a->auren_flags, DIROPQ_DST);
++      }
++      goto out; /* success */
 +
-+              d = a->dst_dentry;
-+              au_set_h_dptr(d, a->btgt, NULL);
-+              err = au_lkup_neg(d, a->btgt, /*wh*/0);
-+              if (unlikely(err))
-+                      goto out_whtmp;
-+              a->dst_h_dentry = au_h_dptr(d, a->btgt);
++out_rev_src:
++      AuDbg("err %d, reverting src\n", err);
++      au_ren_rev_diropq(err, a);
++out:
++      return err;
++}
++
++static int do_rename(struct au_ren_args *a)
++{
++      int err;
++      struct dentry *d, *h_d;
++
++      if (!a->exchange) {
++              /* prepare workqueue args for asynchronous rmdir */
++              h_d = a->dst_h_dentry;
++              if (au_ftest_ren(a->auren_flags, ISDIR_DST)
++                  && d_is_positive(h_d)) {
++                      err = -ENOMEM;
++                      a->thargs = au_whtmp_rmdir_alloc(a->src_dentry->d_sb,
++                                                       GFP_NOFS);
++                      if (unlikely(!a->thargs))
++                              goto out;
++                      a->h_dst = dget(h_d);
++              }
++
++              /* create whiteout for src_dentry */
++              if (au_ftest_ren(a->auren_flags, WHSRC)) {
++                      a->src_bwh = au_dbwh(a->src_dentry);
++                      AuDebugOn(a->src_bwh >= 0);
++                      a->src_wh_dentry = au_wh_create(a->src_dentry, a->btgt,
++                                                      a->src_h_parent);
++                      err = PTR_ERR(a->src_wh_dentry);
++                      if (IS_ERR(a->src_wh_dentry))
++                              goto out_thargs;
++              }
++
++              /* lookup whiteout for dentry */
++              if (au_ftest_ren(a->auren_flags, WHDST)) {
++                      h_d = au_wh_lkup(a->dst_h_parent,
++                                       &a->dst_dentry->d_name, a->br);
++                      err = PTR_ERR(h_d);
++                      if (IS_ERR(h_d))
++                              goto out_whsrc;
++                      if (d_is_negative(h_d))
++                              dput(h_d);
++                      else
++                              a->dst_wh_dentry = h_d;
++              }
++
++              /* rename dentry to tmpwh */
++              if (a->thargs) {
++                      err = au_whtmp_ren(a->dst_h_dentry, a->br);
++                      if (unlikely(err))
++                              goto out_whdst;
++
++                      d = a->dst_dentry;
++                      au_set_h_dptr(d, a->btgt, NULL);
++                      err = au_lkup_neg(d, a->btgt, /*wh*/0);
++                      if (unlikely(err))
++                              goto out_whtmp;
++                      a->dst_h_dentry = au_h_dptr(d, a->btgt);
++              }
 +      }
 +
 +      BUG_ON(d_is_positive(a->dst_h_dentry) && a->src_btop != a->btgt);
 +
 +      /* rename by vfs_rename or cpup */
-+      d = a->dst_dentry;
-+      if (au_ftest_ren(a->flags, ISDIR)
-+          && (a->dst_wh_dentry
-+              || au_dbdiropq(d) == a->btgt
-+              /* hide the lower to keep xino */
-+              || a->btgt < au_dbbot(d)
-+              || au_opt_test(au_mntflags(d->d_sb), ALWAYS_DIROPQ)))
-+              au_fset_ren(a->flags, DIROPQ);
 +      err = au_ren_or_cpup(a);
 +      if (unlikely(err))
 +              /* leave the copied-up one */
 +              goto out_whtmp;
 +
 +      /* make dir opaque */
-+      if (au_ftest_ren(a->flags, DIROPQ)) {
-+              err = au_ren_diropq(a);
-+              if (unlikely(err))
-+                      goto out_rename;
-+      }
++      err = au_ren_diropq(a);
++      if (unlikely(err))
++              goto out_rename;
 +
 +      /* update target timestamps */
++      if (a->exchange) {
++              AuDebugOn(au_dbtop(a->dst_dentry) != a->btgt);
++              a->h_path.dentry = au_h_dptr(a->dst_dentry, a->btgt);
++              vfsub_update_h_iattr(&a->h_path, /*did*/NULL); /*ignore*/
++              a->dst_inode->i_ctime = d_inode(a->h_path.dentry)->i_ctime;
++      }
 +      AuDebugOn(au_dbtop(a->src_dentry) != a->btgt);
 +      a->h_path.dentry = au_h_dptr(a->src_dentry, a->btgt);
 +      vfsub_update_h_iattr(&a->h_path, /*did*/NULL); /*ignore*/
 +      a->src_inode->i_ctime = d_inode(a->h_path.dentry)->i_ctime;
 +
-+      /* remove whiteout for dentry */
-+      if (a->dst_wh_dentry) {
-+              a->h_path.dentry = a->dst_wh_dentry;
-+              err = au_wh_unlink_dentry(a->dst_h_dir, &a->h_path,
-+                                        a->dst_dentry);
-+              if (unlikely(err))
-+                      goto out_diropq;
-+      }
++      if (!a->exchange) {
++              /* remove whiteout for dentry */
++              if (a->dst_wh_dentry) {
++                      a->h_path.dentry = a->dst_wh_dentry;
++                      err = au_wh_unlink_dentry(a->dst_h_dir, &a->h_path,
++                                                a->dst_dentry);
++                      if (unlikely(err))
++                              goto out_diropq;
++              }
 +
-+      /* remove whtmp */
-+      if (a->thargs)
-+              au_ren_del_whtmp(a); /* ignore this error */
++              /* remove whtmp */
++              if (a->thargs)
++                      au_ren_del_whtmp(a); /* ignore this error */
 +
-+      au_fhsm_wrote(a->src_dentry->d_sb, a->btgt, /*force*/0);
++              au_fhsm_wrote(a->src_dentry->d_sb, a->btgt, /*force*/0);
++      }
 +      err = 0;
 +      goto out_success;
 +
 +out_diropq:
-+      if (au_ftest_ren(a->flags, DIROPQ))
-+              au_ren_rev_diropq(err, a);
++      au_ren_rev_diropq(err, a);
 +out_rename:
 +      au_ren_rev_rename(err, a);
 +      dput(a->h_dst);
@@ -20805,7 +20947,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      SiMustAnyLock(d->d_sb);
 +
 +      err = 0;
-+      if (au_ftest_ren(a->flags, ISDIR) && a->dst_inode) {
++      if (au_ftest_ren(a->auren_flags, ISDIR_DST) && a->dst_inode) {
 +              rdhash = au_sbi(d->d_sb)->si_rdhash;
 +              if (!rdhash)
 +                      rdhash = au_rdhash_est(au_dir_size(/*file*/NULL, d));
@@ -20813,9 +20955,12 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              if (unlikely(err))
 +                      goto out;
 +
-+              au_set_dbtop(d, a->dst_btop);
-+              err = may_rename_dstdir(d, &a->whlist);
-+              au_set_dbtop(d, a->btgt);
++              if (!a->exchange) {
++                      au_set_dbtop(d, a->dst_btop);
++                      err = may_rename_dstdir(d, &a->whlist);
++                      au_set_dbtop(d, a->btgt);
++              } else
++                      err = may_rename_srcdir(d, a->btgt);
 +      }
 +      a->dst_h_dentry = au_h_dptr(d, au_dbtop(d));
 +      if (unlikely(err))
@@ -20823,7 +20968,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      d = a->src_dentry;
 +      a->src_h_dentry = au_h_dptr(d, au_dbtop(d));
-+      if (au_ftest_ren(a->flags, ISDIR)) {
++      if (au_ftest_ren(a->auren_flags, ISDIR_SRC)) {
 +              err = may_rename_srcdir(d, a->btgt);
 +              if (unlikely(err)) {
 +                      au_nhash_wh_free(&a->whlist);
@@ -20847,7 +20992,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      if (a->src_btop == a->btgt) {
 +              err = au_may_del(a->src_dentry, a->btgt, a->src_h_parent,
-+                               au_ftest_ren(a->flags, ISDIR));
++                               au_ftest_ren(a->auren_flags, ISDIR_SRC));
 +              if (unlikely(err))
 +                      goto out;
 +              err = -EINVAL;
@@ -20864,7 +21009,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              goto out;
 +
 +      err = -EIO;
-+      isdir = !!au_ftest_ren(a->flags, ISDIR);
++      isdir = !!au_ftest_ren(a->auren_flags, ISDIR_DST);
 +      if (d_really_is_negative(a->dst_dentry)) {
 +              if (d_is_negative(a->dst_h_dentry))
 +                      err = au_may_add(a->dst_dentry, a->btgt,
@@ -20914,7 +21059,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +{
 +      vfsub_unlock_rename(a->src_h_parent, a->src_hdir,
 +                          a->dst_h_parent, a->dst_hdir);
-+      if (au_ftest_ren(a->flags, MNT_WRITE))
++      if (au_ftest_ren(a->auren_flags, MNT_WRITE))
 +              vfsub_mnt_drop_write(au_br_mnt(a->br));
 +}
 +
@@ -20932,7 +21077,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      err = vfsub_mnt_want_write(au_br_mnt(a->br));
 +      if (unlikely(err))
 +              goto out;
-+      au_fset_ren(a->flags, MNT_WRITE);
++      au_fset_ren(a->auren_flags, MNT_WRITE);
 +      a->h_trap = vfsub_lock_rename(a->src_h_parent, a->src_hdir,
 +                                    a->dst_h_parent, a->dst_hdir);
 +      udba = au_opt_udba(a->src_dentry->d_sb);
@@ -20965,20 +21110,30 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      dir = a->dst_dir;
 +      dir->i_version++;
-+      if (au_ftest_ren(a->flags, ISDIR)) {
++      if (au_ftest_ren(a->auren_flags, ISDIR_SRC)) {
 +              /* is this updating defined in POSIX? */
 +              au_cpup_attr_timesizes(a->src_inode);
 +              au_cpup_attr_nlink(dir, /*force*/1);
 +      }
-+
 +      au_dir_ts(dir, a->btgt);
 +
-+      if (au_ftest_ren(a->flags, ISSAMEDIR))
++      if (a->exchange) {
++              dir = a->src_dir;
++              dir->i_version++;
++              if (au_ftest_ren(a->auren_flags, ISDIR_DST)) {
++                      /* is this updating defined in POSIX? */
++                      au_cpup_attr_timesizes(a->dst_inode);
++                      au_cpup_attr_nlink(dir, /*force*/1);
++              }
++              au_dir_ts(dir, a->btgt);
++      }
++
++      if (au_ftest_ren(a->auren_flags, ISSAMEDIR))
 +              return;
 +
 +      dir = a->src_dir;
 +      dir->i_version++;
-+      if (au_ftest_ren(a->flags, ISDIR))
++      if (au_ftest_ren(a->auren_flags, ISDIR_SRC))
 +              au_cpup_attr_nlink(dir, /*force*/1);
 +      au_dir_ts(dir, a->btgt);
 +}
@@ -20998,13 +21153,16 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      i = a->dst_inode;
 +      if (i) {
-+              if (!au_ftest_ren(a->flags, ISDIR))
-+                      vfsub_drop_nlink(i);
-+              else {
-+                      vfsub_dead_dir(i);
-+                      au_cpup_attr_timesizes(i);
-+              }
-+              au_update_dbrange(d, /*do_put_zero*/1);
++              if (!a->exchange) {
++                      if (!au_ftest_ren(a->auren_flags, ISDIR_DST))
++                              vfsub_drop_nlink(i);
++                      else {
++                              vfsub_dead_dir(i);
++                              au_cpup_attr_timesizes(i);
++                      }
++                      au_update_dbrange(d, /*do_put_zero*/1);
++              } else
++                      au_cpup_attr_nlink(i, /*force*/1);
 +      } else {
 +              bbot = a->btgt;
 +              for (bindex = au_dbtop(d); bindex < bbot; bindex++)
@@ -21016,30 +21174,33 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      }
 +
 +      d = a->src_dentry;
-+      au_set_dbwh(d, -1);
-+      bbot = au_dbbot(d);
-+      for (bindex = a->btgt + 1; bindex <= bbot; bindex++) {
-+              h_d = au_h_dptr(d, bindex);
-+              if (h_d)
-+                      au_set_h_dptr(d, bindex, NULL);
-+      }
-+      au_set_dbbot(d, a->btgt);
++      if (!a->exchange) {
++              au_set_dbwh(d, -1);
++              bbot = au_dbbot(d);
++              for (bindex = a->btgt + 1; bindex <= bbot; bindex++) {
++                      h_d = au_h_dptr(d, bindex);
++                      if (h_d)
++                              au_set_h_dptr(d, bindex, NULL);
++              }
++              au_set_dbbot(d, a->btgt);
 +
-+      sb = d->d_sb;
-+      i = a->src_inode;
-+      if (au_opt_test(au_mntflags(sb), PLINK) && au_plink_test(i))
-+              return; /* success */
++              sb = d->d_sb;
++              i = a->src_inode;
++              if (au_opt_test(au_mntflags(sb), PLINK) && au_plink_test(i))
++                      return; /* success */
 +
-+      bbot = au_ibbot(i);
-+      for (bindex = a->btgt + 1; bindex <= bbot; bindex++) {
-+              h_i = au_h_iptr(i, bindex);
-+              if (h_i) {
-+                      au_xino_write(sb, bindex, h_i->i_ino, /*ino*/0);
-+                      /* ignore this error */
-+                      au_set_h_iptr(i, bindex, NULL, 0);
++              bbot = au_ibbot(i);
++              for (bindex = a->btgt + 1; bindex <= bbot; bindex++) {
++                      h_i = au_h_iptr(i, bindex);
++                      if (h_i) {
++                              au_xino_write(sb, bindex, h_i->i_ino, /*ino*/0);
++                              /* ignore this error */
++                              au_set_h_iptr(i, bindex, NULL, 0);
++                      }
 +              }
++              au_set_ibbot(i, a->btgt);
 +      }
-+      au_set_ibbot(i, a->btgt);
++              d_drop(a->src_dentry);
 +}
 +
 +/* ---------------------------------------------------------------------- */
@@ -21077,7 +21238,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      a->src_btop = au_dbtop(a->src_dentry);
 +      a->dst_btop = au_dbtop(a->dst_dentry);
-+      if (au_ftest_ren(a->flags, ISDIR))
++      if (au_ftest_ren(a->auren_flags, ISDIR_SRC)
++          || au_ftest_ren(a->auren_flags, ISDIR_DST))
 +              au_fset_wrdir(wr_dir_args.flags, ISDIR);
 +      wr_dir_args.force_btgt = a->src_btop;
 +      if (a->dst_inode && a->dst_btop < a->src_btop)
@@ -21085,6 +21247,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      wr_dir_args.force_btgt = au_wbr(a->dst_dentry, wr_dir_args.force_btgt);
 +      err = au_wr_dir(a->dst_dentry, a->src_dentry, &wr_dir_args);
 +      a->btgt = err;
++      if (a->exchange)
++              au_update_dbtop(a->dst_dentry);
 +
 +      return err;
 +}
@@ -21093,19 +21257,20 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +{
 +      a->h_path.dentry = a->src_h_parent;
 +      au_dtime_store(a->src_dt + AuPARENT, a->src_parent, &a->h_path);
-+      if (!au_ftest_ren(a->flags, ISSAMEDIR)) {
++      if (!au_ftest_ren(a->auren_flags, ISSAMEDIR)) {
 +              a->h_path.dentry = a->dst_h_parent;
 +              au_dtime_store(a->dst_dt + AuPARENT, a->dst_parent, &a->h_path);
 +      }
 +
-+      au_fclr_ren(a->flags, DT_DSTDIR);
-+      if (!au_ftest_ren(a->flags, ISDIR))
++      au_fclr_ren(a->auren_flags, DT_DSTDIR);
++      if (!au_ftest_ren(a->auren_flags, ISDIR_SRC)
++          && !a->exchange)
 +              return;
 +
 +      a->h_path.dentry = a->src_h_dentry;
 +      au_dtime_store(a->src_dt + AuCHILD, a->src_dentry, &a->h_path);
 +      if (d_is_positive(a->dst_h_dentry)) {
-+              au_fset_ren(a->flags, DT_DSTDIR);
++              au_fset_ren(a->auren_flags, DT_DSTDIR);
 +              a->h_path.dentry = a->dst_h_dentry;
 +              au_dtime_store(a->dst_dt + AuCHILD, a->dst_dentry, &a->h_path);
 +      }
@@ -21117,17 +21282,17 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      struct inode *h_inode;
 +
 +      au_dtime_revert(a->src_dt + AuPARENT);
-+      if (!au_ftest_ren(a->flags, ISSAMEDIR))
++      if (!au_ftest_ren(a->auren_flags, ISSAMEDIR))
 +              au_dtime_revert(a->dst_dt + AuPARENT);
 +
-+      if (au_ftest_ren(a->flags, ISDIR) && err != -EIO) {
++      if (au_ftest_ren(a->auren_flags, ISDIR_SRC) && err != -EIO) {
 +              h_d = a->src_dt[AuCHILD].dt_h_path.dentry;
 +              h_inode = d_inode(h_d);
 +              inode_lock_nested(h_inode, AuLsc_I_CHILD);
 +              au_dtime_revert(a->src_dt + AuCHILD);
 +              inode_unlock(h_inode);
 +
-+              if (au_ftest_ren(a->flags, DT_DSTDIR)) {
++              if (au_ftest_ren(a->auren_flags, DT_DSTDIR)) {
 +                      h_d = a->dst_dt[AuCHILD].dt_h_path.dentry;
 +                      h_inode = d_inode(h_d);
 +                      inode_lock_nested(h_inode, AuLsc_I_CHILD);
@@ -21140,22 +21305,30 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +/* ---------------------------------------------------------------------- */
 +
 +int aufs_rename(struct inode *_src_dir, struct dentry *_src_dentry,
-+              struct inode *_dst_dir, struct dentry *_dst_dentry)
++              struct inode *_dst_dir, struct dentry *_dst_dentry,
++              unsigned int _flags)
 +{
-+      int err, flags;
++      int err, lock_flags;
 +      /* reduce stack space */
 +      struct au_ren_args *a;
++      struct au_pin pin;
 +
-+      AuDbg("%pd, %pd\n", _src_dentry, _dst_dentry);
++      AuDbg("%pd, %pd, 0x%x\n", _src_dentry, _dst_dentry, _flags);
 +      IMustLock(_src_dir);
 +      IMustLock(_dst_dir);
 +
++      err = -EINVAL;
++      if (unlikely(_flags & RENAME_WHITEOUT))
++              goto out;
++
 +      err = -ENOMEM;
 +      BUILD_BUG_ON(sizeof(*a) > PAGE_SIZE);
 +      a = kzalloc(sizeof(*a), GFP_NOFS);
 +      if (unlikely(!a))
 +              goto out;
 +
++      a->flags = _flags;
++      a->exchange = _flags & RENAME_EXCHANGE;
 +      a->src_dir = _src_dir;
 +      a->src_dentry = _src_dentry;
 +      a->src_inode = NULL;
@@ -21169,20 +21342,33 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              a->dst_inode = d_inode(a->dst_dentry);
 +      a->dst_parent = a->dst_dentry->d_parent; /* dir inode is locked */
 +      if (a->dst_inode) {
-+              IMustLock(a->dst_inode);
++              /*
++               * if EXCHANGE && src is non-dir && dst is dir,
++               * dst is not locked.
++               */
++              /* IMustLock(a->dst_inode); */
 +              au_igrab(a->dst_inode);
 +      }
 +
 +      err = -ENOTDIR;
-+      flags = AuLock_FLUSH | AuLock_NOPLM | AuLock_GEN;
++      lock_flags = AuLock_FLUSH | AuLock_NOPLM | AuLock_GEN;
 +      if (d_is_dir(a->src_dentry)) {
-+              au_fset_ren(a->flags, ISDIR);
-+              if (unlikely(d_really_is_positive(a->dst_dentry)
++              au_fset_ren(a->auren_flags, ISDIR_SRC);
++              if (unlikely(!a->exchange
++                           && d_really_is_positive(a->dst_dentry)
 +                           && !d_is_dir(a->dst_dentry)))
 +                      goto out_free;
-+              flags |= AuLock_DIRS;
++              lock_flags |= AuLock_DIRS;
++      }
++      if (a->dst_inode && d_is_dir(a->dst_dentry)) {
++              au_fset_ren(a->auren_flags, ISDIR_DST);
++              if (unlikely(!a->exchange
++                           && d_really_is_positive(a->src_dentry)
++                           && !d_is_dir(a->src_dentry)))
++                      goto out_free;
++              lock_flags |= AuLock_DIRS;
 +      }
-+      err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry, flags);
++      err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry, lock_flags);
 +      if (unlikely(err))
 +              goto out_free;
 +
@@ -21192,14 +21378,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      err = -ENOENT;
 +      if (a->dst_inode) {
 +              /*
-+               * If it is a dir, VFS unhash dst_dentry before this
++               * If it is a dir, VFS unhash it before this
 +               * function. It means we cannot rely upon d_unhashed().
 +               */
 +              if (unlikely(!a->dst_inode->i_nlink))
 +                      goto out_unlock;
-+              if (!S_ISDIR(a->dst_inode->i_mode)) {
++              if (!au_ftest_ren(a->auren_flags, ISDIR_DST)) {
 +                      err = au_d_hashed_positive(a->dst_dentry);
-+                      if (unlikely(err))
++                      if (unlikely(err && !a->exchange))
 +                              goto out_unlock;
 +              } else if (unlikely(IS_DEADDIR(a->dst_inode)))
 +                      goto out_unlock;
@@ -21215,7 +21401,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      if (unlikely(d_inode(a->dst_parent) == d_inode(a->src_dentry)))
 +              goto out_unlock;
 +
-+      au_fset_ren(a->flags, ISSAMEDIR); /* temporary */
++      au_fset_ren(a->auren_flags, ISSAMEDIR); /* temporary */
 +      di_write_lock_parent(a->dst_parent);
 +
 +      /* which branch we process */
@@ -21232,39 +21418,43 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      /* prepare the writable parent dir on the same branch */
 +      if (a->dst_btop == a->btgt) {
-+              au_fset_ren(a->flags, WHDST);
++              au_fset_ren(a->auren_flags, WHDST);
 +      } else {
 +              err = au_cpup_dirs(a->dst_dentry, a->btgt);
 +              if (unlikely(err))
 +                      goto out_children;
 +      }
 +
-+      if (a->src_dir != a->dst_dir) {
-+              /*
-+               * this temporary unlock is safe,
-+               * because both dir->i_mutex are locked.
-+               */
-+              di_write_unlock(a->dst_parent);
-+              di_write_lock_parent(a->src_parent);
-+              err = au_wr_dir_need_wh(a->src_dentry,
-+                                      au_ftest_ren(a->flags, ISDIR),
-+                                      &a->btgt);
-+              di_write_unlock(a->src_parent);
-+              di_write_lock2_parent(a->src_parent, a->dst_parent, /*isdir*/1);
-+              au_fclr_ren(a->flags, ISSAMEDIR);
-+      } else
-+              err = au_wr_dir_need_wh(a->src_dentry,
-+                                      au_ftest_ren(a->flags, ISDIR),
-+                                      &a->btgt);
++      err = 0;
++      if (!a->exchange) {
++              if (a->src_dir != a->dst_dir) {
++                      /*
++                       * this temporary unlock is safe,
++                       * because both dir->i_mutex are locked.
++                       */
++                      di_write_unlock(a->dst_parent);
++                      di_write_lock_parent(a->src_parent);
++                      err = au_wr_dir_need_wh(a->src_dentry,
++                                              au_ftest_ren(a->auren_flags,
++                                                           ISDIR_SRC),
++                                              &a->btgt);
++                      di_write_unlock(a->src_parent);
++                      di_write_lock2_parent(a->src_parent, a->dst_parent,
++                                            /*isdir*/1);
++                      au_fclr_ren(a->auren_flags, ISSAMEDIR);
++              } else
++                      err = au_wr_dir_need_wh(a->src_dentry,
++                                              au_ftest_ren(a->auren_flags,
++                                                           ISDIR_SRC),
++                                              &a->btgt);
++      }
 +      if (unlikely(err < 0))
 +              goto out_children;
 +      if (err)
-+              au_fset_ren(a->flags, WHSRC);
++              au_fset_ren(a->auren_flags, WHSRC);
 +
 +      /* cpup src */
 +      if (a->src_btop != a->btgt) {
-+              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);
@@ -21285,7 +21475,32 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +                      goto out_children;
 +              a->src_btop = a->btgt;
 +              a->src_h_dentry = au_h_dptr(a->src_dentry, a->btgt);
-+              au_fset_ren(a->flags, WHSRC);
++              if (!a->exchange)
++                      au_fset_ren(a->auren_flags, WHSRC);
++      }
++
++      /* cpup dst */
++      if (a->exchange && a->dst_inode
++          && a->dst_btop != a->btgt) {
++              err = au_pin(&pin, a->dst_dentry, a->btgt,
++                           au_opt_udba(a->dst_dentry->d_sb),
++                           AuPin_DI_LOCKED | AuPin_MNT_WRITE);
++              if (!err) {
++                      struct au_cp_generic cpg = {
++                              .dentry = a->dst_dentry,
++                              .bdst   = a->btgt,
++                              .bsrc   = a->dst_btop,
++                              .len    = -1,
++                              .pin    = &pin,
++                              .flags  = AuCpup_DTIME | AuCpup_HOPEN
++                      };
++                      err = au_sio_cpup_simple(&cpg);
++                      au_unpin(&pin);
++              }
++              if (unlikely(err))
++                      goto out_children;
++              a->dst_btop = a->btgt;
++              a->dst_h_dentry = au_h_dptr(a->dst_dentry, a->btgt);
 +      }
 +
 +      /* lock them all */
@@ -21294,12 +21509,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              /* leave the copied-up one */
 +              goto out_children;
 +
-+      if (!au_opt_test(au_mntflags(a->dst_dir->i_sb), UDBA_NONE))
-+              err = au_may_ren(a);
-+      else if (unlikely(a->dst_dentry->d_name.len > AUFS_MAX_NAMELEN))
-+              err = -ENAMETOOLONG;
-+      if (unlikely(err))
-+              goto out_hdir;
++      if (!a->exchange) {
++              if (!au_opt_test(au_mntflags(a->dst_dir->i_sb), UDBA_NONE))
++                      err = au_may_ren(a);
++              else if (unlikely(a->dst_dentry->d_name.len > AUFS_MAX_NAMELEN))
++                      err = -ENAMETOOLONG;
++              if (unlikely(err))
++                      goto out_hdir;
++      }
 +
 +      /* store timestamps to be revertible */
 +      au_ren_dt(a);
@@ -21329,14 +21546,17 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              au_set_dbtop(a->dst_dentry, a->dst_btop);
 +      }
 +out_parent:
-+      if (!err)
-+              d_move(a->src_dentry, a->dst_dentry);
-+      else {
++      if (!err) {
++              if (!a->exchange)
++                      d_move(a->src_dentry, a->dst_dentry);
++              else
++                      d_exchange(a->src_dentry, a->dst_dentry);
++      } else {
 +              au_update_dbtop(a->dst_dentry);
 +              if (!a->dst_inode)
 +                      d_drop(a->dst_dentry);
 +      }
-+      if (au_ftest_ren(a->flags, ISSAMEDIR))
++      if (au_ftest_ren(a->auren_flags, ISSAMEDIR))
 +              di_write_unlock(a->dst_parent);
 +      else
 +              di_write_unlock2(a->src_parent, a->dst_parent);
@@ -21346,14 +21566,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      iput(a->dst_inode);
 +      if (a->thargs)
 +              au_whtmp_rmdir_free(a->thargs);
-+      kfree(a);
++      au_delayed_kfree(a);
 +out:
 +      AuTraceErr(err);
 +      return err;
 +}
 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      2015-09-24 10:47:58.248052907 +0200
++++ linux/fs/aufs/Kconfig      2016-10-09 16:55:36.482701377 +0200
 @@ -0,0 +1,185 @@
 +config AUFS_FS
 +      tristate "Aufs (Advanced multi layered unification filesystem) support"
@@ -21542,8 +21762,8 @@ 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       2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,146 @@
++++ linux/fs/aufs/loop.c       2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,147 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -21650,7 +21870,8 @@ diff -urN /usr/share/empty/fs/aufs/loop.c linux/fs/aufs/loop.c
 +      new_nelem = au_warn_loopback_nelem + au_warn_loopback_step;
 +      a = au_kzrealloc(au_warn_loopback_array,
 +                       au_warn_loopback_nelem * sizeof(unsigned long),
-+                       new_nelem * sizeof(unsigned long), GFP_ATOMIC);
++                       new_nelem * sizeof(unsigned long), GFP_ATOMIC,
++                       /*may_shrink*/0);
 +      if (a) {
 +              au_warn_loopback_nelem = new_nelem;
 +              au_warn_loopback_array = a;
@@ -21688,11 +21909,11 @@ diff -urN /usr/share/empty/fs/aufs/loop.c linux/fs/aufs/loop.c
 +{
 +      if (backing_file_func)
 +              symbol_put(loop_backing_file);
-+      kfree(au_warn_loopback_array);
++      au_delayed_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       2016-07-25 19:05:34.814493242 +0200
++++ linux/fs/aufs/loop.h       2016-10-09 16:55:36.492701639 +0200
 @@ -0,0 +1,52 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -21748,7 +21969,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     2015-09-24 10:47:58.254719746 +0200
++++ linux/fs/aufs/magic.mk     2016-10-09 16:55:36.492701639 +0200
 @@ -0,0 +1,30 @@
 +
 +# defined in ${srctree}/fs/fuse/inode.c
@@ -21782,7 +22003,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     2015-09-24 10:47:58.248052907 +0200
++++ linux/fs/aufs/Makefile     2016-10-09 16:55:36.486034798 +0200
 @@ -0,0 +1,44 @@
 +
 +include ${src}/magic.mk
@@ -21830,8 +22051,8 @@ 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     2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,223 @@
++++ linux/fs/aufs/module.c     2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,333 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -21857,29 +22078,120 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 +#include <linux/seq_file.h>
 +#include "aufs.h"
 +
-+void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp)
++/* shrinkable realloc */
++void *au_krealloc(void *p, unsigned int new_sz, gfp_t gfp, int may_shrink)
 +{
-+      if (new_sz <= nused)
-+              return p;
++      size_t sz;
++      int diff;
 +
-+      p = krealloc(p, new_sz, gfp);
-+      if (p)
++      sz = 0;
++      diff = -1;
++      if (p) {
++#if 0 /* unused */
++              if (!new_sz) {
++                      au_delayed_kfree(p);
++                      p = NULL;
++                      goto out;
++              }
++#else
++              AuDebugOn(!new_sz);
++#endif
++              sz = ksize(p);
++              diff = au_kmidx_sub(sz, new_sz);
++      }
++      if (sz && !diff)
++              goto out;
++
++      if (sz < new_sz)
++              /* expand or SLOB */
++              p = krealloc(p, new_sz, gfp);
++      else if (new_sz < sz && may_shrink) {
++              /* shrink */
++              void *q;
++
++              q = kmalloc(new_sz, gfp);
++              if (q) {
++                      if (p) {
++                              memcpy(q, p, new_sz);
++                              au_delayed_kfree(p);
++                      }
++                      p = q;
++              } else
++                      p = NULL;
++      }
++
++out:
++      return p;
++}
++
++void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp,
++                 int may_shrink)
++{
++      p = au_krealloc(p, new_sz, gfp, may_shrink);
++      if (p && new_sz > nused)
 +              memset(p + nused, 0, new_sz - nused);
 +      return p;
 +}
 +
 +/* ---------------------------------------------------------------------- */
-+
 +/*
 + * aufs caches
 + */
-+struct kmem_cache *au_cachep[AuCache_Last] = {
-+      [0] = NULL
-+};
++
++struct au_dfree au_dfree;
++
++/* delayed free */
++static void au_do_dfree(struct work_struct *work __maybe_unused)
++{
++      struct llist_head *head;
++      struct llist_node *node, *next;
++
++#define AU_CACHE_DFREE_DO_BODY(name, idx, lnode) do {                 \
++              head = &au_dfree.cache[AuCache_##idx].llist;            \
++              node = llist_del_all(head);                             \
++              for (; node; node = next) {                             \
++                      struct au_##name *p                             \
++                              = llist_entry(node, struct au_##name,   \
++                                            lnode);                   \
++                      next = llist_next(node);                        \
++                      au_cache_free_##name(p);                        \
++              }                                                       \
++      } while (0)
++
++      AU_CACHE_DFREE_DO_BODY(dinfo, DINFO, di_lnode);
++      AU_CACHE_DFREE_DO_BODY(icntnr, ICNTNR, lnode);
++      AU_CACHE_DFREE_DO_BODY(finfo, FINFO, fi_lnode);
++      AU_CACHE_DFREE_DO_BODY(vdir, VDIR, vd_lnode);
++      AU_CACHE_DFREE_DO_BODY(vdir_dehstr, DEHSTR, lnode);
++#ifdef CONFIG_AUFS_HNOTIFY
++      AU_CACHE_DFREE_DO_BODY(hnotify, HNOTIFY, hn_lnode);
++#endif
++
++#define AU_DFREE_DO_BODY(llist, func) do {            \
++              node = llist_del_all(llist);            \
++              for (; node; node = next) {             \
++                      next = llist_next(node);        \
++                      func(node);                     \
++              }                                       \
++      } while (0)
++
++      AU_DFREE_DO_BODY(au_dfree.llist + AU_DFREE_KFREE, kfree);
++      AU_DFREE_DO_BODY(au_dfree.llist + AU_DFREE_FREE_PAGE, au_free_page);
++
++#undef AU_CACHE_DFREE_DO_BODY
++#undef AU_DFREE_DO_BODY
++}
++
++AU_CACHE_DFREE_FUNC(dinfo, DINFO, di_lnode);
++AU_CACHE_DFREE_FUNC(icntnr, ICNTNR, lnode);
++AU_CACHE_DFREE_FUNC(finfo, FINFO, fi_lnode);
++AU_CACHE_DFREE_FUNC(vdir, VDIR, vd_lnode);
++AU_CACHE_DFREE_FUNC(vdir_dehstr, DEHSTR, lnode);
 +
 +static void au_cache_fin(void)
 +{
 +      int i;
++      struct au_cache *cp;
 +
 +      /*
 +       * Make sure all delayed rcu free inodes are flushed before we
@@ -21889,27 +22201,33 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 +
 +      /* excluding AuCache_HNOTIFY */
 +      BUILD_BUG_ON(AuCache_HNOTIFY + 1 != AuCache_Last);
++      flush_delayed_work(&au_dfree.dwork);
 +      for (i = 0; i < AuCache_HNOTIFY; i++) {
-+              kmem_cache_destroy(au_cachep[i]);
-+              au_cachep[i] = NULL;
++              cp = au_dfree.cache + i;
++              AuDebugOn(!llist_empty(&cp->llist));
++              kmem_cache_destroy(cp->cache);
++              cp->cache = NULL;
 +      }
 +}
 +
 +static int __init au_cache_init(void)
 +{
-+      au_cachep[AuCache_DINFO] = AuCacheCtor(au_dinfo, au_di_init_once);
-+      if (au_cachep[AuCache_DINFO])
++      struct au_cache *cp;
++
++      cp = au_dfree.cache;
++      cp[AuCache_DINFO].cache = AuCacheCtor(au_dinfo, au_di_init_once);
++      if (cp[AuCache_DINFO].cache)
 +              /* SLAB_DESTROY_BY_RCU */
-+              au_cachep[AuCache_ICNTNR] = AuCacheCtor(au_icntnr,
-+                                                      au_icntnr_init_once);
-+      if (au_cachep[AuCache_ICNTNR])
-+              au_cachep[AuCache_FINFO] = AuCacheCtor(au_finfo,
-+                                                     au_fi_init_once);
-+      if (au_cachep[AuCache_FINFO])
-+              au_cachep[AuCache_VDIR] = AuCache(au_vdir);
-+      if (au_cachep[AuCache_VDIR])
-+              au_cachep[AuCache_DEHSTR] = AuCache(au_vdir_dehstr);
-+      if (au_cachep[AuCache_DEHSTR])
++              cp[AuCache_ICNTNR].cache = AuCacheCtor(au_icntnr,
++                                                     au_icntnr_init_once);
++      if (cp[AuCache_ICNTNR].cache)
++              cp[AuCache_FINFO].cache = AuCacheCtor(au_finfo,
++                                                    au_fi_init_once);
++      if (cp[AuCache_FINFO].cache)
++              cp[AuCache_VDIR].cache = AuCache(au_vdir);
++      if (cp[AuCache_VDIR].cache)
++              cp[AuCache_DEHSTR].cache = AuCache(au_vdir_dehstr);
++      if (cp[AuCache_DEHSTR].cache)
 +              return 0;
 +
 +      au_cache_fin();
@@ -21972,6 +22290,7 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 +{
 +      int err, i;
 +      char *p;
++      struct au_cache *cp;
 +
 +      p = au_esc_chars;
 +      for (i = 1; i <= ' '; i++)
@@ -21986,6 +22305,16 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 +      for (i = 0; i < AuIop_Last; i++)
 +              aufs_iop_nogetattr[i].getattr = NULL;
 +
++      /* First, initialize au_dfree */
++      for (i = 0; i < AuCache_Last; i++) {    /* including hnotify */
++              cp = au_dfree.cache + i;
++              cp->cache = NULL;
++              init_llist_head(&cp->llist);
++      }
++      for (i = 0; i < AU_DFREE_Last; i++)
++              init_llist_head(au_dfree.llist + i);
++      INIT_DELAYED_WORK(&au_dfree.dwork, au_do_dfree);
++
 +      au_sbilist_init();
 +      sysaufs_brs_init();
 +      au_debug_init();
@@ -22036,6 +22365,7 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 +out_sysaufs:
 +      sysaufs_fin();
 +      au_dy_fin();
++      flush_delayed_work(&au_dfree.dwork);
 +out:
 +      return err;
 +}
@@ -22051,14 +22381,15 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 +      au_procfs_fin();
 +      sysaufs_fin();
 +      au_dy_fin();
++      flush_delayed_work(&au_dfree.dwork);
 +}
 +
 +module_init(aufs_init);
 +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     2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,89 @@
++++ linux/fs/aufs/module.h     2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,156 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -22086,6 +22417,7 @@ diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 +#ifdef __KERNEL__
 +
 +#include <linux/slab.h>
++#include "debug.h"
 +
 +struct path;
 +struct seq_file;
@@ -22098,7 +22430,19 @@ diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 +
 +extern int au_dir_roflags;
 +
-+void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp);
++void *au_krealloc(void *p, unsigned int new_sz, gfp_t gfp, int may_shrink);
++void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp,
++                 int may_shrink);
++
++static inline int au_kmidx_sub(size_t sz, size_t new_sz)
++{
++#ifndef CONFIG_SLOB
++      return kmalloc_index(sz) - kmalloc_index(new_sz);
++#else
++      return -1; /* SLOB is untested */
++#endif
++}
++
 +int au_seq_path(struct seq_file *seq, struct path *path);
 +
 +#ifdef CONFIG_PROC_FS
@@ -22112,7 +22456,7 @@ diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 +
 +/* ---------------------------------------------------------------------- */
 +
-+/* kmem cache */
++/* kmem cache and delayed free */
 +enum {
 +      AuCache_DINFO,
 +      AuCache_ICNTNR,
@@ -22123,19 +22467,54 @@ diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 +      AuCache_Last
 +};
 +
++enum {
++      AU_DFREE_KFREE,
++      AU_DFREE_FREE_PAGE,
++      AU_DFREE_Last
++};
++
++struct au_cache {
++      struct kmem_cache       *cache;
++      struct llist_head       llist;  /* delayed free */
++};
++
++/*
++ * in order to reduce the cost of the internal timer, consolidate all the
++ * delayed free works into a single delayed_work.
++ */
++struct au_dfree {
++      struct au_cache         cache[AuCache_Last];
++      struct llist_head       llist[AU_DFREE_Last];
++      struct delayed_work     dwork;
++};
++
++extern struct au_dfree au_dfree;
++
 +#define AuCacheFlags          (SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD)
 +#define AuCache(type)         KMEM_CACHE(type, AuCacheFlags)
 +#define AuCacheCtor(type, ctor)       \
 +      kmem_cache_create(#type, sizeof(struct type), \
 +                        __alignof__(struct type), AuCacheFlags, ctor)
 +
-+extern struct kmem_cache *au_cachep[];
++#define AU_DFREE_DELAY                msecs_to_jiffies(10)
++#define AU_DFREE_BODY(lnode, llist) do {                              \
++              if (llist_add(lnode, llist))                            \
++                      schedule_delayed_work(&au_dfree.dwork,          \
++                                            AU_DFREE_DELAY);          \
++      } while (0)
++#define AU_CACHE_DFREE_FUNC(name, idx, lnode)                         \
++      void au_cache_dfree_##name(struct au_##name *p)                 \
++      {                                                               \
++              struct au_cache *cp = au_dfree.cache + AuCache_##idx;   \
++              AU_DFREE_BODY(&p->lnode, &cp->llist);                   \
++      }
 +
 +#define AuCacheFuncs(name, index) \
 +static inline struct au_##name *au_cache_alloc_##name(void) \
-+{ return kmem_cache_alloc(au_cachep[AuCache_##index], GFP_NOFS); } \
++{ return kmem_cache_alloc(au_dfree.cache[AuCache_##index].cache, GFP_NOFS); } \
 +static inline void au_cache_free_##name(struct au_##name *p) \
-+{ kmem_cache_free(au_cachep[AuCache_##index], p); }
++{ kmem_cache_free(au_dfree.cache[AuCache_##index].cache, p); } \
++void au_cache_dfree_##name(struct au_##name *p)
 +
 +AuCacheFuncs(dinfo, DINFO);
 +AuCacheFuncs(icntnr, ICNTNR);
@@ -22146,11 +22525,30 @@ diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 +AuCacheFuncs(hnotify, HNOTIFY);
 +#endif
 +
++static inline void au_delayed_kfree(const void *p)
++{
++      AuDebugOn(!p);
++      AuDebugOn(ksize(p) < sizeof(struct llist_node));
++
++      AU_DFREE_BODY((void *)p, au_dfree.llist + AU_DFREE_KFREE);
++}
++
++/* cast only */
++static inline void au_free_page(void *p)
++{
++      free_page((unsigned long)p);
++}
++
++static inline void au_delayed_free_page(unsigned long addr)
++{
++      AU_DFREE_BODY((void *)addr, au_dfree.llist + AU_DFREE_FREE_PAGE);
++}
++
 +#endif /* __KERNEL__ */
 +#endif /* __AUFS_MODULE_H__ */
 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     2016-07-25 19:05:34.814493242 +0200
++++ linux/fs/aufs/mvdown.c     2016-10-09 16:55:36.492701639 +0200
 @@ -0,0 +1,704 @@
 +/*
 + * Copyright (C) 2011-2016 Junjiro R. Okajima
@@ -22851,15 +23249,15 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +      e = copy_to_user(uarg, &args->mvdown, sizeof(args->mvdown));
 +      if (unlikely(e))
 +              err = -EFAULT;
-+      kfree(args);
++      au_delayed_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       2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,1859 @@
++++ linux/fs/aufs/opts.c       2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,1870 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -23286,6 +23684,10 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      {AuWbrCreate_MFSV, "mfs:%d"},
 +      {AuWbrCreate_MFSV, "most-free-space:%d"},
 +
++      /* top-down regardless the parent, and then mfs */
++      {AuWbrCreate_TDMFS, "tdmfs:%d"},
++      {AuWbrCreate_TDMFSV, "tdmfs:%d:%d"},
++
 +      {AuWbrCreate_MFSRR, "mfsrr:%d"},
 +      {AuWbrCreate_MFSRRV, "mfsrr:%d:%d"},
 +      {AuWbrCreate_PMFS, "pmfs"},
@@ -23361,6 +23763,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_TDMFSV:
 +      case AuWbrCreate_PMFSRRV:
 +              e = au_wbr_mfs_wmark(&args[0], str, create);
 +              if (!e)
@@ -23369,6 +23772,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +                      err = e;
 +              break;
 +      case AuWbrCreate_MFSRR:
++      case AuWbrCreate_TDMFS:
 +      case AuWbrCreate_PMFSRR:
 +              e = au_wbr_mfs_wmark(&args[0], str, create);
 +              if (unlikely(e)) {
@@ -23579,10 +23983,12 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +                              AuDbg("%d sec\n", u.create->mfs_second);
 +                              break;
 +                      case AuWbrCreate_MFSRR:
++                      case AuWbrCreate_TDMFS:
 +                              AuDbg("%llu watermark\n",
 +                                        u.create->mfsrr_watermark);
 +                              break;
 +                      case AuWbrCreate_MFSRRV:
++                      case AuWbrCreate_TDMFSV:
 +                      case AuWbrCreate_PMFSRRV:
 +                              AuDbg("%llu watermark, %d sec\n",
 +                                        u.create->mfsrr_watermark,
@@ -24118,7 +24524,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              }
 +      }
 +
-+      kfree(a);
++      au_delayed_kfree(a);
 +      dump_opts(opts);
 +      if (unlikely(err))
 +              au_opts_free(opts);
@@ -24148,6 +24554,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_TDMFS:
++      case AuWbrCreate_TDMFSV:
 +      case AuWbrCreate_PMFSRR:
 +      case AuWbrCreate_PMFSRRV:
 +              sbinfo->si_wbr_mfs.mfsrr_watermark = create->mfsrr_watermark;
@@ -24540,7 +24948,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              au_hn_inode_unlock(hdir);
 +
 +              if (!err && do_free) {
-+                      kfree(wbr);
++                      if (wbr)
++                              au_delayed_kfree(wbr);
 +                      br->br_wbr = NULL;
 +              }
 +      }
@@ -24721,8 +25130,8 @@ 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       2016-07-25 19:05:34.814493242 +0200
-@@ -0,0 +1,211 @@
++++ linux/fs/aufs/opts.h       2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,213 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -24824,6 +25233,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 +      AuWbrCreate_MFSV,       /* mfs with seconds */
 +      AuWbrCreate_MFSRR,      /* mfs then rr */
 +      AuWbrCreate_MFSRRV,     /* mfs then rr with seconds */
++      AuWbrCreate_TDMFS,      /* top down regardless parent and mfs */
++      AuWbrCreate_TDMFSV,     /* top down regardless parent and mfs */
 +      AuWbrCreate_PMFS,       /* parent and mfs */
 +      AuWbrCreate_PMFSV,      /* parent and mfs with seconds */
 +      AuWbrCreate_PMFSRR,     /* parent, mfs and round-robin */
@@ -24936,8 +25347,8 @@ 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      2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,502 @@
++++ linux/fs/aufs/plink.c      2016-10-09 16:55:36.496035060 +0200
+@@ -0,0 +1,514 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -24985,6 +25396,7 @@ diff -urN /usr/share/empty/fs/aufs/plink.c linux/fs/aufs/plink.c
 +{
 +      int err;
 +      pid_t pid, ppid;
++      struct task_struct *parent, *prev;
 +      struct au_sbinfo *sbi;
 +
 +      SiMustAnyLock(sb);
@@ -24999,11 +25411,22 @@ diff -urN /usr/share/empty/fs/aufs/plink.c linux/fs/aufs/plink.c
 +              goto out;
 +
 +      /* todo: it highly depends upon /sbin/mount.aufs */
++      prev = NULL;
++      parent = current;
++      ppid = 0;
 +      rcu_read_lock();
-+      ppid = task_pid_vnr(rcu_dereference(current->real_parent));
++      while (1) {
++              parent = rcu_dereference(parent->real_parent);
++              if (parent == prev)
++                      break;
++              ppid = task_pid_vnr(parent);
++              if (pid == ppid) {
++                      rcu_read_unlock();
++                      goto out;
++              }
++              prev = parent;
++      }
 +      rcu_read_unlock();
-+      if (pid == ppid)
-+              goto out;
 +
 +      if (au_ftest_lock(flags, NOPLMW)) {
 +              /* if there is no i_mutex lock in VFS, we don't need to wait */
@@ -25442,7 +25865,7 @@ 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       2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/poll.c       2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,52 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -25498,7 +25921,7 @@ diff -urN /usr/share/empty/fs/aufs/poll.c linux/fs/aufs/poll.c
 +}
 diff -urN /usr/share/empty/fs/aufs/posix_acl.c linux/fs/aufs/posix_acl.c
 --- /usr/share/empty/fs/aufs/posix_acl.c       1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/posix_acl.c  2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/posix_acl.c  2016-12-17 12:28:17.598545045 +0100
 @@ -0,0 +1,98 @@
 +/*
 + * Copyright (C) 2014-2016 Junjiro R. Okajima
@@ -25565,7 +25988,7 @@ diff -urN /usr/share/empty/fs/aufs/posix_acl.c linux/fs/aufs/posix_acl.c
 +      int err;
 +      ssize_t ssz;
 +      struct dentry *dentry;
-+      struct au_srxattr arg = {
++      struct au_sxattr arg = {
 +              .type = AU_ACL_SET,
 +              .u.acl_set = {
 +                      .acl    = acl,
@@ -25589,7 +26012,7 @@ diff -urN /usr/share/empty/fs/aufs/posix_acl.c linux/fs/aufs/posix_acl.c
 +              }
 +      }
 +
-+      ssz = au_srxattr(dentry, inode, &arg);
++      ssz = au_sxattr(dentry, inode, &arg);
 +      dput(dentry);
 +      err = ssz;
 +      if (ssz >= 0)
@@ -25600,7 +26023,7 @@ diff -urN /usr/share/empty/fs/aufs/posix_acl.c linux/fs/aufs/posix_acl.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     2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/procfs.c     2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,169 @@
 +/*
 + * Copyright (C) 2010-2016 Junjiro R. Okajima
@@ -25773,7 +26196,7 @@ 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        2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/rdu.c        2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,381 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -26158,7 +26581,7 @@ 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      2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/rwsem.h      2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,198 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -26360,8 +26783,8 @@ 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     2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,353 @@
++++ linux/fs/aufs/sbinfo.c     2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,355 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -26397,7 +26820,7 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +      sbinfo = container_of(kobj, struct au_sbinfo, si_kobj);
 +      for (i = 0; i < AuPlink_NHASH; i++)
 +              AuDebugOn(!hlist_empty(&sbinfo->si_plink[i].head));
-+      au_nwt_fin(&sbinfo->si_nowait);
++      AuDebugOn(atomic_read(&sbinfo->si_nowait.nw_len));
 +
 +      AuDebugOn(percpu_counter_sum(&sbinfo->si_ninodes));
 +      percpu_counter_destroy(&sbinfo->si_ninodes);
@@ -26408,14 +26831,15 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +      au_br_free(sbinfo);
 +      au_rw_write_unlock(&sbinfo->si_rwsem);
 +
-+      kfree(sbinfo->si_branch);
++      au_delayed_kfree(sbinfo->si_branch);
 +      for (i = 0; i < AU_NPIDMAP; i++)
-+              kfree(sbinfo->au_si_pid.pid_bitmap[i]);
++              if (sbinfo->au_si_pid.pid_bitmap[i])
++                      au_delayed_kfree(sbinfo->au_si_pid.pid_bitmap[i]);
 +      mutex_destroy(&sbinfo->au_si_pid.pid_mtx);
 +      mutex_destroy(&sbinfo->si_xib_mtx);
 +      AuRwDestroy(&sbinfo->si_rwsem);
 +
-+      kfree(sbinfo);
++      au_delayed_kfree(sbinfo);
 +}
 +
 +int au_si_alloc(struct super_block *sb)
@@ -26487,14 +26911,14 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +      return 0; /* success */
 +
 +out_br:
-+      kfree(sbinfo->si_branch);
++      au_delayed_kfree(sbinfo->si_branch);
 +out_sbinfo:
-+      kfree(sbinfo);
++      au_delayed_kfree(sbinfo);
 +out:
 +      return err;
 +}
 +
-+int au_sbr_realloc(struct au_sbinfo *sbinfo, int nbr)
++int au_sbr_realloc(struct au_sbinfo *sbinfo, int nbr, int may_shrink)
 +{
 +      int err, sz;
 +      struct au_branch **brp;
@@ -26505,7 +26929,8 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +      sz = sizeof(*brp) * (sbinfo->si_bbot + 1);
 +      if (unlikely(!sz))
 +              sz = sizeof(*brp);
-+      brp = au_kzrealloc(sbinfo->si_branch, sz, sizeof(*brp) * nbr, GFP_NOFS);
++      brp = au_kzrealloc(sbinfo->si_branch, sz, sizeof(*brp) * nbr, GFP_NOFS,
++                         may_shrink);
 +      if (brp) {
 +              sbinfo->si_branch = brp;
 +              err = 0;
@@ -26717,8 +27142,8 @@ 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        2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,111 @@
++++ linux/fs/aufs/spl.h        2016-10-09 16:55:36.496035060 +0200
+@@ -0,0 +1,113 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -26745,6 +27170,7 @@ diff -urN /usr/share/empty/fs/aufs/spl.h linux/fs/aufs/spl.h
 +
 +#ifdef __KERNEL__
 +
++#if 0
 +struct au_splhead {
 +      spinlock_t              spin;
 +      struct list_head        head;
@@ -26777,6 +27203,7 @@ diff -urN /usr/share/empty/fs/aufs/spl.h linux/fs/aufs/spl.h
 +      list_del_rcu(list);
 +      spin_unlock(&spl->spin);
 +}
++#endif
 +
 +/* ---------------------------------------------------------------------- */
 +
@@ -26832,8 +27259,8 @@ 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      2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,1039 @@
++++ linux/fs/aufs/super.c      2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,1046 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -26882,8 +27309,7 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +{
 +      struct inode *inode = container_of(head, struct inode, i_rcu);
 +
-+      INIT_HLIST_HEAD(&inode->i_dentry);
-+      au_cache_free_icntnr(container_of(inode, struct au_icntnr, vfs_inode));
++      au_cache_dfree_icntnr(container_of(inode, struct au_icntnr, vfs_inode));
 +}
 +
 +static void aufs_destroy_inode(struct inode *inode)
@@ -26955,15 +27381,31 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +      return err;
 +}
 +
++static void au_gen_fmt(char *fmt, int len __maybe_unused, const char *pat,
++                     const char *append)
++{
++      char *p;
++
++      p = fmt;
++      while (*pat != ':')
++              *p++ = *pat++;
++      *p++ = *pat++;
++      strcpy(p, append);
++      AuDebugOn(strlen(fmt) >= len);
++}
++
 +static void au_show_wbr_create(struct seq_file *m, int v,
 +                             struct au_sbinfo *sbinfo)
 +{
 +      const char *pat;
++      char fmt[32];
++      struct au_wbr_mfs *mfs;
 +
 +      AuRwMustAnyLock(&sbinfo->si_rwsem);
 +
 +      seq_puts(m, ",create=");
 +      pat = au_optstr_wbr_create(v);
++      mfs = &sbinfo->si_wbr_mfs;
 +      switch (v) {
 +      case AuWbrCreate_TDP:
 +      case AuWbrCreate_RR:
@@ -26971,36 +27413,28 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +      case AuWbrCreate_PMFS:
 +              seq_puts(m, pat);
 +              break;
-+      case AuWbrCreate_MFSV:
-+              seq_printf(m, /*pat*/"mfs:%lu",
-+                         jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire)
-+                         / MSEC_PER_SEC);
++      case AuWbrCreate_MFSRR:
++      case AuWbrCreate_TDMFS:
++      case AuWbrCreate_PMFSRR:
++              au_gen_fmt(fmt, sizeof(fmt), pat, "%llu");
++              seq_printf(m, fmt, mfs->mfsrr_watermark);
 +              break;
++      case AuWbrCreate_MFSV:
 +      case AuWbrCreate_PMFSV:
-+              seq_printf(m, /*pat*/"pmfs:%lu",
-+                         jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire)
++              au_gen_fmt(fmt, sizeof(fmt), pat, "%lu");
++              seq_printf(m, fmt,
++                         jiffies_to_msecs(mfs->mfs_expire)
 +                         / MSEC_PER_SEC);
 +              break;
-+      case AuWbrCreate_MFSRR:
-+              seq_printf(m, /*pat*/"mfsrr:%llu",
-+                         sbinfo->si_wbr_mfs.mfsrr_watermark);
-+              break;
 +      case AuWbrCreate_MFSRRV:
-+              seq_printf(m, /*pat*/"mfsrr:%llu:%lu",
-+                         sbinfo->si_wbr_mfs.mfsrr_watermark,
-+                         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_TDMFSV:
 +      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);
++              au_gen_fmt(fmt, sizeof(fmt), pat, "%llu:%lu");
++              seq_printf(m, fmt, mfs->mfsrr_watermark,
++                         jiffies_to_msecs(mfs->mfs_expire) / MSEC_PER_SEC);
 +              break;
++      default:
++              BUG();
 +      }
 +}
 +
@@ -27665,7 +28099,7 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +out_mtx:
 +      inode_unlock(inode);
 +out_opts:
-+      free_page((unsigned long)opts.opt);
++      au_delayed_free_page((unsigned long)opts.opt);
 +out:
 +      err = cvt_err(err);
 +      AuTraceErr(err);
@@ -27760,7 +28194,7 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +      sb->s_maxbytes = 0;
 +      sb->s_stack_depth = 1;
 +      au_export_init(sb);
-+      /* au_xattr_init(sb); */
++      au_xattr_init(sb);
 +
 +      err = alloc_root(sb);
 +      if (unlikely(err)) {
@@ -27806,7 +28240,7 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +      kobject_put(&sbinfo->si_kobj);
 +      sb->s_fs_info = NULL;
 +out_opts:
-+      free_page((unsigned long)opts.opt);
++      au_delayed_free_page((unsigned long)opts.opt);
 +out:
 +      AuTraceErr(err);
 +      err = cvt_err(err);
@@ -27875,8 +28309,8 @@ 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      2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,638 @@
++++ linux/fs/aufs/super.h      2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,639 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -28134,6 +28568,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +#define AuLock_IW             (1 << 2)        /* write-lock inode */
 +#define AuLock_FLUSH          (1 << 3)        /* wait for 'nowait' tasks */
 +#define AuLock_DIRS           (1 << 4)        /* target is a pair of dirs */
++                                              /* except RENAME_EXCHANGE */
 +#define AuLock_NOPLM          (1 << 5)        /* return err in plm mode */
 +#define AuLock_NOPLMW         (1 << 6)        /* wait for plm mode ends */
 +#define AuLock_GEN            (1 << 7)        /* test digen/iigen */
@@ -28158,7 +28593,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +/* sbinfo.c */
 +void au_si_free(struct kobject *kobj);
 +int au_si_alloc(struct super_block *sb);
-+int au_sbr_realloc(struct au_sbinfo *sbinfo, int nbr);
++int au_sbr_realloc(struct au_sbinfo *sbinfo, int nbr, int may_shrink);
 +
 +unsigned int au_sigen_inc(struct super_block *sb);
 +aufs_bindex_t au_new_br_id(struct super_block *sb);
@@ -28517,7 +28952,7 @@ 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    2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/sysaufs.c    2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,104 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -28625,7 +29060,7 @@ 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    2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/sysaufs.h    2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,101 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -28730,7 +29165,7 @@ 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      2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/sysfs.c      2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,376 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -28943,7 +29378,7 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +              if (unlikely(err == PAGE_SIZE))
 +                      err = -EFBIG;
 +      }
-+      kfree(seq);
++      au_delayed_kfree(seq);
 +out_unlock:
 +      si_read_unlock(sb);
 +out:
@@ -29014,9 +29449,9 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +              err = -EFAULT;
 +
 +out_seq:
-+      kfree(seq);
++      au_delayed_kfree(seq);
 +out_buf:
-+      free_page((unsigned long)buf);
++      au_delayed_free_page((unsigned long)buf);
 +out:
 +      si_read_unlock(sb);
 +      return err;
@@ -29110,7 +29545,7 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +}
 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      2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/sysrq.c      2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,157 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -29271,8 +29706,8 @@ 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       2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,889 @@
++++ linux/fs/aufs/vdir.c       2016-10-09 16:55:38.889431135 +0200
+@@ -0,0 +1,900 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -29385,7 +29820,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      struct hlist_node *node;
 +
 +      hlist_for_each_entry_safe(pos, node, head, wh_hash)
-+              kfree(pos);
++              au_delayed_kfree(pos);
 +}
 +
 +static void au_nhash_de_do_free(struct hlist_head *head)
@@ -29394,7 +29829,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      struct hlist_node *node;
 +
 +      hlist_for_each_entry_safe(pos, node, head, hash)
-+              au_cache_free_vdir_dehstr(pos);
++              au_cache_dfree_vdir_dehstr(pos);
 +}
 +
 +static void au_nhash_do_free(struct au_nhash *nhash,
@@ -29412,7 +29847,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +              nhash_count(head);
 +              free(head++);
 +      }
-+      kfree(nhash->nh_head);
++      au_delayed_kfree(nhash->nh_head);
 +}
 +
 +void au_nhash_wh_free(struct au_nhash *whlist)
@@ -29455,6 +29890,8 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      AuDebugOn(!nhash->nh_num || !nhash->nh_head);
 +
 +      v = 0;
++      if (len > 8)
++              len = 8;
 +      while (len--)
 +              v += *name++;
 +      /* v = hash_long(v, magic_bit); */
@@ -29552,8 +29989,8 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      unsigned char **o;
 +
 +      err = -ENOMEM;
-+      o = krealloc(vdir->vd_deblk, sizeof(*o) * (vdir->vd_nblk + 1),
-+                   GFP_NOFS);
++      o = au_krealloc(vdir->vd_deblk, sizeof(*o) * (vdir->vd_nblk + 1),
++                      GFP_NOFS, /*may_shrink*/0);
 +      if (unlikely(!o))
 +              goto out;
 +
@@ -29623,15 +30060,23 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +
 +/* ---------------------------------------------------------------------- */
 +
-+void au_vdir_free(struct au_vdir *vdir)
++void au_vdir_free(struct au_vdir *vdir, int atonce)
 +{
 +      unsigned char **deblk;
 +
 +      deblk = vdir->vd_deblk;
-+      while (vdir->vd_nblk--)
-+              kfree(*deblk++);
-+      kfree(vdir->vd_deblk);
-+      au_cache_free_vdir(vdir);
++      if (!atonce) {
++              while (vdir->vd_nblk--)
++                      au_delayed_kfree(*deblk++);
++              au_delayed_kfree(vdir->vd_deblk);
++              au_cache_dfree_vdir(vdir);
++      } else {
++              /* not delayed */
++              while (vdir->vd_nblk--)
++                      kfree(*deblk++);
++              kfree(vdir->vd_deblk);
++              au_cache_free_vdir(vdir);
++      }
 +}
 +
 +static struct au_vdir *alloc_vdir(struct file *file)
@@ -29665,10 +30110,10 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      if (!err)
 +              return vdir; /* success */
 +
-+      kfree(vdir->vd_deblk);
++      au_delayed_kfree(vdir->vd_deblk);
 +
 +out_free:
-+      au_cache_free_vdir(vdir);
++      au_cache_dfree_vdir(vdir);
 +out:
 +      vdir = ERR_PTR(err);
 +      return vdir;
@@ -29680,7 +30125,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      union au_vdir_deblk_p p, deblk_end;
 +
 +      while (vdir->vd_nblk > 1) {
-+              kfree(vdir->vd_deblk[vdir->vd_nblk - 1]);
++              au_delayed_kfree(vdir->vd_deblk[vdir->vd_nblk - 1]);
 +              /* vdir->vd_deblk[vdir->vd_nblk - 1] = NULL; */
 +              vdir->vd_nblk--;
 +      }
@@ -29811,7 +30256,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +              }
 +      }
 +
-+      free_page((unsigned long)o);
++      au_delayed_free_page((unsigned long)o);
 +
 +out:
 +      AuTraceErr(err);
@@ -29950,7 +30395,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +              if (allocated)
 +                      au_set_ivdir(inode, allocated);
 +      } else if (allocated)
-+              au_vdir_free(allocated);
++              au_vdir_free(allocated, /*atonce*/0);
 +
 +out:
 +      return err;
@@ -29968,8 +30413,8 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      if (tgt->vd_nblk < src->vd_nblk) {
 +              unsigned char **p;
 +
-+              p = krealloc(tgt->vd_deblk, sizeof(*p) * src->vd_nblk,
-+                           GFP_NOFS);
++              p = au_krealloc(tgt->vd_deblk, sizeof(*p) * src->vd_nblk,
++                              GFP_NOFS, /*may_shrink*/0);
 +              if (unlikely(!p))
 +                      goto out;
 +              tgt->vd_deblk = p;
@@ -29979,7 +30424,8 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +              unsigned char *p;
 +
 +              tgt->vd_deblk_sz = deblk_sz;
-+              p = krealloc(tgt->vd_deblk[0], deblk_sz, GFP_NOFS);
++              p = au_krealloc(tgt->vd_deblk[0], deblk_sz, GFP_NOFS,
++                              /*may_shrink*/1);
 +              if (unlikely(!p))
 +                      goto out;
 +              tgt->vd_deblk[0] = p;
@@ -30044,7 +30490,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +              if (allocated)
 +                      au_set_fvdir_cache(file, allocated);
 +      } else if (allocated)
-+              au_vdir_free(allocated);
++              au_vdir_free(allocated, /*atonce*/0);
 +
 +out:
 +      return err;
@@ -30164,8 +30610,8 @@ 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      2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,884 @@
++++ linux/fs/aufs/vfsub.c      2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,886 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -30191,7 +30637,9 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +#include <linux/nsproxy.h>
 +#include <linux/security.h>
 +#include <linux/splice.h>
++#ifdef CONFIG_AUFS_BR_FUSE
 +#include "../fs/mount.h"
++#endif
 +#include "aufs.h"
 +
 +#ifdef CONFIG_AUFS_BR_FUSE
@@ -30551,7 +30999,7 @@ 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 **delegated_inode)
++               struct inode **delegated_inode, unsigned int flags)
 +{
 +      int err;
 +      struct path tmp = {
@@ -30572,7 +31020,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +
 +      lockdep_off();
 +      err = vfs_rename(src_dir, src_dentry, dir, path->dentry,
-+                       delegated_inode, /*flags*/0);
++                       delegated_inode, flags);
 +      lockdep_on();
 +      if (!err) {
 +              int did;
@@ -31052,8 +31500,8 @@ 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      2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,310 @@
++++ linux/fs/aufs/vfsub.h      2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,316 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -31219,7 +31667,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +             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 **delegated_inode);
++               struct inode **delegated_inode, unsigned int flags);
 +int vfsub_mkdir(struct inode *dir, struct path *path, int mode);
 +int vfsub_rmdir(struct inode *dir, struct path *path);
 +
@@ -31252,6 +31700,12 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +      return flags;
 +}
 +
++static inline int vfsub_file_execed(struct file *file)
++{
++      /* todo: direct access f_flags */
++      return !!(vfsub_file_flags(file) & __FMODE_EXEC);
++}
++
 +#if 0 /* reserved */
 +static inline void vfsub_file_accessed(struct file *h_file)
 +{
@@ -31366,8 +31820,8 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +#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 2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,765 @@
++++ linux/fs/aufs/wbr_policy.c 2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,830 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -31831,7 +32285,7 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +
 +      mfs->mfsrr_bytes = bavail;
 +      AuDbg("b%d\n", mfs->mfs_bindex);
-+      kfree(st);
++      au_delayed_kfree(st);
 +}
 +
 +static int au_wbr_create_mfs(struct dentry *dentry, unsigned int flags)
@@ -31887,6 +32341,61 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +
 +/* ---------------------------------------------------------------------- */
 +
++/* top down regardless parent, and then mfs */
++static int au_wbr_create_tdmfs(struct dentry *dentry,
++                             unsigned int flags __maybe_unused)
++{
++      int err;
++      aufs_bindex_t bwh, btail, bindex, bfound, bmfs;
++      unsigned long long watermark;
++      struct super_block *sb;
++      struct au_wbr_mfs *mfs;
++      struct au_branch *br;
++      struct dentry *parent;
++
++      sb = dentry->d_sb;
++      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_mfs(dentry, /*parent*/NULL);
++      watermark = mfs->mfsrr_watermark;
++      bmfs = mfs->mfs_bindex;
++      mutex_unlock(&mfs->mfs_lock);
++
++      /* another style of au_wbr_create_exp() */
++      bwh = au_dbwh(dentry);
++      parent = dget_parent(dentry);
++      btail = au_dbtaildir(parent);
++      if (bwh >= 0 && bwh < btail)
++              btail = bwh;
++
++      err = au_wbr_nonopq(dentry, btail);
++      if (unlikely(err < 0))
++              goto out;
++      btail = err;
++      bfound = -1;
++      for (bindex = 0; bindex <= btail; bindex++) {
++              br = au_sbr(sb, bindex);
++              if (au_br_rdonly(br))
++                      continue;
++              if (br->br_wbr->wbr_bytes > watermark) {
++                      bfound = bindex;
++                      break;
++              }
++      }
++      err = bfound;
++      if (err < 0)
++              err = bmfs;
++
++out:
++      dput(parent);
++      AuDbg("b%d\n", err);
++      return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
 +/* most free space and then round robin */
 +static int au_wbr_create_mfsrr(struct dentry *dentry, unsigned int flags)
 +{
@@ -32112,6 +32621,16 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +              .init   = au_wbr_create_init_mfsrr,
 +              .fin    = au_wbr_create_fin_mfs
 +      },
++      [AuWbrCreate_TDMFS] = {
++              .create = au_wbr_create_tdmfs,
++              .init   = au_wbr_create_init_mfs,
++              .fin    = au_wbr_create_fin_mfs
++      },
++      [AuWbrCreate_TDMFSV] = {
++              .create = au_wbr_create_tdmfs,
++              .init   = au_wbr_create_init_mfs,
++              .fin    = au_wbr_create_fin_mfs
++      },
 +      [AuWbrCreate_PMFS] = {
 +              .create = au_wbr_create_pmfs,
 +              .init   = au_wbr_create_init_mfs,
@@ -32135,8 +32654,8 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 +};
 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      2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,1060 @@
++++ linux/fs/aufs/whout.c      2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,1061 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -32301,7 +32820,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +
 +out_name:
 +      if (name != defname)
-+              kfree(name);
++              au_delayed_kfree(name);
 +out:
 +      AuTraceErrPtr(dentry);
 +      return dentry;
@@ -32330,7 +32849,8 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +
 +      /* under the same dir, no need to lock_rename() */
 +      delegated = NULL;
-+      err = vfsub_rename(h_dir, h_dentry, h_dir, &h_path, &delegated);
++      err = vfsub_rename(h_dir, h_dentry, h_dir, &h_path, &delegated,
++                         /*flags*/0);
 +      AuTraceErr(err);
 +      if (unlikely(err == -EWOULDBLOCK)) {
 +              pr_warn("cannot retry for NFSv4 delegation"
@@ -32740,7 +33260,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      au_br_put(a->br);
 +      si_write_unlock(a->sb);
 +      au_nwt_done(&au_sbi(a->sb)->si_nowait);
-+      kfree(arg);
++      au_delayed_kfree(arg);
 +      if (unlikely(err))
 +              AuIOErr("err %d\n", err);
 +}
@@ -32768,7 +33288,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +              if (unlikely(wkq_err)) {
 +                      atomic_dec(&br->br_wbr->wbr_wh_running);
 +                      au_br_put(br);
-+                      kfree(arg);
++                      au_delayed_kfree(arg);
 +              }
 +              do_dec = 0;
 +      }
@@ -32927,7 +33447,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      wh_dentry = ERR_PTR(err);
 +      if (!err) {
 +              wh_dentry = vfsub_lkup_one(&wh_name, h_parent);
-+              kfree(wh_name.name);
++              au_delayed_kfree(wh_name.name);
 +      }
 +      return wh_dentry;
 +}
@@ -33003,7 +33523,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +                      break;
 +              }
 +      }
-+      free_page((unsigned long)wh_name.name);
++      au_delayed_free_page((unsigned long)wh_name.name);
 +
 +out:
 +      return err;
@@ -33045,7 +33565,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +              rdhash = AUFS_RDHASH_DEF;
 +      err = au_nhash_alloc(&whtmp->whlist, rdhash, gfp);
 +      if (unlikely(err)) {
-+              kfree(whtmp);
++              au_delayed_kfree(whtmp);
 +              whtmp = ERR_PTR(err);
 +      }
 +
@@ -33060,7 +33580,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      dput(whtmp->wh_dentry);
 +      iput(whtmp->dir);
 +      au_nhash_wh_free(&whtmp->whlist);
-+      kfree(whtmp);
++      au_delayed_kfree(whtmp);
 +}
 +
 +/*
@@ -33199,7 +33719,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +}
 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      2016-07-25 19:05:34.817826663 +0200
++++ linux/fs/aufs/whout.h      2016-10-09 16:55:36.496035060 +0200
 @@ -0,0 +1,85 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -33288,8 +33808,8 @@ 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        2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,218 @@
++++ linux/fs/aufs/wkq.c        2016-10-09 16:55:36.496035060 +0200
+@@ -0,0 +1,213 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -33346,7 +33866,7 @@ diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 +      else {
 +              kobject_put(wkinfo->kobj);
 +              module_put(THIS_MODULE); /* todo: ?? */
-+              kfree(wkinfo);
++              au_delayed_kfree(wkinfo);
 +      }
 +}
 +
@@ -33369,7 +33889,7 @@ diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 +
 +static void au_wkq_comp_free(struct completion *comp)
 +{
-+      kfree(comp);
++      au_delayed_kfree(comp);
 +}
 +
 +#else
@@ -33450,7 +33970,7 @@ diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 +      int err;
 +      struct au_wkinfo *wkinfo;
 +
-+      percpu_counter_inc(&au_sbi(sb)->si_nowait.nw_len);
++      atomic_inc(&au_sbi(sb)->si_nowait.nw_len);
 +
 +      /*
 +       * wkq_func() must free this wkinfo.
@@ -33480,16 +34000,11 @@ diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 +
 +void au_nwt_init(struct au_nowait_tasks *nwt)
 +{
-+      percpu_counter_init(&nwt->nw_len, 0, GFP_NOFS);
++      atomic_set(&nwt->nw_len, 0);
++      /* smp_mb(); */ /* atomic_set */
 +      init_waitqueue_head(&nwt->nw_wq);
 +}
 +
-+void au_nwt_fin(struct au_nowait_tasks *nwt)
-+{
-+      AuDebugOn(percpu_counter_sum(&nwt->nw_len));
-+      percpu_counter_destroy(&nwt->nw_len);
-+}
-+
 +void au_wkq_fin(void)
 +{
 +      destroy_workqueue(au_wkq);
@@ -33510,8 +34025,8 @@ 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        2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,95 @@
++++ linux/fs/aufs/wkq.h        2016-10-09 16:55:36.496035060 +0200
+@@ -0,0 +1,93 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -33549,7 +34064,7 @@ diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h
 + * in the next operation, wait for the 'nowait' tasks in system-wide workqueue
 + */
 +struct au_nowait_tasks {
-+      struct percpu_counter   nw_len;
++      atomic_t                nw_len;
 +      wait_queue_head_t       nw_wq;
 +};
 +
@@ -33576,7 +34091,6 @@ diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h
 +int au_wkq_nowait(au_wkq_func_t func, void *args, struct super_block *sb,
 +                unsigned int flags);
 +void au_nwt_init(struct au_nowait_tasks *nwt);
-+void au_nwt_fin(struct au_nowait_tasks *nwt);
 +int __init au_wkq_init(void);
 +void au_wkq_fin(void);
 +
@@ -33594,14 +34108,13 @@ diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h
 +
 +static inline void au_nwt_done(struct au_nowait_tasks *nwt)
 +{
-+      percpu_counter_dec(&nwt->nw_len);
-+      if (!percpu_counter_sum(&nwt->nw_len))
++      if (atomic_dec_and_test(&nwt->nw_len))
 +              wake_up_all(&nwt->nw_wq);
 +}
 +
 +static inline int au_nwt_flush(struct au_nowait_tasks *nwt)
 +{
-+      wait_event(nwt->nw_wq, !percpu_counter_sum(&nwt->nw_len));
++      wait_event(nwt->nw_wq, !atomic_read(&nwt->nw_len));
 +      return 0;
 +}
 +
@@ -33609,8 +34122,8 @@ 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/xattr.c linux/fs/aufs/xattr.c
 --- /usr/share/empty/fs/aufs/xattr.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/xattr.c      2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,345 @@
++++ linux/fs/aufs/xattr.c      2016-12-17 12:28:17.598545045 +0100
+@@ -0,0 +1,332 @@
 +/*
 + * Copyright (C) 2014-2016 Junjiro R. Okajima
 + *
@@ -33789,10 +34302,12 @@ diff -urN /usr/share/empty/fs/aufs/xattr.c linux/fs/aufs/xattr.c
 +              AuTraceErr(err);
 +      }
 +
-+      kfree(value);
++      if (value)
++              au_delayed_kfree(value);
 +
 +out_free:
-+      kfree(o);
++      if (o)
++              au_delayed_kfree(o);
 +out:
 +      if (!unlocked)
 +              inode_unlock(h_isrc);
@@ -33875,8 +34390,9 @@ diff -urN /usr/share/empty/fs/aufs/xattr.c linux/fs/aufs/xattr.c
 +      return au_lgxattr(dentry, &arg);
 +}
 +
-+ssize_t aufs_getxattr(struct dentry *dentry, struct inode *inode __maybe_unused,
-+                    const char *name, void *value, size_t size)
++static ssize_t au_getxattr(struct dentry *dentry,
++                         struct inode *inode __maybe_unused,
++                         const char *name, void *value, size_t size)
 +{
 +      struct au_lgxattr arg = {
 +              .type = AU_XATTR_GET,
@@ -33890,10 +34406,11 @@ diff -urN /usr/share/empty/fs/aufs/xattr.c linux/fs/aufs/xattr.c
 +      return au_lgxattr(dentry, &arg);
 +}
 +
-+int aufs_setxattr(struct dentry *dentry, struct inode *inode, const char *name,
-+                const void *value, size_t size, int flags)
++static int au_setxattr(struct dentry *dentry, struct inode *inode,
++                     const char *name, const void *value, size_t size,
++                     int flags)
 +{
-+      struct au_srxattr arg = {
++      struct au_sxattr arg = {
 +              .type = AU_XATTR_SET,
 +              .u.set = {
 +                      .name   = name,
@@ -33903,63 +34420,46 @@ diff -urN /usr/share/empty/fs/aufs/xattr.c linux/fs/aufs/xattr.c
 +              },
 +      };
 +
-+      return au_srxattr(dentry, inode, &arg);
-+}
-+
-+int aufs_removexattr(struct dentry *dentry, const char *name)
-+{
-+      struct au_srxattr arg = {
-+              .type = AU_XATTR_REMOVE,
-+              .u.remove = {
-+                      .name   = name
-+              },
-+      };
-+
-+      return au_srxattr(dentry, d_inode(dentry), &arg);
++      return au_sxattr(dentry, inode, &arg);
 +}
 +
 +/* ---------------------------------------------------------------------- */
 +
-+#if 0
-+static size_t au_xattr_list(struct dentry *dentry, char *list, size_t list_size,
-+                          const char *name, size_t name_len, int type)
-+{
-+      return aufs_listxattr(dentry, list, list_size);
-+}
-+
-+static int au_xattr_get(struct dentry *dentry, const char *name, void *buffer,
-+                      size_t size, int type)
++static int au_xattr_get(const struct xattr_handler *handler,
++                      struct dentry *dentry, struct inode *inode,
++                      const char *name, void *buffer, size_t size)
 +{
-+      return aufs_getxattr(dentry, name, buffer, size);
++      return au_getxattr(dentry, inode, name, buffer, size);
 +}
 +
-+static int au_xattr_set(struct dentry *dentry, const char *name,
-+                      const void *value, size_t size, int flags, int type)
++static int au_xattr_set(const struct xattr_handler *handler,
++                      struct dentry *dentry, struct inode *inode,
++                      const char *name, const void *value, size_t size,
++                      int flags)
 +{
-+      return aufs_setxattr(dentry, name, value, size, flags);
++      return au_setxattr(dentry, inode, name, value, size, flags);
 +}
 +
 +static const struct xattr_handler au_xattr_handler = {
-+      /* no prefix, no flags */
-+      .list   = au_xattr_list,
++      .name   = "",
++      .prefix = "",
 +      .get    = au_xattr_get,
 +      .set    = au_xattr_set
-+      /* why no remove? */
 +};
 +
 +static const struct xattr_handler *au_xattr_handlers[] = {
-+      &au_xattr_handler
++      &au_xattr_handler,
++      NULL
 +};
 +
 +void au_xattr_init(struct super_block *sb)
 +{
-+      /* sb->s_xattr = au_xattr_handlers; */
++      sb->s_xattr = au_xattr_handlers;
 +}
-+#endif
 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       2016-07-25 19:05:34.817826663 +0200
-@@ -0,0 +1,1317 @@
++++ linux/fs/aufs/xino.c       2016-10-09 16:55:36.496035060 +0200
+@@ -0,0 +1,1318 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
 + *
@@ -34300,7 +34800,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +              AuErr1("statfs err %d, ignored\n", err);
 +
 +out_st:
-+      kfree(st);
++      au_delayed_kfree(st);
 +out:
 +      return err;
 +}
@@ -34335,7 +34835,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      au_br_put(br);
 +      si_write_unlock(sb);
 +      au_nwt_done(&au_sbi(sb)->si_nowait);
-+      kfree(args);
++      au_delayed_kfree(args);
 +}
 +
 +static int xino_trunc_test(struct super_block *sb, struct au_branch *br)
@@ -34377,7 +34877,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      args = kmalloc(sizeof(*args), GFP_NOFS);
 +      if (unlikely(!args)) {
 +              AuErr1("no memory\n");
-+              goto out_args;
++              goto out;
 +      }
 +
 +      au_br_get(br);
@@ -34389,9 +34889,8 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +
 +      pr_err("wkq %d\n", wkq_err);
 +      au_br_put(br);
++      au_delayed_kfree(args);
 +
-+out_args:
-+      kfree(args);
 +out:
 +      atomic_dec(&br->br_xino_running);
 +}
@@ -34914,7 +35413,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +                              (sb, au_sbr(sb, bindex)->br_xino.xi_file, page);
 +              else
 +                      AuDbg("b%d\n", bindex);
-+      free_page((unsigned long)page);
++      au_delayed_free_page((unsigned long)page);
 +
 +out:
 +      return err;
@@ -34991,7 +35490,8 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      if (sbinfo->si_xib)
 +              fput(sbinfo->si_xib);
 +      sbinfo->si_xib = NULL;
-+      free_page((unsigned long)sbinfo->si_xib_buf);
++      if (sbinfo->si_xib_buf)
++              au_delayed_free_page((unsigned long)sbinfo->si_xib_buf);
 +      sbinfo->si_xib_buf = NULL;
 +}
 +
@@ -35034,7 +35534,8 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      goto out; /* success */
 +
 +out_free:
-+      free_page((unsigned long)sbinfo->si_xib_buf);
++      if (sbinfo->si_xib_buf)
++              au_delayed_free_page((unsigned long)sbinfo->si_xib_buf);
 +      sbinfo->si_xib_buf = NULL;
 +      if (err >= 0)
 +              err = -EIO;
@@ -35127,7 +35628,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +                      fput(p->new);
 +              else
 +                      break;
-+      kfree(fpair);
++      au_delayed_kfree(fpair);
 +out:
 +      return err;
 +}
@@ -35238,7 +35739,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +                      if (!IS_ERR(file))
 +                              au_xino_brid_set(sb, br->br_id);
 +              }
-+              free_page((unsigned long)page);
++              au_delayed_free_page((unsigned long)page);
 +      } else {
 +              file = au_xino_create(sb, AUFS_XINO_DEFPATH, /*silent*/0);
 +              if (IS_ERR(file))
@@ -35279,7 +35780,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +}
 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       2016-07-25 19:05:34.817826663 +0200
++++ linux/include/uapi/linux/aufs_type.h       2016-12-17 12:28:38.769494865 +0100
 @@ -0,0 +1,419 @@
 +/*
 + * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -35322,7 +35823,7 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +
 +#include <linux/limits.h>
 +
-+#define AUFS_VERSION  "4.x-rcN-20160704"
++#define AUFS_VERSION  "4.9-20161219"
 +
 +/* todo? move this to linux-2.6.19/include/magic.h */
 +#define AUFS_SUPER_MAGIC      ('a' << 24 | 'u' << 16 | 'f' << 8 | 's')
@@ -35700,13 +36201,13 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +#define AUFS_CTL_FHSM_FD      _IOW(AuCtlType, AuCtl_FHSM_FD, int)
 +
 +#endif /* __AUFS_TYPE_H__ */
-aufs4.x-rcN loopback patch
+aufs4.9 loopback patch
 
 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
-index 7339e65..76e5da4 100644
+index 6ee9235..f64161f 100644
 --- a/drivers/block/loop.c
 +++ b/drivers/block/loop.c
-@@ -562,7 +562,7 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
+@@ -551,7 +551,7 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
  }
  
  struct switch_request {
@@ -35715,7 +36216,7 @@ index 7339e65..76e5da4 100644
        struct completion wait;
  };
  
-@@ -588,6 +588,7 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
+@@ -577,6 +577,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;
@@ -35723,7 +36224,7 @@ index 7339e65..76e5da4 100644
        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);
-@@ -600,11 +601,13 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
+@@ -589,11 +590,13 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
   * 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.
   */
@@ -35738,7 +36239,7 @@ index 7339e65..76e5da4 100644
  
        /* freeze queue and wait for completion of scheduled requests */
        blk_mq_freeze_queue(lo->lo_queue);
-@@ -623,7 +626,16 @@ static int loop_switch(struct loop_device *lo, struct file *file)
+@@ -612,7 +615,16 @@ static int loop_switch(struct loop_device *lo, struct file *file)
   */
  static int loop_flush(struct loop_device *lo)
  {
@@ -35756,7 +36257,7 @@ index 7339e65..76e5da4 100644
  }
  
  static void loop_reread_partitions(struct loop_device *lo,
-@@ -660,6 +672,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+@@ -649,6 +661,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
                          unsigned int arg)
  {
        struct file     *file, *old_file;
@@ -35764,7 +36265,7 @@ index 7339e65..76e5da4 100644
        struct inode    *inode;
        int             error;
  
-@@ -676,9 +689,16 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+@@ -665,9 +678,16 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
        file = fget(arg);
        if (!file)
                goto out;
@@ -35781,7 +36282,7 @@ index 7339e65..76e5da4 100644
  
        error = -EINVAL;
  
-@@ -690,17 +710,21 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+@@ -679,17 +699,21 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
                goto out_putf;
  
        /* and ... switch */
@@ -35804,7 +36305,7 @@ index 7339e65..76e5da4 100644
   out:
        return error;
  }
-@@ -887,7 +911,7 @@ static int loop_prepare_queue(struct loop_device *lo)
+@@ -876,7 +900,7 @@ static int loop_prepare_queue(struct loop_device *lo)
  static int loop_set_fd(struct loop_device *lo, fmode_t mode,
                       struct block_device *bdev, unsigned int arg)
  {
@@ -35813,7 +36314,7 @@ index 7339e65..76e5da4 100644
        struct inode    *inode;
        struct address_space *mapping;
        unsigned lo_blocksize;
-@@ -902,6 +926,12 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+@@ -891,6 +915,12 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
        file = fget(arg);
        if (!file)
                goto out;
@@ -35826,7 +36327,7 @@ index 7339e65..76e5da4 100644
  
        error = -EBUSY;
        if (lo->lo_state != Lo_unbound)
-@@ -954,6 +984,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+@@ -943,6 +973,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;
@@ -35834,7 +36335,7 @@ index 7339e65..76e5da4 100644
        lo->transfer = NULL;
        lo->ioctl = NULL;
        lo->lo_sizelimit = 0;
-@@ -986,6 +1017,8 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+@@ -975,6 +1006,8 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
  
   out_putf:
        fput(file);
@@ -35843,7 +36344,7 @@ index 7339e65..76e5da4 100644
   out:
        /* This is safe: open() is still holding a reference. */
        module_put(THIS_MODULE);
-@@ -1032,6 +1065,7 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
+@@ -1021,6 +1054,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
  static int loop_clr_fd(struct loop_device *lo)
  {
        struct file *filp = lo->lo_backing_file;
@@ -35851,7 +36352,7 @@ index 7339e65..76e5da4 100644
        gfp_t gfp = lo->old_gfp_mask;
        struct block_device *bdev = lo->lo_device;
  
-@@ -1063,6 +1097,7 @@ static int loop_clr_fd(struct loop_device *lo)
+@@ -1052,6 +1086,7 @@ static int loop_clr_fd(struct loop_device *lo)
        spin_lock_irq(&lo->lo_lock);
        lo->lo_state = Lo_rundown;
        lo->lo_backing_file = NULL;
@@ -35859,7 +36360,7 @@ index 7339e65..76e5da4 100644
        spin_unlock_irq(&lo->lo_lock);
  
        loop_release_xfer(lo);
-@@ -1107,6 +1142,8 @@ static int loop_clr_fd(struct loop_device *lo)
+@@ -1096,6 +1131,8 @@ static int loop_clr_fd(struct loop_device *lo)
         * bd_mutex which is usually taken before lo_ctl_mutex.
         */
        fput(filp);
@@ -35882,10 +36383,10 @@ index fb2237c..c3888c5 100644
        unsigned        lo_blocksize;
        void            *key_data; 
 diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c
-index 504b767..09426ad 100644
+index d2a9a1d..d7519d0 100644
 --- a/fs/aufs/f_op.c
 +++ b/fs/aufs/f_op.c
-@@ -346,7 +346,7 @@ static ssize_t aufs_read_iter(struct kiocb *kio, struct iov_iter *iov_iter)
+@@ -351,7 +351,7 @@ static ssize_t aufs_read_iter(struct kiocb *kio, struct iov_iter *iov_iter)
        if (IS_ERR(h_file))
                goto out;
  
@@ -35895,12 +36396,12 @@ index 504b767..09426ad 100644
                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 5711e7a..9df5d16 100644
+index c3ca50f..a3dbdaf 100644
 --- a/fs/aufs/loop.c
 +++ b/fs/aufs/loop.c
-@@ -131,3 +131,19 @@ void au_loopback_fin(void)
+@@ -132,3 +132,19 @@ void au_loopback_fin(void)
                symbol_put(loop_backing_file);
-       kfree(au_warn_loopback_array);
+       au_delayed_kfree(au_warn_loopback_array);
  }
 +
 +/* ---------------------------------------------------------------------- */
@@ -35922,7 +36423,7 @@ diff --git a/fs/aufs/loop.h b/fs/aufs/loop.h
 index 48bf070..66afec7 100644
 --- a/fs/aufs/loop.h
 +++ b/fs/aufs/loop.h
-@@ -25,7 +25,11 @@ void au_warn_loopback(struct super_block *h_sb);
+@@ -25,7 +25,11 @@
  
  int au_loopback_init(void);
  void au_loopback_fin(void);
@@ -35934,7 +36435,7 @@ index 48bf070..66afec7 100644
  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)
+@@ -33,6 +37,8 @@
  
  AuStubInt0(au_loopback_init, void)
  AuStubVoid(au_loopback_fin, void)
@@ -35944,10 +36445,10 @@ index 48bf070..66afec7 100644
  
  #endif /* __KERNEL__ */
 diff --git a/fs/aufs/super.c b/fs/aufs/super.c
-index 8bd2d9c..26581c0 100644
+index 0082ce4..5085378 100644
 --- a/fs/aufs/super.c
 +++ b/fs/aufs/super.c
-@@ -832,7 +832,10 @@ static const struct super_operations aufs_sop = {
+@@ -839,7 +839,10 @@ static int aufs_remount_fs(struct super_block *sb, int *flags, char *data)
        .statfs         = aufs_statfs,
        .put_super      = aufs_put_super,
        .sync_fs        = aufs_sync_fs,
@@ -35960,10 +36461,10 @@ index 8bd2d9c..26581c0 100644
  
  /* ---------------------------------------------------------------------- */
 diff --git a/include/linux/fs.h b/include/linux/fs.h
-index 33c6953..f9b06a2 100644
+index a903bc3..db820e3 100644
 --- a/include/linux/fs.h
 +++ b/include/linux/fs.h
-@@ -1805,6 +1805,10 @@ struct super_operations {
+@@ -1823,6 +1823,10 @@ struct super_operations {
                                  struct shrink_control *);
        long (*free_cached_objects)(struct super_block *,
                                    struct shrink_control *);
This page took 0.489453 seconds and 4 git commands to generate.