[packages/kernel/LINUX_3_18] - aufs security fixes: https://sourceforge.net/p/aufs/mailman/message/34864744/ - rel 2
baggins
baggins at pld-linux.org
Sun Feb 28 13:26:00 CET 2016
commit 7f2ca4b1e90dc08ffbaebf9bc3bbc023cfde9733
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sun Feb 28 13:25:08 2016 +0100
- aufs security fixes: https://sourceforge.net/p/aufs/mailman/message/34864744/
- rel 2
kernel-aufs3.patch | 3505 ++++++++++++++++++++++++++++------------------------
kernel.spec | 2 +-
2 files changed, 1903 insertions(+), 1604 deletions(-)
---
diff --git a/kernel.spec b/kernel.spec
index 776e59d..928e05d 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -70,7 +70,7 @@
%define have_pcmcia 0
%endif
-%define rel 1
+%define rel 2
%define basever 3.18
%define postver .27
diff --git a/kernel-aufs3.patch b/kernel-aufs3.patch
index 68ab2f5..9f1e792 100644
--- a/kernel-aufs3.patch
+++ b/kernel-aufs3.patch
@@ -1,4 +1,4 @@
-aufs3.18.1+ kbuild patch
+aufs3.18.25+ kbuild patch
diff --git a/fs/Kconfig b/fs/Kconfig
index 664991a..1481093 100644
@@ -33,7 +33,7 @@ index 8523f9b..11f8f74 100644
header-y += auto_fs.h
header-y += auto_fs4.h
header-y += auxvec.h
-aufs3.18.1+ base patch
+aufs3.18.25+ base patch
diff --git a/MAINTAINERS b/MAINTAINERS
index c721042..83801d0 100644
@@ -90,10 +90,10 @@ index 6cb1beb..30efd68 100644
static ssize_t loop_attr_show(struct device *dev, char *page,
diff --git a/fs/dcache.c b/fs/dcache.c
-index 71acf8d..da7342e 100644
+index d25f8fd..857990a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
-@@ -1019,7 +1019,7 @@ enum d_walk_ret {
+@@ -1022,7 +1022,7 @@ enum d_walk_ret {
*
* The @enter() and @finish() callbacks are called with d_lock held.
*/
@@ -103,7 +103,7 @@ index 71acf8d..da7342e 100644
void (*finish)(void *))
{
diff --git a/fs/inode.c b/fs/inode.c
-index 26753ba..df21e66 100644
+index 56d1d2b..2998e86 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1497,7 +1497,7 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
@@ -143,11 +143,23 @@ index 75c6058..619359a 100644
{
ssize_t (*splice_read)(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
+diff --git a/include/linux/file.h b/include/linux/file.h
+index 4d69123..62cffc0 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);
+
+ static inline void fput_light(struct file *file, int fput_needed)
+ {
diff --git a/include/linux/fs.h b/include/linux/fs.h
-index 9ab779e..aabcbba 100644
+index 6fd017e..e35dc41 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
-@@ -2664,6 +2664,7 @@ extern int inode_change_ok(const struct inode *, struct iattr *);
+@@ -2662,6 +2662,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);
@@ -170,7 +182,7 @@ index da2751d..2e0fca6 100644
+ struct pipe_inode_info *pipe, size_t len,
+ unsigned int flags);
#endif
-aufs3.18.1+ mmap patch
+aufs3.18.25+ mmap patch
diff --git a/fs/buffer.c b/fs/buffer.c
index 20805db..363569f 100644
@@ -186,7 +198,7 @@ index 20805db..363569f 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 772efa4..2c944de 100644
+index 7dc3ea8..b368ad5 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)
@@ -215,7 +227,7 @@ index d4a3574..1397181 100644
ino = inode->i_ino;
}
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
-index 4e0388c..fc429e7 100644
+index 69aa378..426b962 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -276,7 +276,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
@@ -230,7 +242,7 @@ index 4e0388c..fc429e7 100644
dev = inode->i_sb->s_dev;
ino = inode->i_ino;
pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
-@@ -1440,7 +1443,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
+@@ -1447,7 +1450,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;
@@ -240,7 +252,7 @@ index 4e0388c..fc429e7 100644
struct mm_walk walk = {};
struct mempolicy *pol;
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
-index 599ec2e..de6cd6e 100644
+index 599ec2e..1740207 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -160,7 +160,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
@@ -250,20 +262,19 @@ index 599ec2e..de6cd6e 100644
- 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 b464611..8027d51 100644
+index 86a977b..a2d0dbb2 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
-@@ -1206,6 +1206,28 @@ static inline int fixup_user_fault(struct task_struct *tsk,
+@@ -1208,6 +1208,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);
@@ -276,14 +287,15 @@ index b464611..8027d51 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,
@@ -309,7 +321,7 @@ index 6e0b286..8f374ed 100644
#ifndef CONFIG_MMU
diff --git a/kernel/fork.c b/kernel/fork.c
-index 9b7d746..9a3b8fe 100644
+index 0a4f601..67ecb91 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -430,7 +430,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
@@ -335,10 +347,10 @@ index 8405eb0..e0bda2d 100644
obj-y += init-mm.o
diff --git a/mm/filemap.c b/mm/filemap.c
-index 14b4642..99bc835 100644
+index 7e6ab98..2fe1e57 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
-@@ -2067,7 +2067,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
+@@ -2063,7 +2063,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);
@@ -382,31 +394,12 @@ index 72b8fa3..a00bbf0 100644
err = 0;
}
goto out_freed;
-diff --git a/mm/madvise.c b/mm/madvise.c
-index 0938b30..0b66856 100644
---- a/mm/madvise.c
-+++ b/mm/madvise.c
-@@ -324,12 +324,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(¤t->mm->mmap_sem);
- error = do_fallocate(f,
- FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
- offset, end - start);
-- fput(f);
-+ vma_fput(vma);
- down_read(¤t->mm->mmap_sem);
- return error;
- }
diff --git a/mm/memory.c b/mm/memory.c
-index d5f2ae9..0830a96 100644
+index 90fb265..844df2e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
-@@ -2163,7 +2163,7 @@ reuse:
- set_page_dirty_balance(dirty_page);
+@@ -2156,7 +2156,7 @@ reuse:
+
/* file_update_time outside page_lock */
if (vma->vm_file)
- file_update_time(vma->vm_file);
@@ -415,7 +408,7 @@ index d5f2ae9..0830a96 100644
put_page(dirty_page);
if (page_mkwrite) {
diff --git a/mm/mmap.c b/mm/mmap.c
-index ae91989..e3bee5c 100644
+index f88b4f9..9994987 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -277,7 +277,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
@@ -446,7 +439,7 @@ index ae91989..e3bee5c 100644
/* Undo any partial mapping done by a device driver. */
unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
-@@ -2477,7 +2477,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
+@@ -2480,7 +2480,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
goto out_free_mpol;
if (new->vm_file)
@@ -455,7 +448,7 @@ index ae91989..e3bee5c 100644
if (new->vm_ops && new->vm_ops->open)
new->vm_ops->open(new);
-@@ -2496,7 +2496,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
+@@ -2499,7 +2499,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)
@@ -464,7 +457,7 @@ index ae91989..e3bee5c 100644
unlink_anon_vmas(new);
out_free_mpol:
mpol_put(vma_policy(new));
-@@ -2886,7 +2886,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
+@@ -2889,7 +2889,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)
@@ -473,28 +466,8 @@ index ae91989..e3bee5c 100644
if (new_vma->vm_ops && new_vma->vm_ops->open)
new_vma->vm_ops->open(new_vma);
vma_link(mm, new_vma, prev, rb_link, rb_parent);
-diff --git a/mm/msync.c b/mm/msync.c
-index 992a167..ce1915b 100644
---- a/mm/msync.c
-+++ b/mm/msync.c
-@@ -84,13 +84,13 @@ 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);
-- 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 bd1808e..c9ea035 100644
+index b5ba5bc..a7662fc 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -658,7 +658,7 @@ static void __put_nommu_region(struct vm_region *region)
@@ -539,7 +512,7 @@ index bd1808e..c9ea035 100644
return ret;
diff --git a/mm/prfile.c b/mm/prfile.c
new file mode 100644
-index 0000000..fc708d2
+index 0000000..532e518
--- /dev/null
+++ b/mm/prfile.c
@@ -0,0 +1,86 @@
@@ -564,12 +537,11 @@ index 0000000..fc708d2
+{
+#ifdef PRFILE_TRACE
+ if (pr)
-+ pr_info("%s:%d: %s, %p\n", func, line, func2,
++ pr_info("%s:%d: %s, %s\n", func, line, func2,
+ f ? (char *)f->f_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)
+{
@@ -609,7 +581,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)
+{
@@ -628,14 +601,14 @@ index 0000000..fc708d2
+ if (f && pr)
+ fput(pr);
+}
-+#endif /* CONFIG_MMU */
-aufs3.18.1+ standalone patch
++#endif /* !CONFIG_MMU */
+aufs3.18.25+ standalone patch
diff --git a/fs/dcache.c b/fs/dcache.c
-index da7342e..b147b6c 100644
+index 857990a..4d3b72c 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
-@@ -1124,6 +1124,7 @@ rename_retry:
+@@ -1127,6 +1127,7 @@ rename_retry:
seq = 1;
goto again;
}
@@ -643,8 +616,44 @@ index da7342e..b147b6c 100644
/*
* 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..8975b8f 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'
+@@ -258,6 +259,7 @@ void flush_delayed_fput(void)
+ {
+ delayed_fput(NULL);
+ }
++EXPORT_SYMBOL(flush_delayed_fput);
+
+ static DECLARE_DELAYED_WORK(delayed_fput_work, delayed_fput);
+
+@@ -300,6 +302,7 @@ void __fput_sync(struct file *file)
+ }
+
+ EXPORT_SYMBOL(fput);
++EXPORT_SYMBOL(__fput_sync);
+
+ void put_filp(struct file *file)
+ {
+@@ -308,6 +311,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 df21e66..c8df03d 100644
+index 2998e86..dc11e3c 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -57,6 +57,7 @@ static struct hlist_head *inode_hashtable __read_mostly;
@@ -664,7 +673,7 @@ index df21e66..c8df03d 100644
/**
* touch_atime - update the access time
diff --git a/fs/namespace.c b/fs/namespace.c
-index 5b66b2b..68ff4e4 100644
+index da23ad8..1fe9810 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -454,6 +454,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
@@ -675,7 +684,7 @@ index 5b66b2b..68ff4e4 100644
/**
* mnt_drop_write - give up write access to a mount
-@@ -1727,6 +1728,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
+@@ -1736,6 +1737,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
}
return 0;
}
@@ -720,7 +729,7 @@ index d16b62c..06ca6bc 100644
int fsnotify_fasync(int fd, struct file *file, int on)
{
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
-index 34c38fa..d40cf58 100644
+index 28c90a6..b48025e 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -109,6 +109,7 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
@@ -747,7 +756,7 @@ index 34c38fa..d40cf58 100644
int fsnotify_add_mark(struct fsnotify_mark *mark, struct fsnotify_group *group,
struct inode *inode, struct vfsmount *mnt, int allow_dups)
-@@ -372,6 +375,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
+@@ -392,6 +395,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
atomic_set(&mark->refcnt, 1);
mark->free_mark = free_mark;
}
@@ -756,7 +765,7 @@ index 34c38fa..d40cf58 100644
static int fsnotify_mark_destroy(void *ignored)
{
diff --git a/fs/open.c b/fs/open.c
-index de92c13..65d8ab0 100644
+index d058ff1..696084a 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,
@@ -775,6 +784,14 @@ index de92c13..65d8ab0 100644
SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
{
+@@ -663,6 +665,7 @@ int open_check_o_direct(struct file *f)
+ }
+ return 0;
+ }
++EXPORT_SYMBOL(open_check_o_direct);
+
+ static int do_dentry_open(struct file *f,
+ struct inode *inode,
diff --git a/fs/splice.c b/fs/splice.c
index 619359a..c14f60e 100644
--- a/fs/splice.c
@@ -807,6 +824,15 @@ index 64e83ef..bd71e53 100644
/* Compare an extended attribute value with the given value */
int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
+diff --git a/kernel/task_work.c b/kernel/task_work.c
+index 8727032..7003e5a 100644
+--- a/kernel/task_work.c
++++ b/kernel/task_work.c
+@@ -126,3 +126,4 @@ void task_work_run(void)
+ } while (work);
+ }
+ }
++EXPORT_SYMBOL(task_work_run);
diff --git a/security/commoncap.c b/security/commoncap.c
index bab0611..3fa2f82 100644
--- a/security/commoncap.c
@@ -929,7 +955,7 @@ index 18b35c6..12c67af 100644
{
diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Documentation/ABI/testing/debugfs-aufs
--- /usr/share/empty/Documentation/ABI/testing/debugfs-aufs 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/ABI/testing/debugfs-aufs 2015-01-25 13:00:38.627713742 +0100
++++ linux/Documentation/ABI/testing/debugfs-aufs 2016-02-28 11:27:01.273912209 +0100
@@ -0,0 +1,50 @@
+What: /debug/aufs/si_<id>/
+Date: March 2009
@@ -983,7 +1009,7 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Document
+ will be empty. About XINO files, see the aufs manual.
diff -urN /usr/share/empty/Documentation/ABI/testing/sysfs-aufs linux/Documentation/ABI/testing/sysfs-aufs
--- /usr/share/empty/Documentation/ABI/testing/sysfs-aufs 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/ABI/testing/sysfs-aufs 2015-01-25 13:00:38.627713742 +0100
++++ linux/Documentation/ABI/testing/sysfs-aufs 2016-02-28 11:27:01.273912209 +0100
@@ -0,0 +1,31 @@
+What: /sys/fs/aufs/si_<id>/
+Date: March 2009
@@ -1018,10 +1044,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,161 @@
++++ linux/Documentation/filesystems/aufs/design/01intro.txt 2016-02-28 11:27:01.273912209 +0100
+@@ -0,0 +1,170 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -1050,7 +1076,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.
@@ -1101,11 +1127,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
@@ -1127,11 +1158,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
@@ -1162,10 +1196,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
@@ -1183,10 +1218,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,251 @@
++++ linux/Documentation/filesystems/aufs/design/02struct.txt 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,258 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -1216,18 +1251,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
@@ -1235,8 +1270,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)
@@ -1256,13 +1291,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
@@ -1279,8 +1321,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
@@ -1293,7 +1335,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
@@ -1311,12 +1353,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.
+
+
@@ -1328,7 +1371,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
@@ -1367,9 +1410,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
@@ -1387,7 +1429,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
@@ -1395,7 +1437,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
@@ -1425,7 +1467,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.
+
@@ -1436,12 +1478,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 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,85 @@
++
++# Copyright (C) 2015-2016 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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,133 @@
++++ linux/Documentation/filesystems/aufs/design/03lookup.txt 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,113 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -1459,23 +1590,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
@@ -1490,7 +1611,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,
@@ -1499,8 +1620,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.
@@ -1510,17 +1632,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.
@@ -1570,15 +1681,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,75 @@
++++ linux/Documentation/filesystems/aufs/design/04branch.txt 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,74 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -1602,8 +1713,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.
+
@@ -1618,7 +1728,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.
+
+
@@ -1654,10 +1764,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 2015-01-25 13:00:38.627713742 +0100
++++ linux/Documentation/filesystems/aufs/design/05wbr_policy.txt 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,64 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -1679,9 +1789,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
@@ -1722,10 +1832,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 2015-01-25 13:00:38.627713742 +0100
++++ linux/Documentation/filesystems/aufs/design/06fhsm.txt 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,120 @@
+
-+# Copyright (C) 2011-2014 Junjiro R. Okajima
++# Copyright (C) 2011-2016 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
@@ -1746,9 +1856,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.
+
@@ -1846,10 +1956,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,46 @@
++++ linux/Documentation/filesystems/aufs/design/06mmap.txt 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,72 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -1870,7 +1980,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
@@ -1887,19 +1997,45 @@ 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-01-25 13:00:38.627713742 +0100
++++ linux/Documentation/filesystems/aufs/design/06xattr.txt 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,96 @@
+
-+# Copyright (C) 2014 Junjiro R. Okajima
++# Copyright (C) 2014-2016 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
@@ -1920,7 +2056,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt lin
+----------------------------------------------------------------------
+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 entreis since the bahaviour exactly matches the shown
++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
@@ -1933,14 +2069,14 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt lin
+
+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 can happen.
-+- listxattr(2) may return the duplicated entires.
++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 categorazied as these.
++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.
@@ -1954,12 +2090,12 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt lin
+
+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 fails. It can
-+happen that even all copy-up will fail.
++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 XATTR, aufs should not return an error.
++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
@@ -1973,15 +2109,15 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt lin
+
+For the copy-up operation, there two basic approaches.
+- copy the specified XATTR only (by category above), and return the
-+ error if it happens inconditionally.
++ 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 attributes for its
-+branch, "icexsec", "icexsys", "icextr", "icexusr", and "icexoth".
++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 "ix*" attributes are
-+set.
++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.
@@ -1996,10 +2132,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt lin
+now, aufs implements the branch attributes to ignore the error.
diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt linux/Documentation/filesystems/aufs/design/07export.txt
--- /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/07export.txt 2015-01-25 13:00:38.627713742 +0100
++++ linux/Documentation/filesystems/aufs/design/07export.txt 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,58 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -2038,10 +2174,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
@@ -2058,10 +2194,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 2015-01-25 13:00:38.627713742 +0100
++++ linux/Documentation/filesystems/aufs/design/08shwh.txt 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,52 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -2114,10 +2250,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,46 @@
++++ linux/Documentation/filesystems/aufs/design/10dynop.txt 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,47 @@
+
-+# Copyright (C) 2010-2014 Junjiro R. Okajima
++# Copyright (C) 2010-2016 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
@@ -2140,34 +2276,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,58 @@
++++ linux/Documentation/filesystems/aufs/design/99plan.txt 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,57 @@
+
-+# Copyright (C) 2005-2014 Junjiro R. Okajima
++# Copyright (C) 2005-2016 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
@@ -2193,7 +2330,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)
@@ -2211,7 +2348,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?
+
@@ -2222,12 +2359,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,370 @@
++++ linux/Documentation/filesystems/aufs/README 2016-02-28 11:27:01.273912209 +0100
+@@ -0,0 +1,392 @@
+
+Aufs3 -- advanced multi layered unification filesystem version 3.x
+http://aufs.sf.net
@@ -2237,7 +2373,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
@@ -2272,7 +2408,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
@@ -2304,28 +2445,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
@@ -2340,9 +2471,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-standalone tree contains them. They are described 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,
@@ -2351,12 +2486,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
@@ -2480,6 +2629,13 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
+ duplication of inode number, which is important for backup tools and
+ other utilities. When you find aufs XINO files for tmpfs branch
+ growing too much, try this patch.
++- lockdep-debug.patch
++ Because aufs is not only an ordinary filesystem (callee of VFS), but
++ also a caller of VFS functions for branch filesystems, subclassing of
++ the internal locks for LOCKDEP is necessary. LOCKDEP is a debugging
++ feature of linux kernel. If you enable CONFIG_LOCKDEP, then you will
++ need to apply this debug patch to expand several constant values.
++ If don't know what LOCKDEP, then you don't have apply this patch.
+
+
+4. Usage
@@ -2579,8 +2735,10 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta
+The Parted Magic Project made a donation (2013/9 and 11).
+Pavel Barta made a donation (2013/10).
+Nikolay Pertsev made a donation (2014/5).
-+James B made a donation (2014/7).
++James B made a donation (2014/7 and 2015/7).
+Stefano Di Biase made a donation (2014/8).
++Daniel Epellei made a donation (2015/1).
++OmegaPhil made a donation (2016/1).
+
+Thank you very much.
+Donations are always, including future donations, very important and
@@ -2600,10 +2758,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 2015-01-25 13:00:38.627713742 +0100
++++ linux/fs/aufs/aufs.h 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,59 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -2663,10 +2821,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,1410 @@
++++ linux/fs/aufs/branch.c 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,1402 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -2796,7 +2954,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
+
+ err = -ENOMEM;
+ root = sb->s_root;
-+ add_branch = kmalloc(sizeof(*add_branch), GFP_NOFS);
++ add_branch = kzalloc(sizeof(*add_branch), GFP_NOFS);
+ if (unlikely(!add_branch))
+ goto out;
+
@@ -2804,16 +2962,14 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
+ if (unlikely(err))
+ goto out_br;
+
-+ add_branch->br_wbr = NULL;
+ if (au_br_writable(perm)) {
+ /* may be freed separately at changing the branch permission */
-+ add_branch->br_wbr = kmalloc(sizeof(*add_branch->br_wbr),
++ add_branch->br_wbr = kzalloc(sizeof(*add_branch->br_wbr),
+ GFP_NOFS);
+ if (unlikely(!add_branch->br_wbr))
+ goto out_hnotify;
+ }
+
-+ add_branch->br_fhsm = NULL;
+ if (au_br_fhsm(perm)) {
+ err = au_fhsm_br_alloc(add_branch);
+ if (unlikely(err))
@@ -3013,9 +3169,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
+
+ wbr = br->br_wbr;
+ au_rw_init(&wbr->wbr_wh_rwsem);
-+ memset(wbr->wbr_wh, 0, sizeof(wbr->wbr_wh));
+ atomic_set(&wbr->wbr_wh_running, 0);
-+ wbr->wbr_bytes = 0;
+
+ /*
+ * a limit for rmdir/rename a dir
@@ -3043,12 +3197,10 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
+ int err;
+
+ err = 0;
-+ memset(&br->br_xino, 0, sizeof(br->br_xino));
+ mutex_init(&br->br_xino.xi_nondir_mtx);
+ br->br_perm = add->perm;
+ br->br_path = add->path; /* set first, path_get() later */
+ spin_lock_init(&br->br_dykey_lock);
-+ memset(br->br_dykey, 0, sizeof(br->br_dykey));
+ atomic_set(&br->br_count, 0);
+ atomic_set(&br->br_xino_running, 0);
+ br->br_id = au_new_br_id(sb);
@@ -3256,7 +3408,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
+ for (ull = 0; ull < max; ull++)
+ if (a[ull])
+ fput(a[ull]);
-+ au_array_free(a);
++ kvfree(a);
+}
+
+/* ---------------------------------------------------------------------- */
@@ -3469,7 +3621,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;
+
@@ -3490,8 +3641,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;
@@ -3524,7 +3674,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);
@@ -4010,7 +4160,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
+
+ if (unlikely(err)) {
+ rerr = -ENOMEM;
-+ br->br_wbr = kmalloc(sizeof(*br->br_wbr),
++ br->br_wbr = kzalloc(sizeof(*br->br_wbr),
+ GFP_NOFS);
+ if (br->br_wbr)
+ rerr = au_wbr_init(br, sb, br->br_perm);
@@ -4024,7 +4174,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
+ } else if (au_br_writable(mod->perm)) {
+ /* ro --> rw */
+ err = -ENOMEM;
-+ br->br_wbr = kmalloc(sizeof(*br->br_wbr), GFP_NOFS);
++ br->br_wbr = kzalloc(sizeof(*br->br_wbr), GFP_NOFS);
+ if (br->br_wbr) {
+ err = au_wbr_init(br, sb, mod->perm);
+ if (unlikely(err)) {
@@ -4077,10 +4227,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 2015-01-25 13:00:38.627713742 +0100
-@@ -0,0 +1,267 @@
++++ linux/fs/aufs/branch.h 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,279 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -4231,6 +4381,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 */
@@ -4348,7 +4510,7 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
+#endif /* __AUFS_BRANCH_H__ */
diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
--- /usr/share/empty/fs/aufs/conf.mk 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/conf.mk 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/conf.mk 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,38 @@
+
+AuConfStr = CONFIG_AUFS_FS=${CONFIG_AUFS_FS}
@@ -4390,10 +4552,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,1303 @@
++++ linux/fs/aufs/cpup.c 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,1368 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -4415,6 +4577,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+
+#include <linux/fs_stack.h>
+#include <linux/mm.h>
++#include <linux/task_work.h>
+#include "aufs.h"
+
+void au_cpup_attr_flags(struct inode *dst, unsigned int iflags)
@@ -4560,6 +4723,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ struct au_cpup_reg_attr *h_src_attr)
+{
+ int err, sbits, icex;
++ unsigned int mnt_flags;
++ unsigned char verbose;
+ struct iattr ia;
+ struct path h_path;
+ struct inode *h_isrc, *h_idst;
@@ -4611,8 +4776,11 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ }
+
+ icex = br->br_perm & AuBrAttr_ICEX;
-+ if (!err)
-+ err = au_cpup_xattr(h_path.dentry, h_src, 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;
+}
@@ -4782,6 +4950,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ }
+ };
+ struct super_block *sb;
++ struct task_struct *tsk = current;
+
+ /* bsrc branch can be ro/rw. */
+ sb = cpg->dentry->d_sb;
@@ -4799,7 +4968,21 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ IMustLock(file[SRC].dentry->d_inode);
+ err = au_copy_file(file[DST].file, file[SRC].file, cpg->len);
+
-+ fput(file[DST].file);
++ /* i wonder if we had O_NO_DELAY_FPUT flag */
++ if (tsk->flags & PF_KTHREAD)
++ __fput_sync(file[DST].file);
++ else {
++ WARN(1, "%pD\nPlease report this warning to aufs-users ML",
++ file[DST].file);
++ fput(file[DST].file);
++ /*
++ * too bad.
++ * we have to call both since we don't know which place the file
++ * was added to.
++ */
++ task_work_run();
++ flush_delayed_fput();
++ }
+ au_sbr_put(sb, file[DST].bindex);
+
+out_src:
@@ -4890,6 +5073,56 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ return err;
+}
+
++/*
++ * regardless 'acl' option, reset all ACL.
++ * All ACL will be copied up later from the original entry on the lower branch.
++ */
++static int au_reset_acl(struct inode *h_dir, struct path *h_path, umode_t mode)
++{
++ int err;
++ struct dentry *h_dentry;
++ struct inode *h_inode;
++
++ h_dentry = h_path->dentry;
++ h_inode = h_dentry->d_inode;
++ /* forget_all_cached_acls(h_inode)); */
++ err = vfsub_removexattr(h_dentry, XATTR_NAME_POSIX_ACL_ACCESS);
++ AuTraceErr(err);
++ if (err == -EOPNOTSUPP)
++ err = 0;
++ if (!err)
++ err = vfsub_acl_chmod(h_inode, mode);
++
++ AuTraceErr(err);
++ return err;
++}
++
++static int au_do_cpup_dir(struct au_cp_generic *cpg, struct dentry *dst_parent,
++ struct inode *h_dir, struct path *h_path)
++{
++ int err;
++ struct inode *dir;
++
++ err = vfsub_removexattr(h_path->dentry, XATTR_NAME_POSIX_ACL_DEFAULT);
++ AuTraceErr(err);
++ if (err == -EOPNOTSUPP)
++ err = 0;
++ if (unlikely(err))
++ goto out;
++
++ /*
++ * strange behaviour from the users view,
++ * particularry setattr case
++ */
++ dir = dst_parent->d_inode;
++ if (au_ibstart(dir) == cpg->bdst)
++ au_cpup_attr_nlink(dir, /*force*/1);
++ au_cpup_attr_nlink(cpg->dentry->d_inode, /*force*/1);
++
++out:
++ return err;
++}
++
+static noinline_for_stack
+int cpup_entry(struct au_cp_generic *cpg, struct dentry *dst_parent,
+ struct au_cpup_reg_attr *h_src_attr)
@@ -4934,7 +5167,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ switch (mode & S_IFMT) {
+ case S_IFREG:
+ isreg = 1;
-+ err = vfsub_create(h_dir, &h_path, mode | S_IWUSR,
++ err = vfsub_create(h_dir, &h_path, S_IRUSR | S_IWUSR,
+ /*want_excl*/true);
+ if (!err)
+ err = au_do_cpup_regular(cpg, h_src_attr);
@@ -4942,16 +5175,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ case S_IFDIR:
+ isdir = 1;
+ err = vfsub_mkdir(h_dir, &h_path, mode);
-+ if (!err) {
-+ /*
-+ * strange behaviour from the users view,
-+ * particularry setattr case
-+ */
-+ if (au_ibstart(dst_parent->d_inode) == cpg->bdst)
-+ au_cpup_attr_nlink(dst_parent->d_inode,
-+ /*force*/1);
-+ au_cpup_attr_nlink(cpg->dentry->d_inode, /*force*/1);
-+ }
++ if (!err)
++ err = au_do_cpup_dir(cpg, dst_parent, h_dir, &h_path);
+ break;
+ case S_IFLNK:
+ err = au_do_cpup_symlink(&h_path, h_src, h_dir);
@@ -4968,6 +5193,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ AuIOErr("Unknown inode type 0%o\n", mode);
+ err = -EIO;
+ }
++ if (!err)
++ err = au_reset_acl(h_dir, &h_path, mode);
+
+ mnt_flags = au_mntflags(sb);
+ if (!au_opt_test(mnt_flags, UDBA_NONE)
@@ -5103,9 +5330,9 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ goto out_parent;
+ if (unlikely(!h_src->d_inode)) {
+ err = -EIO;
-+ AuIOErr("i%lu exists on a upper branch "
++ AuIOErr("i%lu exists on b%d "
+ "but not pseudo-linked\n",
-+ inode->i_ino);
++ inode->i_ino, cpg->bdst);
+ dput(h_src);
+ goto out_parent;
+ }
@@ -5214,7 +5441,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;
@@ -5270,7 +5497,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;
@@ -5481,7 +5708,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);
@@ -5653,7 +5880,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 = {
@@ -5697,10 +5924,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/cpup.h 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,94 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -5795,10 +6022,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/dbgaufs.c 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,432 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -6156,7 +6383,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' function actually,
++ * This function is a dynamic '__fin' function actually,
+ * so the tiny check for si_rwsem is unnecessary.
+ */
+ /* AuRwMustWriteLock(&sbinfo->si_rwsem); */
@@ -6231,10 +6458,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/dbgaufs.h 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,48 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -6283,10 +6510,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/dcsub.c 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,224 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -6511,10 +6738,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,125 @@
++++ linux/fs/aufs/dcsub.h 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,123 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -6542,8 +6769,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;
@@ -6640,10 +6865,10 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
+#endif /* __AUFS_DCSUB_H__ */
diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
--- /usr/share/empty/fs/aufs/debug.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/debug.c 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,520 @@
++++ linux/fs/aufs/debug.c 2016-02-28 12:40:45.724388517 +0100
+@@ -0,0 +1,436 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -6663,7 +6888,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. */
@@ -6882,7 +7106,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
+ }
+ a[0] = 0;
+ if (bindex < 0
-+ && file->f_dentry
++ && !IS_ERR_OR_NULL(file->f_dentry)
+ && au_test_aufs(file->f_dentry->d_sb)
+ && au_fi(file))
+ snprintf(a, sizeof(a), ", gen %d, mmapped %d",
@@ -6890,7 +7114,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
+ 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)
++ if (!IS_ERR_OR_NULL(file->f_dentry))
+ do_pri_dentry(bindex, file->f_dentry);
+ return 0;
+}
@@ -6904,7 +7128,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_dentry)
++ || !au_test_aufs(file->f_dentry->d_sb))
+ return;
+
+ finfo = au_fi(file);
@@ -6971,9 +7197,7 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
+ }
+
+ a->mnt.mnt_sb = sb;
-+ a->fake.br_perm = 0;
+ a->fake.br_path.mnt = &a->mnt;
-+ a->fake.br_xino.xi_file = NULL;
+ atomic_set(&a->fake.br_count, 0);
+ smp_mb(); /* atomic_set */
+ err = do_pri_br(-1, &a->fake);
@@ -6994,42 +7218,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;
@@ -7064,29 +7252,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;
@@ -7121,26 +7286,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;
@@ -7156,18 +7301,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,262 @@
++++ linux/fs/aufs/debug.h 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,228 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -7274,8 +7415,6 @@ 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;
@@ -7293,19 +7432,13 @@ 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"); \
@@ -7355,32 +7488,11 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
+ mutex_unlock(&au_dbg_mtx); \
+} 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); \
-+} while (0)
-+
+#define AuDbgSym(addr) do { \
+ char sym[KSYM_SYMBOL_LEN]; \
+ 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)
@@ -7389,7 +7501,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)
@@ -7398,11 +7509,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 */
+
+/* ---------------------------------------------------------------------- */
@@ -7430,10 +7537,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,1096 @@
++++ linux/fs/aufs/dentry.c 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,1129 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -7479,7 +7586,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;
@@ -7509,8 +7616,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) {
@@ -7526,9 +7637,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);
@@ -7587,7 +7698,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);
@@ -7608,12 +7719,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);
@@ -7621,11 +7730,12 @@ 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);
+
-+ if (au_dbwh(dentry) >= 0)
++ if (au_dbwh(dentry) == bindex)
+ break;
+ if (!h_dentry)
+ continue;
@@ -7956,11 +8066,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))
@@ -8001,7 +8109,9 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
+ struct dentry *dentry;
+ struct inode *inode;
+ mode_t mode;
-+ } orig_h, tmp_h;
++ } orig_h, tmp_h = {
++ .dentry = NULL
++ };
+ struct au_hdentry *hd;
+ struct inode *inode, *h_inode;
+ struct dentry *h_dentry;
@@ -8013,7 +8123,6 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
+ orig_h.mode = 0;
+ if (orig_h.inode)
+ orig_h.mode = orig_h.inode->i_mode & S_IFMT;
-+ memset(&tmp_h, 0, sizeof(tmp_h));
+ if (tmp->di_bstart >= 0) {
+ tmp_h.dentry = tmp->di_hdentry[tmp->di_bstart].hd_dentry;
+ tmp_h.inode = tmp_h.dentry->d_inode;
@@ -8126,6 +8235,28 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
+ return err;
+}
+
++void au_refresh_dop(struct dentry *dentry, int force_reval)
++{
++ const struct dentry_operations *dop
++ = force_reval ? &aufs_dop : dentry->d_sb->s_d_op;
++ static const unsigned int mask
++ = DCACHE_OP_REVALIDATE | DCACHE_OP_WEAK_REVALIDATE;
++
++ BUILD_BUG_ON(sizeof(mask) != sizeof(dentry->d_flags));
++
++ if (dentry->d_op == dop)
++ return;
++
++ AuDbg("%pd\n", dentry);
++ spin_lock(&dentry->d_lock);
++ if (dop == &aufs_dop)
++ dentry->d_flags |= mask;
++ else
++ dentry->d_flags &= ~mask;
++ dentry->d_op = dop;
++ spin_unlock(&dentry->d_lock);
++}
++
+int au_refresh_dentry(struct dentry *dentry, struct dentry *parent)
+{
+ int err, ebrange;
@@ -8478,8 +8609,10 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
+ if (!(flags & (LOOKUP_OPEN | LOOKUP_EMPTY))
+ && inode
+ && !(inode->i_state && I_LINKABLE)
-+ && (IS_DEADDIR(inode) || !inode->i_nlink))
++ && (IS_DEADDIR(inode) || !inode->i_nlink)) {
++ AuTraceErr(err);
+ goto out_inval;
++ }
+
+ do_udba = !au_opt_test(au_mntflags(sb), UDBA_NONE);
+ if (do_udba && inode) {
@@ -8488,8 +8621,10 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
+
+ if (bstart >= 0) {
+ h_inode = au_h_iptr(inode, bstart);
-+ if (h_inode && au_test_higen(inode, h_inode))
++ if (h_inode && au_test_higen(inode, h_inode)) {
++ AuTraceErr(err);
+ goto out_inval;
++ }
+ }
+ }
+
@@ -8528,12 +8663,17 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
+ .d_weak_revalidate = aufs_d_revalidate,
+ .d_release = aufs_d_release
+};
++
++/* aufs_dop without d_revalidate */
++const struct dentry_operations aufs_dop_noreval = {
++ .d_release = aufs_d_release
++};
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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,233 @@
++++ linux/fs/aufs/dentry.h 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,234 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -8578,7 +8718,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
+/* ---------------------------------------------------------------------- */
+
+/* dentry.c */
-+extern const struct dentry_operations aufs_dop;
++extern const struct dentry_operations aufs_dop, aufs_dop_noreval;
+struct au_branch;
+struct dentry *au_sio_lkup_one(struct qstr *name, struct dentry *parent);
+int au_h_verify(struct dentry *h_dentry, unsigned int udba, struct inode *h_dir,
@@ -8588,6 +8728,7 @@ diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
+int au_lkup_neg(struct dentry *dentry, aufs_bindex_t bindex, int wh);
+int au_refresh_dentry(struct dentry *dentry, struct dentry *parent);
+int au_reval_dpath(struct dentry *dentry, unsigned int sigen);
++void au_refresh_dop(struct dentry *dentry, int force_reval);
+
+/* dinfo.c */
+void au_di_init_once(void *_di);
@@ -8767,10 +8908,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/dinfo.c 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,544 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -9315,10 +9456,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,645 @@
++++ linux/fs/aufs/dir.c 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,756 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -9380,8 +9521,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);
@@ -9393,8 +9533,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);
@@ -9416,6 +9555,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); /* 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)
@@ -9462,16 +9705,18 @@ 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;
++ struct vfsmount *mnt;
+
+ FiMustWriteLock(file);
++ AuDebugOn(h_file);
+
+ err = 0;
++ mnt = file->f_path.mnt;
+ dentry = file->f_dentry;
+ file->f_version = dentry->d_inode->i_version;
+ bindex = au_dbstart(dentry);
@@ -9483,6 +9728,9 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
+ if (!h_dentry)
+ continue;
+
++ err = vfsub_test_mntns(mnt, h_dentry->d_sb);
++ if (unlikely(err))
++ break;
+ h_file = au_h_open(dentry, bindex, flags, file, /*force_wr*/0);
+ if (IS_ERR(h_file)) {
+ err = PTR_ERR(h_file);
@@ -9517,7 +9765,11 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
+ 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);
+ }
@@ -9624,8 +9876,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);
@@ -9964,10 +10216,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,130 @@
++++ linux/fs/aufs/dir.h 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,131 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -10058,6 +10310,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);
+
@@ -10098,10 +10351,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/dynop.c 2016-02-28 11:27:01.277245613 +0100
@@ -0,0 +1,379 @@
+/*
-+ * Copyright (C) 2010-2014 Junjiro R. Okajima
++ * Copyright (C) 2010-2016 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
@@ -10481,10 +10734,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,75 @@
++++ linux/fs/aufs/dynop.h 2016-02-28 11:27:01.277245613 +0100
+@@ -0,0 +1,76 @@
+/*
-+ * Copyright (C) 2010-2014 Junjiro R. Okajima
++ * Copyright (C) 2010-2016 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
@@ -10509,7 +10762,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};
+
@@ -10560,10 +10814,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/export.c 2016-02-28 12:40:45.724388517 +0100
@@ -0,0 +1,831 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -11174,7 +11428,7 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c
+ ino = decode_ino(fh + Fh_ino);
+ /* it should never happen */
+ if (unlikely(ino == AUFS_ROOT_INO))
-+ goto out;
++ goto out_unlock;
+
+ dir_ino = decode_ino(fh + Fh_dir_ino);
+ dentry = decode_by_ino(sb, ino, dir_ino);
@@ -11395,10 +11649,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/fhsm.c 2016-02-28 11:27:01.280579017 +0100
@@ -0,0 +1,426 @@
+/*
-+ * Copyright (C) 2011-2014 Junjiro R. Okajima
++ * Copyright (C) 2011-2016 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
@@ -11825,10 +12079,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,829 @@
++++ linux/fs/aufs/file.c 2016-02-28 11:27:01.280579017 +0100
+@@ -0,0 +1,857 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -11872,7 +12126,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);
@@ -11893,9 +12147,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 */
@@ -11921,7 +12175,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);
@@ -12053,24 +12307,43 @@ 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);
++ 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) {
@@ -12078,7 +12351,13 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
+ au_sphl_add(&finfo->fi_hlist,
+ &au_sbi(file->f_dentry->d_sb)->si_files);
+ }
-+ fi_write_unlock(file);
++ if (!no_lock)
++ fi_write_unlock(file);
++ else {
++ lockdep_off();
++ fi_write_unlock(file);
++ lockdep_on();
++ }
+ if (unlikely(err)) {
+ finfo->fi_hdir = NULL;
+ au_finfo_fin(file);
@@ -12611,9 +12890,11 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
+{ AuUnsupport(); }
+static int aufs_releasepage(struct page *page, gfp_t gfp)
+{ AuUnsupport(); return 0; }
++#if 0 /* called by memory compaction regardless file */
+static int aufs_migratepage(struct address_space *mapping, struct page *newpage,
+ struct page *page, enum migrate_mode mode)
+{ AuUnsupport(); return 0; }
++#endif
+static int aufs_launder_page(struct page *page)
+{ AuUnsupport(); return 0; }
+static int aufs_is_partially_uptodate(struct page *page,
@@ -12647,7 +12928,8 @@ diff -urN /usr/share/empty/fs/aufs/file.c linux/fs/aufs/file.c
+ /* no bmap, no block device */
+ .invalidatepage = aufs_invalidatepage,
+ .releasepage = aufs_releasepage,
-+ .migratepage = aufs_migratepage,
++ /* is fallback_migrate_page ok? */
++ /* .migratepage = aufs_migratepage, */
+ .launder_page = aufs_launder_page,
+ .is_partially_uptodate = aufs_is_partially_uptodate,
+ .is_dirty_writeback = aufs_is_dirty_writeback,
@@ -12658,10 +12940,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,284 @@
++++ linux/fs/aufs/file.h 2016-02-28 11:27:01.280579017 +0100
+@@ -0,0 +1,291 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -12735,8 +13017,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);
@@ -12765,8 +13053,9 @@ diff -urN /usr/share/empty/fs/aufs/file.h linux/fs/aufs/file.h
+
+/* 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);
@@ -12946,10 +13235,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/finfo.c 2016-02-28 11:27:01.280579017 +0100
@@ -0,0 +1,156 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -12999,6 +13288,7 @@ 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_dentry));
+ hf->hf_file = val;
+ hf->hf_br = au_sbr(file->f_dentry->d_sb, bindex);
+ }
@@ -13024,7 +13314,6 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c
+ if (fidir) {
+ fidir->fd_bbot = -1;
+ fidir->fd_nent = nbr;
-+ fidir->fd_vdir_cache = NULL;
+ }
+
+ return fidir;
@@ -13106,10 +13395,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,813 @@
++++ linux/fs/aufs/f_op.c 2016-02-28 11:27:01.280579017 +0100
+@@ -0,0 +1,757 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -13135,12 +13424,11 @@ 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 dentry *dentry, *h_dentry;
+ struct au_finfo *finfo;
+ struct inode *h_inode;
+
@@ -13148,11 +13436,24 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
+
+ err = 0;
+ dentry = file->f_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_dentry = au_h_dptr(dentry, bindex);
++ err = vfsub_test_mntns(file->f_path.mnt, h_dentry->d_sb);
++ if (unlikely(err))
++ goto out;
++ h_file = au_h_open(dentry, bindex, flags, file, /*force_wr*/0);
++ } else {
++ h_dentry = h_file->f_dentry;
++ err = vfsub_test_mntns(file->f_path.mnt, h_dentry->d_sb);
++ if (unlikely(err))
++ goto out;
++ get_file(h_file);
++ }
+ if (IS_ERR(h_file))
+ err = PTR_ERR(h_file);
+ else {
@@ -13170,6 +13471,7 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
+ /* file->f_ra = h_file->f_ra; */
+ }
+
++out:
+ return err;
+}
+
@@ -13178,13 +13480,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;
+ 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;
+}
@@ -13232,33 +13537,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_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_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);
@@ -13291,53 +13685,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 = file_inode(h_file);
-+ 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;
+}
@@ -13389,28 +13754,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);
@@ -13420,53 +13780,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 = file_inode(h_file);
-+ 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;
+}
@@ -13477,19 +13808,18 @@ 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);
+ if (file->f_mapping != h_file->f_mapping) {
@@ -13497,15 +13827,12 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c
+ 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);
@@ -13517,52 +13844,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 = file_inode(h_file);
-+ 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;
+}
@@ -13571,46 +13869,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);
+ 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;
+}
@@ -13675,44 +13952,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
@@ -13723,21 +13983,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);
@@ -13750,45 +14010,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;
+}
+
@@ -13797,28 +14041,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);
@@ -13836,16 +14074,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
@@ -13854,22 +14090,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_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);
@@ -13881,7 +14114,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
@@ -13923,10 +14156,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,469 @@
++++ linux/fs/aufs/fstype.h 2016-02-28 11:27:01.280579017 +0100
+@@ -0,0 +1,400 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -13953,6 +14186,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/nfs_fs.h>
+#include <linux/romfs_fs.h>
+
+static inline int au_test_aufs(struct super_block *sb)
@@ -13967,8 +14201,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
@@ -13976,8 +14210,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
@@ -14036,60 +14270,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;
@@ -14144,15 +14324,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)
@@ -14282,10 +14453,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 */
+ ;
+}
+
@@ -14298,10 +14466,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 */
+ ;
+}
@@ -14313,7 +14477,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);
@@ -14338,19 +14501,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)
+{
@@ -14392,14 +14545,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/hfsnotify.c 2016-02-28 11:27:01.280579017 +0100
@@ -0,0 +1,288 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -14539,7 +14703,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 "";
@@ -14688,10 +14852,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/hfsplus.c 2016-02-28 11:27:01.280579017 +0100
@@ -0,0 +1,56 @@
+/*
-+ * Copyright (C) 2010-2014 Junjiro R. Okajima
++ * Copyright (C) 2010-2016 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
@@ -14748,10 +14912,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/hnotify.c 2016-02-28 12:40:45.724388517 +0100
@@ -0,0 +1,714 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -15466,10 +15630,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 2015-01-25 13:00:38.631047076 +0100
++++ linux/fs/aufs/iinfo.c 2016-02-28 11:27:01.280579017 +0100
@@ -0,0 +1,277 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -15588,13 +15752,13 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
+ sigen = au_sigen(inode->i_sb);
+ iinfo = au_ii(inode);
+ iigen = &iinfo->ii_generation;
-+ spin_lock(&iinfo->ii_genspin);
++ spin_lock(&iigen->ig_spin);
+ iigen->ig_generation = sigen;
+ if (half)
+ au_ig_fset(iigen->ig_flags, HALF_REFRESHED);
+ else
+ au_ig_fclr(iigen->ig_flags, HALF_REFRESHED);
-+ spin_unlock(&iinfo->ii_genspin);
++ spin_unlock(&iigen->ig_spin);
+}
+
+/* it may be called at remount time, too */
@@ -15647,7 +15811,7 @@ diff -urN /usr/share/empty/fs/aufs/iinfo.c linux/fs/aufs/iinfo.c
+ struct au_iinfo *iinfo = &c->iinfo;
+ static struct lock_class_key aufs_ii;
+
-+ spin_lock_init(&iinfo->ii_genspin);
++ spin_lock_init(&iinfo->ii_generation.ig_spin);
+ au_rw_init(&iinfo->ii_rwsem);
+ au_rw_class(&iinfo->ii_rwsem, &aufs_ii);
+ inode_init_once(&c->vfs_inode);
@@ -15747,10 +15911,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 2015-01-25 13:00:38.631047076 +0100
-@@ -0,0 +1,496 @@
++++ linux/fs/aufs/inode.c 2016-02-28 11:27:01.280579017 +0100
+@@ -0,0 +1,522 @@
+/*
-+ * Copyright (C) 2005-2014 Junjiro R. Okajima
++ * Copyright (C) 2005-2016 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
@@ -15851,6 +16015,32 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
+ return err;
+}
+
++void au_refresh_iop(struct inode *inode, int force_getattr)
++{
++ int type;
++ struct au_sbinfo *sbi = au_sbi(inode->i_sb);
++ const struct inode_operations *iop
++ = force_getattr ? aufs_iop : sbi->si_iop_array;
++
++ if (inode->i_op == iop)
++ return;
++
++ switch (inode->i_mode & S_IFMT) {
++ case S_IFDIR:
++ type = AuIop_DIR;
++ break;
++ case S_IFLNK:
++ type = AuIop_SYMLINK;
++ break;
++ default:
++ type = AuIop_OTHER;
++ break;
++ }
++
++ inode->i_op = iop + type;
++ /* unnecessary smp_wmb() */
++}
++
+int au_refresh_hinode_self(struct inode *inode)
+{
+ int err, update;
@@ -15931,18 +16121,20 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
+ struct dentry *h_dentry;
+ struct inode *h_inode;
+ struct au_iinfo *iinfo;
++ struct inode_operations *iop;
+
+ IiMustWriteLock(inode);
+
+ err = 0;
+ isdir = 0;
++ iop = au_sbi(inode->i_sb)->si_iop_array;
+ bstart = au_dbstart(dentry);
+ h_inode = au_h_dptr(dentry, bstart)->d_inode;
+ mode = h_inode->i_mode;
+ switch (mode & S_IFMT) {
+ case S_IFREG:
+ btail = au_dbtail(dentry);
-+ inode->i_op = &aufs_iop;
++ inode->i_op = iop + AuIop_OTHER;
+ inode->i_fop = &aufs_file_fop;
+ err = au_dy_iaop(inode, bstart, h_inode);
+ if (unlikely(err))
@@ -15951,19 +16143,19 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c
+ case S_IFDIR:
+ isdir = 1;
+ btail = au_dbtaildir(dentry);
-+ inode->i_op = &aufs_dir_iop;
++ inode->i_op = iop + AuIop_DIR;
+ inode->i_fop = &aufs_dir_fop;
+ break;
+ case S_IFLNK:
+ btail = au_dbtail(dentry);
-+ inode->i_op = &aufs_symlink_iop;
++ inode->i_op = iop + AuIop_SYMLINK;
+ break;
<Skipped 3170 lines>
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/kernel.git/commitdiff/7f2ca4b1e90dc08ffbaebf9bc3bbc023cfde9733
More information about the pld-cvs-commit
mailing list