]> git.pld-linux.org Git - packages/kernel.git/blobdiff - kernel-aufs3.patch
- partial update to 4.1.0 (aufs, imq need fixes)
[packages/kernel.git] / kernel-aufs3.patch
index 2edef241cfbb55c0fe7e9373f3ac08851110a3bc..53816565ec3236e8b12f862535097122b30f099d 100644 (file)
@@ -1,45 +1,70 @@
-aufs3.16 kbuild patch
+aufs3.x-rcN kbuild patch
 
 diff --git a/fs/Kconfig b/fs/Kconfig
-index 312393f..78632ed 100644
+index ec35851..a059d62 100644
 --- a/fs/Kconfig
 +++ b/fs/Kconfig
-@@ -209,6 +209,7 @@ source "fs/ufs/Kconfig"
+@@ -218,6 +218,7 @@ source "fs/sysv/Kconfig"
+ source "fs/ufs/Kconfig"
  source "fs/exofs/Kconfig"
  source "fs/f2fs/Kconfig"
- source "fs/efivarfs/Kconfig"
 +source "fs/aufs/Kconfig"
  
  endif # MISC_FILESYSTEMS
  
 diff --git a/fs/Makefile b/fs/Makefile
-index 4030cbf..5bd169a 100644
+index a88ac48..162500e 100644
 --- a/fs/Makefile
 +++ b/fs/Makefile
-@@ -125,3 +125,4 @@ obj-y                              += exofs/ # Multiple modules
+@@ -126,3 +126,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 24e9033..fe9a8d4 100644
+index 68ceb97..0352fa4 100644
 --- a/include/uapi/linux/Kbuild
 +++ b/include/uapi/linux/Kbuild
-@@ -56,6 +56,7 @@ header-y += atmppp.h
- header-y += atmsap.h
- header-y += atmsvc.h
+@@ -58,6 +58,7 @@ header-y += atmsvc.h
+ header-y += atm_tcp.h
+ header-y += atm_zatm.h
  header-y += audit.h
 +header-y += aufs_type.h
- header-y += auto_fs.h
  header-y += auto_fs4.h
+ header-y += auto_fs.h
  header-y += auxvec.h
-aufs3.16 base patch
+aufs3.x-rcN base patch
 
+diff --git a/MAINTAINERS b/MAINTAINERS
+index efbcb50..30a1654 100644
+--- a/MAINTAINERS
++++ b/MAINTAINERS
+@@ -1864,6 +1864,20 @@ F:      include/linux/audit.h
+ F:    include/uapi/linux/audit.h
+ F:    kernel/audit*
++AUFS (advanced multi layered unification filesystem) FILESYSTEM
++M:    "J. R. Okajima" <hooanon05g@gmail.com>
++L:    linux-unionfs@vger.kernel.org
++L:    aufs-users@lists.sourceforge.net (members only)
++W:    http://aufs.sourceforge.net
++T:    git://git.code.sf.net/p/aufs/aufs3-linux
++T:    git://github.com/sfjro/aufs3-linux.git
++S:    Supported
++F:    Documentation/filesystems/aufs/
++F:    Documentation/ABI/testing/debugfs-aufs
++F:    Documentation/ABI/testing/sysfs-aufs
++F:    fs/aufs/
++F:    include/uapi/linux/aufs_type.h
++
+ AUXILIARY DISPLAY DRIVERS
+ 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 6cb1beb..30efd68 100644
+index d1f168b..a0da519 100644
 --- a/drivers/block/loop.c
 +++ b/drivers/block/loop.c
-@@ -692,6 +692,24 @@ static inline int is_loop_device(struct file *file)
+@@ -592,6 +592,24 @@ static inline int is_loop_device(struct file *file)
        return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
  }
  
@@ -64,24 +89,24 @@ index 6cb1beb..30efd68 100644
  /* loop sysfs attributes */
  
  static ssize_t loop_attr_show(struct device *dev, char *page,
-diff --git a/fs/inode.c b/fs/inode.c
-index 6eecb7f..b225c0f 100644
---- a/fs/inode.c
-+++ b/fs/inode.c
-@@ -1496,7 +1496,7 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
-  * This does the actual work of updating an inodes time or version.  Must have
-  * had called mnt_want_write() before calling this.
+diff --git a/fs/dcache.c b/fs/dcache.c
+index c71e373..b93a9f2 100644
+--- a/fs/dcache.c
++++ b/fs/dcache.c
+@@ -1130,7 +1130,7 @@ enum d_walk_ret {
+  *
+  * The @enter() and @finish() callbacks are called with d_lock held.
   */
--static int update_time(struct inode *inode, struct timespec *time, int flags)
-+int update_time(struct inode *inode, struct timespec *time, int flags)
+-static void d_walk(struct dentry *parent, void *data,
++void d_walk(struct dentry *parent, void *data,
+                  enum d_walk_ret (*enter)(void *, struct dentry *),
+                  void (*finish)(void *))
  {
-       if (inode->i_op->update_time)
-               return inode->i_op->update_time(inode, time, flags);
 diff --git a/fs/splice.c b/fs/splice.c
-index f5cb9ba..9ba380c 100644
+index 7968da9..beb9993 100644
 --- a/fs/splice.c
 +++ b/fs/splice.c
-@@ -1114,8 +1114,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
+@@ -1099,8 +1099,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
  /*
   * Attempt to initiate a splice from pipe to file.
   */
@@ -92,7 +117,7 @@ index f5cb9ba..9ba380c 100644
  {
        ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
                                loff_t *, size_t, unsigned int);
-@@ -1131,9 +1131,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+@@ -1116,9 +1116,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.
   */
@@ -105,18 +130,18 @@ index f5cb9ba..9ba380c 100644
  {
        ssize_t (*splice_read)(struct file *, loff_t *,
                               struct pipe_inode_info *, size_t, unsigned int);
-diff --git a/include/linux/fs.h b/include/linux/fs.h
-index e11d60c..2f32b35 100644
---- a/include/linux/fs.h
-+++ b/include/linux/fs.h
-@@ -2618,6 +2618,7 @@ extern int inode_change_ok(const struct inode *, struct iattr *);
- extern int inode_newsize_ok(const struct inode *, loff_t offset);
- extern void setattr_copy(struct inode *inode, const struct iattr *attr);
-+extern int update_time(struct inode *, struct timespec *, int);
- extern int file_update_time(struct file *file);
+diff --git a/include/linux/file.h b/include/linux/file.h
+index f87d308..9a290b3 100644
+--- a/include/linux/file.h
++++ b/include/linux/file.h
+@@ -19,6 +19,7 @@ struct dentry;
+ struct path;
+ extern struct file *alloc_file(struct path *, fmode_t mode,
+       const struct file_operations *fop);
++extern struct file *get_empty_filp(void);
  
- extern int generic_show_options(struct seq_file *m, struct dentry *root);
+ static inline void fput_light(struct file *file, int fput_needed)
+ {
 diff --git a/include/linux/splice.h b/include/linux/splice.h
 index da2751d..2e0fca6 100644
 --- a/include/linux/splice.h
@@ -132,13 +157,13 @@ index da2751d..2e0fca6 100644
 +                       struct pipe_inode_info *pipe, size_t len,
 +                       unsigned int flags);
  #endif
-aufs3.16 mmap patch
+aufs3.x-rcN mmap patch
 
 diff --git a/fs/buffer.c b/fs/buffer.c
-index eba6e4f..31f0b2d 100644
+index 20805db..363569f 100644
 --- a/fs/buffer.c
 +++ b/fs/buffer.c
-@@ -2460,7 +2460,7 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
+@@ -2450,7 +2450,7 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
         * Update file times before taking page lock. We may end up failing the
         * fault so this update may be superfluous but who really cares...
         */
@@ -147,6 +172,19 @@ index eba6e4f..31f0b2d 100644
  
        ret = __block_page_mkwrite(vma, vmf, get_block);
        sb_end_pagefault(sb);
+diff --git a/fs/proc/base.c b/fs/proc/base.c
+index 3f3d7ae..426bcc7 100644
+--- a/fs/proc/base.c
++++ b/fs/proc/base.c
+@@ -1735,7 +1735,7 @@ static int proc_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) {
+-              *path = vma->vm_file->f_path;
++              *path = vma_pr_or_file(vma)->f_path;
+               path_get(path);
+               rc = 0;
+       }
 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
 index d4a3574..1397181 100644
 --- a/fs/proc/nommu.c
@@ -164,10 +202,10 @@ index d4a3574..1397181 100644
                ino = inode->i_ino;
        }
 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
-index cfa63ee..bf4919e 100644
+index 6dee68d..9afa35d 100644
 --- a/fs/proc/task_mmu.c
 +++ b/fs/proc/task_mmu.c
-@@ -265,7 +265,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
+@@ -279,7 +279,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
        const char *name = NULL;
  
        if (file) {
@@ -179,40 +217,39 @@ index cfa63ee..bf4919e 100644
                dev = inode->i_sb->s_dev;
                ino = inode->i_ino;
                pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
-@@ -1390,7 +1393,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
+@@ -1479,7 +1482,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;
 -      struct file *file = vma->vm_file;
 +      struct file *file = vma_pr_or_file(vma);
-       struct task_struct *task = proc_priv->task;
        struct mm_struct *mm = vma->vm_mm;
-       struct mm_walk walk = {};
+       struct mm_walk walk = {
+               .hugetlb_entry = gather_hugetlb_stats,
 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
-index 678455d..0ef7ef4 100644
+index 599ec2e..1740207 100644
 --- a/fs/proc/task_nommu.c
 +++ b/fs/proc/task_nommu.c
-@@ -141,7 +141,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
+@@ -160,7 +160,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
        file = vma->vm_file;
  
        if (file) {
 -              struct inode *inode = file_inode(vma->vm_file);
 +              struct inode *inode;
 +
-+              file = vma_pr_or_file(file);
++              file = vma_pr_or_file(vma);
 +              inode = file_inode(file);
                dev = inode->i_sb->s_dev;
                ino = inode->i_ino;
                pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
 diff --git a/include/linux/mm.h b/include/linux/mm.h
-index e03dd29..dd32624 100644
+index 47a9392..c8f8b46 100644
 --- a/include/linux/mm.h
 +++ b/include/linux/mm.h
-@@ -1184,6 +1184,28 @@ static inline int fixup_user_fault(struct task_struct *tsk,
+@@ -1254,6 +1254,28 @@ static inline int fixup_user_fault(struct task_struct *tsk,
  }
  #endif
  
-+#ifdef CONFIG_MMU
 +extern void vma_do_file_update_time(struct vm_area_struct *, const char[], int);
 +extern struct file *vma_do_pr_or_file(struct vm_area_struct *, const char[],
 +                                    int);
@@ -225,23 +262,24 @@ index e03dd29..dd32624 100644
 +                                                        __LINE__)
 +#define vma_get_file(vma)             vma_do_get_file(vma, __func__, __LINE__)
 +#define vma_fput(vma)                 vma_do_fput(vma, __func__, __LINE__)
-+#else
++
++#ifndef CONFIG_MMU
 +extern struct file *vmr_do_pr_or_file(struct vm_region *, const char[], int);
 +extern void vmr_do_fput(struct vm_region *, const char[], int);
 +
 +#define vmr_pr_or_file(region)                vmr_do_pr_or_file(region, __func__, \
 +                                                        __LINE__)
 +#define vmr_fput(region)              vmr_do_fput(region, __func__, __LINE__)
-+#endif /* CONFIG_MMU */
++#endif /* !CONFIG_MMU */
 +
  extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
  extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
                void *buf, int len, int write);
 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
-index 96c5750..a087ecd 100644
+index 199a03a..ed38ea3 100644
 --- a/include/linux/mm_types.h
 +++ b/include/linux/mm_types.h
-@@ -232,6 +232,7 @@ struct vm_region {
+@@ -241,6 +241,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 */
@@ -249,7 +287,7 @@ index 96c5750..a087ecd 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
-@@ -300,6 +301,7 @@ struct vm_area_struct {
+@@ -305,6 +306,7 @@ struct vm_area_struct {
        unsigned long vm_pgoff;         /* Offset (within vm_file) in PAGE_SIZE
                                           units, *not* PAGE_CACHE_SIZE */
        struct file * vm_file;          /* File we map to (can be NULL). */
@@ -258,10 +296,10 @@ index 96c5750..a087ecd 100644
  
  #ifndef CONFIG_MMU
 diff --git a/kernel/fork.c b/kernel/fork.c
-index 6a13c46..714302c 100644
+index cf65139..f28a048 100644
 --- a/kernel/fork.c
 +++ b/kernel/fork.c
-@@ -416,7 +416,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
+@@ -430,7 +430,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
                        struct inode *inode = file_inode(file);
                        struct address_space *mapping = file->f_mapping;
  
@@ -269,25 +307,25 @@ index 6a13c46..714302c 100644
 +                      vma_get_file(tmp);
                        if (tmp->vm_flags & VM_DENYWRITE)
                                atomic_dec(&inode->i_writecount);
-                       mutex_lock(&mapping->i_mmap_mutex);
+                       i_mmap_lock_write(mapping);
 diff --git a/mm/Makefile b/mm/Makefile
-index 4064f3e..0003fdf 100644
+index 15dbe99..88e25b5 100644
 --- a/mm/Makefile
 +++ b/mm/Makefile
-@@ -18,7 +18,7 @@ obj-y                        := filemap.o mempool.o oom_kill.o fadvise.o \
+@@ -21,7 +21,7 @@ obj-y                        := filemap.o mempool.o oom_kill.o \
                           mm_init.o mmu_context.o percpu.o slab_common.o \
-                          compaction.o balloon_compaction.o vmacache.o \
+                          compaction.o vmacache.o \
                           interval_tree.o list_lru.o workingset.o \
--                         iov_iter.o $(mmu-y)
-+                         iov_iter.o prfile.o $(mmu-y)
+-                         debug.o $(mmu-y)
++                         prfile.o debug.o $(mmu-y)
  
  obj-y += init-mm.o
  
 diff --git a/mm/filemap.c b/mm/filemap.c
-index 900edfa..f4dda0c 100644
+index ad72420..8885258 100644
 --- a/mm/filemap.c
 +++ b/mm/filemap.c
-@@ -2040,7 +2040,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -2064,7 +2064,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);
@@ -296,53 +334,18 @@ index 900edfa..f4dda0c 100644
        lock_page(page);
        if (page->mapping != inode->i_mapping) {
                unlock_page(page);
-diff --git a/mm/fremap.c b/mm/fremap.c
-index 72b8fa3..a00bbf0 100644
---- a/mm/fremap.c
-+++ b/mm/fremap.c
-@@ -224,16 +224,28 @@ get_write_lock:
-                */
-               if (mapping_cap_account_dirty(mapping)) {
-                       unsigned long addr;
--                      struct file *file = get_file(vma->vm_file);
-+                      struct file *file = vma->vm_file,
-+                              *prfile = vma->vm_prfile;
-+
-                       /* mmap_region may free vma; grab the info now */
-                       vm_flags = vma->vm_flags;
-+                      vma_get_file(vma);
-                       addr = mmap_region(file, start, size, vm_flags, pgoff);
--                      fput(file);
-+                      vma_fput(vma);
-                       if (IS_ERR_VALUE(addr)) {
-                               err = addr;
-                       } else {
-                               BUG_ON(addr != start);
-+                              if (prfile) {
-+                                      struct vm_area_struct *new_vma;
-+
-+                                      new_vma = find_vma(mm, addr);
-+                                      if (!new_vma->vm_prfile)
-+                                              new_vma->vm_prfile = prfile;
-+                                      if (new_vma != vma)
-+                                              get_file(prfile);
-+                              }
-                               err = 0;
-                       }
-                       goto out_freed;
 diff --git a/mm/madvise.c b/mm/madvise.c
-index a402f8f..134e15d 100644
+index d551475..1ebf71b 100644
 --- a/mm/madvise.c
 +++ b/mm/madvise.c
-@@ -327,12 +327,12 @@ static long madvise_remove(struct vm_area_struct *vma,
+@@ -320,12 +320,12 @@ static long madvise_remove(struct vm_area_struct *vma,
         * vma's reference to the file) can go away as soon as we drop
         * mmap_sem.
         */
 -      get_file(f);
 +      vma_get_file(vma);
        up_read(&current->mm->mmap_sem);
-       error = do_fallocate(f,
+       error = vfs_fallocate(f,
                                FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                                offset, end - start);
 -      fput(f);
@@ -351,23 +354,23 @@ index a402f8f..134e15d 100644
        return error;
  }
 diff --git a/mm/memory.c b/mm/memory.c
-index 8b44f76..69a72bf 100644
+index 97839f5..5e5d491 100644
 --- a/mm/memory.c
 +++ b/mm/memory.c
-@@ -2161,7 +2161,7 @@ reuse:
-                       set_page_dirty_balance(dirty_page);
-                       /* file_update_time outside page_lock */
-                       if (vma->vm_file)
--                              file_update_time(vma->vm_file);
-+                              vma_file_update_time(vma);
+@@ -2034,7 +2034,7 @@ static inline int wp_page_reuse(struct m
                }
-               put_page(dirty_page);
-               if (page_mkwrite) {
+               if (!page_mkwrite)
+-                      file_update_time(vma->vm_file);
++                      vma_file_update_time(vma);
+       }
+       return VM_FAULT_WRITE;
 diff --git a/mm/mmap.c b/mm/mmap.c
-index 129b847..869d1d7 100644
+index 9ec50a3..4a6a641 100644
 --- a/mm/mmap.c
 +++ b/mm/mmap.c
-@@ -253,7 +253,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
+@@ -274,7 +274,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)
@@ -376,7 +379,7 @@ index 129b847..869d1d7 100644
        mpol_put(vma_policy(vma));
        kmem_cache_free(vm_area_cachep, vma);
        return next;
-@@ -863,7 +863,7 @@ again:                     remove_next = 1 + (end > next->vm_end);
+@@ -886,7 +886,7 @@ again:                     remove_next = 1 + (end > next->vm_end);
        if (remove_next) {
                if (file) {
                        uprobe_munmap(next, next->vm_start, next->vm_end);
@@ -385,17 +388,17 @@ index 129b847..869d1d7 100644
                }
                if (next->anon_vma)
                        anon_vma_merge(vma, next);
-@@ -1643,8 +1643,8 @@ out:
+@@ -1671,8 +1671,8 @@ out:
+       return addr;
  unmap_and_free_vma:
-       if (vm_flags & VM_DENYWRITE)
-               allow_write_access(file);
 +      vma_fput(vma);
        vma->vm_file = NULL;
 -      fput(file);
  
        /* Undo any partial mapping done by a device driver. */
        unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
-@@ -2434,7 +2434,7 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
+@@ -2473,7 +2473,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
                goto out_free_mpol;
  
        if (new->vm_file)
@@ -404,7 +407,7 @@ index 129b847..869d1d7 100644
  
        if (new->vm_ops && new->vm_ops->open)
                new->vm_ops->open(new);
-@@ -2453,7 +2453,7 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
+@@ -2492,7 +2492,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)
@@ -413,7 +416,28 @@ index 129b847..869d1d7 100644
        unlink_anon_vmas(new);
   out_free_mpol:
        mpol_put(vma_policy(new));
-@@ -2842,7 +2842,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
+@@ -2635,7 +2635,6 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
+       struct vm_area_struct *vma;
+       unsigned long populate = 0;
+       unsigned long ret = -EINVAL;
+-      struct file *file;
+       pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. "
+                       "See Documentation/vm/remap_file_pages.txt.\n",
+@@ -2679,10 +2678,10 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
+               munlock_vma_pages_range(vma, start, start + size);
+       }
+-      file = get_file(vma->vm_file);
++      vma_get_file(vma);
+       ret = do_mmap_pgoff(vma->vm_file, start, size,
+                       prot, flags, pgoff, &populate);
+-      fput(file);
++      vma_fput(vma);
+ out:
+       up_write(&mm->mmap_sem);
+       if (populate)
+@@ -2950,7 +2949,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)
@@ -423,30 +447,27 @@ index 129b847..869d1d7 100644
                                new_vma->vm_ops->open(new_vma);
                        vma_link(mm, new_vma, prev, rb_link, rb_parent);
 diff --git a/mm/msync.c b/mm/msync.c
-index 992a167..ce1915b 100644
+index bb04d53..5c24c54 100644
 --- a/mm/msync.c
 +++ b/mm/msync.c
-@@ -84,13 +84,13 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
+@@ -84,10 +84,10 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
                start = vma->vm_end;
                if ((flags & MS_SYNC) && file &&
                                (vma->vm_flags & VM_SHARED)) {
 -                      get_file(file);
 +                      vma_get_file(vma);
                        up_read(&mm->mmap_sem);
-                       if (vma->vm_flags & VM_NONLINEAR)
-                               error = vfs_fsync(file, 1);
-                       else
-                               error = vfs_fsync_range(file, fstart, fend, 1);
+                       error = vfs_fsync_range(file, fstart, fend, 1);
 -                      fput(file);
 +                      vma_fput(vma);
                        if (error || start >= end)
                                goto out;
                        down_read(&mm->mmap_sem);
 diff --git a/mm/nommu.c b/mm/nommu.c
-index 4a852f6..b369644 100644
+index 3fba2dc..870ce96 100644
 --- a/mm/nommu.c
 +++ b/mm/nommu.c
-@@ -658,7 +658,7 @@ static void __put_nommu_region(struct vm_region *region)
+@@ -693,7 +693,7 @@ static void __put_nommu_region(struct vm_region *region)
                up_write(&nommu_region_sem);
  
                if (region->vm_file)
@@ -455,7 +476,7 @@ index 4a852f6..b369644 100644
  
                /* IO memory and memory shared directly out of the pagecache
                 * from ramfs/tmpfs mustn't be released here */
-@@ -823,7 +823,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
+@@ -858,7 +858,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)
@@ -464,7 +485,7 @@ index 4a852f6..b369644 100644
        put_nommu_region(vma->vm_region);
        kmem_cache_free(vm_area_cachep, vma);
  }
-@@ -1385,7 +1385,7 @@ unsigned long do_mmap_pgoff(struct file *file,
+@@ -1398,7 +1398,7 @@ unsigned long do_mmap_pgoff(struct file *file,
                                        goto error_just_free;
                                }
                        }
@@ -473,7 +494,7 @@ index 4a852f6..b369644 100644
                        kmem_cache_free(vm_region_jar, region);
                        region = pregion;
                        result = start;
-@@ -1461,10 +1461,10 @@ error_just_free:
+@@ -1474,10 +1474,10 @@ error_just_free:
        up_write(&nommu_region_sem);
  error:
        if (region->vm_file)
@@ -488,7 +509,7 @@ index 4a852f6..b369644 100644
        return ret;
 diff --git a/mm/prfile.c b/mm/prfile.c
 new file mode 100644
-index 0000000..fc708d2
+index 0000000..6aa5ab5
 --- /dev/null
 +++ b/mm/prfile.c
 @@ -0,0 +1,86 @@
@@ -514,11 +535,10 @@ index 0000000..fc708d2
 +#ifdef PRFILE_TRACE
 +      if (pr)
 +              pr_info("%s:%d: %s, %p\n", func, line, func2,
-+                      f ? (char *)f->f_dentry->d_name.name : "(null)");
++                      f ? (char *)f->f_path.dentry->d_name.name : "(null)");
 +#endif
 +}
 +
-+#ifdef CONFIG_MMU
 +void vma_do_file_update_time(struct vm_area_struct *vma, const char func[],
 +                           int line)
 +{
@@ -558,7 +578,8 @@ index 0000000..fc708d2
 +      if (f && pr)
 +              fput(pr);
 +}
-+#else
++
++#ifndef CONFIG_MMU
 +struct file *vmr_do_pr_or_file(struct vm_region *region, const char func[],
 +                             int line)
 +{
@@ -577,14 +598,46 @@ index 0000000..fc708d2
 +      if (f && pr)
 +              fput(pr);
 +}
-+#endif /* CONFIG_MMU */
-aufs3.16 standalone patch
++#endif /* !CONFIG_MMU */
+aufs3.x-rcN standalone patch
 
+diff --git a/fs/dcache.c b/fs/dcache.c
+index b93a9f2..5a010ee 100644
+--- a/fs/dcache.c
++++ b/fs/dcache.c
+@@ -1235,6 +1235,7 @@ rename_retry:
+       seq = 1;
+       goto again;
+ }
++EXPORT_SYMBOL(d_walk);
+ /*
+  * Search for at least 1 mount point in the dentry's subdirs.
+diff --git a/fs/file_table.c b/fs/file_table.c
+index 3f85411..00e9dcf 100644
+--- a/fs/file_table.c
++++ b/fs/file_table.c
+@@ -147,6 +147,7 @@ over:
+       }
+       return ERR_PTR(-ENFILE);
+ }
++EXPORT_SYMBOL(get_empty_filp);
+ /**
+  * alloc_file - allocate and initialize a 'struct file'
+@@ -308,6 +309,7 @@ void put_filp(struct file *file)
+               file_free(file);
+       }
+ }
++EXPORT_SYMBOL(put_filp);
+ void __init files_init(unsigned long mempages)
+ { 
 diff --git a/fs/inode.c b/fs/inode.c
-index b225c0f..73259c8 100644
+index f00b16f..eb7b8b5 100644
 --- a/fs/inode.c
 +++ b/fs/inode.c
-@@ -57,6 +57,7 @@ static struct hlist_head *inode_hashtable __read_mostly;
+@@ -58,6 +58,7 @@ static struct hlist_head *inode_hashtable __read_mostly;
  static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock);
  
  __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_sb_list_lock);
@@ -592,19 +645,11 @@ index b225c0f..73259c8 100644
  
  /*
   * Empty aops. Can be used for the cases where the user does not
-@@ -1512,6 +1513,7 @@ int update_time(struct inode *inode, struct timespec *time, int flags)
-       mark_inode_dirty_sync(inode);
-       return 0;
- }
-+EXPORT_SYMBOL(update_time);
- /**
-  *    touch_atime     -       update the access time
 diff --git a/fs/namespace.c b/fs/namespace.c
-index 182bc41..c88e101 100644
+index 82ef140..a3aa4b9 100644
 --- a/fs/namespace.c
 +++ b/fs/namespace.c
-@@ -453,6 +453,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
+@@ -463,6 +463,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
        mnt_dec_writers(real_mount(mnt));
        preempt_enable();
  }
@@ -612,7 +657,7 @@ index 182bc41..c88e101 100644
  
  /**
   * mnt_drop_write - give up write access to a mount
-@@ -1564,6 +1565,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
+@@ -1718,6 +1719,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
        }
        return 0;
  }
@@ -621,7 +666,7 @@ index 182bc41..c88e101 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 ad19959..adf290d 100644
+index d16b62c..06ca6bc 100644
 --- a/fs/notify/group.c
 +++ b/fs/notify/group.c
 @@ -22,6 +22,7 @@
@@ -657,7 +702,7 @@ index ad19959..adf290d 100644
  int fsnotify_fasync(int fd, struct file *file, int on)
  {
 diff --git a/fs/notify/mark.c b/fs/notify/mark.c
-index d90deaa..60b4239 100644
+index 92e48c7..d2c4b68 100644
 --- a/fs/notify/mark.c
 +++ b/fs/notify/mark.c
 @@ -109,6 +109,7 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
@@ -666,17 +711,17 @@ index d90deaa..60b4239 100644
  }
 +EXPORT_SYMBOL(fsnotify_put_mark);
  
- /*
-  * Any time a mark is getting freed we end up here.
-@@ -191,6 +192,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark,
+ /* Calculate mask of events for a list of marks */
+ u32 fsnotify_recalc_mask(struct hlist_head *head)
+@@ -202,6 +203,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark,
        fsnotify_destroy_mark_locked(mark, group);
        mutex_unlock(&group->mark_mutex);
  }
 +EXPORT_SYMBOL(fsnotify_destroy_mark);
  
- void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask)
- {
-@@ -275,6 +277,7 @@ err:
+ /*
+  * Destroy all marks in the given list. The marks must be already detached from
+@@ -376,6 +378,7 @@ err:
  
        return ret;
  }
@@ -684,7 +729,7 @@ index d90deaa..60b4239 100644
  
  int fsnotify_add_mark(struct fsnotify_mark *mark, struct fsnotify_group *group,
                      struct inode *inode, struct vfsmount *mnt, int allow_dups)
-@@ -336,6 +339,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
+@@ -455,6 +458,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
        atomic_set(&mark->refcnt, 1);
        mark->free_mark = free_mark;
  }
@@ -693,7 +738,7 @@ index d90deaa..60b4239 100644
  static int fsnotify_mark_destroy(void *ignored)
  {
 diff --git a/fs/open.c b/fs/open.c
-index d6fd3ac..5e99d8b 100644
+index 33f9cbf..fcc7eb4 100644
 --- a/fs/open.c
 +++ b/fs/open.c
 @@ -62,6 +62,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
@@ -704,19 +749,19 @@ index d6fd3ac..5e99d8b 100644
  
  long vfs_truncate(struct path *path, loff_t length)
  {
-@@ -298,6 +299,7 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
-       sb_end_write(inode->i_sb);
-       return ret;
+@@ -672,6 +673,7 @@ int open_check_o_direct(struct file *f)
+       }
+       return 0;
  }
-+EXPORT_SYMBOL(do_fallocate);
++EXPORT_SYMBOL(open_check_o_direct);
  
- SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
- {
+ static int do_dentry_open(struct file *f,
+                         int (*open)(struct inode *, struct file *),
 diff --git a/fs/splice.c b/fs/splice.c
-index 9ba380c..3419932 100644
+index beb9993..813275a 100644
 --- a/fs/splice.c
 +++ b/fs/splice.c
-@@ -1127,6 +1127,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+@@ -1112,6 +1112,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
  
        return splice_write(pipe, out, ppos, len, flags);
  }
@@ -724,7 +769,7 @@ index 9ba380c..3419932 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,
+@@ -1138,6 +1139,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
  
        return splice_read(in, ppos, pipe, len, flags);
  }
@@ -732,11 +777,23 @@ index 9ba380c..3419932 100644
  
  /**
   * splice_direct_to_actor - splices data directly between two non-pipes
+diff --git a/fs/xattr.c b/fs/xattr.c
+index 4ef6985..6bb6303 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,
+       *xattr_value = value;
+       return error;
+ }
++EXPORT_SYMBOL(vfs_getxattr_alloc);
+ /* Compare an extended attribute value with the given value */
+ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
 diff --git a/security/commoncap.c b/security/commoncap.c
-index b9d613e..ba3b618 100644
+index f66713b..fd4c4b8 100644
 --- a/security/commoncap.c
 +++ b/security/commoncap.c
-@@ -988,9 +988,11 @@ int cap_mmap_addr(unsigned long addr)
+@@ -975,9 +975,11 @@ int cap_mmap_addr(unsigned long addr)
        }
        return ret;
  }
@@ -749,7 +806,7 @@ index b9d613e..ba3b618 100644
  }
 +EXPORT_SYMBOL(cap_mmap_file);
 diff --git a/security/device_cgroup.c b/security/device_cgroup.c
-index d9d69e6..3f6f471 100644
+index 188c1d2..426d9af 100644
 --- a/security/device_cgroup.c
 +++ b/security/device_cgroup.c
 @@ -7,6 +7,7 @@
@@ -769,10 +826,10 @@ index d9d69e6..3f6f471 100644
  int devcgroup_inode_mknod(int mode, dev_t dev)
  {
 diff --git a/security/security.c b/security/security.c
-index 31614e9..b223a66 100644
+index e81d5bb..0b7b840 100644
 --- a/security/security.c
 +++ b/security/security.c
-@@ -407,6 +407,7 @@ int security_path_rmdir(struct path *dir, struct dentry *dentry)
+@@ -430,6 +430,7 @@ int security_path_rmdir(struct path *dir, struct dentry *dentry)
                return 0;
        return security_ops->path_rmdir(dir, dentry);
  }
@@ -780,7 +837,7 @@ index 31614e9..b223a66 100644
  
  int security_path_unlink(struct path *dir, struct dentry *dentry)
  {
-@@ -423,6 +424,7 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
+@@ -446,6 +447,7 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
                return 0;
        return security_ops->path_symlink(dir, dentry, old_name);
  }
@@ -788,7 +845,7 @@ index 31614e9..b223a66 100644
  
  int security_path_link(struct dentry *old_dentry, struct path *new_dir,
                       struct dentry *new_dentry)
-@@ -431,6 +433,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
+@@ -454,6 +456,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
                return 0;
        return security_ops->path_link(old_dentry, new_dir, new_dentry);
  }
@@ -796,7 +853,7 @@ index 31614e9..b223a66 100644
  
  int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
                         struct path *new_dir, struct dentry *new_dentry,
-@@ -458,6 +461,7 @@ int security_path_truncate(struct path *path)
+@@ -481,6 +484,7 @@ int security_path_truncate(struct path *path)
                return 0;
        return security_ops->path_truncate(path);
  }
@@ -804,7 +861,7 @@ index 31614e9..b223a66 100644
  
  int security_path_chmod(struct path *path, umode_t mode)
  {
-@@ -465,6 +469,7 @@ int security_path_chmod(struct path *path, umode_t mode)
+@@ -488,6 +492,7 @@ int security_path_chmod(struct path *path, umode_t mode)
                return 0;
        return security_ops->path_chmod(path, mode);
  }
@@ -812,7 +869,7 @@ index 31614e9..b223a66 100644
  
  int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
  {
-@@ -472,6 +477,7 @@ int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
+@@ -495,6 +500,7 @@ int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
                return 0;
        return security_ops->path_chown(path, uid, gid);
  }
@@ -820,7 +877,7 @@ index 31614e9..b223a66 100644
  
  int security_path_chroot(struct path *path)
  {
-@@ -557,6 +563,7 @@ int security_inode_readlink(struct dentry *dentry)
+@@ -580,6 +586,7 @@ int security_inode_readlink(struct dentry *dentry)
                return 0;
        return security_ops->inode_readlink(dentry);
  }
@@ -828,7 +885,7 @@ index 31614e9..b223a66 100644
  
  int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd)
  {
-@@ -571,6 +578,7 @@ int security_inode_permission(struct inode *inode, int mask)
+@@ -594,6 +601,7 @@ int security_inode_permission(struct inode *inode, int mask)
                return 0;
        return security_ops->inode_permission(inode, mask);
  }
@@ -836,7 +893,7 @@ index 31614e9..b223a66 100644
  
  int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
  {
-@@ -693,6 +701,7 @@ int security_file_permission(struct file *file, int mask)
+@@ -716,6 +724,7 @@ int security_file_permission(struct file *file, int mask)
  
        return fsnotify_perm(file, mask);
  }
@@ -844,7 +901,7 @@ index 31614e9..b223a66 100644
  
  int security_file_alloc(struct file *file)
  {
-@@ -753,6 +762,7 @@ int security_mmap_file(struct file *file, unsigned long prot,
+@@ -775,6 +784,7 @@ int security_mmap_file(struct file *file, unsigned long prot,
                return ret;
        return ima_file_mmap(file, prot);
  }
@@ -943,10 +1000,10 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/sysfs-aufs linux/Documentat
 +              will be empty. About XINO files, see the aufs manual.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt linux/Documentation/filesystems/aufs/design/01intro.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/01intro.txt    2014-01-30 21:10:02.807480310 +0100
-@@ -0,0 +1,161 @@
++++ linux/Documentation/filesystems/aufs/design/01intro.txt    2015-06-22 08:27:37.867501461 +0200
+@@ -0,0 +1,170 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -975,7 +1032,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt lin
 +- multi layered stackable unification filesystem, the member directory
 +  is called as a branch.
 +- branch permission and attribute, 'readonly', 'real-readonly',
-+  'readwrite', 'whiteout-able', 'link-able whiteout' and their
++  'readwrite', 'whiteout-able', 'link-able whiteout', etc. and their
 +  combination.
 +- internal "file copy-on-write".
 +- logical deletion, whiteout.
@@ -1026,11 +1083,16 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt lin
 +- unnecessary copy-up may happen, for example mmap(MAP_PRIVATE) after
 +  open(O_RDWR).
 +
-+Unionfs has a longer history. When I started implementing a stacking filesystem
-+(Aug 2005), it already existed. It has virtual super_block, inode,
-+dentry and file objects and they have an array pointing lower same kind
-+objects. After contributing many patches for Unionfs, I re-started my
-+project AUFS (Jun 2006).
++In linux-3.18, "overlay" filesystem (formerly known as "overlayfs") was
++merged into mainline. This is another implementation of UnionMount as a
++separated filesystem. All the limitations and known problems which
++UnionMount are equally inherited to "overlay" filesystem.
++
++Unionfs has a longer history. When I started implementing a stackable
++filesystem (Aug 2005), it already existed. It has virtual super_block,
++inode, dentry and file objects and they have an array pointing lower
++same kind objects. After contributing many patches for Unionfs, I
++re-started my project AUFS (Jun 2006).
 +
 +In AUFS, the structure of filesystem resembles to Unionfs, but I
 +implemented my own ideas, approaches and enhancements and it became
@@ -1052,11 +1114,14 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt lin
 +- DM snapshot-merge may help a lot when users try merging. in the
 +  fs-layer union, users will use rsync(1).
 +
++You may want to read my old paper "Filesystems in LiveCD"
++(http://aufs.sourceforge.net/aufs2/report/sq/sq.pdf).
++
 +
-+Several characters/aspects of aufs
++Several characters/aspects/persona of aufs
 +----------------------------------------------------------------------
 +
-+Aufs has several characters or aspects.
++Aufs has several characters, aspects or persona.
 +1. a filesystem, callee of VFS helper
 +2. sub-VFS, caller of VFS helper for branches
 +3. a virtual filesystem which maintains persistent inode number
@@ -1087,10 +1152,11 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt lin
 +numbers. This is particularly important to support exporting a
 +filesystem via NFS. Aufs is a virtual filesystem which doesn't have a
 +backend block device for its own. But some storage is necessary to
-+maintain inode number. It may be a large space and may not suit to keep
-+in memory. Aufs rents some space from its first writable branch
-+filesystem (by default) and creates file(s) on it. These files are
-+created by aufs internally and removed soon (currently) keeping opened.
++keep and maintain the inode numbers. It may be a large space and may not
++suit to keep in memory. Aufs rents some space from its first writable
++branch filesystem (by default) and creates file(s) on it. These files
++are created by aufs internally and removed soon (currently) keeping
++opened.
 +Note: Because these files are removed, they are totally gone after
 +      unmounting aufs. It means the inode numbers are not persistent
 +      across unmount or reboot. I have a plan to make them really
@@ -1108,10 +1174,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt lin
 +about it. But currently I have implemented it in kernel space.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt linux/Documentation/filesystems/aufs/design/02struct.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt        1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/02struct.txt   2014-08-14 10:15:45.115275734 +0200
-@@ -0,0 +1,251 @@
++++ linux/Documentation/filesystems/aufs/design/02struct.txt   2015-06-22 08:27:37.867501461 +0200
+@@ -0,0 +1,258 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1141,18 +1207,18 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +
 +Aufs lookup operation finds /ro/fileA and gets dentry for that. These
 +pointers are stored in a aufs dentry. The array in aufs dentry will be,
-+- [0] = NULL
++- [0] = NULL (because /rw/fileA doesn't exist)
 +- [1] = /ro/fileA
 +
 +This style of an array is essentially same to the aufs
 +superblock/inode/dentry/file objects.
 +
 +Because aufs supports manipulating branches, ie. add/delete/change
-+dynamically, these objects has its own generation. When branches are
-+changed, the generation in aufs superblock is incremented. And a
-+generation in other object are compared when it is accessed.
-+When a generation in other objects are obsoleted, aufs refreshes the
-+internal array.
++branches dynamically, these objects has its own generation. When
++branches are changed, the generation in aufs superblock is
++incremented. And a generation in other object are compared when it is
++accessed. When a generation in other objects are obsoleted, aufs
++refreshes the internal array.
 +
 +
 +Superblock
@@ -1160,8 +1226,8 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +Additionally aufs superblock has some data for policies to select one
 +among multiple writable branches, XIB files, pseudo-links and kobject.
 +See below in detail.
-+About the policies which supports copy-down a directory, see policy.txt
-+too.
++About the policies which supports copy-down a directory, see
++wbr_policy.txt too.
 +
 +
 +Branch and XINO(External Inode Number Translation Table)
@@ -1181,13 +1247,20 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +might appear. If your branch filesystem consumes disk space for such
 +holes, then you should specify 'xino=' option at mounting aufs.
 +
++Aufs has a mount option to free the disk blocks for such holes in XINO
++files on tmpfs or ramdisk. But it is not so effective actually. If you
++meet a problem of disk shortage due to XINO files, then you should try
++"tmpfs-ino.patch" (and "vfs-ino.patch" too) in aufs4-standalone.git.
++The patch localizes the assignment inumbers per tmpfs-mount and avoid
++the holes in XINO files.
++
 +Also a writable branch has three kinds of "whiteout bases". All these
-+are existed when the branch is joined to aufs and the names are
++are existed when the branch is joined to aufs, and their names are
 +whiteout-ed doubly, so that users will never see their names in aufs
 +hierarchy.
-+1. a regular file which will be linked to all whiteouts.
++1. a regular file which will be hardlinked to all whiteouts.
 +2. a directory to store a pseudo-link.
-+3. a directory to store an "orphan-ed" file temporary.
++3. a directory to store an "orphan"-ed file temporary.
 +
 +1. Whiteout Base
 +   When you remove a file on a readonly branch, aufs handles it as a
@@ -1204,8 +1277,8 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +   creating a file under this dir, the file is unlinked.
 +
 +Because aufs supports manipulating branches, ie. add/delete/change
-+dynamically, a branch has its own id. When the branch order changes, aufs
-+finds the new index by searching the branch id.
++dynamically, a branch has its own id. When the branch order changes,
++aufs finds the new index by searching the branch id.
 +
 +
 +Pseudo-link
@@ -1218,7 +1291,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +simple list. If fileB is read after unlinking fileA, aufs returns
 +filedata from the pseudo-link instead of the lower readonly
 +branch. Because the pseudo-link is based upon the inode, to keep the
-+inode number by xino (see above) is important.
++inode number by xino (see above) is essentially necessary.
 +
 +All the hardlinks under the Pseudo-link Directory of the writable branch
 +should be restored in a proper location later. Aufs provides a utility
@@ -1236,12 +1309,13 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +XIB(external inode number bitmap)
 +----------------------------------------------------------------------
 +Addition to the xino file per a branch, aufs has an external inode number
-+bitmap in a superblock object. It is also a file such like a xino file.
++bitmap in a superblock object. It is also an internal file such like a
++xino file.
 +It is a simple bitmap to mark whether the aufs inode number is in-use or
 +not.
 +To reduce the file I/O, aufs prepares a single memory page to cache xib.
 +
-+Aufs implements a feature to truncate/refresh both of xino and xib to
++As well as XINO files, aufs has a feature to truncate/refresh XIB to
 +reduce the number of consumed disk blocks for these files.
 +
 +
@@ -1253,7 +1327,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +with eliminating the whiteout-ed ones, and sets it to file (dir)
 +object. So the file object has its entry list until it is closed. The
 +entry list will be updated when the file position is zero and becomes
-+old. This decision is made in aufs automatically.
++obsoleted. This decision is made in aufs automatically.
 +
 +The dynamically allocated memory block for the name of entries has a
 +unit of 512 bytes (by default) and stores the names contiguously (no
@@ -1292,9 +1366,8 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +its completion. This approach solves a problem of a signal handler
 +simply.
 +If aufs didn't adopt the workqueue and changed the privilege of the
-+process, and if the mkdir/write call arises SIGXFSZ or other signal,
-+then the user process might gain a privilege or the generated core file
-+was owned by a superuser.
++process, then the process may receive the unexpected SIGXFSZ or other
++signals.
 +
 +Also aufs uses the system global workqueue ("events" kernel thread) too
 +for asynchronous tasks, such like handling inotify/fsnotify, re-creating a
@@ -1312,7 +1385,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +
 +Basically the whiteout represents "logical deletion" which stops aufs to
 +lookup further, but also it represents "dir is opaque" which also stop
-+lookup.
++further lookup.
 +
 +In aufs, rmdir(2) and rename(2) for dir uses whiteout alternatively.
 +In order to make several functions in a single systemcall to be
@@ -1320,7 +1393,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +unique whiteouted name.
 +For example, in rename(2) dir where the target dir already existed, aufs
 +renames the target dir to a temporary unique whiteouted name before the
-+actual rename on a branch and then handles other actions (make it opaque,
++actual rename on a branch, and then handles other actions (make it opaque,
 +update the attributes, etc). If an error happens in these actions, aufs
 +simply renames the whiteouted name back and returns an error. If all are
 +succeeded, aufs registers a function to remove the whiteouted unique
@@ -1350,7 +1423,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +- diropq for the ancestor directories may exist on the upper branch.
 +- free space on the lower branch will reduce.
 +- another access to the file may happen during moving-down, including
-+  UDBA.
++  UDBA (see "Revalidate Dentry and UDBA").
 +- the file should not be hard-linked nor pseudo-linked. they should be
 +  handled by auplink utility later.
 +
@@ -1361,12 +1434,101 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
 +- etc.
 +
 +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      2015-06-22 08:27:37.870834875 +0200
+@@ -0,0 +1,85 @@
++
++# Copyright (C) 2015 Junjiro R. Okajima
++# 
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++# 
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++# 
++# You should have received a copy of the GNU General Public License
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
++
++Support for a branch who has its ->atomic_open()
++----------------------------------------------------------------------
++The filesystems who implement its ->atomic_open() are not majority. For
++example NFSv4 does, and aufs should call NFSv4 ->atomic_open,
++particularly for open(O_CREAT|O_EXCL, 0400) case. Other than
++->atomic_open(), NFSv4 returns an error for this open(2). While I am not
++sure whether all filesystems who have ->atomic_open() behave like this,
++but NFSv4 surely returns the error.
++
++In order to support ->atomic_open() for aufs, there are a few
++approaches.
++
++A. Introduce aufs_atomic_open()
++   - calls one of VFS:do_last(), lookup_open() or atomic_open() for
++     branch fs.
++B. Introduce aufs_atomic_open() calling create, open and chmod. this is
++   an aufs user Pip Cet's approach
++   - calls aufs_create(), VFS finish_open() and notify_change().
++   - pass fake-mode to finish_open(), and then correct the mode by
++     notify_change().
++C. Extend aufs_open() to call branch fs's ->atomic_open()
++   - no aufs_atomic_open().
++   - aufs_lookup() registers the TID to an aufs internal object.
++   - aufs_create() does nothing when the matching TID is registered, but
++     registers the mode.
++   - aufs_open() calls branch fs's ->atomic_open() when the matching
++     TID is registered.
++D. Extend aufs_open() to re-try branch fs's ->open() with superuser's
++   credential
++   - no aufs_atomic_open().
++   - aufs_create() registers the TID to an internal object. this info
++     represents "this process created this file just now."
++   - when aufs gets EACCES from branch fs's ->open(), then confirm the
++     registered TID and re-try open() with superuser's credential.
++
++Pros and cons for each approach.
++
++A.
++   - straightforward but highly depends upon VFS internal.
++   - the atomic behavaiour is kept.
++   - some of parameters such as nameidata are hard to reproduce for
++     branch fs.
++   - large overhead.
++B.
++   - easy to implement.
++   - the atomic behavaiour is lost.
++C.
++   - the atomic behavaiour is kept.
++   - dirty and tricky.
++   - VFS checks whether the file is created correctly after calling
++     ->create(), which means this approach doesn't work.
++D.
++   - easy to implement.
++   - the atomic behavaiour is lost.
++   - to open a file with superuser's credential and give it to a user
++     process is a bad idea, since the file object keeps the credential
++     in it. It may affect LSM or something. This approach doesn't work
++     either.
++
++The approach A is ideal, but it hard to implement. So here is a
++variation of A, which is to be implemented.
++
++A-1. Introduce aufs_atomic_open()
++     - calls branch fs ->atomic_open() if exists. otherwise calls
++       vfs_create() and finish_open().
++     - the demerit is that the several checks after branch fs
++       ->atomic_open() are lost. in the ordinary case, the checks are
++       done by VFS:do_last(), lookup_open() and atomic_open(). some can
++       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   2014-08-14 10:15:45.118609182 +0200
-@@ -0,0 +1,133 @@
++++ linux/Documentation/filesystems/aufs/design/03lookup.txt   2015-06-22 08:27:37.870834875 +0200
+@@ -0,0 +1,113 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1384,23 +1546,13 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt li
 +Lookup in a Branch
 +----------------------------------------------------------------------
 +Since aufs has a character of sub-VFS (see Introduction), it operates
-+lookup for branches as VFS does. It may be a heavy work. Generally
-+speaking struct nameidata is a bigger structure and includes many
-+information. But almost all lookup operation in aufs is the simplest
-+case, ie. lookup only an entry directly connected to its parent. Digging
-+down the directory hierarchy is unnecessary.
-+
-+VFS has a function lookup_one_len() for that use, but it is not usable
-+for a branch filesystem which requires struct nameidata. So aufs
-+implements a simple lookup wrapper function. When a branch filesystem
-+allows NULL as nameidata, it calls lookup_one_len(). Otherwise it builds
-+a simplest nameidata and calls lookup_hash().
-+Here aufs applies "a principle in NFSD", ie. if the filesystem supports
-+NFS-export, then it has to support NULL as a nameidata parameter for
-+->create(), ->lookup() and ->d_revalidate(). So the lookup wrapper in
-+aufs tests if ->s_export_op in the branch is NULL or not.
-+
-+When a branch is a remote filesystem, aufs basically trusts its
++lookup for branches as VFS does. It may be a heavy work. But almost all
++lookup operation in aufs is the simplest case, ie. lookup only an entry
++directly connected to its parent. Digging down the directory hierarchy
++is unnecessary. VFS has a function lookup_one_len() for that use, and
++aufs calls it.
++
++When a branch is a remote filesystem, aufs basically relies upon its
 +->d_revalidate(), also aufs forces the hardest revalidate tests for
 +them.
 +For d_revalidate, aufs implements three levels of revalidate tests. See
@@ -1415,7 +1567,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt li
 +- "dirA" exists under /ro, but /rw. and its mode is 0700.
 +- user invoked "chmod a+rx /au/dirA"
 +- the internal copy-up is activated and "/rw/dirA" is created and its
-+  permission bits are set to world readble.
++  permission bits are set to world readable.
 +- then "/au/dirA" becomes world readable?
 +
 +In this case, /ro/dirA is still 0700 since it exists in readonly branch,
@@ -1424,8 +1576,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt li
 +allowed it by chmod. Should really aufs rejects showing the entries
 +under /ro/dirA?
 +
-+To be honest, I don't have a best solution for this case. So aufs
-+implements 'dirperm1' and 'nodirperm1' and leave it to users.
++To be honest, I don't have a good solution for this case. So aufs
++implements 'dirperm1' and 'nodirperm1' mount options, and leave it to
++users.
 +When dirperm1 is specified, aufs checks only the highest one for the
 +directory permission, and shows the entries. Otherwise, as usual, checks
 +every dir existing on all branches and rejects the request.
@@ -1435,17 +1588,6 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt li
 +branch is many.
 +
 +
-+Loopback Mount
-+----------------------------------------------------------------------
-+Basically aufs supports any type of filesystem and block device for a
-+branch (actually there are some exceptions). But it is prohibited to add
-+a loopback mounted one whose backend file exists in a filesystem which is
-+already added to aufs. The reason is to protect aufs from a recursive
-+lookup. If it was allowed, the aufs lookup operation might re-enter a
-+lookup for the loopback mounted branch in the same context, and will
-+cause a deadlock.
-+
-+
 +Revalidate Dentry and UDBA (User's Direct Branch Access)
 +----------------------------------------------------------------------
 +Generally VFS helpers re-validate a dentry as a part of lookup.
@@ -1495,15 +1637,15 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt li
 +   itself.
 +3. No Extra Validation
 +   This is the simplest test and doesn't add any additional revalidation
-+   test, and skip therevalidatin in step 4. It is useful and improves
++   test, and skip the revalidation in step 4. It is useful and improves
 +   aufs performance when system surely hide the aufs branches from user,
 +   by over-mounting something (or another method).
 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   2014-01-30 21:10:02.807480310 +0100
-@@ -0,0 +1,75 @@
++++ linux/Documentation/filesystems/aufs/design/04branch.txt   2015-06-22 08:27:37.870834875 +0200
+@@ -0,0 +1,74 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1527,8 +1669,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt li
 +Add a Branch
 +----------------------------------------------------------------------
 +o Confirm the adding dir exists outside of aufs, including loopback
-+  mount.
-+- and other various attributes...
++  mount, and its various attributes.
 +o Initialize the xino file and whiteout bases if necessary.
 +  See struct.txt.
 +
@@ -1543,7 +1684,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt li
 +  writable branch, and the writable branch is world-writable, then a
 +  malicious guy may create /etc/passwd on the writable branch directly
 +  and the infected file will be valid in aufs.
-+  I am afraid it can be a security issue, but nothing to do except
++  I am afraid it can be a security issue, but aufs can do nothing except
 +  producing a warning.
 +
 +
@@ -1579,10 +1720,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt li
 +    same named entry on the upper branch.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.txt linux/Documentation/filesystems/aufs/design/05wbr_policy.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.txt    1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/05wbr_policy.txt       2014-01-30 21:10:02.807480310 +0100
++++ linux/Documentation/filesystems/aufs/design/05wbr_policy.txt       2015-06-22 08:27:37.870834875 +0200
 @@ -0,0 +1,64 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1604,9 +1745,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.tx
 +writable branch which has the parent (or ancestor) dir of the target
 +file is chosen (top-down-parent policy).
 +By user's request, aufs implements some other policies to select the
-+writable branch, for file creation two policies, round-robin and
-+most-free-space policies. For copy-up three policies, top-down-parent,
-+bottom-up-parent and bottom-up policies.
++writable branch, for file creation several policies, round-robin,
++most-free-space, and other policies. For copy-up, top-down-parent,
++bottom-up-parent, bottom-up and others.
 +
 +As expected, the round-robin policy selects the branch in circular. When
 +you have two writable branches and creates 10 new files, 5 files will be
@@ -1647,10 +1788,10 @@ 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     2014-08-14 10:15:45.118609182 +0200
++++ linux/Documentation/filesystems/aufs/design/06fhsm.txt     2015-06-22 08:27:37.870834875 +0200
 @@ -0,0 +1,120 @@
 +
-+# Copyright (C) 2011-2014 Junjiro R. Okajima
++# Copyright (C) 2011-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1671,9 +1812,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06fhsm.txt linu
 +----------------------------------------------------------------------
 +Hierarchical Storage Management (or HSM) is a well-known feature in the
 +storage world. Aufs provides this feature as file-based with multiple
-+writable branches, based upon the principle of "Colder-Lower".
++writable branches, based upon the principle of "Colder, the Lower".
 +Here the word "colder" means that the less used files, and "lower" means
-+that the position in the order of the stacked branches.
++that the position in the order of the stacked branches vertically.
 +These multiple writable branches are prioritized, ie. the topmost one
 +should be the fastest drive and be used heavily.
 +
@@ -1771,10 +1912,10 @@ 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     2014-01-30 21:10:02.807480310 +0100
-@@ -0,0 +1,46 @@
++++ linux/Documentation/filesystems/aufs/design/06mmap.txt     2015-06-22 08:27:37.870834875 +0200
+@@ -0,0 +1,72 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1795,7 +1936,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt linu
 +interaction with aufs. It means aufs_mmap() calls the branch fs's
 +->mmap().
 +This approach is simple and good, but there is one problem.
-+Under /proc, several entries show the mmap-ped files by its path (with
++Under /proc, several entries show the mmapped files by its path (with
 +device and inode number), and the printed path will be the path on the
 +branch fs's instead of virtual aufs's.
 +This is not a problem in most cases, but some utilities lsof(1) (and its
@@ -1812,19 +1953,145 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt linu
 +  incremented.
 +- merging vma maintains the ref count too.
 +
-+This is not a good approach. It just faking the printed path. But it
++This is not a good approach. It just fakes the printed path. But it
 +leaves all behaviour around f_mapping unchanged. This is surely an
 +advantage.
 +Actually aufs had adopted another complicated approach which calls
 +generic_file_mmap() and handles struct vm_operations_struct. In this
 +approach, aufs met a hard problem and I could not solve it without
 +switching the approach.
++
++There may be one more another approach which is
++- bind-mount the branch-root onto the aufs-root internally
++- grab the new vfsmount (ie. struct mount)
++- lazy-umount the branch-root internally
++- in open(2) the aufs-file, open the branch-file with the hidden
++  vfsmount (instead of the original branch's vfsmount)
++- ideally this "bind-mount and lazy-umount" should be done atomically,
++  but it may be possible from userspace by the mount helper.
++
++Adding the internal hidden vfsmount and using it in opening a file, the
++file path under /proc will be printed correctly. This approach looks
++smarter, but is not possible I am afraid.
++- aufs-root may be bind-mount later. when it happens, another hidden
++  vfsmount will be required.
++- it is hard to get the chance to bind-mount and lazy-umount
++  + in kernel-space, FS can have vfsmount in open(2) via
++    file->f_path, and aufs can know its vfsmount. But several locks are
++    already acquired, and if aufs tries to bind-mount and lazy-umount
++    here, then it may cause a deadlock.
++  + in user-space, bind-mount doesn't invoke the mount helper.
++- since /proc shows dev and ino, aufs has to give vma these info. it
++  means a new member vm_prinode will be necessary. this is essentially
++  equivalent to vm_prfile described above.
++
++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    2015-06-22 08:27:37.870834875 +0200
+@@ -0,0 +1,96 @@
++
++# Copyright (C) 2014-2015 Junjiro R. Okajima
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 2 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
++
++
++Listing XATTR/EA and getting the value
++----------------------------------------------------------------------
++For the inode standard attributes (owner, group, timestamps, etc.), aufs
++shows the values from the topmost existing file. This behaviour is good
++for the non-dir entries since the bahaviour exactly matches the shown
++information. But for the directories, aufs considers all the same named
++entries on the lower branches. Which means, if one of the lower entry
++rejects readdir call, then aufs returns an error even if the topmost
++entry allows it. This behaviour is necessary to respect the branch fs's
++security, but can make users confused since the user-visible standard
++attributes don't match the behaviour.
++To address this issue, aufs has a mount option called dirperm1 which
++checks the permission for the topmost entry only, and ignores the lower
++entry's permission.
++
++A similar issue can happen around XATTR.
++getxattr(2) and listxattr(2) families behave as if dirperm1 option is
++always set. Otherwise these very unpleasant situation would happen.
++- listxattr(2) may return the duplicated entries.
++- users may not be able to remove or reset the XATTR forever,
++
++
++XATTR/EA support in the internal (copy,move)-(up,down)
++----------------------------------------------------------------------
++Generally the extended attributes of inode are categorized as these.
++- "security" for LSM and capability.
++- "system" for posix ACL, 'acl' mount option is required for the branch
++  fs generally.
++- "trusted" for userspace, CAP_SYS_ADMIN is required.
++- "user" for userspace, 'user_xattr' mount option is required for the
++  branch fs generally.
++
++Moreover there are some other categories. Aufs handles these rather
++unpopular categories as the ordinary ones, ie. there is no special
++condition nor exception.
++
++In copy-up, the support for XATTR on the dst branch may differ from the
++src branch. In this case, the copy-up operation will get an error and
++the original user operation which triggered the copy-up will fail. It
++can happen that even all copy-up will fail.
++When both of src and dst branches support XATTR and if an error occurs
++during copying XATTR, then the copy-up should fail obviously. That is a
++good reason and aufs should return an error to userspace. But when only
++the src branch support that XATTR, aufs should not return an error.
++For example, the src branch supports ACL but the dst branch doesn't
++because the dst branch may natively un-support it or temporary
++un-support it due to "noacl" mount option. Of course, the dst branch fs
++may NOT return an error even if the XATTR is not supported. It is
++totally up to the branch fs.
++
++Anyway when the aufs internal copy-up gets an error from the dst branch
++fs, then aufs tries removing the just copied entry and returns the error
++to the userspace. The worst case of this situation will be all copy-up
++will fail.
++
++For the copy-up operation, there two basic approaches.
++- copy the specified XATTR only (by category above), and return the
++  error unconditionally if it happens.
++- copy all XATTR, and ignore the error on the specified category only.
++
++In order to support XATTR and to implement the correct behaviour, aufs
++chooses the latter approach and introduces some new branch attributes,
++"icexsec", "icexsys", "icextr", "icexusr", and "icexoth".
++They correspond to the XATTR namespaces (see above). Additionally, to be
++convenient, "icex" is also provided which means all "icex*" attributes
++are set (here the word "icex" stands for "ignore copy-error on XATTR").
++
++The meaning of these attributes is to ignore the error from setting
++XATTR on that branch.
++Note that aufs tries copying all XATTR unconditionally, and ignores the
++error from the dst branch according to the specified attributes.
++
++Some XATTR may have its default value. The default value may come from
++the parent dir or the environment. If the default value is set at the
++file creating-time, it will be overwritten by copy-up.
++Some contradiction may happen I am afraid.
++Do we need another attribute to stop copying XATTR? I am unsure. For
++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   2014-01-30 21:10:02.807480310 +0100
++++ linux/Documentation/filesystems/aufs/design/07export.txt   2015-06-22 08:27:37.870834875 +0200
 @@ -0,0 +1,58 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1863,10 +2130,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt li
 +  + find the index of a branch from its id in handle, and check it is
 +    still exist in aufs.
 +  + 1st level: get the inode number from handle and search it in cache.
-+  + 2nd level: if not found, get the parent inode number from handle and
-+    search it in cache. and then open the parent dir, find the matching
-+    inode number by vfs_readdir() and get its name, and call
-+    lookup_one_len() for the target dentry.
++  + 2nd level: if not found in cache, get the parent inode number from
++    the handle and search it in cache. and then open the found parent
++    dir, find the matching inode number by vfs_readdir() and get its
++    name, and call lookup_one_len() for the target dentry.
 +  + 3rd level: if the parent dir is not cached, call
 +    exportfs_decode_fh() for a branch and get the parent on a branch,
 +    build a pathname of it, convert it a pathname in aufs, call
@@ -1883,10 +2150,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt li
 +  lookup_one_len(), vfs_getattr(), encode_fh() and others.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt linux/Documentation/filesystems/aufs/design/08shwh.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt  1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/08shwh.txt     2014-01-30 21:10:02.807480310 +0100
++++ linux/Documentation/filesystems/aufs/design/08shwh.txt     2015-06-22 08:27:37.870834875 +0200
 @@ -0,0 +1,52 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1939,10 +2206,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt linu
 +initramfs will use it to replace the old one at the next boot.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt linux/Documentation/filesystems/aufs/design/10dynop.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/10dynop.txt    2014-01-30 21:10:02.807480310 +0100
-@@ -0,0 +1,46 @@
++++ linux/Documentation/filesystems/aufs/design/10dynop.txt    2015-06-22 08:27:37.870834875 +0200
+@@ -0,0 +1,47 @@
 +
-+# Copyright (C) 2010-2014 Junjiro R. Okajima
++# Copyright (C) 2010-2015 Junjiro R. Okajima
 +#
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -1965,34 +2232,35 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt lin
 +operation. Some FS have multiple sets of them. For instance, ext2 has
 +three sets, one for XIP, for NOBH, and for normal.
 +Since aufs overrides and redirects these operations, sometimes aufs has
-+to change its behaviour according to the branch FS type. More imporantly
++to change its behaviour according to the branch FS type. More importantly
 +VFS acts differently if a function (member in the struct) is set or
 +not. It means aufs should have several sets of operations and select one
 +among them according to the branch FS definition.
 +
-+In order to solve this problem and not to affect the behavour of VFS,
++In order to solve this problem and not to affect the behaviour of VFS,
 +aufs defines these operations dynamically. For instance, aufs defines
-+aio_read function for struct file_operations, but it may not be set to
-+the file_operations. When the branch FS doesn't have it, aufs doesn't
-+set it to its file_operations while the function definition itself is
-+still alive. So the behaviour of io_submit(2) will not change, and it
-+will return an error when aio_read is not defined.
++dummy direct_IO function for struct address_space_operations, but it may
++not be set to the address_space_operations actually. When the branch FS
++doesn't have it, aufs doesn't set it to its address_space_operations
++while the function definition itself is still alive. So the behaviour
++itself will not change, and it will return an error when direct_IO is
++not set.
 +
 +The lifetime of these dynamically generated operation object is
 +maintained by aufs branch object. When the branch is removed from aufs,
 +the reference counter of the object is decremented. When it reaches
 +zero, the dynamically generated operation object will be freed.
 +
-+This approach is designed to support AIO (io_submit), Direcit I/O and
-+XIP mainly.
-+Currently this approach is applied to file_operations and
-+vm_operations_struct for regular files only.
++This approach is designed to support AIO (io_submit), Direct I/O and
++XIP (DAX) mainly.
++Currently this approach is applied to address_space_operations for
++regular files only.
 diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt linux/Documentation/filesystems/aufs/design/99plan.txt
 --- /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt  1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/99plan.txt     2014-08-14 10:15:45.118609182 +0200
-@@ -0,0 +1,58 @@
++++ linux/Documentation/filesystems/aufs/design/99plan.txt     2015-06-22 08:27:37.870834875 +0200
+@@ -0,0 +1,57 @@
 +
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2015 Junjiro R. Okajima
 +# 
 +# This program is free software; you can redistribute it and/or modify
 +# it under the terms of the GNU General Public License as published by
@@ -2018,7 +2286,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt linu
 +----------------------------------------------------------------------
 +Aufs1 allows aufs to be another aufs's readonly branch.
 +This feature was developed by a user's request. But it may not be used
-+currecnly.
++currently.
 +
 +
 +Refresh the Opened File (refrof)
@@ -2036,7 +2304,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt linu
 +- user opened "/au/fileA".
 +- he or someone else inserts a branch (/new) between /rw and /ro.
 +  /au = /rw + /new + /ro
-+- the new branch has "fileA".
++- the new branch contains "fileA".
 +- user reads from the opened "fileA"
 +- which filedata should aufs return, from /ro or /new?
 +
@@ -2047,12 +2315,11 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/99plan.txt linu
 +Here again I don't have a best and final answer. I got an idea to
 +implement 'refrof' and 'norefrof' option. When 'refrof' (REFResh the
 +Opened File) is specified (by default), aufs returns the filedata from
-+/new.
-+Otherwise from /new.
++/new. Otherwise from /ro.
 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        2014-08-14 10:15:45.115275734 +0200
-@@ -0,0 +1,370 @@
++++ linux/Documentation/filesystems/aufs/README        2015-06-22 08:27:37.867501461 +0200
+@@ -0,0 +1,384 @@
 +
 +Aufs3 -- advanced multi layered unification filesystem version 3.x
 +http://aufs.sf.net
@@ -2062,7 +2329,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +0. Introduction
 +----------------------------------------
 +In the early days, aufs was entirely re-designed and re-implemented
-+Unionfs Version 1.x series. After many original ideas, approaches,
++Unionfs Version 1.x series. Adding many original ideas, approaches,
 +improvements and implementations, it becomes totally different from
 +Unionfs while keeping the basic features.
 +Recently, Unionfs Version 2.x series begin taking some of the same
@@ -2097,7 +2364,12 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +- dynamic branch manipulation, add, del.
 +- etc...
 +
-+Also there are many enhancements in aufs1, such as:
++Also there are many enhancements in aufs, such as:
++- test only the highest one for the directory permission (dirperm1)
++- copyup on open (coo=)
++- 'move' policy for copy-up between two writable branches, after
++  checking free space.
++- xattr, acl
 +- readdir(3) in userspace.
 +- keep inode number by external inode number table
 +- keep the timestamps of file/dir in internal copyup operation
@@ -2129,28 +2401,18 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +
 +Currently these features are dropped temporary from aufs3.
 +See design/08plan.txt in detail.
-+- test only the highest one for the directory permission (dirperm1)
-+- copyup on open (coo=)
 +- nested mount, i.e. aufs as readonly no-whiteout branch of another aufs
 +  (robr)
 +- statistics of aufs thread (/sys/fs/aufs/stat)
-+- delegation mode (dlgt)
-+  a delegation of the internal branch access to support task I/O
-+  accounting, which also supports Linux Security Modules (LSM) mainly
-+  for Suse AppArmor.
-+- intent.open/create (file open in a single lookup)
 +
 +Features or just an idea in the future (see also design/*.txt),
 +- reorder the branch index without del/re-add.
 +- permanent xino files for NFSD
 +- an option for refreshing the opened files after add/del branches
-+- 'move' policy for copy-up between two writable branches, after
-+  checking free space.
 +- light version, without branch manipulation. (unnecessary?)
 +- copyup in userspace
 +- inotify in userspace
 +- readv/writev
-+- xattr, acl
 +
 +
 +2. Download
@@ -2165,9 +2427,13 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +git://git.kernel.org/.../torvalds/linux.git.
 +And you cannot select CONFIG_AUFS_FS=m for this version, eg. you cannot
 +build aufs3 as an external kernel module.
++Several extra patches are not included in this tree. Only
++aufs3-standalong tree contains them. They are describe in the later
++section "Configuration and Compilation."
 +
 +On the other hand, the aufs3-standalone tree has only aufs source files
 +and necessary patches, and you can select CONFIG_AUFS_FS=m.
++But you need to apply all aufs patches manually.
 +
 +You will find GIT branches whose name is in form of "aufs3.x" where "x"
 +represents the linux kernel version, "linux-3.x". For instance,
@@ -2176,12 +2442,26 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +
 +o aufs3-linux tree
 +$ git clone --reference /your/linux/git/tree \
-+      git://git.code.sf.net/p/aufs/aufs3-linux aufs-aufs3-linux \
-+      aufs3-linux.git
++      git://git.code.sf.net/p/aufs/aufs3-linux aufs3-linux.git
 +- if you don't have linux GIT tree, then remove "--reference ..."
 +$ cd aufs3-linux.git
 +$ git checkout origin/aufs3.0
 +
++Or You may want to directly git-pull aufs into your linux GIT tree, and
++leave the patch-work to GIT.
++$ cd /your/linux/git/tree
++$ git remote add aufs3 https://github.com/sfjro/aufs3-linux.git
++- aufs3-linux.git tree also exists on github.
++$ git fetch aufs3
++$ git checkout -b my3.14 v3.14
++$ (add your change...)
++$ git pull aufs3 aufs3.14
++- now you have v3.14 + your_changes + aufs3.14 in you my3.14 branch.
++- you may need to solve some conflicts between your_changes and
++  aufs3.14. in this case, git-rerere is recommended so that you can
++  solve the similar confilicts automatically when you upgrade to 3.15 or
++  later in the future.
++
 +o aufs3-standalone tree
 +$ git clone git://git.code.sf.net/p/aufs/aufs3-standalone \
 +      aufs3-standalone.git
@@ -2406,6 +2686,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +Nikolay Pertsev made a donation (2014/5).
 +James B made a donation (2014/7).
 +Stefano Di Biase made a donation (2014/8).
++Daniel Epellei made a donation (2015/1).
 +
 +Thank you very much.
 +Donations are always, including future donations, very important and
@@ -2425,10 +2706,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
 +# End: ;
 diff -urN /usr/share/empty/fs/aufs/aufs.h linux/fs/aufs/aufs.h
 --- /usr/share/empty/fs/aufs/aufs.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/aufs.h       2014-01-30 21:10:02.827480967 +0100
++++ linux/fs/aufs/aufs.h       2015-06-22 08:27:37.874168290 +0200
 @@ -0,0 +1,59 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -2488,10 +2769,10 @@ diff -urN /usr/share/empty/fs/aufs/aufs.h linux/fs/aufs/aufs.h
 +#endif /* __AUFS_H__ */
 diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 --- /usr/share/empty/fs/aufs/branch.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/branch.c     2014-08-14 10:16:04.512608923 +0200
-@@ -0,0 +1,1447 @@
++++ linux/fs/aufs/branch.c     2015-06-22 08:29:23.703424266 +0200
+@@ -0,0 +1,1406 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -2518,34 +2799,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +/*
 + * free a single branch
 + */
-+
-+/* prohibit rmdir to the root of the branch */
-+/* todo: another new flag? */
-+static void au_br_dflags_force(struct au_branch *br)
-+{
-+      struct dentry *h_dentry;
-+
-+      h_dentry = au_br_dentry(br);
-+      spin_lock(&h_dentry->d_lock);
-+      br->br_dflags = h_dentry->d_flags & DCACHE_MOUNTED;
-+      h_dentry->d_flags |= DCACHE_MOUNTED;
-+      spin_unlock(&h_dentry->d_lock);
-+}
-+
-+/* restore its d_flags */
-+static void au_br_dflags_restore(struct au_branch *br)
-+{
-+      struct dentry *h_dentry;
-+
-+      if (br->br_dflags)
-+              return;
-+
-+      h_dentry = au_br_dentry(br);
-+      spin_lock(&h_dentry->d_lock);
-+      h_dentry->d_flags &= ~DCACHE_MOUNTED;
-+      spin_unlock(&h_dentry->d_lock);
-+}
-+
 +static void au_br_do_free(struct au_branch *br)
 +{
 +      int i;
@@ -2580,8 +2833,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              else
 +                      break;
 +
-+      au_br_dflags_restore(br);
-+
 +      /* recursive lock, s_umount of branch's */
 +      lockdep_off();
 +      path_put(&br->br_path);
@@ -2768,6 +3019,12 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              goto out;
 +      }
 +
++      if (unlikely(inode->i_sb->s_stack_depth)) {
++              pr_err("already stacked, %s (%s)\n",
++                     add->pathname, au_sbtype(inode->i_sb));
++              goto out;
++      }
++
 +      err = test_br(add->path.dentry->d_inode, add->perm, add->pathname);
 +      if (unlikely(err))
 +              goto out;
@@ -2885,7 +3142,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      return err;
 +}
 +
-+/* intialize a new branch */
++/* initialize a new branch */
 +static int au_br_init(struct au_branch *br, struct super_block *sb,
 +                    struct au_opt_add *add)
 +{
@@ -2895,9 +3152,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      memset(&br->br_xino, 0, sizeof(br->br_xino));
 +      mutex_init(&br->br_xino.xi_nondir_mtx);
 +      br->br_perm = add->perm;
-+      BUILD_BUG_ON(sizeof(br->br_dflags)
-+                   != sizeof(br->br_path.dentry->d_flags));
-+      br->br_dflags = DCACHE_MOUNTED;
 +      br->br_path = add->path; /* set first, path_get() later */
 +      spin_lock_init(&br->br_dykey_lock);
 +      memset(br->br_dykey, 0, sizeof(br->br_dykey));
@@ -2985,8 +3239,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      struct inode *root_inode;
 +      aufs_bindex_t bend, amount;
 +
-+      au_br_dflags_force(br);
-+
 +      root = sb->s_root;
 +      root_inode = root->d_inode;
 +      bend = au_sbend(sb);
@@ -3058,7 +3310,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +          && au_br_writable(add_branch->br_perm)
 +          && !au_test_fs_bad_xino(h_dentry->d_sb)
 +          && add_branch->br_xino.xi_file
-+          && add_branch->br_xino.xi_file->f_dentry->d_parent == h_dentry)
++          && add_branch->br_xino.xi_file->f_path.dentry->d_parent == h_dentry)
 +              au_xino_brid_set(sb, add_branch->br_id);
 +
 +out:
@@ -3161,7 +3413,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              ndentry = dpage->ndentry;
 +              for (j = 0; !err && j < ndentry; j++) {
 +                      d = dpage->dentries[j];
-+                      AuDebugOn(!d_count(d));
++                      AuDebugOn(au_dcount(d) <= 0);
 +                      if (!au_digen_test(d, sigen)) {
 +                              di_read_lock_child(d, AuLock_IR);
 +                              if (unlikely(au_dbrange_test(d))) {
@@ -3281,14 +3533,21 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +                       struct file **to_free, int *idx)
 +{
 +      int err;
-+      unsigned char matched, unmatched;
++      unsigned char matched, root;
 +      aufs_bindex_t bindex, bend;
 +      struct au_fidir *fidir;
 +      struct au_hfile *hfile;
 +
 +      err = 0;
++      root = IS_ROOT(file->f_path.dentry);
++      if (root) {
++              get_file(file);
++              to_free[*idx] = file;
++              (*idx)++;
++              goto out;
++      }
++
 +      matched = 0;
-+      unmatched = 0;
 +      fidir = au_fi(file)->fi_hdir;
 +      AuDebugOn(!fidir);
 +      bend = au_fbend_dir(file);
@@ -3297,21 +3556,12 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              if (!hfile->hf_file)
 +                      continue;
 +
-+              if (hfile->hf_br->br_id == br_id)
++              if (hfile->hf_br->br_id == br_id) {
 +                      matched = 1;
-+              else
-+                      unmatched = 1;
-+              if (matched && unmatched)
 +                      break;
++              }
 +      }
-+      if (!matched)
-+              goto out; /* success */
-+
-+      if (unmatched) {
-+              get_file(file);
-+              to_free[*idx] = file;
-+              (*idx)++;
-+      } else
++      if (matched)
 +              err = -EBUSY;
 +
 +out:
@@ -3325,7 +3575,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      unsigned long long ull, max;
 +      aufs_bindex_t bstart;
 +      struct file *file, **array;
-+      struct inode *inode;
 +      struct dentry *root;
 +      struct au_hfile *hfile;
 +
@@ -3346,8 +3595,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              /* AuDbg("%pD\n", file); */
 +              fi_read_lock(file);
 +              bstart = au_fbstart(file);
-+              inode = file_inode(file);
-+              if (!S_ISDIR(inode->i_mode)) {
++              if (!d_is_dir(file->f_path.dentry)) {
 +                      hfile = &au_fi(file)->fi_htop;
 +                      if (hfile->hf_br->br_id == br_id)
 +                              err = -EBUSY;
@@ -3380,7 +3628,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +                      break;
 +
 +              /* AuDbg("%pD\n", file); */
-+              AuDebugOn(!S_ISDIR(file_inode(file)->i_mode));
++              AuDebugOn(!d_is_dir(file->f_path.dentry));
 +              bfound = -1;
 +              fidir = au_fi(file)->fi_hdir;
 +              AuDebugOn(!fidir);
@@ -3682,13 +3930,13 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +
 +long au_ibusy_ioctl(struct file *file, unsigned long arg)
 +{
-+      return au_ibusy(file->f_dentry->d_sb, (void __user *)arg);
++      return au_ibusy(file->f_path.dentry->d_sb, (void __user *)arg);
 +}
 +
 +#ifdef CONFIG_COMPAT
 +long au_ibusy_compat_ioctl(struct file *file, unsigned long arg)
 +{
-+      return au_ibusy(file->f_dentry->d_sb, compat_ptr(arg));
++      return au_ibusy(file->f_path.dentry->d_sb, compat_ptr(arg));
 +}
 +#endif
 +
@@ -3725,7 +3973,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +      aufs_bindex_t br_id;
 +      unsigned char verbose, writer;
 +      struct file *file, *hf, **array;
-+      struct inode *inode;
 +      struct au_hfile *hfile;
 +
 +      mnt_flags = au_mntflags(sb);
@@ -3754,10 +4001,9 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +                      goto out_array;
 +              }
 +
-+              inode = file_inode(file);
 +              hfile = &au_fi(file)->fi_htop;
 +              hf = hfile->hf_file;
-+              if (!S_ISREG(inode->i_mode)
++              if (!d_is_reg(file->f_path.dentry)
 +                  || !(file->f_mode & FMODE_WRITE)
 +                  || hfile->hf_br->br_id != br_id
 +                  || !(hf->f_mode & FMODE_WRITE))
@@ -3903,12 +4149,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +              /* non-fhsm --> fhsm */
 +              br->br_fhsm = bf;
 +
-+      if ((br->br_perm & AuBrAttr_UNPIN)
-+          && !(mod->perm & AuBrAttr_UNPIN))
-+              au_br_dflags_force(br);
-+      else if (!(br->br_perm & AuBrAttr_UNPIN)
-+               && (mod->perm & AuBrAttr_UNPIN))
-+              au_br_dflags_restore(br);
 +      *do_refresh |= need_sigen_inc(br->br_perm, mod->perm);
 +      br->br_perm = mod->perm;
 +      goto out; /* success */
@@ -3939,10 +4179,10 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
 +}
 diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 --- /usr/share/empty/fs/aufs/branch.h  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/branch.h     2014-08-14 10:15:45.118609182 +0200
-@@ -0,0 +1,268 @@
++++ linux/fs/aufs/branch.h     2015-06-22 08:29:23.703424266 +0200
+@@ -0,0 +1,279 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -4039,7 +4279,6 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 +      aufs_bindex_t           br_id;
 +
 +      int                     br_perm;
-+      unsigned int            br_dflags;
 +      struct path             br_path;
 +      spinlock_t              br_dykey_lock;
 +      struct au_dykey         *br_dykey[AuBrDynOp];
@@ -4094,6 +4333,18 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 +#endif
 +}
 +
++static inline int au_br_test_oflag(int oflag, struct au_branch *br)
++{
++      int err, exec_flag;
++
++      err = 0;
++      exec_flag = oflag & __FMODE_EXEC;
++      if (unlikely(exec_flag && (au_br_mnt(br)->mnt_flags & MNT_NOEXEC)))
++              err = -EACCES;
++
++      return err;
++}
++
 +/* ---------------------------------------------------------------------- */
 +
 +/* branch.c */
@@ -4211,8 +4462,8 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
 +#endif /* __AUFS_BRANCH_H__ */
 diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
 --- /usr/share/empty/fs/aufs/conf.mk   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/conf.mk      2014-08-14 10:15:45.118609182 +0200
-@@ -0,0 +1,37 @@
++++ linux/fs/aufs/conf.mk      2015-06-22 08:27:37.874168290 +0200
+@@ -0,0 +1,38 @@
 +
 +AuConfStr = CONFIG_AUFS_FS=${CONFIG_AUFS_FS}
 +
@@ -4226,6 +4477,7 @@ diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
 +      SBILIST \
 +      HNOTIFY HFSNOTIFY \
 +      EXPORT INO_T_64 \
++      XATTR \
 +      FHSM \
 +      RDU \
 +      SHWH \
@@ -4252,10 +4504,10 @@ diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
 +-include ${srctree}/${src}/conf_priv.mk
 diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 --- /usr/share/empty/fs/aufs/cpup.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/cpup.c       2014-08-14 10:15:45.118609182 +0200
-@@ -0,0 +1,1301 @@
++++ linux/fs/aufs/cpup.c       2015-06-22 08:29:23.703424266 +0200
+@@ -0,0 +1,1308 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -4421,15 +4673,19 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +int cpup_iattr(struct dentry *dst, aufs_bindex_t bindex, struct dentry *h_src,
 +             struct au_cpup_reg_attr *h_src_attr)
 +{
-+      int err, sbits;
++      int err, sbits, icex;
++      unsigned int mnt_flags;
++      unsigned char verbose;
 +      struct iattr ia;
 +      struct path h_path;
 +      struct inode *h_isrc, *h_idst;
 +      struct kstat *h_st;
++      struct au_branch *br;
 +
 +      h_path.dentry = au_h_dptr(dst, bindex);
 +      h_idst = h_path.dentry->d_inode;
-+      h_path.mnt = au_sbr_mnt(dst->d_sb, bindex);
++      br = au_sbr(dst->d_sb, bindex);
++      h_path.mnt = au_br_mnt(br);
 +      h_isrc = h_src->d_inode;
 +      ia.ia_valid = ATTR_FORCE | ATTR_UID | ATTR_GID
 +              | ATTR_ATIME | ATTR_MTIME
@@ -4470,6 +4726,13 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              err = vfsub_notify_change(&h_path, &ia, /*delegated*/NULL);
 +      }
 +
++      icex = br->br_perm & AuBrAttr_ICEX;
++      if (!err) {
++              mnt_flags = au_mntflags(dst->d_sb);
++              verbose = !!au_opt_test(mnt_flags, VERBOSE);
++              err = au_cpup_xattr(h_path.dentry, h_src, icex, verbose);
++      }
++
 +      return err;
 +}
 +
@@ -4546,7 +4809,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              AuLabel(last hole);
 +
 +              err = 1;
-+              if (au_test_nfs(dst->f_dentry->d_sb)) {
++              if (au_test_nfs(dst->f_path.dentry->d_sb)) {
 +                      /* nfs requires this step to make last hole */
 +                      /* is this only nfs? */
 +                      do {
@@ -4582,7 +4845,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      char *buf;
 +
 +      err = -ENOMEM;
-+      blksize = dst->f_dentry->d_sb->s_blocksize;
++      blksize = dst->f_path.dentry->d_sb->s_blocksize;
 +      if (!blksize || PAGE_SIZE < blksize)
 +              blksize = PAGE_SIZE;
 +      AuDbg("blksize %lu\n", blksize);
@@ -5070,7 +5333,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      return err;
 +}
 +
-+#if 0 /* unused */
++#if 0 /* reserved */
 +struct au_cpup_single_args {
 +      int *errp;
 +      struct au_cp_generic *cpg;
@@ -5126,7 +5389,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      return do_sio;
 +}
 +
-+#if 0 /* unused */
++#if 0 /* reserved */
 +int au_sio_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent)
 +{
 +      int err, wkq_err;
@@ -5291,7 +5554,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +      h_d_start = NULL;
 +      if (file) {
 +              h_d_start = hdp[0 + cpg->bsrc].hd_dentry;
-+              hdp[0 + cpg->bsrc].hd_dentry = au_hf_top(file)->f_dentry;
++              hdp[0 + cpg->bsrc].hd_dentry = au_hf_top(file)->f_path.dentry;
 +      }
 +      flags_orig = cpg->flags;
 +      cpg->flags = !AuCpup_DTIME;
@@ -5337,7 +5600,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +
 +      dget(wh_dentry);
 +      h_path.dentry = wh_dentry;
-+      if (!S_ISDIR(wh_dentry->d_inode->i_mode)) {
++      if (!d_is_dir(wh_dentry)) {
 +              /* no delegation since it is just created */
 +              err = vfsub_unlink(h_parent->d_inode, &h_path,
 +                                 /*delegated*/NULL, /*force*/0);
@@ -5377,7 +5640,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +{
 +      int err, wkq_err;
 +      aufs_bindex_t bdst;
-+      struct dentry *dentry, *parent, *h_orph, *h_parent, *h_dentry;
++      struct dentry *dentry, *parent, *h_orph, *h_parent;
 +      struct inode *dir, *h_dir, *h_tmpdir;
 +      struct au_wbr *wbr;
 +      struct au_pin wh_pin, *pin_orig;
@@ -5400,10 +5663,6 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +              h_tmpdir = h_orph->d_inode;
 +              au_set_h_iptr(dir, bdst, au_igrab(h_tmpdir), /*flags*/0);
 +
-+              if (file)
-+                      h_dentry = au_hf_top(file)->f_dentry;
-+              else
-+                      h_dentry = au_h_dptr(dentry, au_dbstart(dentry));
 +              mutex_lock_nested(&h_tmpdir->i_mutex, AuLsc_I_PARENT3);
 +              /* todo: au_h_open_pre()? */
 +
@@ -5513,7 +5772,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +
 +static int au_cpup_dir(struct dentry *dentry, aufs_bindex_t bdst,
 +                     struct au_pin *pin,
-+                     struct dentry *h_parent __maybe_unused ,
++                     struct dentry *h_parent __maybe_unused,
 +                     void *arg __maybe_unused)
 +{
 +      struct au_cp_generic cpg = {
@@ -5557,10 +5816,10 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
 +}
 diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
 --- /usr/share/empty/fs/aufs/cpup.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/cpup.h       2014-01-30 21:10:02.827480967 +0100
++++ linux/fs/aufs/cpup.h       2015-06-22 08:27:37.874168290 +0200
 @@ -0,0 +1,94 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -5655,10 +5914,10 @@ diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
 +#endif /* __AUFS_CPUP_H__ */
 diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 --- /usr/share/empty/fs/aufs/dbgaufs.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dbgaufs.c    2014-01-30 21:10:02.827480967 +0100
++++ linux/fs/aufs/dbgaufs.c    2015-06-22 08:29:23.706757681 +0200
 @@ -0,0 +1,432 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -5885,7 +6144,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +
 +      err = -ENOENT;
 +      xf = NULL;
-+      name = &file->f_dentry->d_name;
++      name = &file->f_path.dentry->d_name;
 +      if (unlikely(name->len < sizeof(DbgaufsXi_PREFIX)
 +                   || memcmp(name->name, DbgaufsXi_PREFIX,
 +                             sizeof(DbgaufsXi_PREFIX) - 1)))
@@ -5990,7 +6249,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +      int err;
 +
 +      /*
-+       * This function is a dynamic '__init' fucntion actually,
++       * This function is a dynamic '__init' function actually,
 +       * so the tiny check for si_rwsem is unnecessary.
 +       */
 +      /* AuRwMustWriteLock(&sbinfo->si_rwsem); */
@@ -6016,7 +6275,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +void dbgaufs_si_fin(struct au_sbinfo *sbinfo)
 +{
 +      /*
-+       * This function is a dynamic '__init' fucntion actually,
++       * This function is a dynamic '__fin' function actually,
 +       * so the tiny check for si_rwsem is unnecessary.
 +       */
 +      /* AuRwMustWriteLock(&sbinfo->si_rwsem); */
@@ -6032,7 +6291,7 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +      char name[SysaufsSiNameLen];
 +
 +      /*
-+       * This function is a dynamic '__init' fucntion actually,
++       * This function is a dynamic '__init' function actually,
 +       * so the tiny check for si_rwsem is unnecessary.
 +       */
 +      /* AuRwMustWriteLock(&sbinfo->si_rwsem); */
@@ -6091,10 +6350,10 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
 +}
 diff -urN /usr/share/empty/fs/aufs/dbgaufs.h linux/fs/aufs/dbgaufs.h
 --- /usr/share/empty/fs/aufs/dbgaufs.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dbgaufs.h    2014-01-30 21:10:02.827480967 +0100
++++ linux/fs/aufs/dbgaufs.h    2015-06-22 08:27:37.874168290 +0200
 @@ -0,0 +1,48 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -6143,10 +6402,10 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.h linux/fs/aufs/dbgaufs.h
 +#endif /* __DBGAUFS_H__ */
 diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 --- /usr/share/empty/fs/aufs/dcsub.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dcsub.c      2014-01-30 21:10:02.827480967 +0100
-@@ -0,0 +1,243 @@
++++ linux/fs/aufs/dcsub.c      2015-06-22 08:27:37.877501704 +0200
+@@ -0,0 +1,224 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -6244,7 +6503,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +              dpages->ndpage++;
 +      }
 +
-+      AuDebugOn(!d_count(dentry));
++      AuDebugOn(au_dcount(dentry) <= 0);
 +      dpage->dentries[dpage->ndentry++] = dget_dlock(dentry);
 +      return 0; /* success */
 +
@@ -6252,79 +6511,60 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      return err;
 +}
 +
-+/* try d_walk() in linux/fs/dcache.c */
-+int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
-+                 au_dpages_test test, void *arg)
-+{
++/* todo: BAD approach */
++/* copied from linux/fs/dcache.c */
++enum d_walk_ret {
++      D_WALK_CONTINUE,
++      D_WALK_QUIT,
++      D_WALK_NORETRY,
++      D_WALK_SKIP,
++};
++
++extern void d_walk(struct dentry *parent, void *data,
++                 enum d_walk_ret (*enter)(void *, struct dentry *),
++                 void (*finish)(void *));
++
++struct ac_dpages_arg {
 +      int err;
-+      struct dentry *this_parent;
-+      struct list_head *next;
-+      struct super_block *sb = root->d_sb;
++      struct au_dcsub_pages *dpages;
++      struct super_block *sb;
++      au_dpages_test test;
++      void *arg;
++};
 +
-+      err = 0;
-+      write_seqlock(&rename_lock);
-+      this_parent = root;
-+      spin_lock(&this_parent->d_lock);
-+repeat:
-+      next = this_parent->d_subdirs.next;
-+resume:
-+      if (this_parent->d_sb == sb
-+          && !IS_ROOT(this_parent)
-+          && au_di(this_parent)
-+          && d_count(this_parent)
-+          && (!test || test(this_parent, arg))) {
-+              err = au_dpages_append(dpages, this_parent, GFP_ATOMIC);
-+              if (unlikely(err))
-+                      goto out;
-+      }
++static enum d_walk_ret au_call_dpages_append(void *_arg, struct dentry *dentry)
++{
++      enum d_walk_ret ret;
++      struct ac_dpages_arg *arg = _arg;
 +
-+      while (next != &this_parent->d_subdirs) {
-+              struct list_head *tmp = next;
-+              struct dentry *dentry = list_entry(tmp, struct dentry,
-+                                                 d_u.d_child);
-+
-+              next = tmp->next;
-+              spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
-+              if (d_count(dentry)) {
-+                      if (!list_empty(&dentry->d_subdirs)) {
-+                              spin_unlock(&this_parent->d_lock);
-+                              spin_release(&dentry->d_lock.dep_map, 1,
-+                                           _RET_IP_);
-+                              this_parent = dentry;
-+                              spin_acquire(&this_parent->d_lock.dep_map, 0, 1,
-+                                           _RET_IP_);
-+                              goto repeat;
-+                      }
-+                      if (dentry->d_sb == sb
-+                          && au_di(dentry)
-+                          && (!test || test(dentry, arg)))
-+                              err = au_dpages_append(dpages, dentry,
-+                                                     GFP_ATOMIC);
-+              }
-+              spin_unlock(&dentry->d_lock);
-+              if (unlikely(err))
-+                      goto out;
++      ret = D_WALK_CONTINUE;
++      if (dentry->d_sb == arg->sb
++          && !IS_ROOT(dentry)
++          && au_dcount(dentry) > 0
++          && au_di(dentry)
++          && (!arg->test || arg->test(dentry, arg->arg))) {
++              arg->err = au_dpages_append(arg->dpages, dentry, GFP_ATOMIC);
++              if (unlikely(arg->err))
++                      ret = D_WALK_QUIT;
 +      }
 +
-+      if (this_parent != root) {
-+              struct dentry *tmp;
-+              struct dentry *child;
++      return ret;
++}
 +
-+              tmp = this_parent->d_parent;
-+              rcu_read_lock();
-+              spin_unlock(&this_parent->d_lock);
-+              child = this_parent;
-+              this_parent = tmp;
-+              spin_lock(&this_parent->d_lock);
-+              rcu_read_unlock();
-+              next = child->d_u.d_child.next;
-+              goto resume;
-+      }
++int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
++                 au_dpages_test test, void *arg)
++{
++      struct ac_dpages_arg args = {
++              .err    = 0,
++              .dpages = dpages,
++              .sb     = root->d_sb,
++              .test   = test,
++              .arg    = arg
++      };
 +
-+out:
-+      spin_unlock(&this_parent->d_lock);
-+      write_sequnlock(&rename_lock);
-+      return err;
++      d_walk(root, &args, au_call_dpages_append, NULL);
++
++      return args.err;
 +}
 +
 +int au_dcsub_pages_rev(struct au_dcsub_pages *dpages, struct dentry *dentry,
@@ -6336,7 +6576,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      write_seqlock(&rename_lock);
 +      spin_lock(&dentry->d_lock);
 +      if (do_include
-+          && d_count(dentry)
++          && au_dcount(dentry) > 0
 +          && (!test || test(dentry, arg)))
 +              err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
 +      spin_unlock(&dentry->d_lock);
@@ -6350,7 +6590,7 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +      while (!IS_ROOT(dentry)) {
 +              dentry = dentry->d_parent; /* rename_lock is locked */
 +              spin_lock(&dentry->d_lock);
-+              if (d_count(dentry)
++              if (au_dcount(dentry) > 0
 +                  && (!test || test(dentry, arg)))
 +                      err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
 +              spin_unlock(&dentry->d_lock);
@@ -6390,10 +6630,10 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
 +}
 diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
 --- /usr/share/empty/fs/aufs/dcsub.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dcsub.h      2014-08-14 10:15:45.118609182 +0200
-@@ -0,0 +1,120 @@
++++ linux/fs/aufs/dcsub.h      2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,132 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -6421,8 +6661,6 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
 +#include <linux/dcache.h>
 +#include <linux/fs.h>
 +
-+struct dentry;
-+
 +struct au_dpage {
 +      int ndentry;
 +      struct dentry **dentries;
@@ -6510,14 +6748,28 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
 +              && !memcmp(a->name, b->name, a->len);
 +}
 +
++/*
++ * by the commit
++ * 360f547 2015-01-25 dcache: let the dentry count go down to zero without
++ *                    taking d_lock
++ * the type of d_lockref.count became int, but the inlined function d_count()
++ * still returns unsigned int.
++ * I don't know why. Maybe it is for every d_count() users?
++ * Anyway au_dcount() lives on.
++ */
++static inline int au_dcount(struct dentry *d)
++{
++      return (int)d_count(d);
++}
++
 +#endif /* __KERNEL__ */
 +#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      2014-08-14 10:15:45.121942630 +0200
-@@ -0,0 +1,519 @@
++++ linux/fs/aufs/debug.c      2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,438 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -6537,7 +6789,6 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 + * debug print functions
 + */
 +
-+#include <linux/vt_kern.h>
 +#include "aufs.h"
 +
 +/* Returns 0, or -errno.  arg is in kp->arg. */
@@ -6574,6 +6825,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +MODULE_PARM_DESC(debug, "debug print");
 +module_param_named(debug, aufs_debug, atomic_t, S_IRUGO | S_IWUSR | S_IWGRP);
 +
++DEFINE_MUTEX(au_dbg_mtx);     /* just to serialize the dbg msgs */
 +char *au_plevel = KERN_DEBUG;
 +#define dpri(fmt, ...) do {                                   \
 +      if ((au_plevel                                          \
@@ -6686,7 +6938,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      struct dentry *d;
 +
 +      spin_lock(&inode->i_lock);
-+      hlist_for_each_entry(d, &inode->i_dentry, d_alias)
++      hlist_for_each_entry(d, &inode->i_dentry, d_u.d_alias)
 +              au_dpri_dentry(d);
 +      spin_unlock(&inode->i_lock);
 +}
@@ -6706,7 +6958,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      dpri("d%d: %p, %pd2?, %s, cnt %d, flags 0x%x, %shashed\n",
 +           bindex, dentry, dentry,
 +           dentry->d_sb ? au_sbtype(dentry->d_sb) : "??",
-+           d_count(dentry), dentry->d_flags,
++           au_dcount(dentry), dentry->d_flags,
 +           d_unhashed(dentry) ? "un" : "");
 +      hn = -1;
 +      if (bindex >= 0 && dentry->d_inode && au_test_aufs(dentry->d_sb)) {
@@ -6755,16 +7007,16 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      }
 +      a[0] = 0;
 +      if (bindex < 0
-+          && file->f_dentry
-+          && au_test_aufs(file->f_dentry->d_sb)
++          && !IS_ERR_OR_NULL(file->f_path.dentry)
++          && au_test_aufs(file->f_path.dentry->d_sb)
 +          && au_fi(file))
 +              snprintf(a, sizeof(a), ", gen %d, mmapped %d",
 +                       au_figen(file), atomic_read(&au_fi(file)->fi_mmapped));
 +      dpri("f%d: mode 0x%x, flags 0%o, cnt %ld, v %llu, pos %llu%s\n",
 +           bindex, file->f_mode, file->f_flags, (long)file_count(file),
 +           file->f_version, file->f_pos, a);
-+      if (file->f_dentry)
-+              do_pri_dentry(bindex, file->f_dentry);
++      if (!IS_ERR_OR_NULL(file->f_path.dentry))
++              do_pri_dentry(bindex, file->f_path.dentry);
 +      return 0;
 +}
 +
@@ -6777,7 +7029,9 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      int err;
 +
 +      err = do_pri_file(-1, file);
-+      if (err || !file->f_dentry || !au_test_aufs(file->f_dentry->d_sb))
++      if (err
++          || IS_ERR_OR_NULL(file->f_path.dentry)
++          || !au_test_aufs(file->f_path.dentry->d_sb))
 +              return;
 +
 +      finfo = au_fi(file);
@@ -6867,42 +7121,6 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +
 +/* ---------------------------------------------------------------------- */
 +
-+void au_dbg_sleep_jiffy(int jiffy)
-+{
-+      while (jiffy)
-+              jiffy = schedule_timeout_uninterruptible(jiffy);
-+}
-+
-+void au_dbg_iattr(struct iattr *ia)
-+{
-+#define AuBit(name)                                   \
-+      do {                                            \
-+              if (ia->ia_valid & ATTR_ ## name)       \
-+                      dpri(#name "\n");               \
-+      } while (0)
-+      AuBit(MODE);
-+      AuBit(UID);
-+      AuBit(GID);
-+      AuBit(SIZE);
-+      AuBit(ATIME);
-+      AuBit(MTIME);
-+      AuBit(CTIME);
-+      AuBit(ATIME_SET);
-+      AuBit(MTIME_SET);
-+      AuBit(FORCE);
-+      AuBit(ATTR_FLAG);
-+      AuBit(KILL_SUID);
-+      AuBit(KILL_SGID);
-+      AuBit(FILE);
-+      AuBit(KILL_PRIV);
-+      AuBit(OPEN);
-+      AuBit(TIMES_SET);
-+#undef        AuBit
-+      dpri("ia_file %p\n", ia->ia_file);
-+}
-+
-+/* ---------------------------------------------------------------------- */
-+
 +void __au_dbg_verify_dinode(struct dentry *dentry, const char *func, int line)
 +{
 +      struct inode *h_inode, *inode = dentry->d_inode;
@@ -6937,29 +7155,6 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      }
 +}
 +
-+void au_dbg_verify_dir_parent(struct dentry *dentry, unsigned int sigen)
-+{
-+      struct dentry *parent;
-+
-+      parent = dget_parent(dentry);
-+      AuDebugOn(!S_ISDIR(dentry->d_inode->i_mode));
-+      AuDebugOn(IS_ROOT(dentry));
-+      AuDebugOn(au_digen_test(parent, sigen));
-+      dput(parent);
-+}
-+
-+void au_dbg_verify_nondir_parent(struct dentry *dentry, unsigned int sigen)
-+{
-+      struct dentry *parent;
-+      struct inode *inode;
-+
-+      parent = dget_parent(dentry);
-+      inode = dentry->d_inode;
-+      AuDebugOn(inode && S_ISDIR(dentry->d_inode->i_mode));
-+      AuDebugOn(au_digen_test(parent, sigen));
-+      dput(parent);
-+}
-+
 +void au_dbg_verify_gen(struct dentry *parent, unsigned int sigen)
 +{
 +      int err, i, j;
@@ -6994,26 +7189,6 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +
 +/* ---------------------------------------------------------------------- */
 +
-+void au_debug_sbinfo_init(struct au_sbinfo *sbinfo __maybe_unused)
-+{
-+#ifdef AuForceNoPlink
-+      au_opt_clr(sbinfo->si_mntflags, PLINK);
-+#endif
-+#ifdef AuForceNoXino
-+      au_opt_clr(sbinfo->si_mntflags, XINO);
-+#endif
-+#ifdef AuForceNoRefrof
-+      au_opt_clr(sbinfo->si_mntflags, REFROF);
-+#endif
-+#ifdef AuForceHnotify
-+      au_opt_set_udba(sbinfo->si_mntflags, UDBA_HNOTIFY);
-+#endif
-+#ifdef AuForceRd0
-+      sbinfo->si_rdblk = 0;
-+      sbinfo->si_rdhash = 0;
-+#endif
-+}
-+
 +int __init au_debug_init(void)
 +{
 +      aufs_bindex_t bindex;
@@ -7029,18 +7204,14 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
 +      pr_warn("CONFIG_4KSTACKS is defined.\n");
 +#endif
 +
-+#ifdef AuForceNoBrs
-+      sysaufs_brs = 0;
-+#endif
-+
 +      return 0;
 +}
 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      2014-01-30 21:10:02.827480967 +0100
-@@ -0,0 +1,247 @@
++++ linux/fs/aufs/debug.h      2015-06-22 08:27:37.877501704 +0200
+@@ -0,0 +1,228 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -7147,10 +7318,9 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +
 +/* ---------------------------------------------------------------------- */
 +
-+struct au_sbinfo;
-+struct au_finfo;
 +struct dentry;
 +#ifdef CONFIG_AUFS_DEBUG
++extern struct mutex au_dbg_mtx;
 +extern char *au_plevel;
 +struct au_nhash;
 +void au_dpri_whlist(struct au_nhash *whlist);
@@ -7165,67 +7335,60 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +struct super_block;
 +void au_dpri_sb(struct super_block *sb);
 +
-+void au_dbg_sleep_jiffy(int jiffy);
-+struct iattr;
-+void au_dbg_iattr(struct iattr *ia);
-+
 +#define au_dbg_verify_dinode(d) __au_dbg_verify_dinode(d, __func__, __LINE__)
 +void __au_dbg_verify_dinode(struct dentry *dentry, const char *func, int line);
-+void au_dbg_verify_dir_parent(struct dentry *dentry, unsigned int sigen);
-+void au_dbg_verify_nondir_parent(struct dentry *dentry, unsigned int sigen);
 +void au_dbg_verify_gen(struct dentry *parent, unsigned int sigen);
 +void au_dbg_verify_kthread(void);
 +
 +int __init au_debug_init(void);
-+void au_debug_sbinfo_init(struct au_sbinfo *sbinfo);
++
 +#define AuDbgWhlist(w) do { \
++      mutex_lock(&au_dbg_mtx); \
 +      AuDbg(#w "\n"); \
 +      au_dpri_whlist(w); \
++      mutex_unlock(&au_dbg_mtx); \
 +} while (0)
 +
 +#define AuDbgVdir(v) do { \
++      mutex_lock(&au_dbg_mtx); \
 +      AuDbg(#v "\n"); \
 +      au_dpri_vdir(v); \
++      mutex_unlock(&au_dbg_mtx); \
 +} while (0)
 +
 +#define AuDbgInode(i) do { \
++      mutex_lock(&au_dbg_mtx); \
 +      AuDbg(#i "\n"); \
 +      au_dpri_inode(i); \
++      mutex_unlock(&au_dbg_mtx); \
 +} while (0)
 +
 +#define AuDbgDAlias(i) do { \
++      mutex_lock(&au_dbg_mtx); \
 +      AuDbg(#i "\n"); \
 +      au_dpri_dalias(i); \
++      mutex_unlock(&au_dbg_mtx); \
 +} while (0)
 +
 +#define AuDbgDentry(d) do { \
++      mutex_lock(&au_dbg_mtx); \
 +      AuDbg(#d "\n"); \
 +      au_dpri_dentry(d); \
++      mutex_unlock(&au_dbg_mtx); \
 +} while (0)
 +
 +#define AuDbgFile(f) do { \
++      mutex_lock(&au_dbg_mtx); \
 +      AuDbg(#f "\n"); \
 +      au_dpri_file(f); \
++      mutex_unlock(&au_dbg_mtx); \
 +} while (0)
 +
 +#define AuDbgSb(sb) do { \
++      mutex_lock(&au_dbg_mtx); \
 +      AuDbg(#sb "\n"); \
 +      au_dpri_sb(sb); \
-+} while (0)
-+
-+#define AuDbgSleep(sec) do { \
-+      AuDbg("sleep %d sec\n", sec); \
-+      ssleep(sec); \
-+} while (0)
-+
-+#define AuDbgSleepJiffy(jiffy) do { \
-+      AuDbg("sleep %d jiffies\n", jiffy); \
-+      au_dbg_sleep_jiffy(jiffy); \
-+} while (0)
-+
-+#define AuDbgIAttr(ia) do { \
-+      AuDbg("ia_valid 0x%x\n", (ia)->ia_valid); \
-+      au_dbg_iattr(ia); \
++      mutex_unlock(&au_dbg_mtx); \
 +} while (0)
 +
 +#define AuDbgSym(addr) do {                           \
@@ -7233,12 +7396,6 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +      sprint_symbol(sym, (unsigned long)addr);        \
 +      AuDbg("%s\n", sym);                             \
 +} while (0)
-+
-+#define AuInfoSym(addr) do {                          \
-+      char sym[KSYM_SYMBOL_LEN];                      \
-+      sprint_symbol(sym, (unsigned long)addr);        \
-+      AuInfo("%s\n", sym);                            \
-+} while (0)
 +#else
 +AuStubVoid(au_dbg_verify_dinode, struct dentry *dentry)
 +AuStubVoid(au_dbg_verify_dir_parent, struct dentry *dentry, unsigned int sigen)
@@ -7247,7 +7404,6 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +AuStubVoid(au_dbg_verify_gen, struct dentry *parent, unsigned int sigen)
 +AuStubVoid(au_dbg_verify_kthread, void)
 +AuStubInt0(__init au_debug_init, void)
-+AuStubVoid(au_debug_sbinfo_init, struct au_sbinfo *sbinfo)
 +
 +#define AuDbgWhlist(w)                do {} while (0)
 +#define AuDbgVdir(v)          do {} while (0)
@@ -7256,11 +7412,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +#define AuDbgDentry(d)                do {} while (0)
 +#define AuDbgFile(f)          do {} while (0)
 +#define AuDbgSb(sb)           do {} while (0)
-+#define AuDbgSleep(sec)               do {} while (0)
-+#define AuDbgSleepJiffy(jiffy)        do {} while (0)
-+#define AuDbgIAttr(ia)                do {} while (0)
 +#define AuDbgSym(addr)                do {} while (0)
-+#define AuInfoSym(addr)               do {} while (0)
 +#endif /* CONFIG_AUFS_DEBUG */
 +
 +/* ---------------------------------------------------------------------- */
@@ -7288,10 +7440,10 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
 +#endif /* __AUFS_DEBUG_H__ */
 diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 --- /usr/share/empty/fs/aufs/dentry.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dentry.c     2014-08-14 10:16:04.515942371 +0200
-@@ -0,0 +1,1094 @@
++++ linux/fs/aufs/dentry.c     2015-06-22 08:27:37.877501704 +0200
+@@ -0,0 +1,1097 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -7337,7 +7489,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +           struct au_do_lookup_args *args)
 +{
 +      struct dentry *h_dentry;
-+      struct inode *h_inode, *inode;
++      struct inode *h_inode;
 +      struct au_branch *br;
 +      int wh_found, opq;
 +      unsigned char wh_able;
@@ -7367,8 +7519,12 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              h_dentry = vfsub_lkup_one(&dentry->d_name, h_parent);
 +      else
 +              h_dentry = au_sio_lkup_one(&dentry->d_name, h_parent);
-+      if (IS_ERR(h_dentry))
++      if (IS_ERR(h_dentry)) {
++              if (PTR_ERR(h_dentry) == -ENAMETOOLONG
++                  && !allow_neg)
++                      h_dentry = NULL;
 +              goto out;
++      }
 +
 +      h_inode = h_dentry->d_inode;
 +      if (!h_inode) {
@@ -7384,9 +7540,9 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              au_set_dbstart(dentry, bindex);
 +      au_set_h_dptr(dentry, bindex, h_dentry);
 +
-+      inode = dentry->d_inode;
-+      if (!h_inode || !S_ISDIR(h_inode->i_mode) || !wh_able
-+          || (inode && !S_ISDIR(inode->i_mode)))
++      if (!d_is_dir(h_dentry)
++          || !wh_able
++          || (d_is_positive(dentry) && !d_is_dir(dentry)))
 +              goto out; /* success */
 +
 +      mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
@@ -7445,7 +7601,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              goto out;
 +
 +      inode = dentry->d_inode;
-+      isdir = !!(inode && S_ISDIR(inode->i_mode));
++      isdir = !!d_is_dir(dentry);
 +      if (!type)
 +              au_fset_lkup(args.flags, ALLOW_NEG);
 +      dirperm1 = !!au_opt_test(au_mntflags(sb), DIRPERM1);
@@ -7466,12 +7622,10 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +                      continue;
 +              }
 +              h_parent = au_h_dptr(parent, bindex);
-+              if (!h_parent)
-+                      continue;
-+              h_dir = h_parent->d_inode;
-+              if (!h_dir || !S_ISDIR(h_dir->i_mode))
++              if (!h_parent || !d_is_dir(h_parent))
 +                      continue;
 +
++              h_dir = h_parent->d_inode;
 +              mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
 +              h_dentry = au_do_lookup(h_parent, dentry, bindex, &whname,
 +                                      &args);
@@ -7479,7 +7633,8 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              err = PTR_ERR(h_dentry);
 +              if (IS_ERR(h_dentry))
 +                      goto out_parent;
-+              au_fclr_lkup(args.flags, ALLOW_NEG);
++              if (h_dentry)
++                      au_fclr_lkup(args.flags, ALLOW_NEG);
 +              if (dirperm1)
 +                      au_fset_lkup(args.flags, IGNORE_PERM);
 +
@@ -7814,11 +7969,9 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +static void au_hide(struct dentry *dentry)
 +{
 +      int err;
-+      struct inode *inode;
 +
 +      AuDbgDentry(dentry);
-+      inode = dentry->d_inode;
-+      if (inode && S_ISDIR(inode->i_mode)) {
++      if (d_is_dir(dentry)) {
 +              /* shrink_dcache_parent(dentry); */
 +              err = au_hide_children(dentry);
 +              if (unlikely(err))
@@ -8296,10 +8449,6 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      if (unlikely(!au_di(dentry)))
 +              goto out;
 +
-+      inode = dentry->d_inode;
-+      if (inode && is_bad_inode(inode))
-+              goto out;
-+
 +      valid = 1;
 +      sb = dentry->d_sb;
 +      /*
@@ -8313,6 +8462,12 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +              AuTraceErr(err);
 +              goto out;
 +      }
++      inode = dentry->d_inode;
++      if (unlikely(inode && is_bad_inode(inode))) {
++              err = -EINVAL;
++              AuTraceErr(err);
++              goto out_dgrade;
++      }
 +      if (unlikely(au_dbrange_test(dentry))) {
 +              err = -EINVAL;
 +              AuTraceErr(err);
@@ -8331,7 +8486,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +      di_downgrade_lock(dentry, AuLock_IR);
 +
 +      err = -EINVAL;
-+      if (!(flags & LOOKUP_OPEN)
++      if (!(flags & (LOOKUP_OPEN | LOOKUP_EMPTY))
 +          && inode
 +          && !(inode->i_state && I_LINKABLE)
 +          && (IS_DEADDIR(inode) || !inode->i_nlink))
@@ -8386,10 +8541,10 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
 +};
 diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
 --- /usr/share/empty/fs/aufs/dentry.h  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dentry.h     2014-08-14 10:15:45.121942630 +0200
++++ linux/fs/aufs/dentry.h     2015-06-22 08:27:37.877501704 +0200
 @@ -0,0 +1,233 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -8623,10 +8778,10 @@ diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
 +#endif /* __AUFS_DENTRY_H__ */
 diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 --- /usr/share/empty/fs/aufs/dinfo.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dinfo.c      2014-08-14 10:15:45.121942630 +0200
++++ linux/fs/aufs/dinfo.c      2015-06-22 08:27:37.877501704 +0200
 @@ -0,0 +1,544 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -8945,7 +9100,7 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 +              return NULL;
 +      AuDebugOn(bindex < 0);
 +      d = au_di(dentry)->di_hdentry[0 + bindex].hd_dentry;
-+      AuDebugOn(d && d_count(d) <= 0);
++      AuDebugOn(d && au_dcount(d) <= 0);
 +      return d;
 +}
 +
@@ -9171,10 +9326,10 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
 +}
 diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 --- /usr/share/empty/fs/aufs/dir.c     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dir.c        2014-08-14 10:15:45.121942630 +0200
-@@ -0,0 +1,645 @@
++++ linux/fs/aufs/dir.c        2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,751 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -9236,8 +9391,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +
 +      sz = 0;
 +      if (file) {
-+              AuDebugOn(!file_inode(file));
-+              AuDebugOn(!S_ISDIR(file_inode(file)->i_mode));
++              AuDebugOn(!d_is_dir(file->f_path.dentry));
 +
 +              bend = au_fbend_dir(file);
 +              for (bindex = au_fbstart(file);
@@ -9249,8 +9403,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +              }
 +      } else {
 +              AuDebugOn(!dentry);
-+              AuDebugOn(!dentry->d_inode);
-+              AuDebugOn(!S_ISDIR(dentry->d_inode->i_mode));
++              AuDebugOn(!d_is_dir(dentry));
 +
 +              bend = au_dbtaildir(dentry);
 +              for (bindex = au_dbstart(dentry);
@@ -9272,6 +9425,110 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      return sz;
 +}
 +
++struct au_dir_ts_arg {
++      struct dentry *dentry;
++      aufs_bindex_t brid;
++};
++
++static void au_do_dir_ts(void *arg)
++{
++      struct au_dir_ts_arg *a = arg;
++      struct au_dtime dt;
++      struct path h_path;
++      struct inode *dir, *h_dir;
++      struct super_block *sb;
++      struct au_branch *br;
++      struct au_hinode *hdir;
++      int err;
++      aufs_bindex_t bstart, bindex;
++
++      sb = a->dentry->d_sb;
++      dir = a->dentry->d_inode;
++      if (!dir)
++              goto out;
++      /* no dir->i_mutex lock */
++      aufs_read_lock(a->dentry, AuLock_DW | AuLock_DIR); /* noflush */
++
++      bstart = au_ibstart(dir);
++      bindex = au_br_index(sb, a->brid);
++      if (bindex < bstart)
++              goto out_unlock;
++
++      br = au_sbr(sb, bindex);
++      h_path.dentry = au_h_dptr(a->dentry, bindex);
++      if (!h_path.dentry)
++              goto out_unlock;
++      h_path.mnt = au_br_mnt(br);
++      au_dtime_store(&dt, a->dentry, &h_path);
++
++      br = au_sbr(sb, bstart);
++      if (!au_br_writable(br->br_perm))
++              goto out_unlock;
++      h_path.dentry = au_h_dptr(a->dentry, bstart);
++      h_path.mnt = au_br_mnt(br);
++      err = vfsub_mnt_want_write(h_path.mnt);
++      if (err)
++              goto out_unlock;
++      hdir = au_hi(dir, bstart);
++      au_hn_imtx_lock_nested(hdir, AuLsc_I_PARENT);
++      h_dir = au_h_iptr(dir, bstart);
++      if (h_dir->i_nlink
++          && timespec_compare(&h_dir->i_mtime, &dt.dt_mtime) < 0) {
++              dt.dt_h_path = h_path;
++              au_dtime_revert(&dt);
++      }
++      au_hn_imtx_unlock(hdir);
++      vfsub_mnt_drop_write(h_path.mnt);
++      au_cpup_attr_timesizes(dir);
++
++out_unlock:
++      aufs_read_unlock(a->dentry, AuLock_DW);
++out:
++      dput(a->dentry);
++      au_nwt_done(&au_sbi(sb)->si_nowait);
++      kfree(arg);
++}
++
++void au_dir_ts(struct inode *dir, aufs_bindex_t bindex)
++{
++      int perm, wkq_err;
++      aufs_bindex_t bstart;
++      struct au_dir_ts_arg *arg;
++      struct dentry *dentry;
++      struct super_block *sb;
++
++      IMustLock(dir);
++
++      dentry = d_find_any_alias(dir);
++      AuDebugOn(!dentry);
++      sb = dentry->d_sb;
++      bstart = au_ibstart(dir);
++      if (bstart == bindex) {
++              au_cpup_attr_timesizes(dir);
++              goto out;
++      }
++
++      perm = au_sbr_perm(sb, bstart);
++      if (!au_br_writable(perm))
++              goto out;
++
++      arg = kmalloc(sizeof(*arg), GFP_NOFS);
++      if (!arg)
++              goto out;
++
++      arg->dentry = dget(dentry); /* will be dput-ted by au_do_dir_ts() */
++      arg->brid = au_sbr_id(sb, bindex);
++      wkq_err = au_wkq_nowait(au_do_dir_ts, arg, sb, /*flags*/0);
++      if (unlikely(wkq_err)) {
++              pr_err("wkq %d\n", wkq_err);
++              dput(dentry);
++              kfree(arg);
++      }
++
++out:
++      dput(dentry);
++}
++
 +/* ---------------------------------------------------------------------- */
 +
 +static int reopen_dir(struct file *file)
@@ -9283,7 +9540,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      struct file *h_file;
 +
 +      /* open all lower dirs */
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      bstart = au_dbstart(dentry);
 +      for (bindex = au_fbstart(file); bindex < bstart; bindex++)
 +              au_set_h_fptr(file, bindex, NULL);
@@ -9318,17 +9575,17 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      return err;
 +}
 +
-+static int do_open_dir(struct file *file, int flags)
++static int do_open_dir(struct file *file, int flags, struct file *h_file)
 +{
 +      int err;
 +      aufs_bindex_t bindex, btail;
 +      struct dentry *dentry, *h_dentry;
-+      struct file *h_file;
 +
 +      FiMustWriteLock(file);
++      AuDebugOn(h_file);
 +
 +      err = 0;
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      file->f_version = dentry->d_inode->i_version;
 +      bindex = au_dbstart(dentry);
 +      au_set_fbstart(file, bindex);
@@ -9369,11 +9626,15 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      struct au_fidir *fidir;
 +
 +      err = -ENOMEM;
-+      sb = file->f_dentry->d_sb;
++      sb = file->f_path.dentry->d_sb;
 +      si_read_lock(sb, AuLock_FLUSH);
 +      fidir = au_fidir_alloc(sb);
 +      if (fidir) {
-+              err = au_do_open(file, do_open_dir, fidir);
++              struct au_do_open_args args = {
++                      .open   = do_open_dir,
++                      .fidir  = fidir
++              };
++              err = au_do_open(file, &args);
 +              if (unlikely(err))
 +                      kfree(fidir);
 +      }
@@ -9393,7 +9654,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      fidir = finfo->fi_hdir;
 +      if (fidir) {
 +              au_sphl_del(&finfo->fi_hlist,
-+                          &au_sbi(file->f_dentry->d_sb)->si_files);
++                          &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);
@@ -9480,8 +9741,8 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      if (unlikely(err))
 +              goto out;
 +
-+      sb = file->f_dentry->d_sb;
 +      inode = file_inode(file);
++      sb = inode->i_sb;
 +      bend = au_fbend_dir(file);
 +      for (bindex = au_fbstart(file); !err && bindex <= bend; bindex++) {
 +              h_file = au_hf_dir(file, bindex);
@@ -9507,7 +9768,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      struct mutex *mtx;
 +
 +      err = 0;
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      mtx = &dentry->d_inode->i_mutex;
 +      mutex_lock(mtx);
 +      sb = dentry->d_sb;
@@ -9539,7 +9800,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +
 +      AuDbg("%pD, ctx{%pf, %llu}\n", file, ctx->actor, ctx->pos);
 +
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      inode = dentry->d_inode;
 +      IMustLock(inode);
 +
@@ -9728,7 +9989,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      struct au_nhash whlist;
 +      struct test_empty_arg arg = {
 +              .ctx = {
-+                      .actor = au_diractor(test_empty_cb)
++                      .actor = test_empty_cb
 +              }
 +      };
 +      int (*test_empty)(struct dentry *dentry, struct test_empty_arg *arg);
@@ -9778,7 +10039,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +      int err;
 +      struct test_empty_arg arg = {
 +              .ctx = {
-+                      .actor = au_diractor(test_empty_cb)
++                      .actor = test_empty_cb
 +              }
 +      };
 +      aufs_bindex_t bindex, btail;
@@ -9820,10 +10081,10 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
 +};
 diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 --- /usr/share/empty/fs/aufs/dir.h     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dir.h        2014-01-30 21:10:02.830814411 +0100
-@@ -0,0 +1,136 @@
++++ linux/fs/aufs/dir.h        2015-06-22 08:27:37.877501704 +0200
+@@ -0,0 +1,131 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -9914,6 +10175,7 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 +void au_add_nlink(struct inode *dir, struct inode *h_dir);
 +void au_sub_nlink(struct inode *dir, struct inode *h_dir);
 +loff_t au_dir_size(struct file *file, struct dentry *dentry);
++void au_dir_ts(struct inode *dir, aufs_bindex_t bsrc);
 +int au_test_empty_lower(struct dentry *dentry);
 +int au_test_empty(struct dentry *dentry, struct au_nhash *whlist);
 +
@@ -9942,17 +10204,11 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 +                       unsigned long arg);
 +#endif
 +#else
-+static inline long au_rdu_ioctl(struct file *file, unsigned int cmd,
-+                              unsigned long arg)
-+{
-+      return -EINVAL;
-+}
++AuStub(long, au_rdu_ioctl, return -EINVAL, struct file *file,
++       unsigned int cmd, unsigned long arg)
 +#ifdef CONFIG_COMPAT
-+static inline long au_rdu_compat_ioctl(struct file *file, unsigned int cmd,
-+                                     unsigned long arg)
-+{
-+      return -EINVAL;
-+}
++AuStub(long, au_rdu_compat_ioctl, return -EINVAL, struct file *file,
++       unsigned int cmd, unsigned long arg)
 +#endif
 +#endif
 +
@@ -9960,10 +10216,10 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
 +#endif /* __AUFS_DIR_H__ */
 diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 --- /usr/share/empty/fs/aufs/dynop.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dynop.c      2014-01-30 21:10:02.830814411 +0100
-@@ -0,0 +1,379 @@
++++ linux/fs/aufs/dynop.c      2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,369 @@
 +/*
-+ * Copyright (C) 2010-2014 Junjiro R. Okajima
++ * Copyright (C) 2010-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -10150,9 +10406,8 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +      DySetAop(invalidatepage);
 +      DySetAop(releasepage);
 +      DySetAop(freepage);
-+      /* these two will be changed according to an aufs mount option */
++      /* this one will be changed according to an aufs mount option */
 +      DySetAop(direct_IO);
-+      DySetAop(get_xip_mem);
 +      DySetAop(migratepage);
 +      DySetAop(launder_page);
 +      DySetAop(is_partially_uptodate);
@@ -10162,7 +10417,6 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +      DySetAop(swap_deactivate);
 +
 +      DyDbgSize(cnt, *h_aop);
-+      dyaop->da_get_xip_mem = h_aop->get_xip_mem;
 +}
 +
 +/* ---------------------------------------------------------------------- */
@@ -10222,25 +10476,17 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +/* ---------------------------------------------------------------------- */
 +/*
 + * Aufs prohibits O_DIRECT by defaut even if the branch supports it.
-+ * This behaviour is neccessary to return an error from open(O_DIRECT) instead
++ * This behaviour is necessary to return an error from open(O_DIRECT) instead
 + * of the succeeding I/O. The dio mount option enables O_DIRECT and makes
 + * open(O_DIRECT) always succeed, but the succeeding I/O may return an error.
 + * See the aufs manual in detail.
-+ *
-+ * To keep this behaviour, aufs has to set NULL to ->get_xip_mem too, and the
-+ * performance of fadvise() and madvise() may be affected.
 + */
 +static void dy_adx(struct au_dyaop *dyaop, int do_dx)
 +{
-+      if (!do_dx) {
++      if (!do_dx)
 +              dyaop->da_op.direct_IO = NULL;
-+              dyaop->da_op.get_xip_mem = NULL;
-+      } else {
++      else
 +              dyaop->da_op.direct_IO = aufs_aop.direct_IO;
-+              dyaop->da_op.get_xip_mem = aufs_aop.get_xip_mem;
-+              if (!dyaop->da_get_xip_mem)
-+                      dyaop->da_op.get_xip_mem = NULL;
-+      }
 +}
 +
 +static struct au_dyaop *dy_aget(struct au_branch *br,
@@ -10343,10 +10589,10 @@ diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
 +}
 diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h
 --- /usr/share/empty/fs/aufs/dynop.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dynop.h      2014-01-30 21:10:02.830814411 +0100
-@@ -0,0 +1,75 @@
++++ linux/fs/aufs/dynop.h      2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,74 @@
 +/*
-+ * Copyright (C) 2010-2014 Junjiro R. Okajima
++ * Copyright (C) 2010-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -10371,7 +10617,8 @@ diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h
 +
 +#ifdef __KERNEL__
 +
-+#include "inode.h"
++#include <linux/fs.h>
++#include <linux/kref.h>
 +
 +enum {AuDy_AOP, AuDyLast};
 +
@@ -10401,8 +10648,6 @@ diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h
 +struct au_dyaop {
 +      struct au_dykey                 da_key;
 +      struct address_space_operations da_op; /* not const */
-+      int (*da_get_xip_mem)(struct address_space *, pgoff_t, int,
-+                            void **, unsigned long *);
 +};
 +
 +/* ---------------------------------------------------------------------- */
@@ -10422,10 +10667,10 @@ diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h
 +#endif /* __AUFS_DYNOP_H__ */
 diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 --- /usr/share/empty/fs/aufs/export.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/export.c     2014-01-30 21:10:02.830814411 +0100
++++ linux/fs/aufs/export.c     2015-06-22 08:29:23.706757681 +0200
 @@ -0,0 +1,831 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -10669,7 +10914,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +              dentry = d_find_alias(inode);
 +      else {
 +              spin_lock(&inode->i_lock);
-+              hlist_for_each_entry(d, &inode->i_dentry, d_alias) {
++              hlist_for_each_entry(d, &inode->i_dentry, d_u.d_alias) {
 +                      spin_lock(&d->d_lock);
 +                      if (!au_test_anon(d)
 +                          && d->d_parent->d_inode->i_ino == dir_ino) {
@@ -10798,7 +11043,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +      struct inode *dir;
 +      struct find_name_by_ino arg = {
 +              .ctx = {
-+                      .actor = au_diractor(find_name_by_ino)
++                      .actor = find_name_by_ino
 +              }
 +      };
 +      int err;
@@ -11140,7 +11385,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +      ii_read_lock_child(inode);
 +      bindex = au_ibstart(inode);
 +      if (!dir) {
-+              dentry = d_find_alias(inode);
++              dentry = d_find_any_alias(inode);
 +              if (unlikely(!dentry))
 +                      goto out_unlock;
 +              AuDebugOn(au_test_anon(dentry));
@@ -11156,7 +11401,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
 +      ii_read_unlock(dir);
 +      if (unlikely(!h_dir))
 +              goto out_parent;
-+      h_parent = d_find_alias(h_dir);
++      h_parent = d_find_any_alias(h_dir);
 +      if (unlikely(!h_parent))
 +              goto out_hparent;
 +
@@ -11257,10 +11502,10 @@ 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       2014-08-14 10:15:45.121942630 +0200
-@@ -0,0 +1,410 @@
++++ linux/fs/aufs/fhsm.c       2015-06-22 08:27:37.880835119 +0200
+@@ -0,0 +1,426 @@
 +/*
-+ * Copyright (C) 2011-2014 Junjiro R. Okajima
++ * Copyright (C) 2011-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -11287,6 +11532,34 @@ diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.c
 +#include <linux/statfs.h>
 +#include "aufs.h"
 +
++static aufs_bindex_t au_fhsm_bottom(struct super_block *sb)
++{
++      struct au_sbinfo *sbinfo;
++      struct au_fhsm *fhsm;
++
++      SiMustAnyLock(sb);
++
++      sbinfo = au_sbi(sb);
++      fhsm = &sbinfo->si_fhsm;
++      AuDebugOn(!fhsm);
++      return fhsm->fhsm_bottom;
++}
++
++void au_fhsm_set_bottom(struct super_block *sb, aufs_bindex_t bindex)
++{
++      struct au_sbinfo *sbinfo;
++      struct au_fhsm *fhsm;
++
++      SiMustWriteLock(sb);
++
++      sbinfo = au_sbi(sb);
++      fhsm = &sbinfo->si_fhsm;
++      AuDebugOn(!fhsm);
++      fhsm->fhsm_bottom = bindex;
++}
++
++/* ---------------------------------------------------------------------- */
++
 +static int au_fhsm_test_jiffy(struct au_sbinfo *sbinfo, struct au_branch *br)
 +{
 +      struct au_br_fhsm *bf;
@@ -11360,8 +11633,6 @@ diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.c
 +void au_fhsm_wrote(struct super_block *sb, aufs_bindex_t bindex, int force)
 +{
 +      int err;
-+      unsigned char do_notify;
-+      aufs_bindex_t bend, blower;
 +      struct au_sbinfo *sbinfo;
 +      struct au_fhsm *fhsm;
 +      struct au_branch *br;
@@ -11372,19 +11643,8 @@ diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.c
 +
 +      sbinfo = au_sbi(sb);
 +      fhsm = &sbinfo->si_fhsm;
-+      if (!au_ftest_si(sbinfo, FHSM))
-+              return;
-+
-+      do_notify = 0;
-+      bend = au_sbend(sb);
-+      for (blower = bindex + 1; blower <= bend; blower++) {
-+              br = au_sbr(sb, blower);
-+              if (au_br_fhsm(br->br_perm)) {
-+                      do_notify = 1;
-+                      break;
-+              }
-+      }
-+      if (!do_notify)
++      if (!au_ftest_si(sbinfo, FHSM)
++          || fhsm->fhsm_bottom == bindex)
 +              return;
 +
 +      br = au_sbr(sb, bindex);
@@ -11405,7 +11665,7 @@ diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.c
 +      struct au_branch *br;
 +
 +      /* exclude the bottom */
-+      bend = au_sbend(sb);
++      bend = au_fhsm_bottom(sb);
 +      for (bindex = 0; bindex < bend; bindex++) {
 +              br = au_sbr(sb, bindex);
 +              if (au_br_fhsm(br->br_perm))
@@ -11459,7 +11719,7 @@ diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.c
 +      /* except the bottom branch */
 +      err = 0;
 +      nstbr = 0;
-+      bend = au_sbend(sb);
++      bend = au_fhsm_bottom(sb);
 +      for (bindex = 0; !err && bindex < bend; bindex++) {
 +              br = au_sbr(sb, bindex);
 +              if (!au_br_fhsm(br->br_perm))
@@ -11522,7 +11782,7 @@ diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.c
 +              AuDebugOn(!sb);
 +              /* exclude the bottom branch */
 +              nfhsm = 0;
-+              bend = au_sbend(sb);
++              bend = au_fhsm_bottom(sb);
 +              for (bindex = 0; bindex < bend; bindex++) {
 +                      br = au_sbr(sb, bindex);
 +                      if (au_br_fhsm(br->br_perm))
@@ -11650,6 +11910,7 @@ diff -urN /usr/share/empty/fs/aufs/fhsm.c linux/fs/aufs/fhsm.c
 +      atomic_set(&fhsm->fhsm_readable, 0);
 +      fhsm->fhsm_expire
 +              = msecs_to_jiffies(AUFS_FHSM_CACHE_DEF_SEC * MSEC_PER_SEC);
++      fhsm->fhsm_bottom = -1;
 +}
 +
 +void au_fhsm_set(struct au_sbinfo *sbinfo, unsigned int sec)
@@ -11671,10 +11932,10 @@ 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       2014-08-14 10:16:04.515942371 +0200
-@@ -0,0 +1,835 @@
++++ linux/fs/aufs/file.c       2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,844 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -11718,7 +11979,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      struct super_block *sb;
 +      struct au_branch *br;
 +      struct path h_path;
-+      int err, exec_flag;
++      int err;
 +
 +      /* a race condition can happen between open and unlink/rmdir */
 +      h_file = ERR_PTR(-ENOENT);
@@ -11739,9 +12000,9 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +
 +      sb = dentry->d_sb;
 +      br = au_sbr(sb, bindex);
-+      h_file = ERR_PTR(-EACCES);
-+      exec_flag = flags & __FMODE_EXEC;
-+      if (exec_flag && (au_br_mnt(br)->mnt_flags & MNT_NOEXEC))
++      err = au_br_test_oflag(flags, br);
++      h_file = ERR_PTR(err);
++      if (unlikely(err))
 +              goto out;
 +
 +      /* drop flags for writing */
@@ -11767,7 +12028,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      if (IS_ERR(h_file))
 +              goto out_br;
 +
-+      if (exec_flag) {
++      if (flags & __FMODE_EXEC) {
 +              err = deny_write_access(h_file);
 +              if (unlikely(err)) {
 +                      fput(h_file);
@@ -11798,7 +12059,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +              .pin    = &pin,
 +              .flags  = AuCpup_DTIME | AuCpup_HOPEN
 +      };
-+      struct inode *inode, *delegated;
++      struct inode *delegated;
 +      struct super_block *sb;
 +      struct au_sbinfo *sbinfo;
 +      struct au_fhsm *fhsm;
@@ -11808,8 +12069,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      struct au_hinode *hdir;
 +
 +      DiMustWriteLock(dentry);
-+      inode = dentry->d_inode;
-+      IiMustWriteLock(inode);
++      IiMustWriteLock(dentry->d_inode);
 +
 +      err = 0;
 +      if (IS_ROOT(dentry))
@@ -11831,7 +12091,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      cmoo = au_br_cmoo(br->br_perm);
 +      if (!cmoo)
 +              goto out;
-+      if (!S_ISREG(inode->i_mode))
++      if (!d_is_reg(dentry))
 +              cmoo &= AuBrAttr_COO_ALL;
 +      if (!cmoo)
 +              goto out;
@@ -11899,32 +12159,57 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      return err;
 +}
 +
-+int au_do_open(struct file *file, int (*open)(struct file *file, int flags),
-+             struct au_fidir *fidir)
++int au_do_open(struct file *file, struct au_do_open_args *args)
 +{
-+      int err;
++      int err, no_lock = args->no_lock;
 +      struct dentry *dentry;
 +      struct au_finfo *finfo;
 +
-+      err = au_finfo_init(file, fidir);
++      if (!no_lock)
++              err = au_finfo_init(file, args->fidir);
++      else {
++              lockdep_off();
++              err = au_finfo_init(file, args->fidir);
++              lockdep_on();
++      }
 +      if (unlikely(err))
 +              goto out;
 +
-+      dentry = file->f_dentry;
-+      di_write_lock_child(dentry);
-+      err = au_cmoo(dentry);
-+      di_downgrade_lock(dentry, AuLock_IR);
-+      if (!err)
-+              err = open(file, vfsub_file_flags(file));
-+      di_read_unlock(dentry, AuLock_IR);
++      dentry = file->f_path.dentry;
++      AuDebugOn(IS_ERR_OR_NULL(dentry));
++      if (!no_lock) {
++              di_write_lock_child(dentry);
++              err = au_cmoo(dentry);
++              di_downgrade_lock(dentry, AuLock_IR);
++              if (!err)
++                      err = args->open(file, vfsub_file_flags(file), NULL);
++              di_read_unlock(dentry, AuLock_IR);
++      } else {
++              err = au_cmoo(dentry);
++              if (!err)
++                      err = args->open(file, vfsub_file_flags(file),
++                                       args->h_file);
++              if (!err && au_fbstart(file) != au_dbstart(dentry))
++                      /*
++                       * cmoo happens after h_file was opened.
++                       * need to refresh file later.
++                       */
++                      atomic_dec(&au_fi(file)->fi_generation);
++      }
 +
 +      finfo = au_fi(file);
 +      if (!err) {
 +              finfo->fi_file = file;
 +              au_sphl_add(&finfo->fi_hlist,
-+                          &au_sbi(file->f_dentry->d_sb)->si_files);
++                          &au_sbi(file->f_path.dentry->d_sb)->si_files);
++      }
++      if (!no_lock)
++              fi_write_unlock(file);
++      else {
++              lockdep_off();
++              fi_write_unlock(file);
++              lockdep_on();
 +      }
-+      fi_write_unlock(file);
 +      if (unlikely(err)) {
 +              finfo->fi_hdir = NULL;
 +              au_finfo_fin(file);
@@ -11941,7 +12226,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      struct dentry *dentry;
 +      struct file *h_file, *h_file_tmp;
 +
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      bstart = au_dbstart(dentry);
 +      h_file_tmp = NULL;
 +      if (au_fbstart(file) == bstart) {
@@ -12001,7 +12286,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      struct dentry *h_dentry;
 +      struct au_hdentry *hdp;
 +
-+      dinfo = au_di(file->f_dentry);
++      dinfo = au_di(file->f_path.dentry);
 +      AuRwMustWriteLock(&dinfo->di_rwsem);
 +
 +      bstart = dinfo->di_bstart;
@@ -12023,7 +12308,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      struct inode *inode, *h_inode;
 +      struct dentry *h_dentry, *hi_wh;
 +      struct au_cp_generic cpg = {
-+              .dentry = file->f_dentry,
++              .dentry = file->f_path.dentry,
 +              .bdst   = bcpup,
 +              .bsrc   = -1,
 +              .len    = len,
@@ -12062,12 +12347,12 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +{
 +      int err;
 +      aufs_bindex_t dbstart;
-+      struct dentry *parent, *h_dentry;
++      struct dentry *parent;
 +      struct inode *inode;
 +      struct super_block *sb;
 +      struct file *h_file;
 +      struct au_cp_generic cpg = {
-+              .dentry = file->f_dentry,
++              .dentry = file->f_path.dentry,
 +              .bdst   = -1,
 +              .bsrc   = -1,
 +              .len    = len,
@@ -12105,13 +12390,9 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      if (unlikely(err))
 +              goto out_dgrade;
 +
-+      h_dentry = au_hf_top(file)->f_dentry;
 +      dbstart = au_dbstart(cpg.dentry);
-+      if (dbstart <= cpg.bdst) {
-+              h_dentry = au_h_dptr(cpg.dentry, cpg.bdst);
-+              AuDebugOn(!h_dentry);
++      if (dbstart <= cpg.bdst)
 +              cpg.bsrc = cpg.bdst;
-+      }
 +
 +      if (dbstart <= cpg.bdst         /* just reopen */
 +          || !d_unhashed(cpg.dentry)  /* copyup and reopen */
@@ -12188,7 +12469,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      struct inode *inode;
 +      struct super_block *sb;
 +      struct au_cp_generic cpg = {
-+              .dentry = file->f_dentry,
++              .dentry = file->f_path.dentry,
 +              .bdst   = -1,
 +              .bsrc   = -1,
 +              .len    = -1,
@@ -12259,7 +12540,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +
 +      FiMustWriteLock(file);
 +
-+      sb = file->f_dentry->d_sb;
++      sb = file->f_path.dentry->d_sb;
 +      finfo = au_fi(file);
 +      fidir = finfo->fi_hdir;
 +      AuDebugOn(!fidir);
@@ -12290,15 +12571,14 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      }
 +
 +      p = fidir->fd_hfile;
-+      if (!au_test_mmapped(file) && !d_unlinked(file->f_dentry)) {
++      if (!au_test_mmapped(file) && !d_unlinked(file->f_path.dentry)) {
 +              bend = au_sbend(sb);
 +              for (finfo->fi_btop = 0; finfo->fi_btop <= bend;
 +                   finfo->fi_btop++, p++)
 +                      if (p->hf_file) {
 +                              if (file_inode(p->hf_file))
 +                                      break;
-+                              else
-+                                      au_hfput(p, file);
++                              au_hfput(p, file);
 +                      }
 +      } else {
 +              bend = au_br_index(sb, brid);
@@ -12315,8 +12595,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;
-+                      else
-+                              au_hfput(p, file);
++                      au_hfput(p, file);
 +              }
 +      AuDebugOn(fidir->fd_bbot < finfo->fi_btop);
 +}
@@ -12332,7 +12611,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      struct au_finfo *finfo;
 +      struct au_hfile *hfile;
 +
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      finfo = au_fi(file);
 +      if (!finfo->fi_hdir) {
 +              hfile = &finfo->fi_htop;
@@ -12382,7 +12661,7 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +      struct inode *inode;
 +
 +      err = 0;
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      inode = dentry->d_inode;
 +      sigen = au_sigen(dentry->d_sb);
 +      fi_write_lock(file);
@@ -12435,14 +12714,6 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +                            struct iov_iter *iter, loff_t offset)
 +{ BUG(); return 0; }
 +
-+/*
-+ * it will never be called, but madvise and fadvise behaves differently
-+ * when get_xip_mem is defined
-+ */
-+static int aufs_get_xip_mem(struct address_space *mapping, pgoff_t pgoff,
-+                          int create, void **kmem, unsigned long *pfn)
-+{ BUG(); return 0; }
-+
 +/* they will never be called. */
 +#ifdef CONFIG_AUFS_DEBUG
 +static int aufs_write_begin(struct file *file, struct address_space *mapping,
@@ -12488,7 +12759,6 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +const struct address_space_operations aufs_aop = {
 +      .readpage               = aufs_readpage,
 +      .direct_IO              = aufs_direct_IO,
-+      .get_xip_mem            = aufs_get_xip_mem,
 +#ifdef CONFIG_AUFS_DEBUG
 +      .writepage              = aufs_writepage,
 +      /* no writepages, because of writepage */
@@ -12510,10 +12780,10 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
 +};
 diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 --- /usr/share/empty/fs/aufs/file.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/file.h       2014-08-14 10:15:45.121942630 +0200
-@@ -0,0 +1,289 @@
++++ linux/fs/aufs/file.h       2015-06-22 08:27:37.880835119 +0200
+@@ -0,0 +1,291 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -12587,8 +12857,14 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +unsigned int au_file_roflags(unsigned int flags);
 +struct file *au_h_open(struct dentry *dentry, aufs_bindex_t bindex, int flags,
 +                     struct file *file, int force_wr);
-+int au_do_open(struct file *file, int (*open)(struct file *file, int flags),
-+             struct au_fidir *fidir);
++struct au_do_open_args {
++      int             no_lock;
++      int             (*open)(struct file *file, int flags,
++                              struct file *h_file);
++      struct au_fidir *fidir;
++      struct file     *h_file;
++};
++int au_do_open(struct file *file, struct au_do_open_args *args);
 +int au_reopen_nondir(struct file *file);
 +struct au_pin;
 +int au_ready_to_write(struct file *file, loff_t len, struct au_pin *pin);
@@ -12609,21 +12885,17 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
 +void au_h_open_post(struct dentry *dentry, aufs_bindex_t bindex,
 +                  struct file *h_file);
 +#else
-+static inline
-+struct file *au_h_open_pre(struct dentry *dentry, aufs_bindex_t bindex,
-+                         int force_wr)
-+{
-+      return NULL;
-+}
-+
++AuStub(struct file *, au_h_open_pre, return NULL, struct dentry *dentry,
++       aufs_bindex_t bindex, int force_wr)
 +AuStubVoid(au_h_open_post, struct dentry *dentry, aufs_bindex_t bindex,
 +         struct file *h_file);
 +#endif
 +
 +/* f_op.c */
 +extern const struct file_operations aufs_file_fop;
-+int au_do_open_nondir(struct file *file, int flags);
++int au_do_open_nondir(struct file *file, int flags, struct file *h_file);
 +int aufs_release_nondir(struct inode *inode __maybe_unused, struct file *file);
++struct file *au_read_pre(struct file *file, int keep_fi);
 +
 +/* finfo.c */
 +void au_hfput(struct au_hfile *hf, struct file *file);
@@ -12803,10 +13075,10 @@ 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      2014-01-30 21:10:02.850815069 +0100
-@@ -0,0 +1,156 @@
++++ linux/fs/aufs/finfo.c      2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,157 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -12856,14 +13128,15 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +              au_hfput(hf, file);
 +      if (val) {
 +              FiMustWriteLock(file);
++              AuDebugOn(IS_ERR_OR_NULL(file->f_path.dentry));
 +              hf->hf_file = val;
-+              hf->hf_br = au_sbr(file->f_dentry->d_sb, bindex);
++              hf->hf_br = au_sbr(file->f_path.dentry->d_sb, bindex);
 +      }
 +}
 +
 +void au_update_figen(struct file *file)
 +{
-+      atomic_set(&au_fi(file)->fi_generation, au_digen(file->f_dentry));
++      atomic_set(&au_fi(file)->fi_generation, au_digen(file->f_path.dentry));
 +      /* smp_mb(); */ /* atomic_set */
 +}
 +
@@ -12914,7 +13187,7 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +{
 +      struct au_finfo *finfo;
 +
-+      au_nfiles_dec(file->f_dentry->d_sb);
++      au_nfiles_dec(file->f_path.dentry->d_sb);
 +
 +      finfo = au_fi(file);
 +      AuDebugOn(finfo->fi_hdir);
@@ -12938,7 +13211,7 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +      struct dentry *dentry;
 +
 +      err = -ENOMEM;
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      finfo = au_cache_alloc_finfo();
 +      if (unlikely(!finfo))
 +              goto out;
@@ -12963,10 +13236,10 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
 +}
 diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 --- /usr/share/empty/fs/aufs/f_op.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/f_op.c       2014-08-14 10:16:04.515942371 +0200
-@@ -0,0 +1,813 @@
++++ linux/fs/aufs/f_op.c       2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,748 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -12992,11 +13265,10 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +#include <linux/security.h>
 +#include "aufs.h"
 +
-+int au_do_open_nondir(struct file *file, int flags)
++int au_do_open_nondir(struct file *file, int flags, struct file *h_file)
 +{
 +      int err;
 +      aufs_bindex_t bindex;
-+      struct file *h_file;
 +      struct dentry *dentry;
 +      struct au_finfo *finfo;
 +      struct inode *h_inode;
@@ -13004,12 +13276,16 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +      FiMustWriteLock(file);
 +
 +      err = 0;
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
++      AuDebugOn(IS_ERR_OR_NULL(dentry));
 +      finfo = au_fi(file);
 +      memset(&finfo->fi_htop, 0, sizeof(finfo->fi_htop));
 +      atomic_set(&finfo->fi_mmapped, 0);
 +      bindex = au_dbstart(dentry);
-+      h_file = au_h_open(dentry, bindex, flags, file, /*force_wr*/0);
++      if (!h_file)
++              h_file = au_h_open(dentry, bindex, flags, file, /*force_wr*/0);
++      else
++              get_file(h_file);
 +      if (IS_ERR(h_file))
 +              err = PTR_ERR(h_file);
 +      else {
@@ -13035,13 +13311,16 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +{
 +      int err;
 +      struct super_block *sb;
++      struct au_do_open_args args = {
++              .open   = au_do_open_nondir
++      };
 +
 +      AuDbg("%pD, f_flags 0x%x, f_mode 0x%x\n",
 +            file, vfsub_file_flags(file), file->f_mode);
 +
-+      sb = file->f_dentry->d_sb;
++      sb = file->f_path.dentry->d_sb;
 +      si_read_lock(sb, AuLock_FLUSH);
-+      err = au_do_open(file, au_do_open_nondir, /*fidir*/NULL);
++      err = au_do_open(file, &args);
 +      si_read_unlock(sb);
 +      return err;
 +}
@@ -13052,7 +13331,8 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +      aufs_bindex_t bindex;
 +
 +      finfo = au_fi(file);
-+      au_sphl_del(&finfo->fi_hlist, &au_sbi(file->f_dentry->d_sb)->si_files);
++      au_sphl_del(&finfo->fi_hlist,
++                  &au_sbi(file->f_path.dentry->d_sb)->si_files);
 +      bindex = finfo->fi_btop;
 +      if (bindex >= 0)
 +              au_set_h_fptr(file, bindex, NULL);
@@ -13089,33 +13369,122 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 + * read functions after [fdi]_rwsem are released, but it should be harmless.
 + */
 +
-+static ssize_t aufs_read(struct file *file, char __user *buf, size_t count,
-+                       loff_t *ppos)
++/* Callers should call au_read_post() or fput() in the end */
++struct file *au_read_pre(struct file *file, int keep_fi)
 +{
-+      ssize_t err;
-+      struct dentry *dentry;
 +      struct file *h_file;
-+      struct super_block *sb;
++      int err;
 +
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
-+      si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLMW);
 +      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/0);
++      if (!err) {
++              di_read_unlock(file->f_path.dentry, AuLock_IR);
++              h_file = au_hf_top(file);
++              get_file(h_file);
++              if (!keep_fi)
++                      fi_read_unlock(file);
++      } else
++              h_file = ERR_PTR(err);
++
++      return h_file;
++}
++
++static void au_read_post(struct inode *inode, struct file *h_file)
++{
++      /* update without lock, I don't think it a problem */
++      fsstack_copy_attr_atime(inode, file_inode(h_file));
++      fput(h_file);
++}
++
++struct au_write_pre {
++      blkcnt_t blks;
++      aufs_bindex_t bstart;
++};
++
++/*
++ * return with iinfo is write-locked
++ * callers should call au_write_post() or iinfo_write_unlock() + fput() in the
++ * end
++ */
++static struct file *au_write_pre(struct file *file, int do_ready,
++                               struct au_write_pre *wpre)
++{
++      struct file *h_file;
++      struct dentry *dentry;
++      int err;
++      struct au_pin pin;
++
++      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
++      h_file = ERR_PTR(err);
 +      if (unlikely(err))
 +              goto out;
 +
++      dentry = file->f_path.dentry;
++      if (do_ready) {
++              err = au_ready_to_write(file, -1, &pin);
++              if (unlikely(err)) {
++                      h_file = ERR_PTR(err);
++                      di_write_unlock(dentry);
++                      goto out_fi;
++              }
++      }
++
++      di_downgrade_lock(dentry, /*flags*/0);
++      if (wpre)
++              wpre->bstart = au_fbstart(file);
 +      h_file = au_hf_top(file);
 +      get_file(h_file);
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_read_unlock(file);
++      if (wpre)
++              wpre->blks = file_inode(h_file)->i_blocks;
++      if (do_ready)
++              au_unpin(&pin);
++      di_read_unlock(dentry, /*flags*/0);
++
++out_fi:
++      fi_write_unlock(file);
++out:
++      return h_file;
++}
++
++static void au_write_post(struct inode *inode, struct file *h_file,
++                        struct au_write_pre *wpre, ssize_t written)
++{
++      struct inode *h_inode;
++
++      au_cpup_attr_timesizes(inode);
++      AuDebugOn(au_ibstart(inode) != wpre->bstart);
++      h_inode = file_inode(h_file);
++      inode->i_mode = h_inode->i_mode;
++      ii_write_unlock(inode);
++      fput(h_file);
++
++      /* AuDbg("blks %llu, %llu\n", (u64)blks, (u64)h_inode->i_blocks); */
++      if (written > 0)
++              au_fhsm_wrote(inode->i_sb, wpre->bstart,
++                            /*force*/h_inode->i_blocks > wpre->blks);
++}
++
++static ssize_t aufs_read(struct file *file, char __user *buf, size_t count,
++                       loff_t *ppos)
++{
++      ssize_t err;
++      struct inode *inode;
++      struct file *h_file;
++      struct super_block *sb;
++
++      inode = file_inode(file);
++      sb = inode->i_sb;
++      si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLMW);
++
++      h_file = au_read_pre(file, /*keep_fi*/0);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
++              goto out;
 +
 +      /* filedata may be obsoleted by concurrent copyup, but no problem */
 +      err = vfsub_read_u(h_file, buf, count, ppos);
 +      /* todo: necessary? */
 +      /* file->f_ra = h_file->f_ra; */
-+      /* update without lock, I don't think it a problem */
-+      fsstack_copy_attr_atime(dentry->d_inode, file_inode(h_file));
-+      fput(h_file);
++      au_read_post(inode, h_file);
 +
 +out:
 +      si_read_unlock(sb);
@@ -13148,53 +13517,24 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +                        size_t count, loff_t *ppos)
 +{
 +      ssize_t err;
-+      blkcnt_t blks;
-+      aufs_bindex_t bstart;
-+      struct au_pin pin;
-+      struct dentry *dentry;
-+      struct inode *inode, *h_inode;
-+      struct super_block *sb;
++      struct au_write_pre wpre;
++      struct inode *inode;
 +      struct file *h_file;
 +      char __user *buf = (char __user *)ubuf;
 +
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
-+      inode = dentry->d_inode;
++      inode = file_inode(file);
 +      au_mtx_and_read_lock(inode);
 +
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
-+      if (unlikely(err))
-+              goto out;
-+
-+      err = au_ready_to_write(file, -1, &pin);
-+      di_downgrade_lock(dentry, AuLock_IR);
-+      if (unlikely(err)) {
-+              di_read_unlock(dentry, AuLock_IR);
-+              fi_write_unlock(file);
++      h_file = au_write_pre(file, /*do_ready*/1, &wpre);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
 +              goto out;
-+      }
-+
-+      bstart = au_fbstart(file);
-+      h_file = au_hf_top(file);
-+      get_file(h_file);
-+      h_inode = h_file->f_dentry->d_inode;
-+      blks = h_inode->i_blocks;
-+      au_unpin(&pin);
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_write_unlock(file);
 +
 +      err = vfsub_write_u(h_file, buf, count, ppos);
-+      ii_write_lock_child(inode);
-+      au_cpup_attr_timesizes(inode);
-+      inode->i_mode = file_inode(h_file)->i_mode;
-+      AuDbg("blks %llu, %llu\n", (u64)blks, (u64)h_inode->i_blocks);
-+      if (err > 0)
-+              au_fhsm_wrote(sb, bstart, /*force*/h_inode->i_blocks > blks);
-+      ii_write_unlock(inode);
-+      fput(h_file);
++      au_write_post(inode, h_file, &wpre, err);
 +
 +out:
-+      si_read_unlock(sb);
++      si_read_unlock(inode->i_sb);
 +      mutex_unlock(&inode->i_mutex);
 +      return err;
 +}
@@ -13246,28 +13586,23 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +{
 +      ssize_t err;
 +      struct file *file, *h_file;
-+      struct dentry *dentry;
++      struct inode *inode;
 +      struct super_block *sb;
 +
 +      file = kio->ki_filp;
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
++      inode = file_inode(file);
++      sb = inode->i_sb;
 +      si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLMW);
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/0);
-+      if (unlikely(err))
-+              goto out;
 +
-+      h_file = au_hf_top(file);
-+      get_file(h_file);
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_read_unlock(file);
++      h_file = au_read_pre(file, /*keep_fi*/0);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
++              goto out;
 +
 +      err = au_do_iter(h_file, MAY_READ, kio, iov_iter);
 +      /* todo: necessary? */
 +      /* file->f_ra = h_file->f_ra; */
-+      /* update without lock, I don't think it a problem */
-+      fsstack_copy_attr_atime(dentry->d_inode, file_inode(h_file));
-+      fput(h_file);
++      au_read_post(inode, h_file);
 +
 +out:
 +      si_read_unlock(sb);
@@ -13277,53 +13612,24 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +static ssize_t aufs_write_iter(struct kiocb *kio, struct iov_iter *iov_iter)
 +{
 +      ssize_t err;
-+      blkcnt_t blks;
-+      aufs_bindex_t bstart;
-+      struct au_pin pin;
-+      struct dentry *dentry;
-+      struct inode *inode, *h_inode;
++      struct au_write_pre wpre;
++      struct inode *inode;
 +      struct file *file, *h_file;
-+      struct super_block *sb;
 +
 +      file = kio->ki_filp;
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
-+      inode = dentry->d_inode;
++      inode = file_inode(file);
 +      au_mtx_and_read_lock(inode);
 +
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
-+      if (unlikely(err))
-+              goto out;
-+
-+      err = au_ready_to_write(file, -1, &pin);
-+      di_downgrade_lock(dentry, AuLock_IR);
-+      if (unlikely(err)) {
-+              di_read_unlock(dentry, AuLock_IR);
-+              fi_write_unlock(file);
++      h_file = au_write_pre(file, /*do_ready*/1, &wpre);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
 +              goto out;
-+      }
-+
-+      bstart = au_fbstart(file);
-+      h_file = au_hf_top(file);
-+      get_file(h_file);
-+      h_inode = h_file->f_dentry->d_inode;
-+      blks = h_inode->i_blocks;
-+      au_unpin(&pin);
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_write_unlock(file);
 +
 +      err = au_do_iter(h_file, MAY_WRITE, kio, iov_iter);
-+      ii_write_lock_child(inode);
-+      au_cpup_attr_timesizes(inode);
-+      inode->i_mode = file_inode(h_file)->i_mode;
-+      AuDbg("blks %llu, %llu\n", (u64)blks, (u64)h_inode->i_blocks);
-+      if (err > 0)
-+              au_fhsm_wrote(sb, bstart, /*force*/h_inode->i_blocks > blks);
-+      ii_write_unlock(inode);
-+      fput(h_file);
++      au_write_post(inode, h_file, &wpre, err);
 +
 +out:
-+      si_read_unlock(sb);
++      si_read_unlock(inode->i_sb);
 +      mutex_unlock(&inode->i_mutex);
 +      return err;
 +}
@@ -13334,35 +13640,31 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +{
 +      ssize_t err;
 +      struct file *h_file;
-+      struct dentry *dentry;
++      struct inode *inode;
 +      struct super_block *sb;
 +
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
++      inode = file_inode(file);
++      sb = inode->i_sb;
 +      si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLMW);
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/0);
-+      if (unlikely(err))
++
++      h_file = au_read_pre(file, /*keep_fi*/1);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
 +              goto out;
 +
-+      err = -EINVAL;
-+      h_file = au_hf_top(file);
-+      get_file(h_file);
 +      if (au_test_loopback_kthread()) {
-+              au_warn_loopback(h_file->f_dentry->d_sb);
++              au_warn_loopback(h_file->f_path.dentry->d_sb);
 +              if (file->f_mapping != h_file->f_mapping) {
 +                      file->f_mapping = h_file->f_mapping;
 +                      smp_mb(); /* unnecessary? */
 +              }
 +      }
-+      di_read_unlock(dentry, AuLock_IR);
 +      fi_read_unlock(file);
 +
 +      err = vfsub_splice_to(h_file, ppos, pipe, len, flags);
 +      /* todo: necessasry? */
 +      /* file->f_ra = h_file->f_ra; */
-+      /* update without lock, I don't think it a problem */
-+      fsstack_copy_attr_atime(dentry->d_inode, file_inode(h_file));
-+      fput(h_file);
++      au_read_post(inode, h_file);
 +
 +out:
 +      si_read_unlock(sb);
@@ -13374,52 +13676,23 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +                size_t len, unsigned int flags)
 +{
 +      ssize_t err;
-+      blkcnt_t blks;
-+      aufs_bindex_t bstart;
-+      struct au_pin pin;
-+      struct dentry *dentry;
-+      struct inode *inode, *h_inode;
-+      struct super_block *sb;
++      struct au_write_pre wpre;
++      struct inode *inode;
 +      struct file *h_file;
 +
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
-+      inode = dentry->d_inode;
++      inode = file_inode(file);
 +      au_mtx_and_read_lock(inode);
 +
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
-+      if (unlikely(err))
-+              goto out;
-+
-+      err = au_ready_to_write(file, -1, &pin);
-+      di_downgrade_lock(dentry, AuLock_IR);
-+      if (unlikely(err)) {
-+              di_read_unlock(dentry, AuLock_IR);
-+              fi_write_unlock(file);
++      h_file = au_write_pre(file, /*do_ready*/1, &wpre);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
 +              goto out;
-+      }
-+
-+      bstart = au_fbstart(file);
-+      h_file = au_hf_top(file);
-+      get_file(h_file);
-+      h_inode = h_file->f_dentry->d_inode;
-+      blks = h_inode->i_blocks;
-+      au_unpin(&pin);
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_write_unlock(file);
 +
 +      err = vfsub_splice_from(pipe, h_file, ppos, len, flags);
-+      ii_write_lock_child(inode);
-+      au_cpup_attr_timesizes(inode);
-+      inode->i_mode = file_inode(h_file)->i_mode;
-+      AuDbg("blks %llu, %llu\n", (u64)blks, (u64)h_inode->i_blocks);
-+      if (err > 0)
-+              au_fhsm_wrote(sb, bstart, /*force*/h_inode->i_blocks > blks);
-+      ii_write_unlock(inode);
-+      fput(h_file);
++      au_write_post(inode, h_file, &wpre, err);
 +
 +out:
-+      si_read_unlock(sb);
++      si_read_unlock(inode->i_sb);
 +      mutex_unlock(&inode->i_mutex);
 +      return err;
 +}
@@ -13428,46 +13701,25 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +                         loff_t len)
 +{
 +      long err;
-+      struct au_pin pin;
-+      struct dentry *dentry;
-+      struct super_block *sb;
++      struct au_write_pre wpre;
 +      struct inode *inode;
 +      struct file *h_file;
 +
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
-+      inode = dentry->d_inode;
++      inode = file_inode(file);
 +      au_mtx_and_read_lock(inode);
 +
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
-+      if (unlikely(err))
-+              goto out;
-+
-+      err = au_ready_to_write(file, -1, &pin);
-+      di_downgrade_lock(dentry, AuLock_IR);
-+      if (unlikely(err)) {
-+              di_read_unlock(dentry, AuLock_IR);
-+              fi_write_unlock(file);
++      h_file = au_write_pre(file, /*do_ready*/1, &wpre);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
 +              goto out;
-+      }
-+
-+      h_file = au_hf_top(file);
-+      get_file(h_file);
-+      au_unpin(&pin);
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_write_unlock(file);
 +
 +      lockdep_off();
-+      err = do_fallocate(h_file, mode, offset, len);
++      err = vfs_fallocate(h_file, mode, offset, len);
 +      lockdep_on();
-+      ii_write_lock_child(inode);
-+      au_cpup_attr_timesizes(inode);
-+      inode->i_mode = file_inode(h_file)->i_mode;
-+      ii_write_unlock(inode);
-+      fput(h_file);
++      au_write_post(inode, h_file, &wpre, /*written*/1);
 +
 +out:
-+      si_read_unlock(sb);
++      si_read_unlock(inode->i_sb);
 +      mutex_unlock(&inode->i_mutex);
 +      return err;
 +}
@@ -13532,44 +13784,27 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +static int aufs_mmap(struct file *file, struct vm_area_struct *vma)
 +{
 +      int err;
-+      aufs_bindex_t bstart;
 +      const unsigned char wlock
 +              = (file->f_mode & FMODE_WRITE) && (vma->vm_flags & VM_SHARED);
-+      struct dentry *dentry;
 +      struct super_block *sb;
 +      struct file *h_file;
-+      struct au_branch *br;
-+      struct au_pin pin;
++      struct inode *inode;
 +
 +      AuDbgVmRegion(file, vma);
 +
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
++      inode = file_inode(file);
++      sb = inode->i_sb;
 +      lockdep_off();
 +      si_read_lock(sb, AuLock_NOPLMW);
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
-+      if (unlikely(err))
-+              goto out;
 +
-+      if (wlock) {
-+              err = au_ready_to_write(file, -1, &pin);
-+              di_write_unlock(dentry);
-+              if (unlikely(err)) {
-+                      fi_write_unlock(file);
-+                      goto out;
-+              }
-+              au_unpin(&pin);
-+      } else
-+              di_write_unlock(dentry);
-+
-+      bstart = au_fbstart(file);
-+      br = au_sbr(sb, bstart);
-+      h_file = au_hf_top(file);
-+      get_file(h_file);
-+      au_set_mmapped(file);
-+      fi_write_unlock(file);
++      h_file = au_write_pre(file, wlock, /*wpre*/NULL);
 +      lockdep_on();
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
++              goto out;
 +
++      err = 0;
++      au_set_mmapped(file);
 +      au_vm_file_reset(vma, h_file);
 +      /*
 +       * we cannot call security_mmap_file() here since it may acquire
@@ -13580,21 +13815,21 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +       */
 +      if (!err)
 +              err = h_file->f_op->mmap(h_file, vma);
-+      if (unlikely(err))
-+              goto out_reset;
-+
-+      au_vm_prfile_set(vma, file);
-+      /* update without lock, I don't think it a problem */
-+      fsstack_copy_attr_atime(file_inode(file), file_inode(h_file));
-+      goto out_fput; /* success */
-+
-+out_reset:
++      if (!err) {
++              au_vm_prfile_set(vma, file);
++              fsstack_copy_attr_atime(inode, file_inode(h_file));
++              goto out_fput; /* success */
++      }
 +      au_unset_mmapped(file);
 +      au_vm_file_reset(vma, file);
++
 +out_fput:
-+      fput(h_file);
 +      lockdep_off();
++      ii_write_unlock(inode);
++      lockdep_on();
++      fput(h_file);
 +out:
++      lockdep_off();
 +      si_read_unlock(sb);
 +      lockdep_on();
 +      AuTraceErr(err);
@@ -13607,45 +13842,29 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +                           int datasync)
 +{
 +      int err;
-+      struct au_pin pin;
-+      struct dentry *dentry;
++      struct au_write_pre wpre;
 +      struct inode *inode;
 +      struct file *h_file;
-+      struct super_block *sb;
-+
-+      dentry = file->f_dentry;
-+      inode = dentry->d_inode;
-+      sb = dentry->d_sb;
-+      mutex_lock(&inode->i_mutex);
-+      err = si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLM);
-+      if (unlikely(err))
-+              goto out;
 +
 +      err = 0; /* -EBADF; */ /* posix? */
 +      if (unlikely(!(file->f_mode & FMODE_WRITE)))
-+              goto out_si;
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
-+      if (unlikely(err))
-+              goto out_si;
++              goto out;
 +
-+      err = au_ready_to_write(file, -1, &pin);
-+      di_downgrade_lock(dentry, AuLock_IR);
-+      if (unlikely(err))
++      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;
-+      au_unpin(&pin);
 +
-+      err = -EINVAL;
-+      h_file = au_hf_top(file);
 +      err = vfsub_fsync(h_file, &h_file->f_path, datasync);
-+      au_cpup_attr_timesizes(inode);
++      au_write_post(inode, h_file, &wpre, /*written*/0);
 +
 +out_unlock:
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_write_unlock(file);
-+out_si:
-+      si_read_unlock(sb);
-+out:
++      si_read_unlock(inode->i_sb);
 +      mutex_unlock(&inode->i_mutex);
++out:
 +      return err;
 +}
 +
@@ -13654,28 +13873,22 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +static int aufs_aio_fsync_nondir(struct kiocb *kio, int datasync)
 +{
 +      int err;
-+      struct au_pin pin;
-+      struct dentry *dentry;
++      struct au_write_pre wpre;
 +      struct inode *inode;
 +      struct file *file, *h_file;
 +
-+      file = kio->ki_filp;
-+      dentry = file->f_dentry;
-+      inode = dentry->d_inode;
-+      au_mtx_and_read_lock(inode);
-+
 +      err = 0; /* -EBADF; */ /* posix? */
 +      if (unlikely(!(file->f_mode & FMODE_WRITE)))
 +              goto out;
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
-+      if (unlikely(err))
-+              goto out;
 +
-+      err = au_ready_to_write(file, -1, &pin);
-+      di_downgrade_lock(dentry, AuLock_IR);
-+      if (unlikely(err))
++      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;
-+      au_unpin(&pin);
 +
 +      err = -ENOSYS;
 +      h_file = au_hf_top(file);
@@ -13693,16 +13906,14 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +              if (!err)
 +                      vfsub_update_h_iattr(&h_file->f_path, /*did*/NULL);
 +              /*ignore*/
-+              au_cpup_attr_timesizes(inode);
 +              mutex_unlock(h_mtx);
 +      }
++      au_write_post(inode, h_file, &wpre, /*written*/0);
 +
 +out_unlock:
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_write_unlock(file);
-+out:
 +      si_read_unlock(inode->sb);
 +      mutex_unlock(&inode->i_mutex);
++out:
 +      return err;
 +}
 +#endif
@@ -13711,22 +13922,19 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +{
 +      int err;
 +      struct file *h_file;
-+      struct dentry *dentry;
 +      struct super_block *sb;
 +
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
++      sb = file->f_path.dentry->d_sb;
 +      si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLMW);
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/0);
-+      if (unlikely(err))
++
++      h_file = au_read_pre(file, /*keep_fi*/0);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
 +              goto out;
 +
-+      h_file = au_hf_top(file);
 +      if (h_file->f_op->fasync)
 +              err = h_file->f_op->fasync(fd, h_file, flag);
-+
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_read_unlock(file);
++      fput(h_file); /* instead of au_read_post() */
 +
 +out:
 +      si_read_unlock(sb);
@@ -13738,7 +13946,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
 +/* no one supports this operation, currently */
 +#if 0
 +static ssize_t aufs_sendpage(struct file *file, struct page *page, int offset,
-+                           size_t len, loff_t *pos , int more)
++                           size_t len, loff_t *pos, int more)
 +{
 +}
 +#endif
@@ -13780,10 +13988,10 @@ 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     2014-01-30 21:10:02.850815069 +0100
-@@ -0,0 +1,469 @@
++++ linux/fs/aufs/fstype.h     2015-06-22 08:27:37.880835119 +0200
+@@ -0,0 +1,400 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -13811,6 +14019,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +#include <linux/fs.h>
 +#include <linux/magic.h>
 +#include <linux/romfs_fs.h>
++#include <linux/nfs_fs.h>
 +
 +static inline int au_test_aufs(struct super_block *sb)
 +{
@@ -13824,8 +14033,8 @@ 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_ROMFS_FS) || defined(CONFIG_ROMFS_FS_MODULE)
-+      return sb->s_magic == ROMFS_MAGIC;
++#if defined(CONFIG_ISO9660_FS) || defined(CONFIG_ISO9660_FS_MODULE)
++      return sb->s_magic == ISOFS_SUPER_MAGIC;
 +#else
 +      return 0;
 +#endif
@@ -13833,8 +14042,8 @@ 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_ISO9660_FS) || defined(CONFIG_ISO9660_FS_MODULE)
-+      return sb->s_magic == ISOFS_SUPER_MAGIC;
++#if defined(CONFIG_ROMFS_FS) || defined(CONFIG_ROMFS_FS_MODULE)
++      return sb->s_magic == ROMFS_MAGIC;
 +#else
 +      return 0;
 +#endif
@@ -13893,60 +14102,6 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +#endif
 +}
 +
-+static inline int au_test_ocfs2(struct super_block *sb __maybe_unused)
-+{
-+#if defined(CONFIG_OCFS2_FS) || defined(CONFIG_OCFS2_FS_MODULE)
-+      return sb->s_magic == OCFS2_SUPER_MAGIC;
-+#else
-+      return 0;
-+#endif
-+}
-+
-+static inline int au_test_ocfs2_dlmfs(struct super_block *sb __maybe_unused)
-+{
-+#if defined(CONFIG_OCFS2_FS_O2CB) || defined(CONFIG_OCFS2_FS_O2CB_MODULE)
-+      return sb->s_magic == DLMFS_MAGIC;
-+#else
-+      return 0;
-+#endif
-+}
-+
-+static inline int au_test_coda(struct super_block *sb __maybe_unused)
-+{
-+#if defined(CONFIG_CODA_FS) || defined(CONFIG_CODA_FS_MODULE)
-+      return sb->s_magic == CODA_SUPER_MAGIC;
-+#else
-+      return 0;
-+#endif
-+}
-+
-+static inline int au_test_v9fs(struct super_block *sb __maybe_unused)
-+{
-+#if defined(CONFIG_9P_FS) || defined(CONFIG_9P_FS_MODULE)
-+      return sb->s_magic == V9FS_MAGIC;
-+#else
-+      return 0;
-+#endif
-+}
-+
-+static inline int au_test_ext4(struct super_block *sb __maybe_unused)
-+{
-+#if defined(CONFIG_EXT4_FS) || defined(CONFIG_EXT4_FS_MODULE)
-+      return sb->s_magic == EXT4_SUPER_MAGIC;
-+#else
-+      return 0;
-+#endif
-+}
-+
-+static inline int au_test_sysv(struct super_block *sb __maybe_unused)
-+{
-+#if defined(CONFIG_SYSV_FS) || defined(CONFIG_SYSV_FS_MODULE)
-+      return !strcmp(au_sbtype(sb), "sysv");
-+#else
-+      return 0;
-+#endif
-+}
-+
 +static inline int au_test_ramfs(struct super_block *sb)
 +{
 +      return sb->s_magic == RAMFS_MAGIC;
@@ -14001,15 +14156,6 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +#endif
 +}
 +
-+static inline int au_test_cifs(struct super_block *sb __maybe_unused)
-+{
-+#if defined(CONFIG_CIFS_FS) || defined(CONFIGCIFS_FS_MODULE)
-+      return sb->s_magic == CIFS_MAGIC_NUMBER;
-+#else
-+      return 0;
-+#endif
-+}
-+
 +static inline int au_test_fat(struct super_block *sb __maybe_unused)
 +{
 +#if defined(CONFIG_FAT_FS) || defined(CONFIG_FAT_FS_MODULE)
@@ -14139,10 +14285,7 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +{
 +      return au_test_nfs(sb)
 +              || au_test_fuse(sb)
-+              /* || au_test_ocfs2(sb) */      /* untested */
 +              /* || au_test_btrfs(sb) */      /* untested */
-+              /* || au_test_coda(sb) */       /* untested */
-+              /* || au_test_v9fs(sb) */       /* untested */
 +              ;
 +}
 +
@@ -14155,10 +14298,6 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +              || au_test_btrfs(sb)
 +              || au_test_ubifs(sb)
 +              || au_test_hfsplus(sb)  /* maintained, but incorrect */
-+              /* || au_test_ext4(sb) */       /* untested */
-+              /* || au_test_ocfs2(sb) */      /* untested */
-+              /* || au_test_ocfs2_dlmfs(sb) */ /* untested */
-+              /* || au_test_sysv(sb) */       /* untested */
 +              /* || au_test_minix(sb) */      /* untested */
 +              ;
 +}
@@ -14170,7 +14309,6 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +static inline int au_test_fs_bad_iattr(struct super_block *sb)
 +{
 +      return au_test_fs_bad_iattr_size(sb)
-+              /* || au_test_cifs(sb) */       /* untested */
 +              || au_test_fat(sb)
 +              || au_test_msdos(sb)
 +              || au_test_vfat(sb);
@@ -14195,19 +14333,9 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +      return au_test_nfs(sb)
 +              || au_test_fuse(sb)
 +              || au_test_ubifs(sb)
-+              /* || au_test_cifs(sb) */       /* untested */
 +              ;
 +}
 +
-+/*
-+ * filesystems which requires replacing i_mapping.
-+ */
-+static inline int au_test_fs_bad_mapping(struct super_block *sb)
-+{
-+      return au_test_fuse(sb)
-+              || au_test_ubifs(sb);
-+}
-+
 +/* temporary support for i#1 in cramfs */
 +static inline int au_test_fs_unique_ino(struct inode *inode)
 +{
@@ -14249,14 +14377,25 @@ diff -urN /usr/share/empty/fs/aufs/fstype.h linux/fs/aufs/fstype.h
 +              || au_test_romfs(sb);
 +}
 +
++/*
++ * test if the @inode is nfs with 'noacl' option
++ * NFS always sets MS_POSIXACL regardless its mount option 'noacl.'
++ */
++static inline int au_test_nfs_noacl(struct inode *inode)
++{
++      return au_test_nfs(inode->i_sb)
++              /* && IS_POSIXACL(inode) */
++              && !nfs_server_capable(inode, NFS_CAP_ACLS);
++}
++
 +#endif /* __KERNEL__ */
 +#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  2014-08-14 10:16:04.515942371 +0200
-@@ -0,0 +1,281 @@
++++ linux/fs/aufs/hfsnotify.c  2015-06-22 08:27:37.880835119 +0200
+@@ -0,0 +1,288 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -14317,10 +14456,12 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +       * by udba rename or rmdir, aufs assign a new inode to the known
 +       * h_inode, so specify 1 to allow dups.
 +       */
++      lockdep_off();
 +      err = fsnotify_add_mark(mark, br->br_hfsn->hfsn_group, hinode->hi_inode,
 +                               /*mnt*/NULL, /*allow_dups*/1);
 +      /* even if err */
 +      fsnotify_put_mark(mark);
++      lockdep_on();
 +
 +      return err;
 +}
@@ -14339,8 +14480,10 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +      group = mark->group;
 +      fsnotify_get_group(group);
 +      spin_unlock(&mark->lock);
++      lockdep_off();
 +      fsnotify_destroy_mark(mark, group);
 +      fsnotify_put_group(group);
++      lockdep_on();
 +
 +      /* free hn by myself */
 +      return 0;
@@ -14392,7 +14535,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +      test_ret(FS_UNMOUNT);
 +      test_ret(FS_Q_OVERFLOW);
 +      test_ret(FS_IN_IGNORED);
-+      test_ret(FS_IN_ISDIR);
++      test_ret(FS_ISDIR);
 +      test_ret(FS_IN_ONESHOT);
 +      test_ret(FS_EVENT_ON_CHILD);
 +      return "";
@@ -14467,8 +14610,11 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +      struct au_br_hfsnotify *hfsn;
 +
 +      hfsn = br->br_hfsn;
-+      if (hfsn)
++      if (hfsn) {
++              lockdep_off();
 +              fsnotify_put_group(hfsn->hfsn_group);
++              lockdep_on();
++      }
 +}
 +
 +static int au_hfsn_init_br(struct au_branch *br, int perm)
@@ -14538,10 +14684,10 @@ diff -urN /usr/share/empty/fs/aufs/hfsnotify.c linux/fs/aufs/hfsnotify.c
 +};
 diff -urN /usr/share/empty/fs/aufs/hfsplus.c linux/fs/aufs/hfsplus.c
 --- /usr/share/empty/fs/aufs/hfsplus.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/hfsplus.c    2014-01-30 21:10:02.850815069 +0100
++++ linux/fs/aufs/hfsplus.c    2015-06-22 08:29:23.706757681 +0200
 @@ -0,0 +1,56 @@
 +/*
-+ * Copyright (C) 2010-2014 Junjiro R. Okajima
++ * Copyright (C) 2010-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -14581,7 +14727,7 @@ diff -urN /usr/share/empty/fs/aufs/hfsplus.c linux/fs/aufs/hfsplus.c
 +
 +      h_file = NULL;
 +      if (au_test_hfsplus(h_dentry->d_sb)
-+          && S_ISREG(h_dentry->d_inode->i_mode))
++          && d_is_reg(h_dentry))
 +              h_file = au_h_open(dentry, bindex,
 +                                 O_RDONLY | O_NOATIME | O_LARGEFILE,
 +                                 /*file*/NULL, force_wr);
@@ -14598,10 +14744,10 @@ diff -urN /usr/share/empty/fs/aufs/hfsplus.c linux/fs/aufs/hfsplus.c
 +}
 diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 --- /usr/share/empty/fs/aufs/hnotify.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/hnotify.c    2014-08-14 10:16:04.515942371 +0200
++++ linux/fs/aufs/hnotify.c    2015-06-22 08:29:23.706757681 +0200
 @@ -0,0 +1,714 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -14813,7 +14959,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +              AuDebugOn(!name);
 +              au_iigen_dec(inode);
 +              spin_lock(&inode->i_lock);
-+              hlist_for_each_entry(d, &inode->i_dentry, d_alias) {
++              hlist_for_each_entry(d, &inode->i_dentry, d_u.d_alias) {
 +                      spin_lock(&d->d_lock);
 +                      dname = &d->d_name;
 +                      if (dname->len != nlen
@@ -14829,7 +14975,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +              spin_unlock(&inode->i_lock);
 +      } else {
 +              au_fset_si(au_sbi(inode->i_sb), FAILED_REFRESH_DIR);
-+              d = d_find_alias(inode);
++              d = d_find_any_alias(inode);
 +              if (!d) {
 +                      au_iigen_dec(inode);
 +                      goto out;
@@ -14974,13 +15120,13 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +      struct dentry *dentry, *d, *parent;
 +      struct qstr *dname;
 +
-+      parent = d_find_alias(dir);
++      parent = d_find_any_alias(dir);
 +      if (!parent)
 +              return NULL;
 +
 +      dentry = NULL;
 +      spin_lock(&parent->d_lock);
-+      list_for_each_entry(d, &parent->d_subdirs, d_u.d_child) {
++      list_for_each_entry(d, &parent->d_subdirs, d_child) {
 +              /* AuDbg("%pd\n", d); */
 +              spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED);
 +              dname = &d->d_name;
@@ -14990,7 +15136,7 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +                      au_digen_dec(d);
 +              else
 +                      goto cont_unlock;
-+              if (d_count(d)) {
++              if (au_dcount(d) > 0) {
 +                      dentry = dget_dlock(d);
 +                      spin_unlock(&d->d_lock);
 +                      break;
@@ -15316,10 +15462,10 @@ diff -urN /usr/share/empty/fs/aufs/hnotify.c linux/fs/aufs/hnotify.c
 +}
 diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 --- /usr/share/empty/fs/aufs/iinfo.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/iinfo.c      2014-08-14 10:15:45.128609525 +0200
++++ linux/fs/aufs/iinfo.c      2015-06-22 08:27:37.884168534 +0200
 @@ -0,0 +1,277 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -15597,10 +15743,10 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
 +}
 diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 --- /usr/share/empty/fs/aufs/inode.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/inode.c      2014-08-14 10:15:45.128609525 +0200
-@@ -0,0 +1,492 @@
++++ linux/fs/aufs/inode.c      2015-06-22 08:27:37.884168534 +0200
+@@ -0,0 +1,495 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -15839,6 +15985,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +                                    au_igrab(h_dentry->d_inode), flags);
 +      }
 +      au_cpup_attr_all(inode, /*force*/1);
++      /*
++       * to force calling aufs_get_acl() every time,
++       * do not call cache_no_acl() for aufs inode.
++       */
 +
 +out:
 +      return err;
@@ -15931,7 +16081,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +/* todo: return with unlocked? */
 +struct inode *au_new_inode(struct dentry *dentry, int must_new)
 +{
-+      struct inode *inode, *h_inode;
++      struct inode *inode;
 +      struct dentry *h_dentry;
 +      struct super_block *sb;
 +      struct mutex *mtx;
@@ -15942,15 +16092,14 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +      sb = dentry->d_sb;
 +      bstart = au_dbstart(dentry);
 +      h_dentry = au_h_dptr(dentry, bstart);
-+      h_inode = h_dentry->d_inode;
-+      h_ino = h_inode->i_ino;
++      h_ino = h_dentry->d_inode->i_ino;
 +
 +      /*
 +       * stop 'race'-ing between hardlinks under different
 +       * parents.
 +       */
 +      mtx = NULL;
-+      if (!S_ISDIR(h_inode->i_mode))
++      if (!d_is_dir(h_dentry))
 +              mtx = &au_sbr(sb, bstart)->br_xino.xi_nondir_mtx;
 +
 +new_ino:
@@ -15978,10 +16127,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +      AuDbg("%lx, new %d\n", inode->i_state, !!(inode->i_state & I_NEW));
 +      if (inode->i_state & I_NEW) {
 +              /* verbose coding for lock class name */
-+              if (unlikely(S_ISLNK(h_inode->i_mode)))
++              if (unlikely(d_is_symlink(h_dentry)))
 +                      au_rw_class(&au_ii(inode)->ii_rwsem,
 +                                  au_lc_key + AuLcSymlink_IIINFO);
-+              else if (unlikely(S_ISDIR(h_inode->i_mode)))
++              else if (unlikely(d_is_dir(h_dentry)))
 +                      au_rw_class(&au_ii(inode)->ii_rwsem,
 +                                  au_lc_key + AuLcDir_IIINFO);
 +              else /* likely */
@@ -16093,10 +16242,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
 +}
 diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 --- /usr/share/empty/fs/aufs/inode.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/inode.h      2014-08-14 10:15:45.128609525 +0200
-@@ -0,0 +1,601 @@
++++ linux/fs/aufs/inode.h      2015-06-22 08:27:37.884168534 +0200
+@@ -0,0 +1,673 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -16205,6 +16354,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +};
 +
 +void au_pin_hdir_unlock(struct au_pin *p);
++int au_pin_hdir_lock(struct au_pin *p);
 +int au_pin_hdir_relock(struct au_pin *p);
 +void au_pin_hdir_set_owner(struct au_pin *p, struct task_struct *task);
 +void au_pin_hdir_acquire_nest(struct au_pin *p);
@@ -16251,9 +16401,8 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +
 +/* au_wr_dir flags */
 +#define AuWrDir_ADD_ENTRY     1
-+#define AuWrDir_TMP_WHENTRY   (1 << 1)
-+#define AuWrDir_ISDIR         (1 << 2)
-+#define AuWrDir_TMPFILE               (1 << 3)
++#define AuWrDir_ISDIR         (1 << 1)
++#define AuWrDir_TMPFILE               (1 << 2)
 +#define au_ftest_wrdir(flags, name)   ((flags) & AuWrDir_##name)
 +#define au_fset_wrdir(flags, name) \
 +      do { (flags) |= AuWrDir_##name; } while (0)
@@ -16275,6 +16424,29 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +         unsigned int udba, unsigned char flags) __must_check;
 +int au_do_pin(struct au_pin *pin) __must_check;
 +void au_unpin(struct au_pin *pin);
++int au_reval_for_attr(struct dentry *dentry, unsigned int sigen);
++
++#define AuIcpup_DID_CPUP      1
++#define au_ftest_icpup(flags, name)   ((flags) & AuIcpup_##name)
++#define au_fset_icpup(flags, name) \
++      do { (flags) |= AuIcpup_##name; } while (0)
++#define au_fclr_icpup(flags, name) \
++      do { (flags) &= ~AuIcpup_##name; } while (0)
++
++struct au_icpup_args {
++      unsigned char flags;
++      unsigned char pin_flags;
++      aufs_bindex_t btgt;
++      unsigned int udba;
++      struct au_pin pin;
++      struct path h_path;
++      struct inode *h_inode;
++};
++
++int au_pin_and_icpup(struct dentry *dentry, struct iattr *ia,
++                   struct au_icpup_args *a);
++
++int au_h_path_getattr(struct dentry *dentry, int force, struct path *h_path);
 +
 +/* i_op_add.c */
 +int au_may_add(struct dentry *dentry, aufs_bindex_t bindex,
@@ -16284,6 +16456,9 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +int aufs_symlink(struct inode *dir, struct dentry *dentry, const char *symname);
 +int aufs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 +              bool want_excl);
++struct vfsub_aopen_args;
++int au_aopen_or_create(struct inode *dir, struct dentry *dentry,
++                     struct vfsub_aopen_args *args);
 +int aufs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode);
 +int aufs_link(struct dentry *src_dentry, struct inode *dir,
 +            struct dentry *dentry);
@@ -16336,6 +16511,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +#ifdef CONFIG_PROC_FS
 +/* plink.c */
 +int au_plink_maint(struct super_block *sb, int flags);
++struct au_sbinfo;
 +void au_plink_maint_leave(struct au_sbinfo *sbinfo);
 +int au_plink_maint_enter(struct super_block *sb);
 +#ifdef CONFIG_AUFS_DEBUG
@@ -16365,6 +16541,57 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +AuStubVoid(au_plink_half_refresh, struct super_block *sb, aufs_bindex_t br_id);
 +#endif /* CONFIG_PROC_FS */
 +
++#ifdef CONFIG_AUFS_XATTR
++/* xattr.c */
++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, const char *name, void *value,
++                    size_t size);
++int aufs_setxattr(struct dentry *dentry, 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); */
++#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); */
++#endif
++
++#ifdef CONFIG_FS_POSIX_ACL
++struct posix_acl *aufs_get_acl(struct inode *inode, int type);
++int aufs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
++#endif
++
++#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 {
++      int type;
++      union {
++              struct {
++                      const char      *name;
++                      const void      *value;
++                      size_t          size;
++                      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 au_srxattr *arg);
++#endif
++
 +/* ---------------------------------------------------------------------- */
 +
 +/* lock subclass for iinfo */
@@ -16578,6 +16805,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +      }
 +}
 +
++#if 0 /* reserved */
 +static inline void au_pin_set_parent(struct au_pin *pin, struct dentry *parent)
 +{
 +      if (pin) {
@@ -16585,6 +16813,7 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +              pin->parent = dget(parent);
 +      }
 +}
++#endif
 +
 +/* ---------------------------------------------------------------------- */
 +
@@ -16637,18 +16866,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +}
 +
 +#else
-+static inline
-+int au_hn_alloc(struct au_hinode *hinode __maybe_unused,
-+              struct inode *inode __maybe_unused)
-+{
-+      return -EOPNOTSUPP;
-+}
-+
-+static inline struct au_hnotify *au_hn(struct au_hinode *hinode)
-+{
-+      return NULL;
-+}
-+
++AuStub(int, au_hn_alloc, return -EOPNOTSUPP,
++       struct au_hinode *hinode __maybe_unused,
++       struct inode *inode __maybe_unused)
++AuStub(struct au_hnotify *, au_hn, return NULL, struct au_hinode *hinode)
 +AuStubVoid(au_hn_free, struct au_hinode *hinode __maybe_unused)
 +AuStubVoid(au_hn_ctl, struct au_hinode *hinode __maybe_unused,
 +         int do_set __maybe_unused)
@@ -16698,10 +16919,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h
 +#endif /* __AUFS_INODE_H__ */
 diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 --- /usr/share/empty/fs/aufs/ioctl.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/ioctl.c      2014-08-14 10:15:45.128609525 +0200
-@@ -0,0 +1,214 @@
++++ linux/fs/aufs/ioctl.c      2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,219 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -16761,7 +16982,7 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 +                      goto out;
 +      }
 +
-+      fd = get_unused_fd();
++      fd = get_unused_fd_flags(0);
 +      err = fd;
 +      if (unlikely(fd < 0))
 +              goto out;
@@ -16824,6 +17045,7 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 +long aufs_ioctl_dir(struct file *file, unsigned int cmd, unsigned long arg)
 +{
 +      long err;
++      struct dentry *dentry;
 +
 +      switch (cmd) {
 +      case AUFS_CTL_RDU:
@@ -16844,7 +17066,11 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 +              break;
 +
 +      case AUFS_CTL_FHSM_FD:
-+              err = au_fhsm_fd(file->f_dentry->d_sb, arg);
++              dentry = file->f_path.dentry;
++              if (IS_ROOT(dentry))
++                      err = au_fhsm_fd(dentry->d_sb, arg);
++              else
++                      err = -ENOTTY;
 +              break;
 +
 +      default:
@@ -16863,7 +17089,7 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c
 +
 +      switch (cmd) {
 +      case AUFS_CTL_MVDOWN:
-+              err = au_mvdown(file->f_dentry, (void __user *)arg);
++              err = au_mvdown(file->f_path.dentry, (void __user *)arg);
 +              break;
 +
 +      case AUFS_CTL_WBR_FD:
@@ -16916,10 +17142,10 @@ 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   2014-08-14 10:15:45.121942630 +0200
-@@ -0,0 +1,885 @@
++++ linux/fs/aufs/i_op_add.c   2015-06-22 08:27:37.880835119 +0200
+@@ -0,0 +1,930 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -16977,8 +17203,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              d_instantiate(dentry, inode);
 +              dir = dentry->d_parent->d_inode; /* dir inode is locked */
 +              IMustLock(dir);
-+              if (au_ibstart(dir) == au_dbstart(dentry))
-+                      au_cpup_attr_timesizes(dir);
++              au_dir_ts(dir, bindex);
 +              dir->i_version++;
 +              au_fhsm_wrote(sb, bindex, /*force*/0);
 +              return 0; /* success */
@@ -17121,6 +17346,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      if (bcpup != au_dbwh(dentry))
 +              goto out; /* success */
 +
++      /*
++       * ENAMETOOLONG here means that if we allowed create such name, then it
++       * would not be able to removed in the future. So we don't allow such
++       * name here and we don't handle ENAMETOOLONG differently here.
++       */
 +      wh_dentry = au_wh_lkup(h_parent, &dentry->d_name, br);
 +
 +out_unpin:
@@ -17137,8 +17367,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      int type;
 +      union {
 +              struct {
-+                      umode_t mode;
-+                      bool want_excl;
++                      umode_t                 mode;
++                      bool                    want_excl;
++                      bool                    try_aopen;
++                      struct vfsub_aopen_args *aopen;
 +              } c;
 +              struct {
 +                      const char *symname;
@@ -17156,8 +17388,12 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      int err, rerr;
 +      aufs_bindex_t bstart;
 +      unsigned char created;
++      const unsigned char try_aopen
++              = (arg->type == Creat && arg->u.c.try_aopen);
 +      struct dentry *wh_dentry, *parent;
 +      struct inode *h_dir;
++      struct super_block *sb;
++      struct au_branch *br;
 +      /* to reuduce stack size */
 +      struct {
 +              struct au_dtime dt;
@@ -17177,13 +17413,16 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      a->wr_dir_args.flags = AuWrDir_ADD_ENTRY;
 +
 +      parent = dentry->d_parent; /* dir inode is locked */
-+      err = aufs_read_lock(dentry, AuLock_DW | AuLock_GEN);
-+      if (unlikely(err))
-+              goto out_free;
++      if (!try_aopen) {
++              err = aufs_read_lock(dentry, AuLock_DW | AuLock_GEN);
++              if (unlikely(err))
++                      goto out_free;
++      }
 +      err = au_d_may_add(dentry);
 +      if (unlikely(err))
 +              goto out_unlock;
-+      di_write_lock_parent(parent);
++      if (!try_aopen)
++              di_write_lock_parent(parent);
 +      wh_dentry = lock_hdir_lkup_wh(dentry, &a->dt, /*src_dentry*/NULL,
 +                                    &a->pin, &a->wr_dir_args);
 +      err = PTR_ERR(wh_dentry);
@@ -17191,13 +17430,20 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              goto out_parent;
 +
 +      bstart = au_dbstart(dentry);
++      sb = dentry->d_sb;
++      br = au_sbr(sb, bstart);
 +      a->h_path.dentry = au_h_dptr(dentry, bstart);
-+      a->h_path.mnt = au_sbr_mnt(dentry->d_sb, bstart);
++      a->h_path.mnt = au_br_mnt(br);
 +      h_dir = au_pinned_h_dir(&a->pin);
 +      switch (arg->type) {
 +      case Creat:
-+              err = vfsub_create(h_dir, &a->h_path, arg->u.c.mode,
-+                                 arg->u.c.want_excl);
++              err = 0;
++              if (!try_aopen || !h_dir->i_op->atomic_open)
++                      err = vfsub_create(h_dir, &a->h_path, arg->u.c.mode,
++                                         arg->u.c.want_excl);
++              else
++                      err = vfsub_atomic_open(h_dir, a->h_path.dentry,
++                                              arg->u.c.aopen, br);
 +              break;
 +      case Symlink:
 +              err = vfsub_symlink(h_dir, &a->h_path, arg->u.s.symname);
@@ -17226,17 +17472,22 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +              au_dtime_revert(&a->dt);
 +      }
 +
++      if (!err && try_aopen && !h_dir->i_op->atomic_open)
++              *arg->u.c.aopen->opened |= FILE_CREATED;
++
 +      au_unpin(&a->pin);
 +      dput(wh_dentry);
 +
 +out_parent:
-+      di_write_unlock(parent);
++      if (!try_aopen)
++              di_write_unlock(parent);
 +out_unlock:
 +      if (unlikely(err)) {
 +              au_update_dbstart(dentry);
 +              d_drop(dentry);
 +      }
-+      aufs_read_unlock(dentry, AuLock_DW);
++      if (!try_aopen)
++              aufs_read_unlock(dentry, AuLock_DW);
 +out_free:
 +      kfree(a);
 +out:
@@ -17278,6 +17529,21 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +      return add_simple(dir, dentry, &arg);
 +}
 +
++int au_aopen_or_create(struct inode *dir, struct dentry *dentry,
++                     struct vfsub_aopen_args *aopen_args)
++{
++      struct simple_arg arg = {
++              .type = Creat,
++              .u.c = {
++                      .mode           = aopen_args->create_mode,
++                      .want_excl      = aopen_args->open_flag & O_EXCL,
++                      .try_aopen      = true,
++                      .aopen          = aopen_args
++              }
++      };
++      return add_simple(dir, dentry, &arg);
++}
++
 +int aufs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 +{
 +      int err;
@@ -17462,7 +17728,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +                            dget(au_h_dptr(src_dentry, a->bsrc)));
 +              dget(a->h_path.dentry);
 +              au_set_h_dptr(dentry, a->bdst, NULL);
++              AuDbg("temporary d_inode...\n");
++              spin_lock(&dentry->d_lock);
 +              dentry->d_inode = src_dentry->d_inode; /* tmp */
++              spin_unlock(&dentry->d_lock);
 +              h_file = au_h_open_pre(dentry, a->bsrc, /*force_wr*/0);
 +              if (IS_ERR(h_file))
 +                      err = PTR_ERR(h_file);
@@ -17484,7 +17753,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +                              au_set_h_dptr(dentry, a->bdst,
 +                                            a->h_path.dentry);
 +              }
++              spin_lock(&dentry->d_lock);
 +              dentry->d_inode = NULL; /* restore */
++              spin_unlock(&dentry->d_lock);
++              AuDbg("temporary d_inode...done\n");
 +              au_set_h_dptr(dentry, a->bsrc, NULL);
 +              au_set_dbend(dentry, bend);
 +      } else {
@@ -17654,9 +17926,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +                      goto out_revert;
 +      }
 +
++      au_dir_ts(dir, a->bdst);
 +      dir->i_version++;
-+      if (au_ibstart(dir) == au_dbstart(dentry))
-+              au_cpup_attr_timesizes(dir);
 +      inc_nlink(inode);
 +      inode->i_ctime = dir->i_ctime;
 +      d_instantiate(dentry, au_igrab(inode));
@@ -17805,10 +18076,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c
 +}
 diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 --- /usr/share/empty/fs/aufs/i_op.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/i_op.c       2014-08-14 10:15:45.121942630 +0200
-@@ -0,0 +1,1142 @@
++++ linux/fs/aufs/i_op.c       2015-06-22 08:29:23.706757681 +0200
+@@ -0,0 +1,1445 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -17853,13 +18124,19 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +       * - skip the lower fs test in the case of write to ro branch.
 +       * - nfs dir permission write check is optimized, but a policy for
 +       *   link/rename requires a real check.
++       * - nfs always sets MS_POSIXACL regardless its mount option 'noacl.'
++       *   in this case, generic_permission() returns -EOPNOTSUPP.
 +       */
 +      if ((write_mask && !au_br_writable(brperm))
 +          || (au_test_nfs(h_inode->i_sb) && S_ISDIR(h_inode->i_mode)
 +              && write_mask && !(mask & MAY_READ))
 +          || !h_inode->i_op->permission) {
 +              /* AuLabel(generic_permission); */
++              /* AuDbg("get_acl %pf\n", h_inode->i_op->get_acl); */
 +              err = generic_permission(h_inode, mask);
++              if (err == -EOPNOTSUPP && au_test_nfs_noacl(h_inode))
++                      err = h_inode->i_op->permission(h_inode, mask);
++              AuTraceErr(err);
 +      } else {
 +              /* AuLabel(h_inode->permission); */
 +              err = h_inode->i_op->permission(h_inode, mask);
@@ -18012,13 +18289,15 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +
 +      if (npositive) {
 +              inode = au_new_inode(dentry, /*must_new*/0);
-+              ret = (void *)inode;
-+      }
-+      if (IS_ERR(inode)) {
-+              inode = NULL;
-+              goto out_unlock;
++              if (IS_ERR(inode)) {
++                      ret = (void *)inode;
++                      inode = NULL;
++                      goto out_unlock;
++              }
 +      }
 +
++      if (inode)
++              atomic_inc(&inode->i_count);
 +      ret = d_splice_alias(inode, dentry);
 +#if 0
 +      if (unlikely(d_need_lookup(dentry))) {
@@ -18027,10 +18306,16 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              spin_unlock(&dentry->d_lock);
 +      } else
 +#endif
-+      if (unlikely(IS_ERR(ret) && inode)) {
-+              ii_write_unlock(inode);
-+              iput(inode);
-+              inode = NULL;
++      if (inode) {
++              if (!IS_ERR(ret)) {
++                      iput(inode);
++                      if (ret && ret != dentry)
++                              ii_write_unlock(inode);
++              } else {
++                      ii_write_unlock(inode);
++                      iput(inode);
++                      inode = NULL;
++              }
 +      }
 +
 +out_unlock:
@@ -18055,6 +18340,149 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +
 +/* ---------------------------------------------------------------------- */
 +
++struct aopen_node {
++      struct hlist_node hlist;
++      struct file *file, *h_file;
++};
++
++static int au_do_aopen(struct inode *inode, struct file *file)
++{
++      struct au_sphlhead *aopen;
++      struct aopen_node *node;
++      struct au_do_open_args args = {
++              .no_lock        = 1,
++              .open           = au_do_open_nondir
++      };
++
++      aopen = &au_sbi(inode->i_sb)->si_aopen;
++      spin_lock(&aopen->spin);
++      hlist_for_each_entry(node, &aopen->head, hlist)
++              if (node->file == file) {
++                      args.h_file = node->h_file;
++                      break;
++              }
++      spin_unlock(&aopen->spin);
++      /* AuDebugOn(!args.h_file); */
++
++      return au_do_open(file, &args);
++}
++
++static int aufs_atomic_open(struct inode *dir, struct dentry *dentry,
++                          struct file *file, unsigned int open_flag,
++                          umode_t create_mode, int *opened)
++{
++      int err, h_opened = *opened;
++      struct dentry *parent;
++      struct dentry *d;
++      struct au_sphlhead *aopen;
++      struct vfsub_aopen_args args = {
++              .open_flag      = open_flag,
++              .create_mode    = create_mode,
++              .opened         = &h_opened
++      };
++      struct aopen_node aopen_node = {
++              .file   = file
++      };
++
++      IMustLock(dir);
++      AuDbg("open_flag 0x%x\n", open_flag);
++      AuDbgDentry(dentry);
++
++      err = 0;
++      if (!au_di(dentry)) {
++              d = aufs_lookup(dir, dentry, /*flags*/0);
++              if (IS_ERR(d)) {
++                      err = PTR_ERR(d);
++                      goto out;
++              } else if (d) {
++                      /*
++                       * obsoleted dentry found.
++                       * another error will be returned later.
++                       */
++                      d_drop(d);
++                      dput(d);
++                      AuDbgDentry(d);
++              }
++              AuDbgDentry(dentry);
++      }
++
++      if (d_is_positive(dentry)
++          || d_unhashed(dentry)
++          || d_unlinked(dentry)
++          || !(open_flag & O_CREAT))
++              goto out_no_open;
++
++      err = aufs_read_lock(dentry, AuLock_DW | AuLock_FLUSH | AuLock_GEN);
++      if (unlikely(err))
++              goto out;
++
++      parent = dentry->d_parent;      /* dir is locked */
++      di_write_lock_parent(parent);
++      err = au_lkup_dentry(dentry, /*bstart*/0, /*type*/0);
++      if (unlikely(err))
++              goto out_unlock;
++
++      AuDbgDentry(dentry);
++      if (d_is_positive(dentry))
++              goto out_unlock;
++
++      args.file = get_empty_filp();
++      err = PTR_ERR(args.file);
++      if (IS_ERR(args.file))
++              goto out_unlock;
++
++      args.file->f_flags = file->f_flags;
++      err = au_aopen_or_create(dir, dentry, &args);
++      AuTraceErr(err);
++      AuDbgFile(args.file);
++      if (unlikely(err < 0)) {
++              if (h_opened & FILE_OPENED)
++                      fput(args.file);
++              else
++                      put_filp(args.file);
++              goto out_unlock;
++      }
++
++      /* some filesystems don't set FILE_CREATED while succeeded? */
++      *opened |= FILE_CREATED;
++      if (h_opened & FILE_OPENED)
++              aopen_node.h_file = args.file;
++      else {
++              put_filp(args.file);
++              args.file = NULL;
++      }
++      aopen = &au_sbi(dir->i_sb)->si_aopen;
++      au_sphl_add(&aopen_node.hlist, aopen);
++      err = finish_open(file, dentry, au_do_aopen, opened);
++      au_sphl_del(&aopen_node.hlist, aopen);
++      AuTraceErr(err);
++      AuDbgFile(file);
++      if (aopen_node.h_file)
++              fput(aopen_node.h_file);
++
++out_unlock:
++      di_write_unlock(parent);
++      aufs_read_unlock(dentry, AuLock_DW);
++      AuDbgDentry(dentry);
++      if (unlikely(err))
++              goto out;
++out_no_open:
++      if (!err && !(*opened & FILE_CREATED)) {
++              AuLabel(out_no_open);
++              dget(dentry);
++              err = finish_no_open(file, dentry);
++      }
++out:
++      AuDbg("%pd%s%s\n", dentry,
++            (*opened & FILE_CREATED) ? " created" : "",
++            (*opened & FILE_OPENED) ? " opened" : "");
++      AuTraceErr(err);
++      return err;
++}
++
++
++/* ---------------------------------------------------------------------- */
++
 +static int au_wr_dir_cpup(struct dentry *dentry, struct dentry *parent,
 +                        const unsigned char add_entry, aufs_bindex_t bcpup,
 +                        aufs_bindex_t bstart)
@@ -18081,8 +18509,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              h_parent = au_h_dptr(parent, bcpup);
 +              h_dir = h_parent->d_inode;
 +              mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
-+              err = au_lkup_neg(dentry, bcpup,
-+                                au_ftest_wrdir(add_entry, TMP_WHENTRY));
++              err = au_lkup_neg(dentry, bcpup, /*wh*/0);
 +              /* todo: no unlock here */
 +              mutex_unlock(&h_dir->i_mutex);
 +
@@ -18116,7 +18543,6 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      aufs_bindex_t bcpup, bstart, src_bstart;
 +      const unsigned char add_entry
 +              = au_ftest_wrdir(args->flags, ADD_ENTRY)
-+              | au_ftest_wrdir(args->flags, TMP_WHENTRY)
 +              | au_ftest_wrdir(args->flags, TMPFILE);
 +      struct super_block *sb;
 +      struct dentry *parent;
@@ -18191,7 +18617,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              au_hn_imtx_unlock(p->hdir);
 +}
 +
-+static int au_pin_hdir_lock(struct au_pin *p)
++int au_pin_hdir_lock(struct au_pin *p)
 +{
 +      int err;
 +
@@ -18405,7 +18831,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 + * for ->setattr(), ia->ia_file is passed from ftruncate only.
 + */
 +/* todo: consolidate with do_refresh() and simple_reval_dpath() */
-+static int au_reval_for_attr(struct dentry *dentry, unsigned int sigen)
++int au_reval_for_attr(struct dentry *dentry, unsigned int sigen)
 +{
 +      int err;
 +      struct inode *inode;
@@ -18425,25 +18851,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      return err;
 +}
 +
-+#define AuIcpup_DID_CPUP      1
-+#define au_ftest_icpup(flags, name)   ((flags) & AuIcpup_##name)
-+#define au_fset_icpup(flags, name) \
-+      do { (flags) |= AuIcpup_##name; } while (0)
-+#define au_fclr_icpup(flags, name) \
-+      do { (flags) &= ~AuIcpup_##name; } while (0)
-+
-+struct au_icpup_args {
-+      unsigned char flags;
-+      unsigned char pin_flags;
-+      aufs_bindex_t btgt;
-+      unsigned int udba;
-+      struct au_pin pin;
-+      struct path h_path;
-+      struct inode *h_inode;
-+};
-+
-+static int au_pin_and_icpup(struct dentry *dentry, struct iattr *ia,
-+                          struct au_icpup_args *a)
++int au_pin_and_icpup(struct dentry *dentry, struct iattr *ia,
++                   struct au_icpup_args *a)
 +{
 +      int err;
 +      loff_t sz;
@@ -18455,11 +18864,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              .flags          = 0
 +      };
 +
-+      bstart = au_dbstart(dentry);
-+      inode = dentry->d_inode;
-+      if (S_ISDIR(inode->i_mode))
++      if (d_is_dir(dentry))
 +              au_fset_wrdir(wr_dir_args.flags, ISDIR);
 +      /* plink or hi_wh() case */
++      bstart = au_dbstart(dentry);
++      inode = dentry->d_inode;
 +      ibstart = au_ibstart(inode);
 +      if (bstart != ibstart && !au_test_ro(inode->i_sb, ibstart, inode))
 +              wr_dir_args.force_btgt = ibstart;
@@ -18485,11 +18894,13 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +
 +      a->h_path.dentry = au_h_dptr(dentry, bstart);
 +      a->h_inode = a->h_path.dentry->d_inode;
-+      mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
 +      sz = -1;
-+      if ((ia->ia_valid & ATTR_SIZE) && ia->ia_size < i_size_read(a->h_inode))
-+              sz = ia->ia_size;
-+      mutex_unlock(&a->h_inode->i_mutex);
++      if (ia && (ia->ia_valid & ATTR_SIZE)) {
++              mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
++              if (ia->ia_size < i_size_read(a->h_inode))
++                      sz = ia->ia_size;
++              mutex_unlock(&a->h_inode->i_mutex);
++      }
 +
 +      hi_wh = NULL;
 +      if (au_ftest_icpup(a->flags, DID_CPUP) && d_unlinked(dentry)) {
@@ -18579,7 +18990,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +
 +      if (ia->ia_valid & ATTR_FILE) {
 +              /* currently ftruncate(2) only */
-+              AuDebugOn(!S_ISREG(inode->i_mode));
++              AuDebugOn(!d_is_reg(dentry));
 +              file = ia->ia_file;
 +              err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/1);
 +              if (unlikely(err))
@@ -18671,6 +19082,99 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      return err;
 +}
 +
++#if IS_ENABLED(CONFIG_AUFS_XATTR) || IS_ENABLED(CONFIG_FS_POSIX_ACL)
++static int au_h_path_to_set_attr(struct dentry *dentry,
++                               struct au_icpup_args *a, struct path *h_path)
++{
++      int err;
++      struct super_block *sb;
++
++      sb = dentry->d_sb;
++      a->udba = au_opt_udba(sb);
++      /* no d_unlinked(), to set UDBA_NONE for root */
++      if (d_unhashed(dentry))
++              a->udba = AuOpt_UDBA_NONE;
++      if (a->udba != AuOpt_UDBA_NONE) {
++              AuDebugOn(IS_ROOT(dentry));
++              err = au_reval_for_attr(dentry, au_sigen(sb));
++              if (unlikely(err))
++                      goto out;
++      }
++      err = au_pin_and_icpup(dentry, /*ia*/NULL, a);
++      if (unlikely(err < 0))
++              goto out;
++
++      h_path->dentry = a->h_path.dentry;
++      h_path->mnt = au_sbr_mnt(sb, a->btgt);
++
++out:
++      return err;
++}
++
++ssize_t au_srxattr(struct dentry *dentry, struct au_srxattr *arg)
++{
++      int err;
++      struct path h_path;
++      struct super_block *sb;
++      struct au_icpup_args *a;
++      struct inode *inode, *h_inode;
++
++      inode = dentry->d_inode;
++      IMustLock(inode);
++
++      err = -ENOMEM;
++      a = kzalloc(sizeof(*a), GFP_NOFS);
++      if (unlikely(!a))
++              goto out;
++
++      sb = dentry->d_sb;
++      err = si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLM);
++      if (unlikely(err))
++              goto out_kfree;
++
++      h_path.dentry = NULL;   /* silence gcc */
++      di_write_lock_child(dentry);
++      err = au_h_path_to_set_attr(dentry, a, &h_path);
++      if (unlikely(err))
++              goto out_di;
++
++      mutex_unlock(&a->h_inode->i_mutex);
++      switch (arg->type) {
++      case AU_XATTR_SET:
++              err = vfsub_setxattr(h_path.dentry,
++                                   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 = h_path.dentry->d_inode;
++              if (h_inode->i_op->set_acl)
++                      err = h_inode->i_op->set_acl(h_inode,
++                                                   arg->u.acl_set.acl,
++                                                   arg->u.acl_set.type);
++              break;
++      }
++      if (!err)
++              au_cpup_attr_timesizes(inode);
++
++      au_unpin(&a->pin);
++      if (unlikely(err))
++              au_update_dbstart(dentry);
++
++out_di:
++      di_write_unlock(dentry);
++      si_read_unlock(sb);
++out_kfree:
++      kfree(a);
++out:
++      AuTraceErr(err);
++      return err;
++}
++#endif
++
 +static void au_refresh_iattr(struct inode *inode, struct kstat *st,
 +                           unsigned int nlink)
 +{
@@ -18700,22 +19204,25 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      spin_unlock(&inode->i_lock);
 +}
 +
-+static int aufs_getattr(struct vfsmount *mnt __maybe_unused,
-+                      struct dentry *dentry, struct kstat *st)
++/*
++ * common routine for aufs_getattr() and aufs_getxattr().
++ * returns zero or negative (an error).
++ * @dentry will be read-locked in success.
++ */
++int au_h_path_getattr(struct dentry *dentry, int force, struct path *h_path)
 +{
 +      int err;
 +      unsigned int mnt_flags, sigen;
++      unsigned char udba_none;
 +      aufs_bindex_t bindex;
-+      unsigned char udba_none, positive;
 +      struct super_block *sb, *h_sb;
 +      struct inode *inode;
-+      struct path h_path;
 +
++      h_path->mnt = NULL;
++      h_path->dentry = NULL;
++
++      err = 0;
 +      sb = dentry->d_sb;
-+      inode = dentry->d_inode;
-+      err = si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLM);
-+      if (unlikely(err))
-+              goto out;
 +      mnt_flags = au_mntflags(sb);
 +      udba_none = !!au_opt_test(mnt_flags, UDBA_NONE);
 +
@@ -18726,43 +19233,74 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              if (!err) {
 +                      di_read_lock_child(dentry, AuLock_IR);
 +                      err = au_dbrange_test(dentry);
-+                      if (unlikely(err))
-+                              goto out_unlock;
++                      if (unlikely(err)) {
++                              di_read_unlock(dentry, AuLock_IR);
++                              goto out;
++                      }
 +              } else {
 +                      AuDebugOn(IS_ROOT(dentry));
 +                      di_write_lock_child(dentry);
 +                      err = au_dbrange_test(dentry);
 +                      if (!err)
 +                              err = au_reval_for_attr(dentry, sigen);
-+                      di_downgrade_lock(dentry, AuLock_IR);
-+                      if (unlikely(err))
-+                              goto out_unlock;
++                      if (!err)
++                              di_downgrade_lock(dentry, AuLock_IR);
++                      else {
++                              di_write_unlock(dentry);
++                              goto out;
++                      }
 +              }
 +      } else
 +              di_read_lock_child(dentry, AuLock_IR);
 +
++      inode = dentry->d_inode;
 +      bindex = au_ibstart(inode);
-+      h_path.mnt = au_sbr_mnt(sb, bindex);
-+      h_sb = h_path.mnt->mnt_sb;
-+      if (!au_test_fs_bad_iattr(h_sb) && udba_none)
-+              goto out_fill; /* success */
++      h_path->mnt = au_sbr_mnt(sb, bindex);
++      h_sb = h_path->mnt->mnt_sb;
++      if (!force
++          && !au_test_fs_bad_iattr(h_sb)
++          && udba_none)
++              goto out; /* success */
 +
-+      h_path.dentry = NULL;
 +      if (au_dbstart(dentry) == bindex)
-+              h_path.dentry = dget(au_h_dptr(dentry, bindex));
++              h_path->dentry = au_h_dptr(dentry, bindex);
 +      else if (au_opt_test(mnt_flags, PLINK) && au_plink_test(inode)) {
-+              h_path.dentry = au_plink_lkup(inode, bindex);
-+              if (IS_ERR(h_path.dentry))
-+                      goto out_fill; /* pretending success */
++              h_path->dentry = au_plink_lkup(inode, bindex);
++              if (IS_ERR(h_path->dentry))
++                      /* pretending success */
++                      h_path->dentry = NULL;
++              else
++                      dput(h_path->dentry);
 +      }
-+      /* illegally overlapped or something */
++
++out:
++      return err;
++}
++
++static int aufs_getattr(struct vfsmount *mnt __maybe_unused,
++                      struct dentry *dentry, struct kstat *st)
++{
++      int err;
++      unsigned char positive;
++      struct path h_path;
++      struct inode *inode;
++      struct super_block *sb;
++
++      inode = dentry->d_inode;
++      sb = dentry->d_sb;
++      err = si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLM);
++      if (unlikely(err))
++              goto out;
++      err = au_h_path_getattr(dentry, /*force*/0, &h_path);
++      if (unlikely(err))
++              goto out_si;
 +      if (unlikely(!h_path.dentry))
++              /* illegally overlapped or something */
 +              goto out_fill; /* pretending success */
 +
 +      positive = !!h_path.dentry->d_inode;
 +      if (positive)
 +              err = vfs_getattr(&h_path, st);
-+      dput(h_path.dentry);
 +      if (!err) {
 +              if (positive)
 +                      au_refresh_iattr(inode, st,
@@ -18770,12 +19308,13 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +              goto out_fill; /* success */
 +      }
 +      AuTraceErr(err);
-+      goto out_unlock;
++      goto out_di;
 +
 +out_fill:
 +      generic_fillattr(inode, st);
-+out_unlock:
++out_di:
 +      di_read_unlock(dentry, AuLock_IR);
++out_si:
 +      si_read_unlock(sb);
 +out:
 +      AuTraceErr(err);
@@ -18911,9 +19450,21 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +
 +struct inode_operations aufs_symlink_iop = {
 +      .permission     = aufs_permission,
++#ifdef CONFIG_FS_POSIX_ACL
++      .get_acl        = aufs_get_acl,
++      .set_acl        = aufs_set_acl, /* unsupport for symlink? */
++#endif
++
 +      .setattr        = aufs_setattr,
 +      .getattr        = aufs_getattr,
 +
++#ifdef CONFIG_AUFS_XATTR
++      .setxattr       = aufs_setxattr,
++      .getxattr       = aufs_getxattr,
++      .listxattr      = aufs_listxattr,
++      .removexattr    = aufs_removexattr,
++#endif
++
 +      .readlink       = aufs_readlink,
 +      .follow_link    = aufs_follow_link,
 +      .put_link       = aufs_put_link,
@@ -18933,28 +19484,51 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c
 +      .rename         = aufs_rename,
 +
 +      .permission     = aufs_permission,
++#ifdef CONFIG_FS_POSIX_ACL
++      .get_acl        = aufs_get_acl,
++      .set_acl        = aufs_set_acl,
++#endif
++
 +      .setattr        = aufs_setattr,
 +      .getattr        = aufs_getattr,
 +
-+      .update_time    = aufs_update_time,
-+      /* no support for atomic_open() */
++#ifdef CONFIG_AUFS_XATTR
++      .setxattr       = aufs_setxattr,
++      .getxattr       = aufs_getxattr,
++      .listxattr      = aufs_listxattr,
++      .removexattr    = aufs_removexattr,
++#endif
 +
++      .update_time    = aufs_update_time,
++      .atomic_open    = aufs_atomic_open,
 +      .tmpfile        = aufs_tmpfile
 +};
 +
 +struct inode_operations aufs_iop = {
 +      .permission     = aufs_permission,
++#ifdef CONFIG_FS_POSIX_ACL
++      .get_acl        = aufs_get_acl,
++      .set_acl        = aufs_set_acl,
++#endif
++
 +      .setattr        = aufs_setattr,
 +      .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
 +};
 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   2014-08-14 10:15:45.121942630 +0200
-@@ -0,0 +1,507 @@
++++ linux/fs/aufs/i_op_del.c   2015-06-22 08:27:37.884168534 +0200
+@@ -0,0 +1,506 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -19218,8 +19792,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +      d_drop(dentry);
 +      inode->i_ctime = dir->i_ctime;
 +
-+      if (au_ibstart(dir) == bindex)
-+              au_cpup_attr_timesizes(dir);
++      au_dir_ts(dir, bindex);
 +      dir->i_version++;
 +}
 +
@@ -19278,7 +19851,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +      inode = dentry->d_inode;
 +      IMustLock(inode);
 +      err = -EISDIR;
-+      if (unlikely(S_ISDIR(inode->i_mode)))
++      if (unlikely(d_is_dir(dentry)))
 +              goto out_unlock; /* possible? */
 +
 +      bstart = au_dbstart(dentry);
@@ -19379,7 +19952,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +      inode = dentry->d_inode;
 +      IMustLock(inode);
 +      err = -ENOTDIR;
-+      if (unlikely(!S_ISDIR(inode->i_mode)))
++      if (unlikely(!d_is_dir(dentry)))
 +              goto out_unlock; /* possible? */
 +
 +      err = -ENOMEM;
@@ -19462,10 +20035,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c
 +}
 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   2014-08-14 10:15:45.128609525 +0200
-@@ -0,0 +1,1034 @@
++++ linux/fs/aufs/i_op_ren.c   2015-06-22 08:27:37.884168534 +0200
+@@ -0,0 +1,1015 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -19498,7 +20071,6 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +#define AuRen_MNT_WRITE       (1 << 4)
 +#define AuRen_DT_DSTDIR       (1 << 5)
 +#define AuRen_DIROPQ  (1 << 6)
-+#define AuRen_CPUP    (1 << 7)
 +#define au_ftest_ren(flags, name)     ((flags) & AuRen_##name)
 +#define au_fset_ren(flags, name) \
 +      do { (flags) |= AuRen_##name; } while (0)
@@ -19609,20 +20181,6 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              RevertFailure("rename %pd", a->src_dentry);
 +}
 +
-+static void au_ren_rev_cpup(int err, struct au_ren_args *a)
-+{
-+      int rerr;
-+
-+      a->h_path.dentry = a->dst_h_dentry;
-+      /* no delegation since it is just created */
-+      rerr = vfsub_unlink(a->dst_h_dir, &a->h_path, /*delegated*/NULL,
-+                          /*force*/0);
-+      au_set_h_dptr(a->src_dentry, a->btgt, NULL);
-+      au_set_dbstart(a->src_dentry, a->src_bstart);
-+      if (rerr)
-+              RevertFailure("unlink %pd", a->dst_h_dentry);
-+}
-+
 +static void au_ren_rev_whtmp(int err, struct au_ren_args *a)
 +{
 +      int rerr;
@@ -19857,10 +20415,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      if (au_ftest_ren(a->flags, DIROPQ))
 +              au_ren_rev_diropq(err, a);
 +out_rename:
-+      if (!au_ftest_ren(a->flags, CPUP))
-+              au_ren_rev_rename(err, a);
-+      else
-+              au_ren_rev_cpup(err, a);
++      au_ren_rev_rename(err, a);
 +      dput(a->h_dst);
 +out_whtmp:
 +      if (a->thargs)
@@ -20119,8 +20674,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +              au_cpup_attr_nlink(dir, /*force*/1);
 +      }
 +
-+      if (au_ibstart(dir) == a->btgt)
-+              au_cpup_attr_timesizes(dir);
++      au_dir_ts(dir, a->btgt);
 +
 +      if (au_ftest_ren(a->flags, ISSAMEDIR))
 +              return;
@@ -20129,8 +20683,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +      dir->i_version++;
 +      if (au_ftest_ren(a->flags, ISDIR))
 +              au_cpup_attr_nlink(dir, /*force*/1);
-+      if (au_ibstart(dir) == a->btgt)
-+              au_cpup_attr_timesizes(dir);
++      au_dir_ts(dir, a->btgt);
 +}
 +
 +static void au_ren_refresh(struct au_ren_args *a)
@@ -20321,9 +20874,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +
 +      err = -ENOTDIR;
 +      flags = AuLock_FLUSH | AuLock_NOPLM | AuLock_GEN;
-+      if (S_ISDIR(a->src_inode->i_mode)) {
++      if (d_is_dir(a->src_dentry)) {
 +              au_fset_ren(a->flags, ISDIR);
-+              if (unlikely(a->dst_inode && !S_ISDIR(a->dst_inode->i_mode)))
++              if (unlikely(d_is_positive(a->dst_dentry)
++                           && !d_is_dir(a->dst_dentry)))
 +                      goto out_free;
 +              err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry,
 +                                              AuLock_DIR | flags);
@@ -20500,8 +21054,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c
 +}
 diff -urN /usr/share/empty/fs/aufs/Kconfig linux/fs/aufs/Kconfig
 --- /usr/share/empty/fs/aufs/Kconfig   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/Kconfig      2014-08-14 10:15:45.118609182 +0200
-@@ -0,0 +1,177 @@
++++ linux/fs/aufs/Kconfig      2015-06-22 08:27:37.874168290 +0200
+@@ -0,0 +1,185 @@
 +config AUFS_FS
 +      tristate "Aufs (Advanced multi layered unification filesystem) support"
 +      help
@@ -20591,6 +21145,14 @@ diff -urN /usr/share/empty/fs/aufs/Kconfig linux/fs/aufs/Kconfig
 +      /* typedef unsigned long/int __kernel_ino_t */
 +      /* alpha and s390x are int */
 +
++config AUFS_XATTR
++      bool "support for XATTR/EA (including Security Labels)"
++      help
++      If your branch fs supports XATTR/EA and you want to make them
++      available in aufs too, then enable this opsion and specify the
++      branch attributes for EA.
++      See detail in aufs.5.
++
 +config AUFS_FHSM
 +      bool "File-based Hierarchical Storage Management"
 +      help
@@ -20681,10 +21243,10 @@ diff -urN /usr/share/empty/fs/aufs/Kconfig linux/fs/aufs/Kconfig
 +endif
 diff -urN /usr/share/empty/fs/aufs/loop.c linux/fs/aufs/loop.c
 --- /usr/share/empty/fs/aufs/loop.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/loop.c       2014-01-30 21:10:02.850815069 +0100
++++ linux/fs/aufs/loop.c       2015-06-22 08:29:23.706757681 +0200
 @@ -0,0 +1,145 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -20730,7 +21292,7 @@ diff -urN /usr/share/empty/fs/aufs/loop.c linux/fs/aufs/loop.c
 +      if (!backing_file)
 +              return 0;
 +
-+      h_adding = backing_file->f_dentry;
++      h_adding = backing_file->f_path.dentry;
 +      /*
 +       * h_adding can be local NFS.
 +       * in this case aufs cannot detect the loop.
@@ -20830,10 +21392,10 @@ diff -urN /usr/share/empty/fs/aufs/loop.c linux/fs/aufs/loop.c
 +}
 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       2014-01-30 21:10:02.850815069 +0100
++++ linux/fs/aufs/loop.h       2015-06-22 08:27:37.884168534 +0200
 @@ -0,0 +1,52 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -20886,8 +21448,8 @@ 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     2014-01-30 21:10:02.850815069 +0100
-@@ -0,0 +1,54 @@
++++ linux/fs/aufs/magic.mk     2015-06-22 08:27:37.884168534 +0200
+@@ -0,0 +1,30 @@
 +
 +# defined in ${srctree}/fs/fuse/inode.c
 +# tristate
@@ -20895,24 +21457,6 @@ diff -urN /usr/share/empty/fs/aufs/magic.mk linux/fs/aufs/magic.mk
 +ccflags-y += -DFUSE_SUPER_MAGIC=0x65735546
 +endif
 +
-+# defined in ${srctree}/fs/ocfs2/ocfs2_fs.h
-+# tristate
-+ifdef CONFIG_OCFS2_FS
-+ccflags-y += -DOCFS2_SUPER_MAGIC=0x7461636f
-+endif
-+
-+# defined in ${srctree}/fs/ocfs2/dlm/userdlm.h
-+# tristate
-+ifdef CONFIG_OCFS2_FS_O2CB
-+ccflags-y += -DDLMFS_MAGIC=0x76a9f425
-+endif
-+
-+# defined in ${srctree}/fs/cifs/cifsfs.c
-+# tristate
-+ifdef CONFIG_CIFS_FS
-+ccflags-y += -DCIFS_MAGIC_NUMBER=0xFF534D42
-+endif
-+
 +# defined in ${srctree}/fs/xfs/xfs_sb.h
 +# tristate
 +ifdef CONFIG_XFS_FS
@@ -20925,12 +21469,6 @@ diff -urN /usr/share/empty/fs/aufs/magic.mk linux/fs/aufs/magic.mk
 +ccflags-y += -DCONFIGFS_MAGIC=0x62656570
 +endif
 +
-+# defined in ${srctree}/fs/9p/v9fs.h
-+# tristate
-+ifdef CONFIG_9P_FS
-+ccflags-y += -DV9FS_MAGIC=0x01021997
-+endif
-+
 +# defined in ${srctree}/fs/ubifs/ubifs.h
 +# tristate
 +ifdef CONFIG_UBIFS_FS
@@ -20944,8 +21482,8 @@ 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     2014-08-14 10:15:45.118609182 +0200
-@@ -0,0 +1,42 @@
++++ linux/fs/aufs/Makefile     2015-06-22 08:27:37.874168290 +0200
+@@ -0,0 +1,44 @@
 +
 +include ${src}/magic.mk
 +ifeq (${CONFIG_AUFS_FS},m)
@@ -20982,6 +21520,8 @@ diff -urN /usr/share/empty/fs/aufs/Makefile linux/fs/aufs/Makefile
 +aufs-$(CONFIG_AUFS_HNOTIFY) += hnotify.o
 +aufs-$(CONFIG_AUFS_HFSNOTIFY) += hfsnotify.o
 +aufs-$(CONFIG_AUFS_EXPORT) += export.o
++aufs-$(CONFIG_AUFS_XATTR) += xattr.o
++aufs-$(CONFIG_FS_POSIX_ACL) += posix_acl.o
 +aufs-$(CONFIG_AUFS_FHSM) += fhsm.o
 +aufs-$(CONFIG_AUFS_POLL) += poll.o
 +aufs-$(CONFIG_AUFS_RDU) += rdu.o
@@ -20990,10 +21530,10 @@ diff -urN /usr/share/empty/fs/aufs/Makefile linux/fs/aufs/Makefile
 +aufs-$(CONFIG_AUFS_MAGIC_SYSRQ) += sysrq.o
 diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 --- /usr/share/empty/fs/aufs/module.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/module.c     2014-08-14 10:15:45.128609525 +0200
++++ linux/fs/aufs/module.c     2015-06-22 08:27:37.884168534 +0200
 @@ -0,0 +1,210 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -21204,10 +21744,10 @@ diff -urN /usr/share/empty/fs/aufs/module.c linux/fs/aufs/module.c
 +module_exit(aufs_exit);
 diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 --- /usr/share/empty/fs/aufs/module.h  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/module.h     2014-01-30 21:10:02.850815069 +0100
++++ linux/fs/aufs/module.h     2015-06-22 08:27:37.884168534 +0200
 @@ -0,0 +1,104 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -21312,10 +21852,10 @@ diff -urN /usr/share/empty/fs/aufs/module.h linux/fs/aufs/module.h
 +#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     2014-08-14 10:15:45.128609525 +0200
-@@ -0,0 +1,657 @@
++++ linux/fs/aufs/mvdown.c     2015-06-22 08:27:37.884168534 +0200
+@@ -0,0 +1,694 @@
 +/*
-+ * Copyright (C) 2011-2014 Junjiro R. Okajima
++ * Copyright (C) 2011-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -21343,6 +21883,7 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +              struct dentry *h_parent;
 +              struct au_hinode *hdir;
 +              struct inode *h_dir, *h_inode;
++              struct au_pin pin;
 +      } info[AUFS_MVDOWN_NARRAY];
 +
 +      struct aufs_mvdown mvdown;
@@ -21351,7 +21892,6 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +      struct super_block *sb;
 +      aufs_bindex_t bopq, bwh, bfound;
 +      unsigned char rename_lock;
-+      struct au_pin pin;
 +};
 +
 +#define mvd_errno             mvdown.au_errno
@@ -21365,12 +21905,14 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +#define mvd_hdir_src          info[AUFS_MVDOWN_UPPER].hdir
 +#define mvd_h_src_dir         info[AUFS_MVDOWN_UPPER].h_dir
 +#define mvd_h_src_inode               info[AUFS_MVDOWN_UPPER].h_inode
++#define mvd_pin_src           info[AUFS_MVDOWN_UPPER].pin
 +
 +#define mvd_h_dst_sb          info[AUFS_MVDOWN_LOWER].h_sb
 +#define mvd_h_dst_parent      info[AUFS_MVDOWN_LOWER].h_parent
 +#define mvd_hdir_dst          info[AUFS_MVDOWN_LOWER].hdir
 +#define mvd_h_dst_dir         info[AUFS_MVDOWN_LOWER].h_dir
 +#define mvd_h_dst_inode               info[AUFS_MVDOWN_LOWER].h_inode
++#define mvd_pin_dst           info[AUFS_MVDOWN_LOWER].pin
 +
 +#define AU_MVD_PR(flag, ...) do {                     \
 +              if (flag)                               \
@@ -21447,22 +21989,44 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +
 +      a->mvd_h_src_sb = au_sbr_sb(a->sb, a->mvd_bsrc);
 +      a->mvd_h_dst_sb = au_sbr_sb(a->sb, a->mvd_bdst);
++      err = au_pin(&a->mvd_pin_dst, a->dentry, a->mvd_bdst,
++                   au_opt_udba(a->sb),
++                   AuPin_MNT_WRITE | AuPin_DI_LOCKED);
++      AuTraceErr(err);
++      if (unlikely(err)) {
++              AU_MVD_PR(dmsg, "pin_dst failed\n");
++              goto out;
++      }
++
 +      if (a->mvd_h_src_sb != a->mvd_h_dst_sb) {
 +              a->rename_lock = 0;
-+              err = au_pin(&a->pin, a->dentry, a->mvd_bdst,
-+                           au_opt_udba(a->sb),
-+                           AuPin_MNT_WRITE | AuPin_DI_LOCKED);
-+              if (!err) {
-+                      a->mvd_h_src_dir = a->mvd_h_src_parent->d_inode;
-+                      mutex_lock_nested(&a->mvd_h_src_dir->i_mutex,
-+                                        AuLsc_I_PARENT3);
-+              } else
-+                      AU_MVD_PR(dmsg, "pin failed\n");
-+              goto out;
++              au_pin_init(&a->mvd_pin_src, a->dentry, a->mvd_bsrc,
++                          AuLsc_DI_PARENT, AuLsc_I_PARENT3,
++                          au_opt_udba(a->sb),
++                          AuPin_MNT_WRITE | AuPin_DI_LOCKED);
++              err = au_do_pin(&a->mvd_pin_src);
++              AuTraceErr(err);
++              a->mvd_h_src_dir = a->mvd_h_src_parent->d_inode;
++              if (unlikely(err)) {
++                      AU_MVD_PR(dmsg, "pin_src failed\n");
++                      goto out_dst;
++              }
++              goto out; /* success */
 +      }
 +
-+      err = 0;
 +      a->rename_lock = 1;
++      au_pin_hdir_unlock(&a->mvd_pin_dst);
++      err = au_pin(&a->mvd_pin_src, a->dentry, a->mvd_bsrc,
++                   au_opt_udba(a->sb),
++                   AuPin_MNT_WRITE | AuPin_DI_LOCKED);
++      AuTraceErr(err);
++      a->mvd_h_src_dir = a->mvd_h_src_parent->d_inode;
++      if (unlikely(err)) {
++              AU_MVD_PR(dmsg, "pin_src failed\n");
++              au_pin_hdir_lock(&a->mvd_pin_dst);
++              goto out_dst;
++      }
++      au_pin_hdir_unlock(&a->mvd_pin_src);
 +      h_trap = vfsub_lock_rename(a->mvd_h_src_parent, a->mvd_hdir_src,
 +                                 a->mvd_h_dst_parent, a->mvd_hdir_dst);
 +      if (h_trap) {
@@ -21471,7 +22035,20 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +                      err = (h_trap != a->mvd_h_dst_parent);
 +      }
 +      BUG_ON(err); /* it should never happen */
++      if (unlikely(a->mvd_h_src_dir != au_pinned_h_dir(&a->mvd_pin_src))) {
++              err = -EBUSY;
++              AuTraceErr(err);
++              vfsub_unlock_rename(a->mvd_h_src_parent, a->mvd_hdir_src,
++                                  a->mvd_h_dst_parent, a->mvd_hdir_dst);
++              au_pin_hdir_lock(&a->mvd_pin_src);
++              au_unpin(&a->mvd_pin_src);
++              au_pin_hdir_lock(&a->mvd_pin_dst);
++              goto out_dst;
++      }
++      goto out; /* success */
 +
++out_dst:
++      au_unpin(&a->mvd_pin_dst);
 +out:
 +      AuTraceErr(err);
 +      return err;
@@ -21479,12 +22056,16 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +
 +static void au_do_unlock(const unsigned char dmsg, struct au_mvd_args *a)
 +{
-+      if (!a->rename_lock) {
-+              mutex_unlock(&a->mvd_h_src_dir->i_mutex);
-+              au_unpin(&a->pin);
-+      } else
++      if (!a->rename_lock)
++              au_unpin(&a->mvd_pin_src);
++      else {
 +              vfsub_unlock_rename(a->mvd_h_src_parent, a->mvd_hdir_src,
 +                                  a->mvd_h_dst_parent, a->mvd_hdir_dst);
++              au_pin_hdir_lock(&a->mvd_pin_src);
++              au_unpin(&a->mvd_pin_src);
++              au_pin_hdir_lock(&a->mvd_pin_dst);
++      }
++      au_unpin(&a->mvd_pin_dst);
 +}
 +
 +/* copy-down the file */
@@ -21496,7 +22077,7 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +              .bdst   = a->mvd_bdst,
 +              .bsrc   = a->mvd_bsrc,
 +              .len    = -1,
-+              .pin    = &a->pin,
++              .pin    = &a->mvd_pin_dst,
 +              .flags  = AuCpup_DTIME | AuCpup_HOPEN
 +      };
 +
@@ -21555,8 +22136,6 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +
 +/*
 + * unlink the topmost h_dentry
-+ * Note: the target file MAY be modified by UDBA between this mutex_unlock() and
-+ *    mutex_lock() in vfs_unlink(). in this case, such changes may be lost.
 + */
 +static int au_do_unlink(const unsigned char dmsg, struct au_mvd_args *a)
 +{
@@ -21629,6 +22208,8 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +      if (unlikely(err))
 +              goto out_unlock;
 +
++      AuDbg("%pd2, 0x%x, %d --> %d\n",
++            a->dentry, a->mvdown.flags, a->mvd_bsrc, a->mvd_bdst);
 +      if (find_lower_writable(a) < 0)
 +              a->mvdown.flags |= AUFS_MVDOWN_BOTTOM;
 +
@@ -21664,7 +22245,7 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +      err = 0;
 +      plinked = !!au_opt_test(au_mntflags(a->sb), PLINK);
 +      if (au_dbstart(a->dentry) == a->mvd_bsrc
-+          && d_count(a->dentry) == 1
++          && au_dcount(a->dentry) == 1
 +          && atomic_read(&a->inode->i_count) == 1
 +          /* && a->mvd_h_src_inode->i_nlink == 1 */
 +          && (!plinked || !au_plink_test(a->inode))
@@ -21673,8 +22254,8 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +
 +      err = -EBUSY;
 +      AU_MVD_PR(dmsg,
-+                "b%d, d{b%d, c%u?}, i{c%d?, l%u}, hi{l%u}, p{%d, %d}\n",
-+                a->mvd_bsrc, au_dbstart(a->dentry), d_count(a->dentry),
++                "b%d, d{b%d, c%d?}, i{c%d?, l%u}, hi{l%u}, p{%d, %d}\n",
++                a->mvd_bsrc, au_dbstart(a->dentry), au_dcount(a->dentry),
 +                atomic_read(&a->inode->i_count), a->inode->i_nlink,
 +                a->mvd_h_src_inode->i_nlink,
 +                plinked, plinked ? au_plink_test(a->inode) : 0);
@@ -21942,13 +22523,9 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +      if (unlikely(err))
 +              goto out_parent;
 +
-+      AuDbgDentry(dentry);
-+      AuDbgInode(args->inode);
 +      err = au_do_mvdown(dmsg, args);
 +      if (unlikely(err))
 +              goto out_parent;
-+      AuDbgDentry(dentry);
-+      AuDbgInode(args->inode);
 +
 +      au_cpup_attr_timesizes(args->dir);
 +      au_cpup_attr_timesizes(args->inode);
@@ -21973,10 +22550,10 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c
 +}
 diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 --- /usr/share/empty/fs/aufs/opts.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/opts.c       2014-08-14 10:15:45.128609525 +0200
-@@ -0,0 +1,1790 @@
++++ linux/fs/aufs/opts.c       2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,1854 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -22005,11 +22582,11 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +
 +enum {
 +      Opt_br,
-+      Opt_add, Opt_del, Opt_mod, Opt_reorder, Opt_append, Opt_prepend,
-+      Opt_idel, Opt_imod, Opt_ireorder,
-+      Opt_dirwh, Opt_rdcache, Opt_rdblk, Opt_rdhash, Opt_rendir,
++      Opt_add, Opt_del, Opt_mod, Opt_append, Opt_prepend,
++      Opt_idel, Opt_imod,
++      Opt_dirwh, Opt_rdcache, Opt_rdblk, Opt_rdhash,
 +      Opt_rdblk_def, Opt_rdhash_def,
-+      Opt_xino, Opt_zxino, Opt_noxino,
++      Opt_xino, Opt_noxino,
 +      Opt_trunc_xino, Opt_trunc_xino_v, Opt_notrunc_xino,
 +      Opt_trunc_xino_path, Opt_itrunc_xino,
 +      Opt_trunc_xib, Opt_notrunc_xib,
@@ -22017,8 +22594,6 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      Opt_plink, Opt_noplink, Opt_list_plink,
 +      Opt_udba,
 +      Opt_dio, Opt_nodio,
-+      /* Opt_lock, Opt_unlock, */
-+      Opt_cmd, Opt_cmd_args,
 +      Opt_diropq_a, Opt_diropq_w,
 +      Opt_warn_perm, Opt_nowarn_perm,
 +      Opt_wbr_copyup, Opt_wbr_create,
@@ -22027,6 +22602,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      Opt_verbose, Opt_noverbose,
 +      Opt_sum, Opt_nosum, Opt_wsum,
 +      Opt_dirperm1, Opt_nodirperm1,
++      Opt_acl, Opt_noacl,
 +      Opt_tail, Opt_ignore, Opt_ignore_silent, Opt_err
 +};
 +
@@ -22106,8 +22682,6 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      {Opt_dirperm1, "dirperm1"},
 +      {Opt_nodirperm1, "nodirperm1"},
 +
-+      {Opt_rendir, "rendir=%d"},
-+
 +      {Opt_refrof, "refrof"},
 +      {Opt_norefrof, "norefrof"},
 +
@@ -22134,6 +22708,15 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      {Opt_wbr_copyup, "copyup=%s"},
 +      {Opt_wbr_copyup, "copyup_policy=%s"},
 +
++      /* generic VFS flag */
++#ifdef CONFIG_FS_POSIX_ACL
++      {Opt_acl, "acl"},
++      {Opt_noacl, "noacl"},
++#else
++      {Opt_ignore_silent, "acl"},
++      {Opt_ignore_silent, "noacl"},
++#endif
++
 +      /* internal use for the scripts */
 +      {Opt_ignore_silent, "si=%s"},
 +
@@ -22171,14 +22754,19 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      int v;
 +
 +      v = *val;
++      if (!v)
++              goto out;
 +      p = tbl;
-+      while (p->token) {
-+              if ((v & p->token) == p->token) {
++      while (p->pattern) {
++              if (p->token
++                  && (v & p->token) == p->token) {
 +                      *val &= ~p->token;
 +                      return p->pattern;
 +              }
 +              p++;
 +      }
++
++out:
 +      return NULL;
 +}
 +
@@ -22195,8 +22783,19 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      /* general */
 +      {AuBrAttr_COO_REG, AUFS_BRATTR_COO_REG},
 +      {AuBrAttr_COO_ALL, AUFS_BRATTR_COO_ALL},
++      /* 'unpin' attrib is meaningless since linux-3.18-rc1 */
 +      {AuBrAttr_UNPIN, AUFS_BRATTR_UNPIN},
++#ifdef CONFIG_AUFS_FHSM
 +      {AuBrAttr_FHSM, AUFS_BRATTR_FHSM},
++#endif
++#ifdef CONFIG_AUFS_XATTR
++      {AuBrAttr_ICEX, AUFS_BRATTR_ICEX},
++      {AuBrAttr_ICEX_SEC, AUFS_BRATTR_ICEX_SEC},
++      {AuBrAttr_ICEX_SYS, AUFS_BRATTR_ICEX_SYS},
++      {AuBrAttr_ICEX_TR, AUFS_BRATTR_ICEX_TR},
++      {AuBrAttr_ICEX_USR, AUFS_BRATTR_ICEX_USR},
++      {AuBrAttr_ICEX_OTH, AUFS_BRATTR_ICEX_OTH},
++#endif
 +
 +      /* ro/rr branch */
 +      {AuBrRAttr_WH, AUFS_BRRATTR_WH},
@@ -22242,7 +22841,6 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      const char *p;
 +      char *q;
 +
-+      sz = 0;
 +      q = str->a;
 +      *q = 0;
 +      p = au_optstr(&perm, brattr);
@@ -22264,7 +22862,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +      } while (p);
 +
 +out:
-+      return sz;
++      return q - str->a;
 +}
 +
 +static int noinline_for_stack br_perm_val(char *perm)
@@ -22302,6 +22900,17 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              val &= ~AuBrRAttr_Mask;
 +              break;
 +      }
++
++      /*
++       * 'unpin' attrib becomes meaningless since linux-3.18-rc1, but aufs
++       * does not treat it as an error, just warning.
++       * this is a tiny guard for the user operation.
++       */
++      if (val & AuBrAttr_UNPIN) {
++              bad |= AuBrAttr_UNPIN;
++              val &= ~AuBrAttr_UNPIN;
++      }
++
 +      if (unlikely(bad)) {
 +              sz = au_do_optstr_br_attr(&attr, bad);
 +              AuDebugOn(!sz);
@@ -22589,7 +23198,6 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +                      u.xino_itrunc = &opt->xino_itrunc;
 +                      AuDbg("trunc_xino %d\n", u.xino_itrunc->bindex);
 +                      break;
-+
 +              case Opt_noxino:
 +                      AuLabel(noxino);
 +                      break;
@@ -22691,6 +23299,12 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              case Opt_fhsm_sec:
 +                      AuDbg("fhsm_sec %u\n", opt->fhsm_second);
 +                      break;
++              case Opt_acl:
++                      AuLabel(acl);
++                      break;
++              case Opt_noacl:
++                      AuLabel(noacl);
++                      break;
 +              default:
 +                      BUG();
 +              }
@@ -22872,7 +23486,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              goto out;
 +
 +      err = -EINVAL;
-+      if (unlikely(file->f_dentry->d_sb == sb)) {
++      if (unlikely(file->f_path.dentry->d_sb == sb)) {
 +              fput(file);
 +              pr_err("%s must be outside\n", args[0].from);
 +              goto out;
@@ -23137,6 +23751,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              case Opt_wsum:
 +              case Opt_rdblk_def:
 +              case Opt_rdhash_def:
++              case Opt_acl:
++              case Opt_noacl:
 +                      err = 0;
 +                      opt->type = token;
 +                      break;
@@ -23406,6 +24022,13 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              au_fclr_opts(opts->flags, TRUNC_XIB);
 +              break;
 +
++      case Opt_acl:
++              sb->s_flags |= MS_POSIXACL;
++              break;
++      case Opt_noacl:
++              sb->s_flags &= ~MS_POSIXACL;
++              break;
++
 +      default:
 +              err = 0;
 +              break;
@@ -23491,7 +24114,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              au_xino_brid_set(sb, -1);
 +
 +              /* safe d_parent access */
-+              parent = opt->xino.file->f_dentry->d_parent;
++              parent = opt->xino.file->f_path.dentry->d_parent;
 +              root = sb->s_root;
 +              bend = au_sbend(sb);
 +              for (bindex = 0; bindex <= bend; bindex++) {
@@ -23556,8 +24179,17 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              skip = 0;
 +              h_dir = au_h_iptr(dir, bindex);
 +              br = au_sbr(sb, bindex);
-+              do_free = 0;
 +
++              if ((br->br_perm & AuBrAttr_ICEX)
++                  && !h_dir->i_op->listxattr)
++                      br->br_perm &= ~AuBrAttr_ICEX;
++#if 0
++              if ((br->br_perm & AuBrAttr_ICEX_SEC)
++                  && (au_br_sb(br)->s_flags & MS_NOSEC))
++                      br->br_perm &= ~AuBrAttr_ICEX_SEC;
++#endif
++
++              do_free = 0;
 +              wbr = br->br_wbr;
 +              if (wbr)
 +                      wbr_wh_read_lock(wbr);
@@ -23613,10 +24245,19 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +              }
 +      }
 +
-+      if (fhsm >= 2)
++      if (fhsm >= 2) {
 +              au_fset_si(sbinfo, FHSM);
-+      else
++              for (bindex = bend; bindex >= 0; bindex--) {
++                      br = au_sbr(sb, bindex);
++                      if (au_br_fhsm(br->br_perm)) {
++                              au_fhsm_set_bottom(sb, bindex);
++                              break;
++                      }
++              }
++      } else {
 +              au_fclr_si(sbinfo, FHSM);
++              au_fhsm_set_bottom(sb, -1);
++      }
 +
 +      return err;
 +}
@@ -23767,10 +24408,10 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c
 +}
 diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 --- /usr/share/empty/fs/aufs/opts.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/opts.h       2014-08-14 10:15:45.128609525 +0200
-@@ -0,0 +1,213 @@
++++ linux/fs/aufs/opts.h       2015-06-22 08:27:37.887501948 +0200
+@@ -0,0 +1,211 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -23796,7 +24437,6 @@ diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 +#ifdef __KERNEL__
 +
 +#include <linux/path.h>
-+#include "branch.h"
 +
 +struct file;
 +struct super_block;
@@ -23964,6 +24604,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 +
 +/* ---------------------------------------------------------------------- */
 +
++/* opts.c */
 +void au_optstr_br_perm(au_br_perm_str_t *str, int perm);
 +const char *au_optstr_udba(int udba);
 +const char *au_optstr_wbr_copyup(int wbr_copyup);
@@ -23978,16 +24619,14 @@ diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h
 +
 +unsigned int au_opt_udba(struct super_block *sb);
 +
-+/* ---------------------------------------------------------------------- */
-+
 +#endif /* __KERNEL__ */
 +#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      2014-01-30 21:10:02.857481956 +0100
++++ linux/fs/aufs/plink.c      2015-06-22 08:27:37.887501948 +0200
 @@ -0,0 +1,532 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -24520,10 +25159,10 @@ diff -urN /usr/share/empty/fs/aufs/plink.c linux/fs/aufs/plink.c
 +}
 diff -urN /usr/share/empty/fs/aufs/poll.c linux/fs/aufs/poll.c
 --- /usr/share/empty/fs/aufs/poll.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/poll.c       2014-01-30 21:10:02.857481956 +0100
-@@ -0,0 +1,55 @@
++++ linux/fs/aufs/poll.c       2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,52 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -24551,38 +25190,138 @@ diff -urN /usr/share/empty/fs/aufs/poll.c linux/fs/aufs/poll.c
 +      unsigned int mask;
 +      int err;
 +      struct file *h_file;
-+      struct dentry *dentry;
 +      struct super_block *sb;
 +
 +      /* We should pretend an error happened. */
 +      mask = POLLERR /* | POLLIN | POLLOUT */;
-+      dentry = file->f_dentry;
-+      sb = dentry->d_sb;
++      sb = file->f_path.dentry->d_sb;
 +      si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLMW);
-+      err = au_reval_and_lock_fdi(file, au_reopen_nondir, /*wlock*/0);
-+      if (unlikely(err))
++
++      h_file = au_read_pre(file, /*keep_fi*/0);
++      err = PTR_ERR(h_file);
++      if (IS_ERR(h_file))
 +              goto out;
 +
 +      /* it is not an error if h_file has no operation */
 +      mask = DEFAULT_POLLMASK;
-+      h_file = au_hf_top(file);
 +      if (h_file->f_op->poll)
 +              mask = h_file->f_op->poll(h_file, wait);
-+
-+      di_read_unlock(dentry, AuLock_IR);
-+      fi_read_unlock(file);
++      fput(h_file); /* instead of au_read_post() */
 +
 +out:
 +      si_read_unlock(sb);
 +      AuTraceErr((int)mask);
 +      return mask;
 +}
+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  2015-06-22 08:27:37.887501948 +0200
+@@ -0,0 +1,99 @@
++/*
++ * Copyright (C) 2014-2015 Junjiro R. Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
++ */
++
++/*
++ * posix acl operations
++ */
++
++#include <linux/fs.h>
++#include <linux/posix_acl.h>
++#include "aufs.h"
++
++struct posix_acl *aufs_get_acl(struct inode *inode, int type)
++{
++      struct posix_acl *acl;
++      int err;
++      aufs_bindex_t bindex;
++      struct inode *h_inode;
++      struct super_block *sb;
++
++      acl = NULL;
++      sb = inode->i_sb;
++      si_read_lock(sb, AuLock_FLUSH);
++      ii_read_lock_child(inode);
++      if (!(sb->s_flags & MS_POSIXACL))
++              goto out;
++
++      bindex = au_ibstart(inode);
++      h_inode = au_h_iptr(inode, bindex);
++      if (unlikely(!h_inode
++                   || ((h_inode->i_mode & S_IFMT)
++                       != (inode->i_mode & S_IFMT)))) {
++              err = au_busy_or_stale();
++              acl = ERR_PTR(err);
++              goto out;
++      }
++
++      /* always topmost only */
++      acl = get_acl(h_inode, type);
++
++out:
++      ii_read_unlock(inode);
++      si_read_unlock(sb);
++
++      AuTraceErrPtr(acl);
++      return acl;
++}
++
++int aufs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
++{
++      int err;
++      ssize_t ssz;
++      struct dentry *dentry;
++      struct au_srxattr arg = {
++              .type = AU_ACL_SET,
++              .u.acl_set = {
++                      .acl    = acl,
++                      .type   = type
++              },
++      };
++
++      mutex_lock(&inode->i_mutex);
++      if (inode->i_ino == AUFS_ROOT_INO)
++              dentry = dget(inode->i_sb->s_root);
++      else {
++              dentry = d_find_alias(inode);
++              if (!dentry)
++                      dentry = d_find_any_alias(inode);
++              if (!dentry) {
++                      pr_warn("cannot handle this inode, "
++                              "please report to aufs-users ML\n");
++                      err = -ENOENT;
++                      goto out;
++              }
++      }
++
++      ssz = au_srxattr(dentry, &arg);
++      dput(dentry);
++      err = ssz;
++      if (ssz >= 0)
++              err = 0;
++
++out:
++      mutex_unlock(&inode->i_mutex);
++      return err;
++}
 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     2014-01-30 21:10:02.857481956 +0100
++++ linux/fs/aufs/procfs.c     2015-06-22 08:27:37.887501948 +0200
 @@ -0,0 +1,169 @@
 +/*
-+ * Copyright (C) 2010-2014 Junjiro R. Okajima
++ * Copyright (C) 2010-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -24752,10 +25491,10 @@ diff -urN /usr/share/empty/fs/aufs/procfs.c linux/fs/aufs/procfs.c
 +}
 diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 --- /usr/share/empty/fs/aufs/rdu.c     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/rdu.c        2014-01-30 21:10:02.857481956 +0100
++++ linux/fs/aufs/rdu.c        2015-06-22 08:29:23.710091096 +0200
 @@ -0,0 +1,388 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -24881,7 +25620,7 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +      aufs_bindex_t bend;
 +      struct au_rdu_arg arg = {
 +              .ctx = {
-+                      .actor = au_diractor(au_rdu_fill)
++                      .actor = au_rdu_fill
 +              }
 +      };
 +      struct dentry *dentry;
@@ -24912,7 +25651,7 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +      if (unlikely(err))
 +              goto out;
 +
-+      dentry = file->f_dentry;
++      dentry = file->f_path.dentry;
 +      inode = dentry->d_inode;
 +#if 1
 +      mutex_lock(&inode->i_mutex);
@@ -24996,7 +25735,7 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +      err = 0;
 +      nent = rdu->nent;
 +      u = &rdu->ent;
-+      sb = file->f_dentry->d_sb;
++      sb = file->f_path.dentry->d_sb;
 +      si_read_lock(sb, AuLock_FLUSH);
 +      while (nent-- > 0) {
 +              /* unnecessary to support mmap_sem since this is a dir */
@@ -25144,10 +25883,10 @@ diff -urN /usr/share/empty/fs/aufs/rdu.c linux/fs/aufs/rdu.c
 +#endif
 diff -urN /usr/share/empty/fs/aufs/rwsem.h linux/fs/aufs/rwsem.h
 --- /usr/share/empty/fs/aufs/rwsem.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/rwsem.h      2014-08-14 10:15:45.128609525 +0200
++++ linux/fs/aufs/rwsem.h      2015-06-22 08:27:37.887501948 +0200
 @@ -0,0 +1,191 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25339,10 +26078,10 @@ diff -urN /usr/share/empty/fs/aufs/rwsem.h linux/fs/aufs/rwsem.h
 +#endif /* __AUFS_RWSEM_H__ */
 diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 --- /usr/share/empty/fs/aufs/sbinfo.c  1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sbinfo.c     2014-08-14 10:15:45.128609525 +0200
-@@ -0,0 +1,353 @@
++++ linux/fs/aufs/sbinfo.c     2015-06-22 08:27:37.887501948 +0200
+@@ -0,0 +1,354 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25451,6 +26190,8 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +      sbinfo->si_xino_brid = -1;
 +      /* leave si_xib_last_pindex and si_xib_next_bit */
 +
++      au_sphl_init(&sbinfo->si_aopen);
++
 +      sbinfo->si_rdcache = msecs_to_jiffies(AUFS_RDCACHE_DEF * MSEC_PER_SEC);
 +      sbinfo->si_rdblk = AUFS_RDBLK_DEF;
 +      sbinfo->si_rdhash = AUFS_RDHASH_DEF;
@@ -25467,7 +26208,6 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +      sbinfo->si_sb = sb;
 +      sb->s_fs_info = sbinfo;
 +      si_pid_set(sb);
-+      au_debug_sbinfo_init(sbinfo);
 +      return 0; /* success */
 +
 +out_br:
@@ -25696,10 +26436,10 @@ diff -urN /usr/share/empty/fs/aufs/sbinfo.c linux/fs/aufs/sbinfo.c
 +}
 diff -urN /usr/share/empty/fs/aufs/spl.h linux/fs/aufs/spl.h
 --- /usr/share/empty/fs/aufs/spl.h     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/spl.h        2014-01-30 21:10:02.857481956 +0100
++++ linux/fs/aufs/spl.h        2015-06-22 08:27:37.887501948 +0200
 @@ -0,0 +1,111 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25811,10 +26551,10 @@ diff -urN /usr/share/empty/fs/aufs/spl.h linux/fs/aufs/spl.h
 +#endif /* __AUFS_SPL_H__ */
 diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 --- /usr/share/empty/fs/aufs/super.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/super.c      2014-08-14 10:15:45.131942973 +0200
-@@ -0,0 +1,1004 @@
++++ linux/fs/aufs/super.c      2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,1007 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -25835,11 +26575,9 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 + */
 +
 +#include <linux/mm.h>
-+#include <linux/module.h>
 +#include <linux/seq_file.h>
 +#include <linux/statfs.h>
 +#include <linux/vmalloc.h>
-+#include <linux/writeback.h>
 +#include "aufs.h"
 +
 +/*
@@ -26011,7 +26749,7 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +              hdp = au_di(sb->s_root)->di_hdentry;
 +              h_root = hdp[0 + bindex].hd_dentry;
 +      }
-+      d = f->f_dentry;
++      d = f->f_path.dentry;
 +      name = &d->d_name;
 +      /* safe ->d_parent because the file is unlinked */
 +      if (d->d_parent == h_root
@@ -26052,8 +26790,11 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +              seq_printf(m, "," #str "=%u", val); \
 +} while (0)
 +
-+      /* lock free root dinfo */
 +      sb = dentry->d_sb;
++      if (sb->s_flags & MS_POSIXACL)
++              seq_puts(m, ",acl");
++
++      /* lock free root dinfo */
 +      si_noflush_read_lock(sb);
 +      sbinfo = au_sbi(sb);
 +      seq_printf(m, ",si=%lx", sysaufs_si_id(sbinfo));
@@ -26711,7 +27452,9 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +      sb->s_d_op = &aufs_dop;
 +      sb->s_magic = AUFS_SUPER_MAGIC;
 +      sb->s_maxbytes = 0;
++      sb->s_stack_depth = 1;
 +      au_export_init(sb);
++      /* au_xattr_init(sb); */
 +
 +      err = alloc_root(sb);
 +      if (unlikely(err)) {
@@ -26819,10 +27562,10 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c
 +};
 diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 --- /usr/share/empty/fs/aufs/super.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/super.h      2014-08-14 10:15:45.131942973 +0200
-@@ -0,0 +1,642 @@
++++ linux/fs/aufs/super.h      2015-06-22 08:27:37.887501948 +0200
+@@ -0,0 +1,638 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -26907,8 +27650,9 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      wait_queue_head_t       fhsm_wqh;
 +      atomic_t                fhsm_readable;
 +
-+      /* only this is protected by si_rwsem */
++      /* these are protected by si_rwsem */
 +      unsigned long           fhsm_expire;
++      aufs_bindex_t           fhsm_bottom;
 +#endif
 +};
 +
@@ -26939,7 +27683,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      /* branch management */
 +      unsigned int            si_generation;
 +
-+      /* see above flags */
++      /* see AuSi_ flags */
 +      unsigned char           au_si_status;
 +
 +      aufs_bindex_t           si_bend;
@@ -26988,6 +27732,9 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      atomic_t                si_xigen_next;
 +#endif
 +
++      /* dirty trick to suppoer atomic_open */
++      struct au_sphlhead      si_aopen;
++
 +      /* vdir parameters */
 +      unsigned long           si_rdcache;     /* max cache time in jiffies */
 +      unsigned int            si_rdblk;       /* deblk size */
@@ -27001,12 +27748,6 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +       */
 +      unsigned int            si_dirwh;
 +
-+      /*
-+       * rename(2) a directory with all children.
-+       */
-+      /* reserved for future use */
-+      /* int                  si_rendir; */
-+
 +      /* pseudo_link list */
 +      struct au_sphlhead      si_plink[AuPlink_NHASH];
 +      wait_queue_head_t       si_plink_wq;
@@ -27155,6 +27896,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +void au_fhsm_wrote_all(struct super_block *sb, int force);
 +int au_fhsm_fd(struct super_block *sb, int oflags);
 +int au_fhsm_br_alloc(struct au_branch *br);
++void au_fhsm_set_bottom(struct super_block *sb, aufs_bindex_t bindex);
 +void au_fhsm_fin(struct super_block *sb);
 +void au_fhsm_init(struct au_sbinfo *sbinfo);
 +void au_fhsm_set(struct au_sbinfo *sbinfo, unsigned int sec);
@@ -27164,8 +27906,9 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +         int force)
 +AuStubVoid(au_fhsm_wrote_all, struct super_block *sb, int force)
 +AuStub(int, au_fhsm_fd, return -EOPNOTSUPP, struct super_block *sb, int oflags)
-+AuStub(pid_t, au_fhsm_pid, return 0, struct au_fhsm *fhsm);
-+AuStubInt0(au_fhsm_br_alloc, struct au_branch *br);
++AuStub(pid_t, au_fhsm_pid, return 0, struct au_fhsm *fhsm)
++AuStubInt0(au_fhsm_br_alloc, struct au_branch *br)
++AuStubVoid(au_fhsm_set_bottom, struct super_block *sb, aufs_bindex_t bindex)
 +AuStubVoid(au_fhsm_fin, struct super_block *sb)
 +AuStubVoid(au_fhsm_init, struct au_sbinfo *sbinfo)
 +AuStubVoid(au_fhsm_set, struct au_sbinfo *sbinfo, unsigned int sec)
@@ -27202,10 +27945,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +AuStubInt0(au_xigen_new, struct inode *inode)
 +AuStubInt0(au_xigen_set, struct super_block *sb, struct file *base)
 +AuStubVoid(au_xigen_clr, struct super_block *sb)
-+static inline int au_busy_or_stale(void)
-+{
-+      return -EBUSY;
-+}
++AuStub(int, au_busy_or_stale, return -EBUSY, void)
 +#endif /* CONFIG_AUFS_EXPORT */
 +
 +/* ---------------------------------------------------------------------- */
@@ -27247,8 +27987,8 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +#endif /* CONFIG_AUFS_MAGIC_SYSRQ */
 +#else
 +AuStubVoid(au_sbilist_init, void)
-+AuStubVoid(au_sbilist_add, struct super_block*)
-+AuStubVoid(au_sbilist_del, struct super_block*)
++AuStubVoid(au_sbilist_add, struct super_block *sb)
++AuStubVoid(au_sbilist_del, struct super_block *sb)
 +AuStubVoid(au_sbilist_lock, void)
 +AuStubVoid(au_sbilist_unlock, void)
 +#define AuGFP_SBILIST GFP_NOFS
@@ -27259,7 +27999,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +static inline void dbgaufs_si_null(struct au_sbinfo *sbinfo)
 +{
 +      /*
-+       * This function is a dynamic '__init' fucntion actually,
++       * This function is a dynamic '__init' function actually,
 +       * so the tiny check for si_rwsem is unnecessary.
 +       */
 +      /* AuRwMustWriteLock(&sbinfo->si_rwsem); */
@@ -27288,8 +28028,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      bit = si_pid_bit();
 +      if (bit < PID_MAX_DEFAULT)
 +              return test_bit(bit, au_sbi(sb)->au_si_pid.bitmap);
-+      else
-+              return si_pid_test_slow(sb);
++      return si_pid_test_slow(sb);
 +}
 +
 +static inline void si_pid_set(struct super_block *sb)
@@ -27363,7 +28102,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      return locked;
 +}
 +
-+#if 0 /* unused */
++#if 0 /* reserved */
 +static inline int si_read_trylock(struct super_block *sb, int flags)
 +{
 +      if (au_ftest_lock(flags, FLUSH))
@@ -27378,7 +28117,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      __si_read_unlock(sb);
 +}
 +
-+#if 0 /* unused */
++#if 0 /* reserved */
 +static inline int si_write_trylock(struct super_block *sb, int flags)
 +{
 +      if (au_ftest_lock(flags, FLUSH))
@@ -27393,7 +28132,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +      __si_write_unlock(sb);
 +}
 +
-+#if 0 /* unused */
++#if 0 /* reserved */
 +static inline void si_downgrade_lock(struct super_block *sb)
 +{
 +      __si_downgrade_lock(sb);
@@ -27465,10 +28204,10 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h
 +#endif /* __AUFS_SUPER_H__ */
 diff -urN /usr/share/empty/fs/aufs/sysaufs.c linux/fs/aufs/sysaufs.c
 --- /usr/share/empty/fs/aufs/sysaufs.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sysaufs.c    2014-01-30 21:10:02.857481956 +0100
++++ linux/fs/aufs/sysaufs.c    2015-06-22 08:27:37.887501948 +0200
 @@ -0,0 +1,104 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -27573,10 +28312,10 @@ diff -urN /usr/share/empty/fs/aufs/sysaufs.c linux/fs/aufs/sysaufs.c
 +}
 diff -urN /usr/share/empty/fs/aufs/sysaufs.h linux/fs/aufs/sysaufs.h
 --- /usr/share/empty/fs/aufs/sysaufs.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sysaufs.h    2014-08-14 10:15:45.131942973 +0200
-@@ -0,0 +1,107 @@
++++ linux/fs/aufs/sysaufs.h    2015-06-22 08:27:37.887501948 +0200
+@@ -0,0 +1,101 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -27661,14 +28400,8 @@ diff -urN /usr/share/empty/fs/aufs/sysaufs.h linux/fs/aufs/sysaufs.h
 +#define sysaufs_attr_group    NULL
 +
 +AuStubInt0(sysaufs_si_xi_path, struct seq_file *seq, struct super_block *sb)
-+
-+static inline
-+ssize_t sysaufs_si_show(struct kobject *kobj, struct attribute *attr,
-+                       char *buf)
-+{
-+      return 0;
-+}
-+
++AuStub(ssize_t, sysaufs_si_show, return 0, struct kobject *kobj,
++       struct attribute *attr, char *buf)
 +AuStubVoid(sysaufs_br_init, struct au_branch *br)
 +AuStubVoid(sysaufs_brs_add, struct super_block *sb, aufs_bindex_t bindex)
 +AuStubVoid(sysaufs_brs_del, struct super_block *sb, aufs_bindex_t bindex)
@@ -27684,10 +28417,10 @@ diff -urN /usr/share/empty/fs/aufs/sysaufs.h linux/fs/aufs/sysaufs.h
 +#endif /* __SYSAUFS_H__ */
 diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 --- /usr/share/empty/fs/aufs/sysfs.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/sysfs.c      2014-08-14 10:15:45.131942973 +0200
++++ linux/fs/aufs/sysfs.c      2015-06-22 08:29:23.710091096 +0200
 @@ -0,0 +1,372 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -27974,13 +28707,13 @@ diff -urN /usr/share/empty/fs/aufs/sysfs.c linux/fs/aufs/sysfs.c
 +
 +long au_brinfo_ioctl(struct file *file, unsigned long arg)
 +{
-+      return au_brinfo(file->f_dentry->d_sb, (void __user *)arg);
++      return au_brinfo(file->f_path.dentry->d_sb, (void __user *)arg);
 +}
 +
 +#ifdef CONFIG_COMPAT
 +long au_brinfo_compat_ioctl(struct file *file, unsigned long arg)
 +{
-+      return au_brinfo(file->f_dentry->d_sb, compat_ptr(arg));
++      return au_brinfo(file->f_path.dentry->d_sb, compat_ptr(arg));
 +}
 +#endif
 +
@@ -28060,10 +28793,10 @@ 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      2014-08-14 10:15:45.131942973 +0200
++++ linux/fs/aufs/sysrq.c      2015-06-22 08:27:37.887501948 +0200
 @@ -0,0 +1,157 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -28221,10 +28954,10 @@ diff -urN /usr/share/empty/fs/aufs/sysrq.c linux/fs/aufs/sysrq.c
 +}
 diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 --- /usr/share/empty/fs/aufs/vdir.c    1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/vdir.c       2014-08-14 10:15:45.131942973 +0200
-@@ -0,0 +1,889 @@
++++ linux/fs/aufs/vdir.c       2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,888 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -28590,7 +29323,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      struct super_block *sb;
 +      int err;
 +
-+      sb = file->f_dentry->d_sb;
++      sb = file->f_path.dentry->d_sb;
 +      SiMustAnyLock(sb);
 +
 +      err = -ENOMEM;
@@ -28684,7 +29417,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      const unsigned char shwh = !!au_ftest_fillvdir(arg->flags, SHWH);
 +
 +      arg->err = 0;
-+      sb = arg->file->f_dentry->d_sb;
++      sb = arg->file->f_path.dentry->d_sb;
 +      au_fset_fillvdir(arg->flags, CALLED);
 +      /* smp_mb(); */
 +      if (nlen <= AUFS_WH_PFX_LEN
@@ -28693,7 +29426,6 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +                  || au_nhash_test_known_wh(&arg->whlist, name, nlen))
 +                      goto out; /* already exists or whiteouted */
 +
-+              sb = arg->file->f_dentry->d_sb;
 +              arg->err = au_ino(sb, arg->bindex, h_ino, d_type, &ino);
 +              if (!arg->err) {
 +                      if (unlikely(nlen > AUFS_MAX_NAMELEN))
@@ -28783,7 +29515,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      struct super_block *sb;
 +
 +      file = arg->file;
-+      sb = file->f_dentry->d_sb;
++      sb = file->f_path.dentry->d_sb;
 +      SiMustAnyLock(sb);
 +
 +      rdhash = au_sbi(sb)->si_rdhash;
@@ -28854,7 +29586,7 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +      unsigned char do_read;
 +      struct fillvdir_arg arg = {
 +              .ctx = {
-+                      .actor = au_diractor(fillvdir)
++                      .actor = fillvdir
 +              }
 +      };
 +      struct inode *inode;
@@ -29114,10 +29846,10 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c
 +}
 diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 --- /usr/share/empty/fs/aufs/vfsub.c   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/vfsub.c      2014-08-14 10:16:04.515942371 +0200
-@@ -0,0 +1,782 @@
++++ linux/fs/aufs/vfsub.c      2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,846 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -29137,7 +29869,6 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 + * sub-routines for VFS
 + */
 +
-+#include <linux/ima.h>
 +#include <linux/namei.h>
 +#include <linux/security.h>
 +#include <linux/splice.h>
@@ -29195,6 +29926,57 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      return file;
 +}
 +
++/*
++ * Ideally this function should call VFS:do_last() in order to keep all its
++ * checkings. But it is very hard for aufs to regenerate several VFS internal
++ * structure such as nameidata. This is a second (or third) best approach.
++ * cf. linux/fs/namei.c:do_last(), lookup_open() and atomic_open().
++ */
++int vfsub_atomic_open(struct inode *dir, struct dentry *dentry,
++                    struct vfsub_aopen_args *args, struct au_branch *br)
++{
++      int err;
++      struct file *file = args->file;
++      /* copied from linux/fs/namei.c:atomic_open() */
++      struct dentry *const DENTRY_NOT_SET = (void *)-1UL;
++
++      IMustLock(dir);
++      AuDebugOn(!dir->i_op->atomic_open);
++
++      err = au_br_test_oflag(args->open_flag, br);
++      if (unlikely(err))
++              goto out;
++
++      args->file->f_path.dentry = DENTRY_NOT_SET;
++      args->file->f_path.mnt = au_br_mnt(br);
++      err = dir->i_op->atomic_open(dir, dentry, file, args->open_flag,
++                                   args->create_mode, args->opened);
++      if (err >= 0) {
++              /* some filesystems don't set FILE_CREATED while succeeded? */
++              if (*args->opened & FILE_CREATED)
++                      fsnotify_create(dir, dentry);
++      } else
++              goto out;
++
++
++      if (!err) {
++              /* todo: call VFS:may_open() here */
++              err = open_check_o_direct(file);
++              /* todo: ima_file_check() too? */
++              if (!err && (args->open_flag & __FMODE_EXEC))
++                      err = deny_write_access(file);
++              if (unlikely(err))
++                      /* note that the file is created and still opened */
++                      goto out;
++      }
++
++      atomic_inc(&br->br_count);
++      fsnotify_open(file);
++
++out:
++      return err;
++}
++
 +int vfsub_kern_path(const char *name, unsigned int flags, struct path *path)
 +{
 +      int err;
@@ -29276,7 +30058,9 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      if (unlikely(err))
 +              goto out;
 +
++      lockdep_off();
 +      err = vfs_create(dir, path->dentry, mode, want_excl);
++      lockdep_on();
 +      if (!err) {
 +              struct path tmp = *path;
 +              int did;
@@ -29307,7 +30091,9 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      if (unlikely(err))
 +              goto out;
 +
++      lockdep_off();
 +      err = vfs_symlink(dir, path->dentry, symname);
++      lockdep_on();
 +      if (!err) {
 +              struct path tmp = *path;
 +              int did;
@@ -29338,7 +30124,9 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      if (unlikely(err))
 +              goto out;
 +
++      lockdep_off();
 +      err = vfs_mknod(dir, path->dentry, mode, dev);
++      lockdep_on();
 +      if (!err) {
 +              struct path tmp = *path;
 +              int did;
@@ -29464,7 +30252,9 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      if (unlikely(err))
 +              goto out;
 +
++      lockdep_off();
 +      err = vfs_mkdir(dir, path->dentry, mode);
++      lockdep_on();
 +      if (!err) {
 +              struct path tmp = *path;
 +              int did;
@@ -29582,7 +30372,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +
 +      err = 0;
 +      if (file->f_op->flush) {
-+              if (!au_test_nfs(file->f_dentry->d_sb))
++              if (!au_test_nfs(file->f_path.dentry->d_sb))
 +                      err = file->f_op->flush(file, id);
 +              else {
 +                      lockdep_off();
@@ -29710,9 +30500,11 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      int err, do_sio, wkq_err;
 +
 +      do_sio = au_test_h_perm_sio(dir, MAY_EXEC | MAY_WRITE);
-+      if (!do_sio)
++      if (!do_sio) {
++              lockdep_off();
 +              err = vfsub_mkdir(dir, path, mode);
-+      else {
++              lockdep_on();
++      } else {
 +              struct au_vfsub_mkdir_args args = {
 +                      .errp   = &err,
 +                      .dir    = dir,
@@ -29744,9 +30536,11 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      int err, do_sio, wkq_err;
 +
 +      do_sio = au_test_h_perm_sio(dir, MAY_EXEC | MAY_WRITE);
-+      if (!do_sio)
++      if (!do_sio) {
++              lockdep_off();
 +              err = vfsub_rmdir(dir, path);
-+      else {
++              lockdep_on();
++      } else {
 +              struct au_vfsub_rmdir_args args = {
 +                      .errp   = &err,
 +                      .dir    = dir,
@@ -29779,8 +30573,10 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +
 +      *a->errp = -EPERM;
 +      if (!IS_IMMUTABLE(h_inode) && !IS_APPEND(h_inode)) {
++              lockdep_off();
 +              *a->errp = notify_change(a->path->dentry, a->ia,
 +                                       a->delegated_inode);
++              lockdep_on();
 +              if (!*a->errp)
 +                      vfsub_update_h_iattr(a->path, /*did*/NULL); /*ignore*/
 +      }
@@ -29836,7 +30632,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +      struct dentry *d = a->path->dentry;
 +      struct inode *h_inode;
 +      const int stop_sillyrename = (au_test_nfs(d->d_sb)
-+                                    && d_count(d) == 1);
++                                    && au_dcount(d) == 1);
 +
 +      IMustLock(a->dir);
 +
@@ -29900,10 +30696,10 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c
 +}
 diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 --- /usr/share/empty/fs/aufs/vfsub.h   1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/vfsub.h      2014-08-14 10:15:45.131942973 +0200
-@@ -0,0 +1,284 @@
++++ linux/fs/aufs/vfsub.h      2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,286 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -29929,14 +30725,15 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +#ifdef __KERNEL__
 +
 +#include <linux/fs.h>
-+#include <linux/lglock.h>
 +#include <linux/mount.h>
++#include <linux/xattr.h>
 +#include "debug.h"
 +
 +/* copied from linux/fs/internal.h */
 +/* todo: BAD approach!! */
 +extern void __mnt_drop_write(struct vfsmount *);
 +extern spinlock_t inode_sb_list_lock;
++extern int open_check_o_direct(struct file *f);
 +
 +/* ---------------------------------------------------------------------- */
 +
@@ -29944,7 +30741,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +/* default MAX_LOCKDEP_SUBCLASSES(8) is not enough */
 +/* reduce? gave up. */
 +enum {
-+      AuLsc_I_Begin = I_MUTEX_NONDIR2, /* 4 */
++      AuLsc_I_Begin = I_MUTEX_PARENT2, /* 5 */
 +      AuLsc_I_PARENT,         /* lower inode, parent first */
 +      AuLsc_I_PARENT2,        /* copyup dirs */
 +      AuLsc_I_PARENT3,        /* copyup wh */
@@ -29985,6 +30782,15 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +int vfsub_update_h_iattr(struct path *h_path, int *did);
 +struct file *vfsub_dentry_open(struct path *path, int flags);
 +struct file *vfsub_filp_open(const char *path, int oflags, int mode);
++struct vfsub_aopen_args {
++      struct file     *file;
++      unsigned int    open_flag;
++      umode_t         create_mode;
++      int             *opened;
++};
++struct au_branch;
++int vfsub_atomic_open(struct inode *dir, struct dentry *dentry,
++                    struct vfsub_aopen_args *args, struct au_branch *br);
 +int vfsub_kern_path(const char *name, unsigned int flags, struct path *path);
 +
 +struct dentry *vfsub_lookup_one_len(const char *name, struct dentry *parent,
@@ -30023,12 +30829,14 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +      lockdep_on();
 +}
 +
++#if 0 /* reserved */
 +static inline void vfsub_mnt_drop_write_file(struct file *file)
 +{
 +      lockdep_off();
 +      mnt_drop_write_file(file);
 +      lockdep_on();
 +}
++#endif
 +
 +/* ---------------------------------------------------------------------- */
 +
@@ -30064,15 +30872,6 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +int vfsub_flush(struct file *file, fl_owner_t id);
 +int vfsub_iterate_dir(struct file *file, struct dir_context *ctx);
 +
-+/* just for type-check */
-+static inline filldir_t au_diractor(int (*func)(struct dir_context *,
-+                                              const char *, int, loff_t, u64,
-+                                              unsigned))
-+{
-+      return (filldir_t)func;
-+}
-+
-+
 +static inline loff_t vfsub_f_size_read(struct file *file)
 +{
 +      return i_size_read(file_inode(file));
@@ -30089,11 +30888,13 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +      return flags;
 +}
 +
++#if 0 /* reserved */
 +static inline void vfsub_file_accessed(struct file *h_file)
 +{
 +      file_accessed(h_file);
 +      vfsub_update_h_iattr(&h_file->f_path, /*did*/NULL); /*ignore*/
 +}
++#endif
 +
 +static inline void vfsub_touch_atime(struct vfsmount *h_mnt,
 +                                   struct dentry *h_dentry)
@@ -30109,7 +30910,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +static inline int vfsub_update_time(struct inode *h_inode, struct timespec *ts,
 +                                  int flags)
 +{
-+      return update_time(h_inode, ts, flags);
++      return generic_update_time(h_inode, ts, flags);
 +      /* no vfsub_update_h_iattr() since we don't have struct path */
 +}
 +
@@ -30147,51 +30948,48 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h
 +
 +/* ---------------------------------------------------------------------- */
 +
-+/* dirty workaround for strict type of fmode_t */
-+union vfsub_fmu {
-+      fmode_t fm;
-+      unsigned int ui;
-+};
++int vfsub_sio_mkdir(struct inode *dir, struct path *path, int mode);
++int vfsub_sio_rmdir(struct inode *dir, struct path *path);
++int vfsub_sio_notify_change(struct path *path, struct iattr *ia,
++                          struct inode **delegated_inode);
++int vfsub_notify_change(struct path *path, struct iattr *ia,
++                      struct inode **delegated_inode);
++int vfsub_unlink(struct inode *dir, struct path *path,
++               struct inode **delegated_inode, int force);
 +
-+static inline unsigned int vfsub_fmode_to_uint(fmode_t fm)
++/* ---------------------------------------------------------------------- */
++
++static inline int vfsub_setxattr(struct dentry *dentry, const char *name,
++                               const void *value, size_t size, int flags)
 +{
-+      union vfsub_fmu u = {
-+              .fm = fm
-+      };
++      int err;
 +
-+      BUILD_BUG_ON(sizeof(u.fm) != sizeof(u.ui));
++      lockdep_off();
++      err = vfs_setxattr(dentry, name, value, size, flags);
++      lockdep_on();
 +
-+      return u.ui;
++      return err;
 +}
 +
-+static inline fmode_t vfsub_uint_to_fmode(unsigned int ui)
++static inline int vfsub_removexattr(struct dentry *dentry, const char *name)
 +{
-+      union vfsub_fmu u = {
-+              .ui = ui
-+      };
-+
-+      return u.fm;
-+}
++      int err;
 +
-+/* ---------------------------------------------------------------------- */
++      lockdep_off();
++      err = vfs_removexattr(dentry, name);
++      lockdep_on();
 +
-+int vfsub_sio_mkdir(struct inode *dir, struct path *path, int mode);
-+int vfsub_sio_rmdir(struct inode *dir, struct path *path);
-+int vfsub_sio_notify_change(struct path *path, struct iattr *ia,
-+                          struct inode **delegated_inode);
-+int vfsub_notify_change(struct path *path, struct iattr *ia,
-+                      struct inode **delegated_inode);
-+int vfsub_unlink(struct inode *dir, struct path *path,
-+               struct inode **delegated_inode, int force);
++      return err;
++}
 +
 +#endif /* __KERNEL__ */
 +#endif /* __AUFS_VFSUB_H__ */
 diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c
 --- /usr/share/empty/fs/aufs/wbr_policy.c      1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/wbr_policy.c 2014-08-14 10:15:45.131942973 +0200
++++ linux/fs/aufs/wbr_policy.c 2015-06-22 08:27:37.887501948 +0200
 @@ -0,0 +1,765 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -30957,10 +31755,10 @@ 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      2014-08-14 10:15:45.131942973 +0200
-@@ -0,0 +1,1056 @@
++++ linux/fs/aufs/whout.c      2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,1064 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -31034,15 +31832,18 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      else
 +              wh_dentry = au_sio_lkup_one(wh_name, h_parent);
 +      err = PTR_ERR(wh_dentry);
-+      if (IS_ERR(wh_dentry))
++      if (IS_ERR(wh_dentry)) {
++              if (err == -ENAMETOOLONG)
++                      err = 0;
 +              goto out;
++      }
 +
 +      err = 0;
 +      if (!wh_dentry->d_inode)
 +              goto out_wh; /* success */
 +
 +      err = 1;
-+      if (S_ISREG(wh_dentry->d_inode->i_mode))
++      if (d_is_reg(wh_dentry))
 +              goto out_wh; /* success */
 +
 +      err = -EIO;
@@ -31215,7 +32016,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +              err = PTR_ERR(h_path.dentry);
 +      else {
 +              if (h_path.dentry->d_inode
-+                  && S_ISREG(h_path.dentry->d_inode->i_mode))
++                  && d_is_reg(h_path.dentry))
 +                      err = do_unlink_wh(h_parent->d_inode, &h_path);
 +              dput(h_path.dentry);
 +      }
@@ -31277,7 +32078,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +              if (au_test_nfs(path->dentry->d_sb))
 +                      mode |= S_IXUGO;
 +              err = vfsub_mkdir(h_dir, path, mode);
-+      } else if (S_ISDIR(path->dentry->d_inode->i_mode))
++      } else if (d_is_dir(path->dentry))
 +              err = 0;
 +      else
 +              pr_err("unknown %pd exists\n", path->dentry);
@@ -31303,9 +32104,9 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +
 +/*
 + * returns tri-state,
-+ * minus: error, caller should print the mesage
++ * minus: error, caller should print the message
 + * zero: succuess
-+ * plus: error, caller should NOT print the mesage
++ * plus: error, caller should NOT print the message
 + */
 +static int au_wh_init_rw_nolink(struct dentry *h_root, struct au_wbr *wbr,
 +                              int do_plink, struct au_wh_base base[],
@@ -31372,7 +32173,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      if (!base[AuBrWh_BASE].dentry->d_inode) {
 +              h_path->dentry = base[AuBrWh_BASE].dentry;
 +              err = vfsub_create(h_dir, h_path, WH_MASK, /*want_excl*/true);
-+      } else if (S_ISREG(base[AuBrWh_BASE].dentry->d_inode->i_mode))
++      } else if (d_is_reg(base[AuBrWh_BASE].dentry))
 +              err = 0;
 +      else
 +              pr_err("unknown %pd2 exists\n", base[AuBrWh_BASE].dentry);
@@ -31894,6 +32695,7 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +                 struct dentry *wh_dentry, struct au_nhash *whlist)
 +{
 +      int err;
++      unsigned int h_nlink;
 +      struct path h_tmp;
 +      struct inode *wh_inode, *h_dir;
 +      struct au_branch *br;
@@ -31930,14 +32732,18 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c
 +      if (!err) {
 +              h_tmp.dentry = wh_dentry;
 +              h_tmp.mnt = au_br_mnt(br);
++              h_nlink = h_dir->i_nlink;
 +              err = vfsub_rmdir(h_dir, &h_tmp);
++              /* some fs doesn't change the parent nlink in some cases */
++              h_nlink -= h_dir->i_nlink;
 +      }
 +
 +      if (!err) {
 +              if (au_ibstart(dir) == bindex) {
 +                      /* todo: dir->i_mutex is necessary */
 +                      au_cpup_attr_timesizes(dir);
-+                      vfsub_drop_nlink(dir);
++                      if (h_nlink)
++                              vfsub_drop_nlink(dir);
 +              }
 +              return 0; /* success */
 +      }
@@ -32017,10 +32823,10 @@ 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      2014-08-14 10:15:45.131942973 +0200
++++ linux/fs/aufs/whout.h      2015-06-22 08:27:37.890835363 +0200
 @@ -0,0 +1,85 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -32049,9 +32855,9 @@ diff -urN /usr/share/empty/fs/aufs/whout.h linux/fs/aufs/whout.h
 +
 +/* whout.c */
 +int au_wh_name_alloc(struct qstr *wh, const struct qstr *name);
-+struct au_branch;
 +int au_wh_test(struct dentry *h_parent, struct qstr *wh_name, int try_sio);
 +int au_diropq_test(struct dentry *h_dentry);
++struct au_branch;
 +struct dentry *au_whtmp_lkup(struct dentry *h_parent, struct au_branch *br,
 +                           struct qstr *prefix);
 +int au_whtmp_ren(struct dentry *h_dentry, struct au_branch *br);
@@ -32106,10 +32912,10 @@ diff -urN /usr/share/empty/fs/aufs/whout.h linux/fs/aufs/whout.h
 +#endif /* __AUFS_WHOUT_H__ */
 diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 --- /usr/share/empty/fs/aufs/wkq.c     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/wkq.c        2014-08-14 10:16:04.515942371 +0200
++++ linux/fs/aufs/wkq.c        2015-06-22 08:27:37.890835363 +0200
 @@ -0,0 +1,213 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -32323,10 +33129,10 @@ diff -urN /usr/share/empty/fs/aufs/wkq.c linux/fs/aufs/wkq.c
 +}
 diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h
 --- /usr/share/empty/fs/aufs/wkq.h     1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/wkq.h        2014-01-30 21:10:02.860815399 +0100
++++ linux/fs/aufs/wkq.h        2015-06-22 08:27:37.890835363 +0200
 @@ -0,0 +1,91 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -32416,12 +33222,360 @@ diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h
 +
 +#endif /* __KERNEL__ */
 +#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      2015-06-22 08:27:37.890835363 +0200
+@@ -0,0 +1,344 @@
++/*
++ * Copyright (C) 2014-2015 Junjiro R. Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
++ */
++
++/*
++ * handling xattr functions
++ */
++
++#include <linux/xattr.h>
++#include "aufs.h"
++
++static int au_xattr_ignore(int err, char *name, unsigned int ignore_flags)
++{
++      if (!ignore_flags)
++              goto out;
++      switch (err) {
++      case -ENOMEM:
++      case -EDQUOT:
++              goto out;
++      }
++
++      if ((ignore_flags & AuBrAttr_ICEX) == AuBrAttr_ICEX) {
++              err = 0;
++              goto out;
++      }
++
++#define cmp(brattr, prefix) do {                                      \
++              if (!strncmp(name, XATTR_##prefix##_PREFIX,             \
++                           XATTR_##prefix##_PREFIX_LEN)) {            \
++                      if (ignore_flags & AuBrAttr_ICEX_##brattr)      \
++                              err = 0;                                \
++                      goto out;                                       \
++              }                                                       \
++      } while (0)
++
++      cmp(SEC, SECURITY);
++      cmp(SYS, SYSTEM);
++      cmp(TR, TRUSTED);
++      cmp(USR, USER);
++#undef cmp
++
++      if (ignore_flags & AuBrAttr_ICEX_OTH)
++              err = 0;
++
++out:
++      return err;
++}
++
++static const int au_xattr_out_of_list = AuBrAttr_ICEX_OTH << 1;
++
++static int au_do_cpup_xattr(struct dentry *h_dst, struct dentry *h_src,
++                          char *name, char **buf, unsigned int ignore_flags,
++                          unsigned int verbose)
++{
++      int err;
++      ssize_t ssz;
++      struct inode *h_idst;
++
++      ssz = vfs_getxattr_alloc(h_src, name, buf, 0, GFP_NOFS);
++      err = ssz;
++      if (unlikely(err <= 0)) {
++              if (err == -ENODATA
++                  || (err == -EOPNOTSUPP
++                      && ((ignore_flags & au_xattr_out_of_list)
++                          || (au_test_nfs_noacl(h_src->d_inode)
++                              && (!strcmp(name, XATTR_NAME_POSIX_ACL_ACCESS)
++                                  || !strcmp(name,
++                                             XATTR_NAME_POSIX_ACL_DEFAULT))))
++                          ))
++                      err = 0;
++              if (err && (verbose || au_debug_test()))
++                      pr_err("%s, err %d\n", name, err);
++              goto out;
++      }
++
++      /* unlock it temporary */
++      h_idst = h_dst->d_inode;
++      mutex_unlock(&h_idst->i_mutex);
++      err = vfsub_setxattr(h_dst, name, *buf, ssz, /*flags*/0);
++      mutex_lock_nested(&h_idst->i_mutex, AuLsc_I_CHILD2);
++      if (unlikely(err)) {
++              if (verbose || au_debug_test())
++                      pr_err("%s, err %d\n", name, err);
++              err = au_xattr_ignore(err, name, ignore_flags);
++      }
++
++out:
++      return err;
++}
++
++int au_cpup_xattr(struct dentry *h_dst, struct dentry *h_src, int ignore_flags,
++                unsigned int verbose)
++{
++      int err, unlocked, acl_access, acl_default;
++      ssize_t ssz;
++      struct inode *h_isrc, *h_idst;
++      char *value, *p, *o, *e;
++
++      /* try stopping to update the source inode while we are referencing */
++      /* there should not be the parent-child relationship between them */
++      h_isrc = h_src->d_inode;
++      h_idst = h_dst->d_inode;
++      mutex_unlock(&h_idst->i_mutex);
++      mutex_lock_nested(&h_isrc->i_mutex, AuLsc_I_CHILD);
++      mutex_lock_nested(&h_idst->i_mutex, AuLsc_I_CHILD2);
++      unlocked = 0;
++
++      /* some filesystems don't list POSIX ACL, for example tmpfs */
++      ssz = vfs_listxattr(h_src, NULL, 0);
++      err = ssz;
++      if (unlikely(err < 0)) {
++              AuTraceErr(err);
++              if (err == -ENODATA
++                  || err == -EOPNOTSUPP)
++                      err = 0;        /* ignore */
++              goto out;
++      }
++
++      err = 0;
++      p = NULL;
++      o = NULL;
++      if (ssz) {
++              err = -ENOMEM;
++              p = kmalloc(ssz, GFP_NOFS);
++              o = p;
++              if (unlikely(!p))
++                      goto out;
++              err = vfs_listxattr(h_src, p, ssz);
++      }
++      mutex_unlock(&h_isrc->i_mutex);
++      unlocked = 1;
++      AuDbg("err %d, ssz %zd\n", err, ssz);
++      if (unlikely(err < 0))
++              goto out_free;
++
++      err = 0;
++      e = p + ssz;
++      value = NULL;
++      acl_access = 0;
++      acl_default = 0;
++      while (!err && p < e) {
++              acl_access |= !strncmp(p, XATTR_NAME_POSIX_ACL_ACCESS,
++                                     sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1);
++              acl_default |= !strncmp(p, XATTR_NAME_POSIX_ACL_DEFAULT,
++                                      sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)
++                                      - 1);
++              err = au_do_cpup_xattr(h_dst, h_src, p, &value, ignore_flags,
++                                     verbose);
++              p += strlen(p) + 1;
++      }
++      AuTraceErr(err);
++      ignore_flags |= au_xattr_out_of_list;
++      if (!err && !acl_access) {
++              err = au_do_cpup_xattr(h_dst, h_src,
++                                     XATTR_NAME_POSIX_ACL_ACCESS, &value,
++                                     ignore_flags, verbose);
++              AuTraceErr(err);
++      }
++      if (!err && !acl_default) {
++              err = au_do_cpup_xattr(h_dst, h_src,
++                                     XATTR_NAME_POSIX_ACL_DEFAULT, &value,
++                                     ignore_flags, verbose);
++              AuTraceErr(err);
++      }
++
++      kfree(value);
++
++out_free:
++      kfree(o);
++out:
++      if (!unlocked)
++              mutex_unlock(&h_isrc->i_mutex);
++      AuTraceErr(err);
++      return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++enum {
++      AU_XATTR_LIST,
++      AU_XATTR_GET
++};
++
++struct au_lgxattr {
++      int type;
++      union {
++              struct {
++                      char    *list;
++                      size_t  size;
++              } list;
++              struct {
++                      const char      *name;
++                      void            *value;
++                      size_t          size;
++              } get;
++      } u;
++};
++
++static ssize_t au_lgxattr(struct dentry *dentry, struct au_lgxattr *arg)
++{
++      ssize_t err;
++      struct path h_path;
++      struct super_block *sb;
++
++      sb = dentry->d_sb;
++      err = si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLM);
++      if (unlikely(err))
++              goto out;
++      err = au_h_path_getattr(dentry, /*force*/1, &h_path);
++      if (unlikely(err))
++              goto out_si;
++      if (unlikely(!h_path.dentry))
++              /* illegally overlapped or something */
++              goto out_di; /* pretending success */
++
++      /* always topmost entry only */
++      switch (arg->type) {
++      case AU_XATTR_LIST:
++              err = vfs_listxattr(h_path.dentry,
++                                  arg->u.list.list, arg->u.list.size);
++              break;
++      case AU_XATTR_GET:
++              err = vfs_getxattr(h_path.dentry,
++                                 arg->u.get.name, arg->u.get.value,
++                                 arg->u.get.size);
++              break;
++      }
++
++out_di:
++      di_read_unlock(dentry, AuLock_IR);
++out_si:
++      si_read_unlock(sb);
++out:
++      AuTraceErr(err);
++      return err;
++}
++
++ssize_t aufs_listxattr(struct dentry *dentry, char *list, size_t size)
++{
++      struct au_lgxattr arg = {
++              .type = AU_XATTR_LIST,
++              .u.list = {
++                      .list   = list,
++                      .size   = size
++              },
++      };
++
++      return au_lgxattr(dentry, &arg);
++}
++
++ssize_t aufs_getxattr(struct dentry *dentry, const char *name, void *value,
++                    size_t size)
++{
++      struct au_lgxattr arg = {
++              .type = AU_XATTR_GET,
++              .u.get = {
++                      .name   = name,
++                      .value  = value,
++                      .size   = size
++              },
++      };
++
++      return au_lgxattr(dentry, &arg);
++}
++
++int aufs_setxattr(struct dentry *dentry, const char *name, const void *value,
++                size_t size, int flags)
++{
++      struct au_srxattr arg = {
++              .type = AU_XATTR_SET,
++              .u.set = {
++                      .name   = name,
++                      .value  = value,
++                      .size   = size,
++                      .flags  = flags
++              },
++      };
++
++      return au_srxattr(dentry, &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, &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)
++{
++      return aufs_getxattr(dentry, name, buffer, size);
++}
++
++static int au_xattr_set(struct dentry *dentry, const char *name,
++                      const void *value, size_t size, int flags, int type)
++{
++      return aufs_setxattr(dentry, name, value, size, flags);
++}
++
++static const struct xattr_handler au_xattr_handler = {
++      /* no prefix, no flags */
++      .list   = au_xattr_list,
++      .get    = au_xattr_get,
++      .set    = au_xattr_set
++      /* why no remove? */
++};
++
++static const struct xattr_handler *au_xattr_handlers[] = {
++      &au_xattr_handler
++};
++
++void au_xattr_init(struct super_block *sb)
++{
++      /* 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       2014-08-14 10:16:04.515942371 +0200
-@@ -0,0 +1,1316 @@
++++ linux/fs/aufs/xino.c       2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,1322 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -32467,7 +33621,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +
 +#if 0 /* reserved for future use */
 +      if (err > 0)
-+              fsnotify_access(file->f_dentry);
++              fsnotify_access(file->f_path.dentry);
 +#endif
 +
 +      return err;
@@ -32496,7 +33650,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +
 +#if 0 /* reserved for future use */
 +      if (err > 0)
-+              fsnotify_modify(file->f_dentry);
++              fsnotify_modify(file->f_path.dentry);
 +#endif
 +
 +      return err;
@@ -32564,7 +33718,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      struct path path;
 +      int err;
 +
-+      base = base_file->f_dentry;
++      base = base_file->f_path.dentry;
 +      parent = base->d_parent; /* dir inode is locked */
 +      dir = parent->d_inode;
 +      IMustLock(dir);
@@ -32647,7 +33801,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +              ldir->hdir = au_hi(sb->s_root->d_inode, bindex);
 +              au_hn_imtx_lock_nested(ldir->hdir, AuLsc_I_PARENT);
 +      } else {
-+              ldir->parent = dget_parent(xino->f_dentry);
++              ldir->parent = dget_parent(xino->f_path.dentry);
 +              ldir->mtx = &ldir->parent->d_inode->i_mutex;
 +              mutex_lock_nested(ldir->mtx, AuLsc_I_PARENT);
 +      }
@@ -33151,7 +34305,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +{
 +      struct file *file;
 +      struct dentry *h_parent, *d;
-+      struct inode *h_dir;
++      struct inode *h_dir, *inode;
 +      int err;
 +
 +      /*
@@ -33169,12 +34323,16 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      }
 +
 +      /* keep file count */
-+      h_parent = dget_parent(file->f_dentry);
++      err = 0;
++      inode = file_inode(file);
++      h_parent = dget_parent(file->f_path.dentry);
 +      h_dir = h_parent->d_inode;
 +      mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
 +      /* mnt_want_write() is unnecessary here */
 +      /* no delegation since it is just created */
-+      err = vfsub_unlink(h_dir, &file->f_path, /*delegated*/NULL, /*force*/0);
++      if (inode->i_nlink)
++              err = vfsub_unlink(h_dir, &file->f_path, /*delegated*/NULL,
++                                 /*force*/0);
 +      mutex_unlock(&h_dir->i_mutex);
 +      dput(h_parent);
 +      if (unlikely(err)) {
@@ -33184,7 +34342,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +      }
 +
 +      err = -EINVAL;
-+      d = file->f_dentry;
++      d = file->f_path.dentry;
 +      if (unlikely(sb == d->d_sb)) {
 +              if (!silent)
 +                      pr_err("%s must be outside\n", fname);
@@ -33617,14 +34775,14 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +
 +      err = 0;
 +      sbinfo = au_sbi(sb);
-+      parent = dget_parent(xino->file->f_dentry);
++      parent = dget_parent(xino->file->f_path.dentry);
 +      if (remount) {
 +              skip = 0;
-+              dname = &xino->file->f_dentry->d_name;
++              dname = &xino->file->f_path.dentry->d_name;
 +              cur_xino = sbinfo->si_xib;
 +              if (cur_xino) {
-+                      cur_parent = dget_parent(cur_xino->f_dentry);
-+                      cur_name = &cur_xino->f_dentry->d_name;
++                      cur_parent = dget_parent(cur_xino->f_path.dentry);
++                      cur_name = &cur_xino->f_path.dentry->d_name;
 +                      skip = (cur_parent == parent
 +                              && au_qstreq(dname, cur_name));
 +                      dput(cur_parent);
@@ -33648,6 +34806,8 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +
 +      /* reset all */
 +      AuIOErr("failed creating xino(%d).\n", err);
++      au_xigen_clr(sb);
++      xino_clear_xib(sb);
 +
 +out:
 +      dput(parent);
@@ -33701,7 +34861,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c
 +              file = au_xino_create(sb, AUFS_XINO_DEFPATH, /*silent*/0);
 +              if (IS_ERR(file))
 +                      goto out;
-+              h_sb = file->f_dentry->d_sb;
++              h_sb = file->f_path.dentry->d_sb;
 +              if (unlikely(au_test_fs_bad_xino(h_sb))) {
 +                      pr_err("xino doesn't support %s(%s)\n",
 +                             AUFS_XINO_DEFPATH, au_sbtype(h_sb));
@@ -33738,10 +34898,10 @@ 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       2014-08-14 10:16:04.522609267 +0200
-@@ -0,0 +1,380 @@
++++ linux/include/uapi/linux/aufs_type.h       2015-06-22 08:29:23.710091096 +0200
+@@ -0,0 +1,419 @@
 +/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2015 Junjiro R. Okajima
 + *
 + * This program, aufs is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
@@ -33781,7 +34941,7 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +
 +#include <linux/limits.h>
 +
-+#define AUFS_VERSION  "3.16-20140811"
++#define AUFS_VERSION  "3.x-rcN-20150622"
 +
 +/* todo? move this to linux-2.6.19/include/magic.h */
 +#define AUFS_SUPER_MAGIC      ('a' << 24 | 'u' << 16 | 'f' << 8 | 's')
@@ -33863,6 +35023,12 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +#define AUFS_BRATTR_COO_ALL   "coo_all"
 +#define AUFS_BRATTR_FHSM      "fhsm"
 +#define AUFS_BRATTR_UNPIN     "unpin"
++#define AUFS_BRATTR_ICEX      "icex"
++#define AUFS_BRATTR_ICEX_SEC  "icexsec"
++#define AUFS_BRATTR_ICEX_SYS  "icexsys"
++#define AUFS_BRATTR_ICEX_TR   "icextr"
++#define AUFS_BRATTR_ICEX_USR  "icexusr"
++#define AUFS_BRATTR_ICEX_OTH  "icexoth"
 +#define AUFS_BRRATTR_WH               "wh"
 +#define AUFS_BRWATTR_NLWH     "nolwh"
 +#define AUFS_BRWATTR_MOO      "moo"
@@ -33878,29 +35044,62 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin
 +
 +#define AuBrAttr_FHSM         (1 << 5)        /* file-based hsm */
 +#define AuBrAttr_UNPIN                (1 << 6)        /* rename-able top dir of
-+                                                 branch */
-+
-+#define AuBrRAttr_WH          (1 << 7)        /* whiteout-able */
++                                                 branch. meaningless since
++                                                 linux-3.18-rc1 */
++
++/* ignore error in copying XATTR */
++#define AuBrAttr_ICEX_SEC     (1 << 7)
++#define AuBrAttr_ICEX_SYS     (1 << 8)
++#define AuBrAttr_ICEX_TR      (1 << 9)
++#define AuBrAttr_ICEX_USR     (1 << 10)
++#define AuBrAttr_ICEX_OTH     (1 << 11)
++#define AuBrAttr_ICEX         (AuBrAttr_ICEX_SEC      \
++                               | AuBrAttr_ICEX_SYS    \
++                               | AuBrAttr_ICEX_TR     \
++                               | AuBrAttr_ICEX_USR    \
++                               | AuBrAttr_ICEX_OTH)
++
++#define AuBrRAttr_WH          (1 << 12)       /* whiteout-able */
 +#define AuBrRAttr_Mask                AuBrRAttr_WH
 +
-+#define AuBrWAttr_NoLinkWH    (1 << 8)        /* un-hardlinkable whiteouts */
-+#define AuBrWAttr_MOO         (1 << 9)        /* move-up on open */
++#define AuBrWAttr_NoLinkWH    (1 << 13)       /* un-hardlinkable whiteouts */
++#define AuBrWAttr_MOO         (1 << 14)       /* move-up on open */
 +#define AuBrWAttr_Mask                (AuBrWAttr_NoLinkWH | AuBrWAttr_MOO)
 +
 +#define AuBrAttr_CMOO_Mask    (AuBrAttr_COO_Mask | AuBrWAttr_MOO)
 +
++/* #warning test userspace */
 +#ifdef __KERNEL__
 +#ifndef CONFIG_AUFS_FHSM
 +#undef AuBrAttr_FHSM
 +#define AuBrAttr_FHSM         0
 +#endif
++#ifndef CONFIG_AUFS_XATTR
++#undef        AuBrAttr_ICEX
++#define AuBrAttr_ICEX         0
++#undef        AuBrAttr_ICEX_SEC
++#define AuBrAttr_ICEX_SEC     0
++#undef        AuBrAttr_ICEX_SYS
++#define AuBrAttr_ICEX_SYS     0
++#undef        AuBrAttr_ICEX_TR
++#define AuBrAttr_ICEX_TR      0
++#undef        AuBrAttr_ICEX_USR
++#define AuBrAttr_ICEX_USR     0
++#undef        AuBrAttr_ICEX_OTH
++#define AuBrAttr_ICEX_OTH     0
++#endif
 +#endif
 +
 +/* the longest combination */
-+#define AuBrPermStrSz sizeof(AUFS_BRPERM_RW           \
-+                             "+" AUFS_BRATTR_COO_REG  \
-+                             "+" AUFS_BRATTR_FHSM     \
-+                             "+" AUFS_BRATTR_UNPIN    \
++/* AUFS_BRATTR_ICEX and AUFS_BRATTR_ICEX_TR don't affect here */
++#define AuBrPermStrSz sizeof(AUFS_BRPERM_RW                   \
++                             "+" AUFS_BRATTR_COO_REG          \
++                             "+" AUFS_BRATTR_FHSM             \
++                             "+" AUFS_BRATTR_UNPIN            \
++                             "+" AUFS_BRATTR_ICEX_SEC         \
++                             "+" AUFS_BRATTR_ICEX_SYS         \
++                             "+" AUFS_BRATTR_ICEX_USR         \
++                             "+" AUFS_BRATTR_ICEX_OTH         \
 +                             "+" AUFS_BRWATTR_NLWH)
 +
 +typedef struct {
@@ -34120,293 +35319,3 @@ 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__ */
-aufs3.16 loopback patch
-
-diff --git a/drivers/block/loop.c b/drivers/block/loop.c
-index 30efd68..77b31b4 100644
---- a/drivers/block/loop.c
-+++ b/drivers/block/loop.c
-@@ -514,7 +514,7 @@ out:
- }
- struct switch_request {
--      struct file *file;
-+      struct file *file, *virt_file;
-       struct completion wait;
- };
-@@ -576,7 +576,8 @@ static int loop_thread(void *data)
-  * First it needs to flush existing IO, it does this by sending a magic
-  * BIO down the pipe. The completion of this BIO does the actual switch.
-  */
--static int loop_switch(struct loop_device *lo, struct file *file)
-+static int loop_switch(struct loop_device *lo, struct file *file,
-+                     struct file *virt_file)
- {
-       struct switch_request w;
-       struct bio *bio = bio_alloc(GFP_KERNEL, 0);
-@@ -584,6 +585,7 @@ static int loop_switch(struct loop_device *lo, struct file *file)
-               return -ENOMEM;
-       init_completion(&w.wait);
-       w.file = file;
-+      w.virt_file = virt_file;
-       bio->bi_private = &w;
-       bio->bi_bdev = NULL;
-       loop_make_request(lo->lo_queue, bio);
-@@ -600,7 +602,7 @@ static int loop_flush(struct loop_device *lo)
-       if (!lo->lo_thread)
-               return 0;
--      return loop_switch(lo, NULL);
-+      return loop_switch(lo, NULL, NULL);
- }
- /*
-@@ -619,6 +621,7 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
-       mapping = file->f_mapping;
-       mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
-       lo->lo_backing_file = file;
-+      lo->lo_backing_virt_file = p->virt_file;
-       lo->lo_blocksize = S_ISBLK(mapping->host->i_mode) ?
-               mapping->host->i_bdev->bd_block_size : PAGE_SIZE;
-       lo->old_gfp_mask = mapping_gfp_mask(mapping);
-@@ -627,6 +630,13 @@ out:
-       complete(&p->wait);
- }
-+static struct file *loop_real_file(struct file *file)
-+{
-+      struct file *f = NULL;
-+      if (file->f_dentry->d_sb->s_op->real_loop)
-+              f = file->f_dentry->d_sb->s_op->real_loop(file);
-+      return f;
-+}
- /*
-  * loop_change_fd switched the backing store of a loopback device to
-@@ -640,6 +650,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
-                         unsigned int arg)
- {
-       struct file     *file, *old_file;
-+      struct file     *f, *virt_file = NULL, *old_virt_file;
-       struct inode    *inode;
-       int             error;
-@@ -656,9 +667,16 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
-       file = fget(arg);
-       if (!file)
-               goto out;
-+      f = loop_real_file(file);
-+      if (f) {
-+              virt_file = file;
-+              file = f;
-+              get_file(file);
-+      }
-       inode = file->f_mapping->host;
-       old_file = lo->lo_backing_file;
-+      old_virt_file = lo->lo_backing_virt_file;
-       error = -EINVAL;
-@@ -670,17 +688,21 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
-               goto out_putf;
-       /* and ... switch */
--      error = loop_switch(lo, file);
-+      error = loop_switch(lo, file, virt_file);
-       if (error)
-               goto out_putf;
-       fput(old_file);
-+      if (old_virt_file)
-+              fput(old_virt_file);
-       if (lo->lo_flags & LO_FLAGS_PARTSCAN)
-               ioctl_by_bdev(bdev, BLKRRPART, 0);
-       return 0;
-  out_putf:
-       fput(file);
-+      if (virt_file)
-+              fput(virt_file);
-  out:
-       return error;
- }
-@@ -841,7 +863,7 @@ static void loop_config_discard(struct loop_device *lo)
- static int loop_set_fd(struct loop_device *lo, fmode_t mode,
-                      struct block_device *bdev, unsigned int arg)
- {
--      struct file     *file, *f;
-+      struct file     *file, *f, *virt_file = NULL;
-       struct inode    *inode;
-       struct address_space *mapping;
-       unsigned lo_blocksize;
-@@ -856,6 +878,12 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
-       file = fget(arg);
-       if (!file)
-               goto out;
-+      f = loop_real_file(file);
-+      if (f) {
-+              virt_file = file;
-+              file = f;
-+              get_file(file);
-+      }
-       error = -EBUSY;
-       if (lo->lo_state != Lo_unbound)
-@@ -904,6 +932,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
-       lo->lo_device = bdev;
-       lo->lo_flags = lo_flags;
-       lo->lo_backing_file = file;
-+      lo->lo_backing_virt_file = virt_file;
-       lo->transfer = transfer_none;
-       lo->ioctl = NULL;
-       lo->lo_sizelimit = 0;
-@@ -948,6 +977,7 @@ out_clr:
-       lo->lo_thread = NULL;
-       lo->lo_device = NULL;
-       lo->lo_backing_file = NULL;
-+      lo->lo_backing_virt_file = NULL;
-       lo->lo_flags = 0;
-       set_capacity(lo->lo_disk, 0);
-       invalidate_bdev(bdev);
-@@ -957,6 +987,8 @@ out_clr:
-       lo->lo_state = Lo_unbound;
-  out_putf:
-       fput(file);
-+      if (virt_file)
-+              fput(virt_file);
-  out:
-       /* This is safe: open() is still holding a reference. */
-       module_put(THIS_MODULE);
-@@ -1003,6 +1035,7 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
- static int loop_clr_fd(struct loop_device *lo)
- {
-       struct file *filp = lo->lo_backing_file;
-+      struct file *virt_filp = lo->lo_backing_virt_file;
-       gfp_t gfp = lo->old_gfp_mask;
-       struct block_device *bdev = lo->lo_device;
-@@ -1036,6 +1069,7 @@ static int loop_clr_fd(struct loop_device *lo)
-       spin_lock_irq(&lo->lo_lock);
-       lo->lo_backing_file = NULL;
-+      lo->lo_backing_virt_file = NULL;
-       spin_unlock_irq(&lo->lo_lock);
-       loop_release_xfer(lo);
-@@ -1078,6 +1112,8 @@ static int loop_clr_fd(struct loop_device *lo)
-        * bd_mutex which is usually taken before lo_ctl_mutex.
-        */
-       fput(filp);
-+      if (virt_filp)
-+              fput(virt_filp);
-       return 0;
- }
-diff --git a/drivers/block/loop.h b/drivers/block/loop.h
-index 90df5d6..cb91822 100644
---- a/drivers/block/loop.h
-+++ b/drivers/block/loop.h
-@@ -44,7 +44,7 @@ struct loop_device {
-       int             (*ioctl)(struct loop_device *, int cmd, 
-                                unsigned long arg); 
--      struct file *   lo_backing_file;
-+      struct file *   lo_backing_file, *lo_backing_virt_file;
-       struct block_device *lo_device;
-       unsigned        lo_blocksize;
-       void            *key_data; 
-diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c
-index 24ced51..69fa5cc 100644
---- a/fs/aufs/f_op.c
-+++ b/fs/aufs/f_op.c
-@@ -367,7 +367,7 @@ static ssize_t aufs_splice_read(struct file *file, loff_t *ppos,
-       err = -EINVAL;
-       h_file = au_hf_top(file);
-       get_file(h_file);
--      if (au_test_loopback_kthread()) {
-+      if (0 && au_test_loopback_kthread()) {
-               au_warn_loopback(h_file->f_dentry->d_sb);
-               if (file->f_mapping != h_file->f_mapping) {
-                       file->f_mapping = h_file->f_mapping;
-diff --git a/fs/aufs/loop.c b/fs/aufs/loop.c
-index 3b03b52..4ab749d 100644
---- a/fs/aufs/loop.c
-+++ b/fs/aufs/loop.c
-@@ -130,3 +130,19 @@ void au_loopback_fin(void)
-       symbol_put(loop_backing_file);
-       kfree(au_warn_loopback_array);
- }
-+
-+/* ---------------------------------------------------------------------- */
-+
-+/* support the loopback block device insude aufs */
-+
-+struct file *aufs_real_loop(struct file *file)
-+{
-+      struct file *f;
-+
-+      BUG_ON(!au_test_aufs(file->f_dentry->d_sb));
-+      fi_read_lock(file);
-+      f = au_hf_top(file);
-+      fi_read_unlock(file);
-+      AuDebugOn(!f);
-+      return f;
-+}
-diff --git a/fs/aufs/loop.h b/fs/aufs/loop.h
-index da8b756..28cb7ea 100644
---- a/fs/aufs/loop.h
-+++ b/fs/aufs/loop.h
-@@ -25,7 +25,11 @@ void au_warn_loopback(struct super_block *h_sb);
- int au_loopback_init(void);
- void au_loopback_fin(void);
-+
-+struct file *aufs_real_loop(struct file *file);
- #else
-+AuStub(struct file *, loop_backing_file, return NULL)
-+
- AuStubInt0(au_test_loopback_overlap, struct super_block *sb,
-          struct dentry *h_adding)
- AuStubInt0(au_test_loopback_kthread, void)
-@@ -33,6 +37,8 @@ AuStubVoid(au_warn_loopback, struct super_block *h_sb)
- AuStubInt0(au_loopback_init, void)
- AuStubVoid(au_loopback_fin, void)
-+
-+AuStub(struct file *, aufs_real_loop, return NULL, struct file *file)
- #endif /* BLK_DEV_LOOP */
- #endif /* __KERNEL__ */
-diff --git a/fs/aufs/super.c b/fs/aufs/super.c
-index 45146eb..fccd7d6 100644
---- a/fs/aufs/super.c
-+++ b/fs/aufs/super.c
-@@ -809,7 +809,10 @@ static const struct super_operations aufs_sop = {
-       .statfs         = aufs_statfs,
-       .put_super      = aufs_put_super,
-       .sync_fs        = aufs_sync_fs,
--      .remount_fs     = aufs_remount_fs
-+      .remount_fs     = aufs_remount_fs,
-+#ifdef CONFIG_AUFS_BDEV_LOOP
-+      .real_loop      = aufs_real_loop
-+#endif
- };
- /* ---------------------------------------------------------------------- */
-diff --git a/include/linux/fs.h b/include/linux/fs.h
-index 2f32b35..f94f0e6 100644
---- a/include/linux/fs.h
-+++ b/include/linux/fs.h
-@@ -1561,6 +1561,10 @@ struct super_operations {
-       int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
-       long (*nr_cached_objects)(struct super_block *, int);
-       long (*free_cached_objects)(struct super_block *, long, int);
-+#if defined(CONFIG_BLK_DEV_LOOP) ||  defined(CONFIG_BLK_DEV_LOOP_MODULE)
-+      /* and aufs */
-+      struct file *(*real_loop)(struct file *);
-+#endif
- };
- /*
This page took 0.500233 seconds and 4 git commands to generate.