From f2c43d5f9be66527e3189ec126a8f04f1f4d2107 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Sat, 17 Dec 2016 12:34:00 +0100 Subject: [PATCH] - update aufs patch --- kernel-aufs4.patch | 1154 +++++++++++++++++++++++++------------------- 1 file changed, 664 insertions(+), 490 deletions(-) diff --git a/kernel-aufs4.patch b/kernel-aufs4.patch index 2a028f1b..16f65cba 100644 --- a/kernel-aufs4.patch +++ b/kernel-aufs4.patch @@ -1,10 +1,10 @@ -aufs4.x-rcN kbuild patch +aufs4.9 kbuild patch diff --git a/fs/Kconfig b/fs/Kconfig -index 2bc7ad7..3049386 100644 +index 4bd03a2..620e01b 100644 --- a/fs/Kconfig +++ b/fs/Kconfig -@@ -245,6 +245,7 @@ source "fs/pstore/Kconfig" +@@ -249,6 +249,7 @@ source "fs/pstore/Kconfig" source "fs/sysv/Kconfig" source "fs/ufs/Kconfig" source "fs/exofs/Kconfig" @@ -22,7 +22,7 @@ index ed2b632..aa6d14b 100644 obj-$(CONFIG_EFIVAR_FS) += efivarfs/ +obj-$(CONFIG_AUFS_FS) += aufs/ diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild -index 185f8ea..5deb0d1 100644 +index cd2be1c..78f3c68 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild @@ -59,6 +59,7 @@ header-y += atmsvc.h @@ -33,13 +33,13 @@ index 185f8ea..5deb0d1 100644 header-y += auto_fs4.h header-y += auto_fs.h header-y += auxvec.h -aufs4.x-rcN base patch +aufs4.9 base patch diff --git a/MAINTAINERS b/MAINTAINERS -index f593300..8a17054 100644 +index 63cefa6..d78b954 100644 --- a/MAINTAINERS +++ b/MAINTAINERS -@@ -2256,6 +2256,19 @@ F: include/linux/audit.h +@@ -2293,6 +2293,19 @@ F: include/linux/audit.h F: include/uapi/linux/audit.h F: kernel/audit* @@ -60,7 +60,7 @@ index f593300..8a17054 100644 M: Miguel Ojeda Sandonis W: http://miguelojeda.es/auxdisplay.htm diff --git a/drivers/block/loop.c b/drivers/block/loop.c -index c9f2107..005e292 100644 +index fa1b7a9..6ee9235 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -701,6 +701,24 @@ static inline int is_loop_device(struct file *file) @@ -124,10 +124,10 @@ index 350a2c8..6f42279 100644 return error; diff --git a/fs/inode.c b/fs/inode.c -index 7e3ef3a..675fe84 100644 +index 88110fd..9a9ba3a 100644 --- a/fs/inode.c +++ b/fs/inode.c -@@ -1593,7 +1593,7 @@ EXPORT_SYMBOL(generic_update_time); +@@ -1642,7 +1642,7 @@ int generic_update_time(struct inode *inode, struct timespec *time, int flags) * This does the actual work of updating an inodes time or version. Must have * had called mnt_want_write() before calling this. */ @@ -137,7 +137,7 @@ index 7e3ef3a..675fe84 100644 int (*update_time)(struct inode *, struct timespec *, int); diff --git a/fs/read_write.c b/fs/read_write.c -index 66215a7..a1da117 100644 +index 190e0d36..4052813 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -515,6 +515,28 @@ ssize_t __vfs_write(struct file *file, const char __user *p, size_t count, @@ -170,10 +170,10 @@ index 66215a7..a1da117 100644 { mm_segment_t old_fs; diff --git a/fs/splice.c b/fs/splice.c -index dd9bf7e..9326c2a 100644 +index 5a7750b..28160a7 100644 --- a/fs/splice.c +++ b/fs/splice.c -@@ -1111,8 +1111,8 @@ EXPORT_SYMBOL(generic_splice_sendpage); +@@ -855,8 +855,8 @@ ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out, /* * Attempt to initiate a splice from pipe to file. */ @@ -184,7 +184,7 @@ index dd9bf7e..9326c2a 100644 { ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); -@@ -1128,9 +1128,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, +@@ -872,9 +872,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, /* * Attempt to initiate a splice from a file to a pipe. */ @@ -201,7 +201,7 @@ diff --git a/include/linux/file.h b/include/linux/file.h index 7444f5f..bdac0be 100644 --- a/include/linux/file.h +++ b/include/linux/file.h -@@ -19,6 +19,7 @@ struct dentry; +@@ -19,6 +19,7 @@ struct path; extern struct file *alloc_file(struct path *, fmode_t mode, const struct file_operations *fop); @@ -210,10 +210,10 @@ index 7444f5f..bdac0be 100644 static inline void fput_light(struct file *file, int fput_needed) { diff --git a/include/linux/fs.h b/include/linux/fs.h -index 901e25d..a71aa9e 100644 +index dc0478c..27c05e7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h -@@ -1275,6 +1275,7 @@ extern void fasync_free(struct fasync_struct *); +@@ -1291,6 +1291,7 @@ struct fasync_struct { /* can be called from interrupts */ extern void kill_fasync(struct fasync_struct **, int, int); @@ -221,7 +221,7 @@ index 901e25d..a71aa9e 100644 extern void __f_setown(struct file *filp, struct pid *, enum pid_type, int force); extern void f_setown(struct file *filp, unsigned long arg, int force); extern void f_delown(struct file *filp); -@@ -1699,6 +1700,7 @@ struct file_operations { +@@ -1715,6 +1716,7 @@ struct file_operations { ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); int (*check_flags)(int); @@ -229,7 +229,7 @@ index 901e25d..a71aa9e 100644 int (*flock) (struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); -@@ -1759,6 +1761,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, +@@ -1768,6 +1770,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, struct iovec *fast_pointer, struct iovec **ret_pointer); @@ -242,7 +242,7 @@ index 901e25d..a71aa9e 100644 extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *); extern ssize_t __vfs_write(struct file *, const char __user *, size_t, loff_t *); extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); -@@ -2123,6 +2131,7 @@ extern int current_umask(void); +@@ -2140,6 +2148,7 @@ extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, extern void ihold(struct inode * inode); extern void iput(struct inode *); extern int generic_update_time(struct inode *, struct timespec *, int); @@ -251,10 +251,10 @@ index 901e25d..a71aa9e 100644 /* /sys/fs */ extern struct kobject *fs_kobj; diff --git a/include/linux/splice.h b/include/linux/splice.h -index da2751d..2e0fca6 100644 +index 00a2116..1f0a4a2 100644 --- a/include/linux/splice.h +++ b/include/linux/splice.h -@@ -83,4 +83,10 @@ extern void splice_shrink_spd(struct splice_pipe_desc *); +@@ -86,4 +86,10 @@ extern ssize_t splice_direct_to_actor(struct file *, struct splice_desc *, extern const struct pipe_buf_operations page_cache_pipe_buf_ops; extern const struct pipe_buf_operations default_pipe_buf_ops; @@ -265,13 +265,13 @@ index da2751d..2e0fca6 100644 + struct pipe_inode_info *pipe, size_t len, + unsigned int flags); #endif -aufs4.x-rcN mmap patch +aufs4.9 mmap patch diff --git a/fs/proc/base.c b/fs/proc/base.c -index ac0df4d..42255e5 100644 +index ca651ac..0e8551a 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c -@@ -1938,7 +1938,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path) +@@ -1953,7 +1953,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path) down_read(&mm->mmap_sem); vma = find_exact_vma(mm, vm_start, vm_end); if (vma && vma->vm_file) { @@ -297,10 +297,10 @@ index f8595e8..cb8eda0 100644 ino = inode->i_ino; } diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c -index f6fa99e..2750949 100644 +index 35b92d8..5b981db 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c -@@ -298,7 +298,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) +@@ -291,7 +291,10 @@ static int is_stack(struct proc_maps_private *priv, const char *name = NULL; if (file) { @@ -312,7 +312,7 @@ index f6fa99e..2750949 100644 dev = inode->i_sb->s_dev; ino = inode->i_ino; pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT; -@@ -1634,7 +1637,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) +@@ -1627,7 +1630,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) struct proc_maps_private *proc_priv = &numa_priv->proc_maps; struct vm_area_struct *vma = v; struct numa_maps *md = &numa_priv->md; @@ -322,10 +322,10 @@ index f6fa99e..2750949 100644 struct mm_walk walk = { .hugetlb_entry = gather_hugetlb_stats, diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c -index faacb0c..17b43be 100644 +index 3717562..6a328f1 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c -@@ -163,7 +163,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, +@@ -155,7 +155,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, file = vma->vm_file; if (file) { @@ -338,40 +338,40 @@ index faacb0c..17b43be 100644 ino = inode->i_ino; pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT; diff --git a/include/linux/mm.h b/include/linux/mm.h -index ef815b9..a772481 100644 +index a92c8d7..1d83a2a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h -@@ -1266,6 +1266,28 @@ static inline int fixup_user_fault(struc +@@ -1266,6 +1266,28 @@ static inline int fixup_user_fault(struct task_struct *tsk, } #endif +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); ++ int); +extern void vma_do_get_file(struct vm_area_struct *, const char[], int); +extern void vma_do_fput(struct vm_area_struct *, const char[], int); + -+#define vma_file_update_time(vma) vma_do_file_update_time(vma, __func__, \ -+ __LINE__) -+#define vma_pr_or_file(vma) vma_do_pr_or_file(vma, __func__, \ -+ __LINE__) -+#define vma_get_file(vma) vma_do_get_file(vma, __func__, __LINE__) -+#define vma_fput(vma) vma_do_fput(vma, __func__, __LINE__) ++#define vma_file_update_time(vma) vma_do_file_update_time(vma, __func__, \ ++ __LINE__) ++#define vma_pr_or_file(vma) vma_do_pr_or_file(vma, __func__, \ ++ __LINE__) ++#define vma_get_file(vma) vma_do_get_file(vma, __func__, __LINE__) ++#define vma_fput(vma) vma_do_fput(vma, __func__, __LINE__) + +#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__) ++#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 */ + extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, unsigned int gup_flags); extern int access_remote_vm(struct mm_struct *mm, unsigned long addr, diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h -index 903200f..55fc528 100644 +index 4a8aced..badd16b 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -275,6 +275,7 @@ struct vm_region { @@ -391,10 +391,10 @@ index 903200f..55fc528 100644 #ifndef CONFIG_MMU diff --git a/kernel/fork.c b/kernel/fork.c -index beb3172..ad4cfa8 100644 +index 997ac1d..4d0131b 100644 --- a/kernel/fork.c +++ b/kernel/fork.c -@@ -477,7 +477,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) +@@ -624,7 +624,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, struct inode *inode = file_inode(file); struct address_space *mapping = file->f_mapping; @@ -404,10 +404,10 @@ index beb3172..ad4cfa8 100644 atomic_dec(&inode->i_writecount); i_mmap_lock_write(mapping); diff --git a/mm/Makefile b/mm/Makefile -index 2ca1faf..6b9da3f 100644 +index 295bd7a..14fa1c8 100644 --- a/mm/Makefile +++ b/mm/Makefile -@@ -40,7 +40,7 @@ obj-y := filemap.o mempool.o oom_kill.o \ +@@ -37,7 +37,7 @@ obj-y := filemap.o mempool.o oom_kill.o \ mm_init.o mmu_context.o percpu.o slab_common.o \ compaction.o vmacache.o \ interval_tree.o list_lru.o workingset.o \ @@ -417,10 +417,10 @@ index 2ca1faf..6b9da3f 100644 obj-y += init-mm.o diff --git a/mm/filemap.c b/mm/filemap.c -index 2d0986a..4a31bad 100644 +index 50b52fe..9e607f9 100644 --- a/mm/filemap.c +++ b/mm/filemap.c -@@ -2284,7 +2284,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) +@@ -2304,7 +2304,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) int ret = VM_FAULT_LOCKED; sb_start_pagefault(inode->i_sb); @@ -430,10 +430,10 @@ index 2d0986a..4a31bad 100644 if (page->mapping != inode->i_mapping) { unlock_page(page); diff --git a/mm/memory.c b/mm/memory.c -index 793fe0f..45f39f3 100644 +index e18c57b..7be4a39 100644 --- a/mm/memory.c +++ b/mm/memory.c -@@ -2113,7 +2113,7 @@ static inline int wp_page_reuse(struct fault_env *fe, pte_t orig_pte, +@@ -2117,7 +2117,7 @@ static inline int wp_page_reuse(struct fault_env *fe, pte_t orig_pte, } if (!page_mkwrite) @@ -443,10 +443,10 @@ index 793fe0f..45f39f3 100644 return VM_FAULT_WRITE; diff --git a/mm/mmap.c b/mm/mmap.c -index ca9d91b..f3ebc5a 100644 +index 1af87c1..95b0ff4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c -@@ -163,7 +163,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma) +@@ -170,7 +170,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma) if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); if (vma->vm_file) @@ -455,7 +455,7 @@ index ca9d91b..f3ebc5a 100644 mpol_put(vma_policy(vma)); kmem_cache_free(vm_area_cachep, vma); return next; -@@ -790,7 +790,7 @@ again: +@@ -879,7 +879,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, if (remove_next) { if (file) { uprobe_munmap(next, next->vm_start, next->vm_end); @@ -464,7 +464,7 @@ index ca9d91b..f3ebc5a 100644 } if (next->anon_vma) anon_vma_merge(vma, next); -@@ -1574,8 +1574,8 @@ out: +@@ -1727,8 +1727,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr, return addr; unmap_and_free_vma: @@ -474,7 +474,7 @@ index ca9d91b..f3ebc5a 100644 /* Undo any partial mapping done by a device driver. */ unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end); -@@ -2380,7 +2380,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, +@@ -2533,7 +2533,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, goto out_free_mpol; if (new->vm_file) @@ -483,7 +483,7 @@ index ca9d91b..f3ebc5a 100644 if (new->vm_ops && new->vm_ops->open) new->vm_ops->open(new); -@@ -2399,7 +2399,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, +@@ -2552,7 +2552,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, if (new->vm_ops && new->vm_ops->close) new->vm_ops->close(new); if (new->vm_file) @@ -492,7 +492,7 @@ index ca9d91b..f3ebc5a 100644 unlink_anon_vmas(new); out_free_mpol: mpol_put(vma_policy(new)); -@@ -2550,7 +2550,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, +@@ -2703,7 +2703,7 @@ int vm_munmap(unsigned long start, size_t len) struct vm_area_struct *vma; unsigned long populate = 0; unsigned long ret = -EINVAL; @@ -501,7 +501,7 @@ index ca9d91b..f3ebc5a 100644 pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. See Documentation/vm/remap_file_pages.txt.\n", current->comm, current->pid); -@@ -2625,10 +2625,27 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, +@@ -2778,10 +2778,27 @@ int vm_munmap(unsigned long start, size_t len) } } @@ -530,7 +530,7 @@ index ca9d91b..f3ebc5a 100644 out: up_write(&mm->mmap_sem); if (populate) -@@ -2903,7 +2920,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, +@@ -3056,7 +3073,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, if (anon_vma_clone(new_vma, vma)) goto out_free_mempol; if (new_vma->vm_file) @@ -540,10 +540,10 @@ index ca9d91b..f3ebc5a 100644 new_vma->vm_ops->open(new_vma); vma_link(mm, new_vma, prev, rb_link, rb_parent); diff --git a/mm/nommu.c b/mm/nommu.c -index 95daf81..5086a29 100644 +index 8b8faaf..5d26ed94 100644 --- a/mm/nommu.c +++ b/mm/nommu.c -@@ -644,7 +644,7 @@ static void __put_nommu_region(struct vm_region *region) +@@ -636,7 +636,7 @@ static void __put_nommu_region(struct vm_region *region) up_write(&nommu_region_sem); if (region->vm_file) @@ -552,7 +552,7 @@ index 95daf81..5086a29 100644 /* IO memory and memory shared directly out of the pagecache * from ramfs/tmpfs mustn't be released here */ -@@ -802,7 +802,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma) +@@ -794,7 +794,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma) if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); if (vma->vm_file) @@ -561,7 +561,7 @@ index 95daf81..5086a29 100644 put_nommu_region(vma->vm_region); kmem_cache_free(vm_area_cachep, vma); } -@@ -1328,7 +1328,7 @@ unsigned long do_mmap(struct file *file, +@@ -1320,7 +1320,7 @@ unsigned long do_mmap(struct file *file, goto error_just_free; } } @@ -570,7 +570,7 @@ index 95daf81..5086a29 100644 kmem_cache_free(vm_region_jar, region); region = pregion; result = start; -@@ -1403,10 +1403,10 @@ error_just_free: +@@ -1395,10 +1395,10 @@ unsigned long do_mmap(struct file *file, up_write(&nommu_region_sem); error: if (region->vm_file) @@ -675,13 +675,13 @@ index 0000000..b323b8a + fput(pr); +} +#endif /* !CONFIG_MMU */ -aufs4.x-rcN standalone patch +aufs4.9 standalone patch diff --git a/fs/dcache.c b/fs/dcache.c -index df0268c..76280ee 100644 +index df0268c..755fea1 100644 --- a/fs/dcache.c +++ b/fs/dcache.c -@@ -1272,6 +1272,7 @@ rename_retry: +@@ -1272,6 +1272,7 @@ void d_walk(struct dentry *parent, void *data, seq = 1; goto again; } @@ -689,8 +689,16 @@ index df0268c..76280ee 100644 /* * Search for at least 1 mount point in the dentry's subdirs. +@@ -2855,6 +2856,7 @@ void d_exchange(struct dentry *dentry1, struct dentry *dentry2) + + write_sequnlock(&rename_lock); + } ++EXPORT_SYMBOL_GPL(d_exchange); + + /** + * d_ancestor - search for an ancestor diff --git a/fs/exec.c b/fs/exec.c -index 6fcfb3f..ed9d646 100644 +index 4e497b9..e27d323 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -104,6 +104,7 @@ bool path_noexec(const struct path *path) @@ -717,7 +725,7 @@ diff --git a/fs/file_table.c b/fs/file_table.c index ad17e05..ae9f267 100644 --- a/fs/file_table.c +++ b/fs/file_table.c -@@ -147,6 +147,7 @@ over: +@@ -147,6 +147,7 @@ struct file *get_empty_filp(void) } return ERR_PTR(-ENFILE); } @@ -750,10 +758,10 @@ index ad17e05..ae9f267 100644 void __init files_init(void) { diff --git a/fs/inode.c b/fs/inode.c -index 675fe84..da063d3 100644 +index 9a9ba3a..a3a18d8 100644 --- a/fs/inode.c +++ b/fs/inode.c -@@ -1602,6 +1602,7 @@ int update_time(struct inode *inode, struct timespec *time, int flags) +@@ -1651,6 +1651,7 @@ int update_time(struct inode *inode, struct timespec *time, int flags) return update_time(inode, time, flags); } @@ -762,10 +770,10 @@ index 675fe84..da063d3 100644 /** * touch_atime - update the access time diff --git a/fs/namespace.c b/fs/namespace.c -index 7bb2cda..88ec098 100644 +index e6c234b..8d13f7b 100644 --- a/fs/namespace.c +++ b/fs/namespace.c -@@ -463,6 +463,7 @@ void __mnt_drop_write(struct vfsmount *mnt) +@@ -466,6 +466,7 @@ void __mnt_drop_write(struct vfsmount *mnt) mnt_dec_writers(real_mount(mnt)); preempt_enable(); } @@ -773,7 +781,7 @@ index 7bb2cda..88ec098 100644 /** * mnt_drop_write - give up write access to a mount -@@ -1812,6 +1813,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, +@@ -1823,6 +1824,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg, } return 0; } @@ -782,7 +790,7 @@ index 7bb2cda..88ec098 100644 static void cleanup_group_ids(struct mount *mnt, struct mount *end) { diff --git a/fs/notify/group.c b/fs/notify/group.c -index b47f7cf..618bc9e 100644 +index fbe3cbe..bdfc61e 100644 --- a/fs/notify/group.c +++ b/fs/notify/group.c @@ -22,6 +22,7 @@ @@ -837,7 +845,7 @@ index d3fea0b..5fc06ad 100644 void fsnotify_destroy_marks(struct hlist_head *head, spinlock_t *lock) { -@@ -415,6 +417,7 @@ err: +@@ -415,6 +417,7 @@ int fsnotify_add_mark_locked(struct fsnotify_mark *mark, return ret; } @@ -854,7 +862,7 @@ index d3fea0b..5fc06ad 100644 /* * Destroy all marks in destroy_list, waits for SRCU period to finish before diff --git a/fs/open.c b/fs/open.c -index 4fd6e25..ec6f532 100644 +index d3ed817..20d2494 100644 --- a/fs/open.c +++ b/fs/open.c @@ -64,6 +64,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs, @@ -865,7 +873,7 @@ index 4fd6e25..ec6f532 100644 long vfs_truncate(const struct path *path, loff_t length) { -@@ -678,6 +679,7 @@ int open_check_o_direct(struct file *f) +@@ -695,6 +696,7 @@ int open_check_o_direct(struct file *f) } return 0; } @@ -874,7 +882,7 @@ index 4fd6e25..ec6f532 100644 static int do_dentry_open(struct file *f, struct inode *inode, diff --git a/fs/read_write.c b/fs/read_write.c -index a1da117..c643215 100644 +index 4052813..7dfd732 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -525,6 +525,7 @@ vfs_readf_t vfs_readf(struct file *file) @@ -894,10 +902,10 @@ index a1da117..c643215 100644 ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos) { diff --git a/fs/splice.c b/fs/splice.c -index 9326c2a..0606690 100644 +index 28160a7..98c1902 100644 --- a/fs/splice.c +++ b/fs/splice.c -@@ -1124,6 +1124,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out, +@@ -868,6 +868,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out, return splice_write(pipe, out, ppos, len, flags); } @@ -905,7 +913,7 @@ index 9326c2a..0606690 100644 /* * Attempt to initiate a splice from a file to a pipe. -@@ -1153,6 +1154,7 @@ long do_splice_to(struct file *in, loff_t *ppos, +@@ -897,6 +898,7 @@ long do_splice_to(struct file *in, loff_t *ppos, return splice_read(in, ppos, pipe, len, flags); } @@ -914,17 +922,17 @@ index 9326c2a..0606690 100644 /** * splice_direct_to_actor - splices data directly between two non-pipes diff --git a/fs/xattr.c b/fs/xattr.c -index c243905..b60dc60 100644 +index 2d13b4e..41c2bcd 100644 --- a/fs/xattr.c +++ b/fs/xattr.c -@@ -214,6 +214,7 @@ vfs_getxattr_alloc(struct dentry *dentry, const char *name, char **xattr_value, +@@ -296,6 +296,7 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name, *xattr_value = value; return error; } +EXPORT_SYMBOL_GPL(vfs_getxattr_alloc); ssize_t - vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) + __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name, diff --git a/kernel/task_work.c b/kernel/task_work.c index d513051..e056d54 100644 --- a/kernel/task_work.c @@ -935,10 +943,10 @@ index d513051..e056d54 100644 } +EXPORT_SYMBOL_GPL(task_work_run); diff --git a/security/commoncap.c b/security/commoncap.c -index 14540bd..4e3b242 100644 +index 8df676f..6b5cc07 100644 --- a/security/commoncap.c +++ b/security/commoncap.c -@@ -1066,12 +1066,14 @@ int cap_mmap_addr(unsigned long addr) +@@ -1061,12 +1061,14 @@ int cap_mmap_addr(unsigned long addr) } return ret; } @@ -974,10 +982,10 @@ index 03c1652..f88c84b 100644 int devcgroup_inode_mknod(int mode, dev_t dev) { diff --git a/security/security.c b/security/security.c -index 4838e7f..36c741e 100644 +index f825304..8dd441d 100644 --- a/security/security.c +++ b/security/security.c -@@ -434,6 +434,7 @@ int security_path_rmdir(const struct path *dir, struct dentry *dentry) +@@ -443,6 +443,7 @@ int security_path_rmdir(const struct path *dir, struct dentry *dentry) return 0; return call_int_hook(path_rmdir, 0, dir, dentry); } @@ -985,7 +993,7 @@ index 4838e7f..36c741e 100644 int security_path_unlink(const struct path *dir, struct dentry *dentry) { -@@ -450,6 +451,7 @@ int security_path_symlink(const struct path *dir, struct dentry *dentry, +@@ -459,6 +460,7 @@ int security_path_symlink(const struct path *dir, struct dentry *dentry, return 0; return call_int_hook(path_symlink, 0, dir, dentry, old_name); } @@ -993,7 +1001,7 @@ index 4838e7f..36c741e 100644 int security_path_link(struct dentry *old_dentry, const struct path *new_dir, struct dentry *new_dentry) -@@ -458,6 +460,7 @@ int security_path_link(struct dentry *old_dentry, const struct path *new_dir, +@@ -467,6 +469,7 @@ int security_path_link(struct dentry *old_dentry, const struct path *new_dir, return 0; return call_int_hook(path_link, 0, old_dentry, new_dir, new_dentry); } @@ -1001,7 +1009,7 @@ index 4838e7f..36c741e 100644 int security_path_rename(const struct path *old_dir, struct dentry *old_dentry, const struct path *new_dir, struct dentry *new_dentry, -@@ -485,6 +488,7 @@ int security_path_truncate(const struct path *path) +@@ -494,6 +497,7 @@ int security_path_truncate(const struct path *path) return 0; return call_int_hook(path_truncate, 0, path); } @@ -1009,7 +1017,7 @@ index 4838e7f..36c741e 100644 int security_path_chmod(const struct path *path, umode_t mode) { -@@ -492,6 +496,7 @@ int security_path_chmod(const struct path *path, umode_t mode) +@@ -501,6 +505,7 @@ int security_path_chmod(const struct path *path, umode_t mode) return 0; return call_int_hook(path_chmod, 0, path, mode); } @@ -1017,7 +1025,7 @@ index 4838e7f..36c741e 100644 int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid) { -@@ -499,6 +504,7 @@ int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid) +@@ -508,6 +513,7 @@ int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid) return 0; return call_int_hook(path_chown, 0, path, uid, gid); } @@ -1025,7 +1033,7 @@ index 4838e7f..36c741e 100644 int security_path_chroot(const struct path *path) { -@@ -584,6 +590,7 @@ int security_inode_readlink(struct dentry *dentry) +@@ -593,6 +599,7 @@ int security_inode_readlink(struct dentry *dentry) return 0; return call_int_hook(inode_readlink, 0, dentry); } @@ -1033,7 +1041,7 @@ index 4838e7f..36c741e 100644 int security_inode_follow_link(struct dentry *dentry, struct inode *inode, bool rcu) -@@ -599,6 +606,7 @@ int security_inode_permission(struct inode *inode, int mask) +@@ -608,6 +615,7 @@ int security_inode_permission(struct inode *inode, int mask) return 0; return call_int_hook(inode_permission, 0, inode, mask); } @@ -1041,7 +1049,7 @@ index 4838e7f..36c741e 100644 int security_inode_setattr(struct dentry *dentry, struct iattr *attr) { -@@ -758,6 +766,7 @@ int security_file_permission(struct file *file, int mask) +@@ -779,6 +787,7 @@ int security_file_permission(struct file *file, int mask) return fsnotify_perm(file, mask); } @@ -1049,7 +1057,7 @@ index 4838e7f..36c741e 100644 int security_file_alloc(struct file *file) { -@@ -817,6 +826,7 @@ int security_mmap_file(struct file *file, unsigned long prot, +@@ -838,6 +847,7 @@ int security_mmap_file(struct file *file, unsigned long prot, return ret; return ima_file_mmap(file, prot); } @@ -2405,8 +2413,8 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt lin +regular files only. diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documentation/filesystems/aufs/README --- /usr/share/empty/Documentation/filesystems/aufs/README 1970-01-01 01:00:00.000000000 +0100 -+++ linux/Documentation/filesystems/aufs/README 2016-10-09 16:55:36.479367956 +0200 -@@ -0,0 +1,392 @@ ++++ linux/Documentation/filesystems/aufs/README 2016-12-17 12:28:17.595211562 +0100 +@@ -0,0 +1,393 @@ + +Aufs4 -- advanced multi layered unification filesystem version 4.x +http://aufs.sf.net @@ -2782,6 +2790,7 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/README linux/Documenta +Daniel Epellei made a donation (2015/1). +OmegaPhil made a donation (2016/1). +Tomasz Szewczyk made a donation (2016/4). ++James Burry made a donation (2016/12). + +Thank you very much. +Donations are always, including future donations, very important and @@ -4635,8 +4644,8 @@ diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk +-include ${srctree}/${src}/conf_priv.mk diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c --- /usr/share/empty/fs/aufs/cpup.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/cpup.c 2016-10-09 16:55:38.886097714 +0200 -@@ -0,0 +1,1391 @@ ++++ linux/fs/aufs/cpup.c 2016-12-17 12:28:17.595211562 +0100 +@@ -0,0 +1,1394 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -5358,7 +5367,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c + IMustLock(h_dir); + AuDbg("%pd %pd\n", h_dentry, h_path->dentry); + /* no delegation since it is just created */ -+ err = vfsub_rename(h_dir, h_dentry, h_dir, h_path, /*delegated*/NULL); ++ err = vfsub_rename(h_dir, h_dentry, h_dir, h_path, /*delegated*/NULL, ++ /*flags*/0); + dput(h_path->dentry); + +out: @@ -5371,6 +5381,8 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c + * @len is for truncating when it is -1 copyup the entire file. + * in link/rename cases, @dst_parent may be different from the real one. + * basic->bsrc can be larger than basic->bdst. ++ * aufs doesn't touch the credential so ++ * security_inode_copy_up{,_xattr}() are unnecrssary. + */ +static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent) +{ @@ -10974,8 +10986,8 @@ diff -urN /usr/share/empty/fs/aufs/dynop.h linux/fs/aufs/dynop.h +#endif /* __AUFS_DYNOP_H__ */ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c --- /usr/share/empty/fs/aufs/export.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/export.c 2016-10-09 16:55:36.489368218 +0200 -@@ -0,0 +1,837 @@ ++++ linux/fs/aufs/export.c 2016-12-17 12:28:17.595211562 +0100 +@@ -0,0 +1,836 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -11003,7 +11015,6 @@ diff -urN /usr/share/empty/fs/aufs/export.c linux/fs/aufs/export.c +#include +#include +#include -+#include "../fs/mount.h" +#include "aufs.h" + +union conv { @@ -13559,8 +13570,8 @@ diff -urN /usr/share/empty/fs/aufs/finfo.c linux/fs/aufs/finfo.c +} diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c --- /usr/share/empty/fs/aufs/f_op.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/f_op.c 2016-10-09 16:55:36.489368218 +0200 -@@ -0,0 +1,772 @@ ++++ linux/fs/aufs/f_op.c 2016-12-17 12:28:17.595211562 +0100 +@@ -0,0 +1,723 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -14193,54 +14204,6 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c + return err; +} + -+/* no one supports this operation, currently */ -+#if 0 -+static int aufs_aio_fsync_nondir(struct kiocb *kio, int datasync) -+{ -+ int err; -+ struct au_write_pre wpre; -+ struct inode *inode, *h_inode; -+ struct file *file, *h_file; -+ -+ err = 0; /* -EBADF; */ /* posix? */ -+ if (unlikely(!(file->f_mode & FMODE_WRITE))) -+ goto out; -+ -+ file = kio->ki_filp; -+ inode = file_inode(file); -+ au_mtx_and_read_lock(inode); -+ -+ h_file = au_write_pre(file, /*do_ready*/1, &wpre); -+ err = PTR_ERR(h_file); -+ if (IS_ERR(h_file)) -+ goto out_unlock; -+ -+ err = -ENOSYS; -+ h_file = au_hf_top(file); -+ if (h_file->f_op->aio_fsync) { -+ h_inode = file_inode(h_file); -+ if (!is_sync_kiocb(kio)) { -+ get_file(h_file); -+ fput(file); -+ } -+ kio->ki_filp = h_file; -+ err = h_file->f_op->aio_fsync(kio, datasync); -+ inode_lock_nested(h_inode, AuLsc_I_CHILD); -+ if (!err) -+ vfsub_update_h_iattr(&h_file->f_path, /*did*/NULL); -+ /*ignore*/ -+ inode_unlock(h_inode); -+ } -+ au_write_post(inode, h_file, &wpre, /*written*/0); -+ -+out_unlock: -+ si_read_unlock(inode->sb); -+ inode_unlock(inode); -+out: -+ return err; -+} -+#endif -+ +static int aufs_fasync(int fd, struct file *file, int flag) +{ + int err; @@ -14321,7 +14284,6 @@ diff -urN /usr/share/empty/fs/aufs/f_op.c linux/fs/aufs/f_op.c + .flush = aufs_flush_nondir, + .release = aufs_release_nondir, + .fsync = aufs_fsync_nondir, -+ /* .aio_fsync = aufs_aio_fsync_nondir, */ + .fasync = aufs_fasync, + /* .sendpage = aufs_sendpage, */ + .setfl = aufs_setfl, @@ -16629,8 +16591,8 @@ diff -urN /usr/share/empty/fs/aufs/inode.c linux/fs/aufs/inode.c +} diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h --- /usr/share/empty/fs/aufs/inode.h 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/inode.h 2016-10-09 16:55:38.889431135 +0200 -@@ -0,0 +1,700 @@ ++++ linux/fs/aufs/inode.h 2016-12-17 12:28:17.595211562 +0100 +@@ -0,0 +1,691 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -16871,7 +16833,8 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h +/* i_op_ren.c */ +int au_wbr(struct dentry *dentry, aufs_bindex_t btgt); +int aufs_rename(struct inode *src_dir, struct dentry *src_dentry, -+ struct inode *dir, struct dentry *dentry); ++ struct inode *dir, struct dentry *dentry, ++ unsigned int flags); + +/* iinfo.c */ +struct inode *au_h_iptr(struct inode *inode, aufs_bindex_t bindex); @@ -16944,17 +16907,11 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h +int au_cpup_xattr(struct dentry *h_dst, struct dentry *h_src, int ignore_flags, + unsigned int verbose); +ssize_t aufs_listxattr(struct dentry *dentry, char *list, size_t size); -+ssize_t aufs_getxattr(struct dentry *dentry, struct inode *inode, -+ const char *name, void *value, size_t size); -+int aufs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, -+ const void *value, size_t size, int flags); -+int aufs_removexattr(struct dentry *dentry, const char *name); -+ -+/* void au_xattr_init(struct super_block *sb); */ ++void au_xattr_init(struct super_block *sb); +#else +AuStubInt0(au_cpup_xattr, struct dentry *h_dst, struct dentry *h_src, + int ignore_flags, unsigned int verbose); -+/* AuStubVoid(au_xattr_init, struct super_block *sb); */ ++AuStubVoid(au_xattr_init, struct super_block *sb); +#endif + +#ifdef CONFIG_FS_POSIX_ACL @@ -16965,11 +16922,10 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h +#if IS_ENABLED(CONFIG_AUFS_XATTR) || IS_ENABLED(CONFIG_FS_POSIX_ACL) +enum { + AU_XATTR_SET, -+ AU_XATTR_REMOVE, + AU_ACL_SET +}; + -+struct au_srxattr { ++struct au_sxattr { + int type; + union { + struct { @@ -16979,16 +16935,13 @@ diff -urN /usr/share/empty/fs/aufs/inode.h linux/fs/aufs/inode.h + int flags; + } set; + struct { -+ const char *name; -+ } remove; -+ struct { + struct posix_acl *acl; + int type; + } acl_set; + } u; +}; -+ssize_t au_srxattr(struct dentry *dentry, struct inode *inode, -+ struct au_srxattr *arg); ++ssize_t au_sxattr(struct dentry *dentry, struct inode *inode, ++ struct au_sxattr *arg); +#endif + +/* ---------------------------------------------------------------------- */ @@ -17556,8 +17509,8 @@ diff -urN /usr/share/empty/fs/aufs/ioctl.c linux/fs/aufs/ioctl.c +#endif diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c --- /usr/share/empty/fs/aufs/i_op_add.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/i_op_add.c 2016-10-09 16:55:36.492701639 +0200 -@@ -0,0 +1,924 @@ ++++ linux/fs/aufs/i_op_add.c 2016-12-17 12:28:17.595211562 +0100 +@@ -0,0 +1,928 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -18272,6 +18225,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c + goto out_parent; + } + ++ /* ++ * aufs doesn't touch the credential so ++ * security_dentry_create_files_as() is unnecrssary. ++ */ + if (au_opt_test(au_mntflags(sb), PLINK)) { + if (a->bdst < a->bsrc + /* && h_src_dentry->d_sb != a->h_path.dentry->d_sb */) @@ -18484,8 +18441,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_add.c linux/fs/aufs/i_op_add.c +} diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c --- /usr/share/empty/fs/aufs/i_op.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/i_op.c 2016-10-09 16:55:38.889431135 +0200 -@@ -0,0 +1,1451 @@ ++++ linux/fs/aufs/i_op.c 2016-12-17 12:28:17.595211562 +0100 +@@ -0,0 +1,1444 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -19376,6 +19333,10 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c + inode = d_inode(dentry); + IMustLock(inode); + ++ err = setattr_prepare(dentry, ia); ++ if (unlikely(err)) ++ goto out; ++ + err = -ENOMEM; + a = kzalloc(sizeof(*a), GFP_NOFS); + if (unlikely(!a)) @@ -19519,8 +19480,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c + return err; +} + -+ssize_t au_srxattr(struct dentry *dentry, struct inode *inode, -+ struct au_srxattr *arg) ++ssize_t au_sxattr(struct dentry *dentry, struct inode *inode, ++ struct au_sxattr *arg) +{ + int err; + struct path h_path; @@ -19554,13 +19515,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c + arg->u.set.name, arg->u.set.value, + arg->u.set.size, arg->u.set.flags); + break; -+ case AU_XATTR_REMOVE: -+ err = vfsub_removexattr(h_path.dentry, arg->u.remove.name); -+ break; + case AU_ACL_SET: + err = -EOPNOTSUPP; + h_inode = d_inode(h_path.dentry); + if (h_inode->i_op->set_acl) ++ /* this will call posix_acl_update_mode */ + err = h_inode->i_op->set_acl(h_inode, + arg->u.acl_set.acl, + arg->u.acl_set.type); @@ -19614,7 +19573,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c +} + +/* -+ * common routine for aufs_getattr() and aufs_getxattr(). ++ * common routine for aufs_getattr() and au_getxattr(). + * returns zero or negative (an error). + * @dentry will be read-locked in success. + */ @@ -19781,7 +19740,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c + err = 0; + AuDbg("%pf\n", h_inode->i_op->get_link); + AuDbgDentry(h_dentry); -+ ret = h_inode->i_op->get_link(h_dentry, h_inode, done); ++ ret = vfs_get_link(h_dentry, done); + dput(h_dentry); + if (IS_ERR(ret)) + err = PTR_ERR(ret); @@ -19875,10 +19834,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c + .getattr = aufs_getattr, + +#ifdef CONFIG_AUFS_XATTR -+ .setxattr = aufs_setxattr, -+ .getxattr = aufs_getxattr, + .listxattr = aufs_listxattr, -+ .removexattr = aufs_removexattr, +#endif + + .readlink = generic_readlink, @@ -19907,10 +19863,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c + .getattr = aufs_getattr, + +#ifdef CONFIG_AUFS_XATTR -+ .setxattr = aufs_setxattr, -+ .getxattr = aufs_getxattr, + .listxattr = aufs_listxattr, -+ .removexattr = aufs_removexattr, +#endif + + .update_time = aufs_update_time, @@ -19928,10 +19881,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op.c linux/fs/aufs/i_op.c + .getattr = aufs_getattr, + +#ifdef CONFIG_AUFS_XATTR -+ .setxattr = aufs_setxattr, -+ .getxattr = aufs_getxattr, + .listxattr = aufs_listxattr, -+ .removexattr = aufs_removexattr, +#endif + + .update_time = aufs_update_time @@ -20454,8 +20404,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_del.c linux/fs/aufs/i_op_del.c +} diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c --- /usr/share/empty/fs/aufs/i_op_ren.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/i_op_ren.c 2016-10-09 16:55:36.492701639 +0200 -@@ -0,0 +1,1015 @@ ++++ linux/fs/aufs/i_op_ren.c 2016-12-17 12:28:17.595211562 +0100 +@@ -0,0 +1,1165 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -20483,13 +20433,15 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c +enum { AuSRC, AuDST, AuSrcDst }; +enum { AuPARENT, AuCHILD, AuParentChild }; + -+#define AuRen_ISDIR 1 -+#define AuRen_ISSAMEDIR (1 << 1) -+#define AuRen_WHSRC (1 << 2) -+#define AuRen_WHDST (1 << 3) -+#define AuRen_MNT_WRITE (1 << 4) -+#define AuRen_DT_DSTDIR (1 << 5) -+#define AuRen_DIROPQ (1 << 6) ++#define AuRen_ISDIR_SRC 1 ++#define AuRen_ISDIR_DST (1 << 1) ++#define AuRen_ISSAMEDIR (1 << 2) ++#define AuRen_WHSRC (1 << 3) ++#define AuRen_WHDST (1 << 4) ++#define AuRen_MNT_WRITE (1 << 5) ++#define AuRen_DT_DSTDIR (1 << 6) ++#define AuRen_DIROPQ_SRC (1 << 7) ++#define AuRen_DIROPQ_DST (1 << 8) +#define au_ftest_ren(flags, name) ((flags) & AuRen_##name) +#define au_fset_ren(flags, name) \ + do { (flags) |= AuRen_##name; } while (0) @@ -20501,9 +20453,9 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + struct dentry *dentry, *h_dentry, *parent, *h_parent, + *wh_dentry; + struct inode *dir, *inode; -+ struct au_hinode *hdir; ++ struct au_hinode *hdir, *hinode; + struct au_dtime dt[AuParentChild]; -+ aufs_bindex_t btop; ++ aufs_bindex_t btop, bdiropq; + } sd[AuSrcDst]; + +#define src_dentry sd[AuSRC].dentry @@ -20514,9 +20466,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c +#define src_h_parent sd[AuSRC].h_parent +#define src_wh_dentry sd[AuSRC].wh_dentry +#define src_hdir sd[AuSRC].hdir ++#define src_hinode sd[AuSRC].hinode +#define src_h_dir sd[AuSRC].hdir->hi_inode +#define src_dt sd[AuSRC].dt +#define src_btop sd[AuSRC].btop ++#define src_bdiropq sd[AuSRC].bdiropq + +#define dst_dentry sd[AuDST].dentry +#define dst_dir sd[AuDST].dir @@ -20526,18 +20480,23 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c +#define dst_h_parent sd[AuDST].h_parent +#define dst_wh_dentry sd[AuDST].wh_dentry +#define dst_hdir sd[AuDST].hdir ++#define dst_hinode sd[AuDST].hinode +#define dst_h_dir sd[AuDST].hdir->hi_inode +#define dst_dt sd[AuDST].dt +#define dst_btop sd[AuDST].btop ++#define dst_bdiropq sd[AuDST].bdiropq + + struct dentry *h_trap; + struct au_branch *br; -+ struct au_hinode *src_hinode; + struct path h_path; + struct au_nhash whlist; -+ aufs_bindex_t btgt, src_bwh, src_bdiropq; ++ aufs_bindex_t btgt, src_bwh; + -+ unsigned int flags; ++ struct { ++ unsigned short auren_flags; ++ unsigned char flags; /* syscall parameter */ ++ unsigned char exchange; ++ } __packed; + + struct au_whtmp_rmdir *thargs; + struct dentry *h_dst; @@ -20559,16 +20518,29 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + err = -EIO; \ +} while (0) + -+static void au_ren_rev_diropq(int err, struct au_ren_args *a) ++static void au_ren_do_rev_diropq(int err, struct au_ren_args *a, int idx) +{ + int rerr; ++ struct dentry *d; ++#define src_or_dst(member) a->sd[idx].member + -+ au_hn_inode_lock_nested(a->src_hinode, AuLsc_I_CHILD); -+ rerr = au_diropq_remove(a->src_dentry, a->btgt); -+ au_hn_inode_unlock(a->src_hinode); -+ au_set_dbdiropq(a->src_dentry, a->src_bdiropq); ++ d = src_or_dst(dentry); /* {src,dst}_dentry */ ++ au_hn_inode_lock_nested(src_or_dst(hinode), AuLsc_I_CHILD); ++ rerr = au_diropq_remove(d, a->btgt); ++ au_hn_inode_unlock(src_or_dst(hinode)); ++ au_set_dbdiropq(d, src_or_dst(bdiropq)); + if (rerr) -+ RevertFailure("remove diropq %pd", a->src_dentry); ++ RevertFailure("remove diropq %pd", d); ++ ++#undef src_or_dst_ ++} ++ ++static void au_ren_rev_diropq(int err, struct au_ren_args *a) ++{ ++ if (au_ftest_ren(a->auren_flags, DIROPQ_SRC)) ++ au_ren_do_rev_diropq(err, a, AuSRC); ++ if (au_ftest_ren(a->auren_flags, DIROPQ_DST)) ++ au_ren_do_rev_diropq(err, a, AuDST); +} + +static void au_ren_rev_rename(int err, struct au_ren_args *a) @@ -20587,7 +20559,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + delegated = NULL; + rerr = vfsub_rename(a->dst_h_dir, + au_h_dptr(a->src_dentry, a->btgt), -+ a->src_h_dir, &a->h_path, &delegated); ++ a->src_h_dir, &a->h_path, &delegated, a->flags); + if (unlikely(rerr == -EWOULDBLOCK)) { + pr_warn("cannot retry for NFSv4 delegation" + " for an internal rename\n"); @@ -20620,7 +20592,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + + delegated = NULL; + rerr = vfsub_rename(a->dst_h_dir, a->h_dst, a->dst_h_dir, &a->h_path, -+ &delegated); ++ &delegated, a->flags); + if (unlikely(rerr == -EWOULDBLOCK)) { + pr_warn("cannot retry for NFSv4 delegation" + " for an internal rename\n"); @@ -20662,13 +20634,11 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + d = a->src_dentry; + if (au_dbtop(d) == a->btgt) { + a->h_path.dentry = a->dst_h_dentry; -+ if (au_ftest_ren(a->flags, DIROPQ) -+ && au_dbdiropq(d) == a->btgt) -+ au_fclr_ren(a->flags, DIROPQ); + AuDebugOn(au_dbtop(d) != a->btgt); + delegated = NULL; + err = vfsub_rename(a->src_h_dir, au_h_dptr(d, a->btgt), -+ a->dst_h_dir, &a->h_path, &delegated); ++ a->dst_h_dir, &a->h_path, &delegated, ++ a->flags); + if (unlikely(err == -EWOULDBLOCK)) { + pr_warn("cannot retry for NFSv4 delegation" + " for an internal rename\n"); @@ -20712,127 +20682,179 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c +} + +/* make it 'opaque' dir. */ -+static int au_ren_diropq(struct au_ren_args *a) ++static int au_ren_do_diropq(struct au_ren_args *a, int idx) +{ + int err; -+ struct dentry *diropq; ++ struct dentry *d, *diropq; ++#define src_or_dst(member) a->sd[idx].member + + err = 0; -+ a->src_bdiropq = au_dbdiropq(a->src_dentry); -+ a->src_hinode = au_hi(a->src_inode, a->btgt); -+ au_hn_inode_lock_nested(a->src_hinode, AuLsc_I_CHILD); -+ diropq = au_diropq_create(a->src_dentry, a->btgt); -+ au_hn_inode_unlock(a->src_hinode); ++ d = src_or_dst(dentry); /* {src,dst}_dentry */ ++ src_or_dst(bdiropq) = au_dbdiropq(d); ++ src_or_dst(hinode) = au_hi(src_or_dst(inode), a->btgt); ++ au_hn_inode_lock_nested(src_or_dst(hinode), AuLsc_I_CHILD); ++ diropq = au_diropq_create(d, a->btgt); ++ au_hn_inode_unlock(src_or_dst(hinode)); + if (IS_ERR(diropq)) + err = PTR_ERR(diropq); + else + dput(diropq); + ++#undef src_or_dst_ + return err; +} + -+static int do_rename(struct au_ren_args *a) ++static int au_ren_diropq(struct au_ren_args *a) +{ + int err; -+ struct dentry *d, *h_d; ++ unsigned char always; ++ struct dentry *d; + -+ /* prepare workqueue args for asynchronous rmdir */ -+ h_d = a->dst_h_dentry; -+ if (au_ftest_ren(a->flags, ISDIR) && d_is_positive(h_d)) { -+ err = -ENOMEM; -+ a->thargs = au_whtmp_rmdir_alloc(a->src_dentry->d_sb, GFP_NOFS); -+ if (unlikely(!a->thargs)) ++ err = 0; ++ d = a->dst_dentry; /* already renamed on the branch */ ++ always = !!au_opt_test(au_mntflags(d->d_sb), ALWAYS_DIROPQ); ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC) ++ && a->btgt != au_dbdiropq(a->src_dentry) ++ && (a->dst_wh_dentry ++ || a->btgt <= au_dbdiropq(d) ++ /* hide the lower to keep xino */ ++ /* the lowers may not be a dir, but we hide them anyway */ ++ || a->btgt < au_dbbot(d) ++ || always)) { ++ AuDbg("here\n"); ++ err = au_ren_do_diropq(a, AuSRC); ++ if (unlikely(err)) + goto out; -+ a->h_dst = dget(h_d); -+ } -+ -+ /* create whiteout for src_dentry */ -+ if (au_ftest_ren(a->flags, WHSRC)) { -+ a->src_bwh = au_dbwh(a->src_dentry); -+ AuDebugOn(a->src_bwh >= 0); -+ a->src_wh_dentry -+ = au_wh_create(a->src_dentry, a->btgt, a->src_h_parent); -+ err = PTR_ERR(a->src_wh_dentry); -+ if (IS_ERR(a->src_wh_dentry)) -+ goto out_thargs; -+ } -+ -+ /* lookup whiteout for dentry */ -+ if (au_ftest_ren(a->flags, WHDST)) { -+ h_d = au_wh_lkup(a->dst_h_parent, &a->dst_dentry->d_name, -+ a->br); -+ err = PTR_ERR(h_d); -+ if (IS_ERR(h_d)) -+ goto out_whsrc; -+ if (d_is_negative(h_d)) -+ dput(h_d); -+ else -+ a->dst_wh_dentry = h_d; ++ au_fset_ren(a->auren_flags, DIROPQ_SRC); + } ++ if (!a->exchange) ++ goto out; /* success */ + -+ /* rename dentry to tmpwh */ -+ if (a->thargs) { -+ err = au_whtmp_ren(a->dst_h_dentry, a->br); ++ d = a->src_dentry; /* already renamed on the branch */ ++ if (au_ftest_ren(a->auren_flags, ISDIR_DST) ++ && a->btgt != au_dbdiropq(a->dst_dentry) ++ && (a->btgt < au_dbdiropq(d) ++ || a->btgt < au_dbbot(d) ++ || always)) { ++ AuDbgDentry(a->src_dentry); ++ AuDbgDentry(a->dst_dentry); ++ err = au_ren_do_diropq(a, AuDST); + if (unlikely(err)) -+ goto out_whdst; ++ goto out_rev_src; ++ au_fset_ren(a->auren_flags, DIROPQ_DST); ++ } ++ goto out; /* success */ + -+ d = a->dst_dentry; -+ au_set_h_dptr(d, a->btgt, NULL); -+ err = au_lkup_neg(d, a->btgt, /*wh*/0); -+ if (unlikely(err)) -+ goto out_whtmp; -+ a->dst_h_dentry = au_h_dptr(d, a->btgt); ++out_rev_src: ++ AuDbg("err %d, reverting src\n", err); ++ au_ren_rev_diropq(err, a); ++out: ++ return err; ++} ++ ++static int do_rename(struct au_ren_args *a) ++{ ++ int err; ++ struct dentry *d, *h_d; ++ ++ if (!a->exchange) { ++ /* prepare workqueue args for asynchronous rmdir */ ++ h_d = a->dst_h_dentry; ++ if (au_ftest_ren(a->auren_flags, ISDIR_DST) ++ && d_is_positive(h_d)) { ++ err = -ENOMEM; ++ a->thargs = au_whtmp_rmdir_alloc(a->src_dentry->d_sb, ++ GFP_NOFS); ++ if (unlikely(!a->thargs)) ++ goto out; ++ a->h_dst = dget(h_d); ++ } ++ ++ /* create whiteout for src_dentry */ ++ if (au_ftest_ren(a->auren_flags, WHSRC)) { ++ a->src_bwh = au_dbwh(a->src_dentry); ++ AuDebugOn(a->src_bwh >= 0); ++ a->src_wh_dentry = au_wh_create(a->src_dentry, a->btgt, ++ a->src_h_parent); ++ err = PTR_ERR(a->src_wh_dentry); ++ if (IS_ERR(a->src_wh_dentry)) ++ goto out_thargs; ++ } ++ ++ /* lookup whiteout for dentry */ ++ if (au_ftest_ren(a->auren_flags, WHDST)) { ++ h_d = au_wh_lkup(a->dst_h_parent, ++ &a->dst_dentry->d_name, a->br); ++ err = PTR_ERR(h_d); ++ if (IS_ERR(h_d)) ++ goto out_whsrc; ++ if (d_is_negative(h_d)) ++ dput(h_d); ++ else ++ a->dst_wh_dentry = h_d; ++ } ++ ++ /* rename dentry to tmpwh */ ++ if (a->thargs) { ++ err = au_whtmp_ren(a->dst_h_dentry, a->br); ++ if (unlikely(err)) ++ goto out_whdst; ++ ++ d = a->dst_dentry; ++ au_set_h_dptr(d, a->btgt, NULL); ++ err = au_lkup_neg(d, a->btgt, /*wh*/0); ++ if (unlikely(err)) ++ goto out_whtmp; ++ a->dst_h_dentry = au_h_dptr(d, a->btgt); ++ } + } + + BUG_ON(d_is_positive(a->dst_h_dentry) && a->src_btop != a->btgt); + + /* rename by vfs_rename or cpup */ -+ d = a->dst_dentry; -+ if (au_ftest_ren(a->flags, ISDIR) -+ && (a->dst_wh_dentry -+ || au_dbdiropq(d) == a->btgt -+ /* hide the lower to keep xino */ -+ || a->btgt < au_dbbot(d) -+ || au_opt_test(au_mntflags(d->d_sb), ALWAYS_DIROPQ))) -+ au_fset_ren(a->flags, DIROPQ); + err = au_ren_or_cpup(a); + if (unlikely(err)) + /* leave the copied-up one */ + goto out_whtmp; + + /* make dir opaque */ -+ if (au_ftest_ren(a->flags, DIROPQ)) { -+ err = au_ren_diropq(a); -+ if (unlikely(err)) -+ goto out_rename; -+ } ++ err = au_ren_diropq(a); ++ if (unlikely(err)) ++ goto out_rename; + + /* update target timestamps */ ++ if (a->exchange) { ++ AuDebugOn(au_dbtop(a->dst_dentry) != a->btgt); ++ a->h_path.dentry = au_h_dptr(a->dst_dentry, a->btgt); ++ vfsub_update_h_iattr(&a->h_path, /*did*/NULL); /*ignore*/ ++ a->dst_inode->i_ctime = d_inode(a->h_path.dentry)->i_ctime; ++ } + AuDebugOn(au_dbtop(a->src_dentry) != a->btgt); + a->h_path.dentry = au_h_dptr(a->src_dentry, a->btgt); + vfsub_update_h_iattr(&a->h_path, /*did*/NULL); /*ignore*/ + a->src_inode->i_ctime = d_inode(a->h_path.dentry)->i_ctime; + -+ /* remove whiteout for dentry */ -+ if (a->dst_wh_dentry) { -+ a->h_path.dentry = a->dst_wh_dentry; -+ err = au_wh_unlink_dentry(a->dst_h_dir, &a->h_path, -+ a->dst_dentry); -+ if (unlikely(err)) -+ goto out_diropq; -+ } ++ if (!a->exchange) { ++ /* remove whiteout for dentry */ ++ if (a->dst_wh_dentry) { ++ a->h_path.dentry = a->dst_wh_dentry; ++ err = au_wh_unlink_dentry(a->dst_h_dir, &a->h_path, ++ a->dst_dentry); ++ if (unlikely(err)) ++ goto out_diropq; ++ } + -+ /* remove whtmp */ -+ if (a->thargs) -+ au_ren_del_whtmp(a); /* ignore this error */ ++ /* remove whtmp */ ++ if (a->thargs) ++ au_ren_del_whtmp(a); /* ignore this error */ + -+ au_fhsm_wrote(a->src_dentry->d_sb, a->btgt, /*force*/0); ++ au_fhsm_wrote(a->src_dentry->d_sb, a->btgt, /*force*/0); ++ } + err = 0; + goto out_success; + +out_diropq: -+ if (au_ftest_ren(a->flags, DIROPQ)) -+ au_ren_rev_diropq(err, a); ++ au_ren_rev_diropq(err, a); +out_rename: + au_ren_rev_rename(err, a); + dput(a->h_dst); @@ -20925,7 +20947,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + SiMustAnyLock(d->d_sb); + + err = 0; -+ if (au_ftest_ren(a->flags, ISDIR) && a->dst_inode) { ++ if (au_ftest_ren(a->auren_flags, ISDIR_DST) && a->dst_inode) { + rdhash = au_sbi(d->d_sb)->si_rdhash; + if (!rdhash) + rdhash = au_rdhash_est(au_dir_size(/*file*/NULL, d)); @@ -20933,9 +20955,12 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + if (unlikely(err)) + goto out; + -+ au_set_dbtop(d, a->dst_btop); -+ err = may_rename_dstdir(d, &a->whlist); -+ au_set_dbtop(d, a->btgt); ++ if (!a->exchange) { ++ au_set_dbtop(d, a->dst_btop); ++ err = may_rename_dstdir(d, &a->whlist); ++ au_set_dbtop(d, a->btgt); ++ } else ++ err = may_rename_srcdir(d, a->btgt); + } + a->dst_h_dentry = au_h_dptr(d, au_dbtop(d)); + if (unlikely(err)) @@ -20943,7 +20968,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + + d = a->src_dentry; + a->src_h_dentry = au_h_dptr(d, au_dbtop(d)); -+ if (au_ftest_ren(a->flags, ISDIR)) { ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC)) { + err = may_rename_srcdir(d, a->btgt); + if (unlikely(err)) { + au_nhash_wh_free(&a->whlist); @@ -20967,7 +20992,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + + if (a->src_btop == a->btgt) { + err = au_may_del(a->src_dentry, a->btgt, a->src_h_parent, -+ au_ftest_ren(a->flags, ISDIR)); ++ au_ftest_ren(a->auren_flags, ISDIR_SRC)); + if (unlikely(err)) + goto out; + err = -EINVAL; @@ -20984,7 +21009,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + goto out; + + err = -EIO; -+ isdir = !!au_ftest_ren(a->flags, ISDIR); ++ isdir = !!au_ftest_ren(a->auren_flags, ISDIR_DST); + if (d_really_is_negative(a->dst_dentry)) { + if (d_is_negative(a->dst_h_dentry)) + err = au_may_add(a->dst_dentry, a->btgt, @@ -21034,7 +21059,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c +{ + vfsub_unlock_rename(a->src_h_parent, a->src_hdir, + a->dst_h_parent, a->dst_hdir); -+ if (au_ftest_ren(a->flags, MNT_WRITE)) ++ if (au_ftest_ren(a->auren_flags, MNT_WRITE)) + vfsub_mnt_drop_write(au_br_mnt(a->br)); +} + @@ -21052,7 +21077,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + err = vfsub_mnt_want_write(au_br_mnt(a->br)); + if (unlikely(err)) + goto out; -+ au_fset_ren(a->flags, MNT_WRITE); ++ au_fset_ren(a->auren_flags, MNT_WRITE); + a->h_trap = vfsub_lock_rename(a->src_h_parent, a->src_hdir, + a->dst_h_parent, a->dst_hdir); + udba = au_opt_udba(a->src_dentry->d_sb); @@ -21085,20 +21110,30 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + + dir = a->dst_dir; + dir->i_version++; -+ if (au_ftest_ren(a->flags, ISDIR)) { ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC)) { + /* is this updating defined in POSIX? */ + au_cpup_attr_timesizes(a->src_inode); + au_cpup_attr_nlink(dir, /*force*/1); + } -+ + au_dir_ts(dir, a->btgt); + -+ if (au_ftest_ren(a->flags, ISSAMEDIR)) ++ if (a->exchange) { ++ dir = a->src_dir; ++ dir->i_version++; ++ if (au_ftest_ren(a->auren_flags, ISDIR_DST)) { ++ /* is this updating defined in POSIX? */ ++ au_cpup_attr_timesizes(a->dst_inode); ++ au_cpup_attr_nlink(dir, /*force*/1); ++ } ++ au_dir_ts(dir, a->btgt); ++ } ++ ++ if (au_ftest_ren(a->auren_flags, ISSAMEDIR)) + return; + + dir = a->src_dir; + dir->i_version++; -+ if (au_ftest_ren(a->flags, ISDIR)) ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC)) + au_cpup_attr_nlink(dir, /*force*/1); + au_dir_ts(dir, a->btgt); +} @@ -21118,13 +21153,16 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + + i = a->dst_inode; + if (i) { -+ if (!au_ftest_ren(a->flags, ISDIR)) -+ vfsub_drop_nlink(i); -+ else { -+ vfsub_dead_dir(i); -+ au_cpup_attr_timesizes(i); -+ } -+ au_update_dbrange(d, /*do_put_zero*/1); ++ if (!a->exchange) { ++ if (!au_ftest_ren(a->auren_flags, ISDIR_DST)) ++ vfsub_drop_nlink(i); ++ else { ++ vfsub_dead_dir(i); ++ au_cpup_attr_timesizes(i); ++ } ++ au_update_dbrange(d, /*do_put_zero*/1); ++ } else ++ au_cpup_attr_nlink(i, /*force*/1); + } else { + bbot = a->btgt; + for (bindex = au_dbtop(d); bindex < bbot; bindex++) @@ -21136,30 +21174,33 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + } + + d = a->src_dentry; -+ au_set_dbwh(d, -1); -+ bbot = au_dbbot(d); -+ for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { -+ h_d = au_h_dptr(d, bindex); -+ if (h_d) -+ au_set_h_dptr(d, bindex, NULL); -+ } -+ au_set_dbbot(d, a->btgt); ++ if (!a->exchange) { ++ au_set_dbwh(d, -1); ++ bbot = au_dbbot(d); ++ for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { ++ h_d = au_h_dptr(d, bindex); ++ if (h_d) ++ au_set_h_dptr(d, bindex, NULL); ++ } ++ au_set_dbbot(d, a->btgt); + -+ sb = d->d_sb; -+ i = a->src_inode; -+ if (au_opt_test(au_mntflags(sb), PLINK) && au_plink_test(i)) -+ return; /* success */ ++ sb = d->d_sb; ++ i = a->src_inode; ++ if (au_opt_test(au_mntflags(sb), PLINK) && au_plink_test(i)) ++ return; /* success */ + -+ bbot = au_ibbot(i); -+ for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { -+ h_i = au_h_iptr(i, bindex); -+ if (h_i) { -+ au_xino_write(sb, bindex, h_i->i_ino, /*ino*/0); -+ /* ignore this error */ -+ au_set_h_iptr(i, bindex, NULL, 0); ++ bbot = au_ibbot(i); ++ for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { ++ h_i = au_h_iptr(i, bindex); ++ if (h_i) { ++ au_xino_write(sb, bindex, h_i->i_ino, /*ino*/0); ++ /* ignore this error */ ++ au_set_h_iptr(i, bindex, NULL, 0); ++ } + } ++ au_set_ibbot(i, a->btgt); + } -+ au_set_ibbot(i, a->btgt); ++ d_drop(a->src_dentry); +} + +/* ---------------------------------------------------------------------- */ @@ -21197,7 +21238,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + + a->src_btop = au_dbtop(a->src_dentry); + a->dst_btop = au_dbtop(a->dst_dentry); -+ if (au_ftest_ren(a->flags, ISDIR)) ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC) ++ || au_ftest_ren(a->auren_flags, ISDIR_DST)) + au_fset_wrdir(wr_dir_args.flags, ISDIR); + wr_dir_args.force_btgt = a->src_btop; + if (a->dst_inode && a->dst_btop < a->src_btop) @@ -21205,6 +21247,8 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + wr_dir_args.force_btgt = au_wbr(a->dst_dentry, wr_dir_args.force_btgt); + err = au_wr_dir(a->dst_dentry, a->src_dentry, &wr_dir_args); + a->btgt = err; ++ if (a->exchange) ++ au_update_dbtop(a->dst_dentry); + + return err; +} @@ -21213,19 +21257,20 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c +{ + a->h_path.dentry = a->src_h_parent; + au_dtime_store(a->src_dt + AuPARENT, a->src_parent, &a->h_path); -+ if (!au_ftest_ren(a->flags, ISSAMEDIR)) { ++ if (!au_ftest_ren(a->auren_flags, ISSAMEDIR)) { + a->h_path.dentry = a->dst_h_parent; + au_dtime_store(a->dst_dt + AuPARENT, a->dst_parent, &a->h_path); + } + -+ au_fclr_ren(a->flags, DT_DSTDIR); -+ if (!au_ftest_ren(a->flags, ISDIR)) ++ au_fclr_ren(a->auren_flags, DT_DSTDIR); ++ if (!au_ftest_ren(a->auren_flags, ISDIR_SRC) ++ && !a->exchange) + return; + + a->h_path.dentry = a->src_h_dentry; + au_dtime_store(a->src_dt + AuCHILD, a->src_dentry, &a->h_path); + if (d_is_positive(a->dst_h_dentry)) { -+ au_fset_ren(a->flags, DT_DSTDIR); ++ au_fset_ren(a->auren_flags, DT_DSTDIR); + a->h_path.dentry = a->dst_h_dentry; + au_dtime_store(a->dst_dt + AuCHILD, a->dst_dentry, &a->h_path); + } @@ -21237,17 +21282,17 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + struct inode *h_inode; + + au_dtime_revert(a->src_dt + AuPARENT); -+ if (!au_ftest_ren(a->flags, ISSAMEDIR)) ++ if (!au_ftest_ren(a->auren_flags, ISSAMEDIR)) + au_dtime_revert(a->dst_dt + AuPARENT); + -+ if (au_ftest_ren(a->flags, ISDIR) && err != -EIO) { ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC) && err != -EIO) { + h_d = a->src_dt[AuCHILD].dt_h_path.dentry; + h_inode = d_inode(h_d); + inode_lock_nested(h_inode, AuLsc_I_CHILD); + au_dtime_revert(a->src_dt + AuCHILD); + inode_unlock(h_inode); + -+ if (au_ftest_ren(a->flags, DT_DSTDIR)) { ++ if (au_ftest_ren(a->auren_flags, DT_DSTDIR)) { + h_d = a->dst_dt[AuCHILD].dt_h_path.dentry; + h_inode = d_inode(h_d); + inode_lock_nested(h_inode, AuLsc_I_CHILD); @@ -21260,22 +21305,30 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c +/* ---------------------------------------------------------------------- */ + +int aufs_rename(struct inode *_src_dir, struct dentry *_src_dentry, -+ struct inode *_dst_dir, struct dentry *_dst_dentry) ++ struct inode *_dst_dir, struct dentry *_dst_dentry, ++ unsigned int _flags) +{ -+ int err, flags; ++ int err, lock_flags; + /* reduce stack space */ + struct au_ren_args *a; ++ struct au_pin pin; + -+ AuDbg("%pd, %pd\n", _src_dentry, _dst_dentry); ++ AuDbg("%pd, %pd, 0x%x\n", _src_dentry, _dst_dentry, _flags); + IMustLock(_src_dir); + IMustLock(_dst_dir); + ++ err = -EINVAL; ++ if (unlikely(_flags & RENAME_WHITEOUT)) ++ goto out; ++ + err = -ENOMEM; + BUILD_BUG_ON(sizeof(*a) > PAGE_SIZE); + a = kzalloc(sizeof(*a), GFP_NOFS); + if (unlikely(!a)) + goto out; + ++ a->flags = _flags; ++ a->exchange = _flags & RENAME_EXCHANGE; + a->src_dir = _src_dir; + a->src_dentry = _src_dentry; + a->src_inode = NULL; @@ -21289,20 +21342,33 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + a->dst_inode = d_inode(a->dst_dentry); + a->dst_parent = a->dst_dentry->d_parent; /* dir inode is locked */ + if (a->dst_inode) { -+ IMustLock(a->dst_inode); ++ /* ++ * if EXCHANGE && src is non-dir && dst is dir, ++ * dst is not locked. ++ */ ++ /* IMustLock(a->dst_inode); */ + au_igrab(a->dst_inode); + } + + err = -ENOTDIR; -+ flags = AuLock_FLUSH | AuLock_NOPLM | AuLock_GEN; ++ lock_flags = AuLock_FLUSH | AuLock_NOPLM | AuLock_GEN; + if (d_is_dir(a->src_dentry)) { -+ au_fset_ren(a->flags, ISDIR); -+ if (unlikely(d_really_is_positive(a->dst_dentry) ++ au_fset_ren(a->auren_flags, ISDIR_SRC); ++ if (unlikely(!a->exchange ++ && d_really_is_positive(a->dst_dentry) + && !d_is_dir(a->dst_dentry))) + goto out_free; -+ flags |= AuLock_DIRS; ++ lock_flags |= AuLock_DIRS; ++ } ++ if (a->dst_inode && d_is_dir(a->dst_dentry)) { ++ au_fset_ren(a->auren_flags, ISDIR_DST); ++ if (unlikely(!a->exchange ++ && d_really_is_positive(a->src_dentry) ++ && !d_is_dir(a->src_dentry))) ++ goto out_free; ++ lock_flags |= AuLock_DIRS; + } -+ err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry, flags); ++ err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry, lock_flags); + if (unlikely(err)) + goto out_free; + @@ -21312,14 +21378,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + err = -ENOENT; + if (a->dst_inode) { + /* -+ * If it is a dir, VFS unhash dst_dentry before this ++ * If it is a dir, VFS unhash it before this + * function. It means we cannot rely upon d_unhashed(). + */ + if (unlikely(!a->dst_inode->i_nlink)) + goto out_unlock; -+ if (!S_ISDIR(a->dst_inode->i_mode)) { ++ if (!au_ftest_ren(a->auren_flags, ISDIR_DST)) { + err = au_d_hashed_positive(a->dst_dentry); -+ if (unlikely(err)) ++ if (unlikely(err && !a->exchange)) + goto out_unlock; + } else if (unlikely(IS_DEADDIR(a->dst_inode))) + goto out_unlock; @@ -21335,7 +21401,7 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + if (unlikely(d_inode(a->dst_parent) == d_inode(a->src_dentry))) + goto out_unlock; + -+ au_fset_ren(a->flags, ISSAMEDIR); /* temporary */ ++ au_fset_ren(a->auren_flags, ISSAMEDIR); /* temporary */ + di_write_lock_parent(a->dst_parent); + + /* which branch we process */ @@ -21352,39 +21418,43 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + + /* prepare the writable parent dir on the same branch */ + if (a->dst_btop == a->btgt) { -+ au_fset_ren(a->flags, WHDST); ++ au_fset_ren(a->auren_flags, WHDST); + } else { + err = au_cpup_dirs(a->dst_dentry, a->btgt); + if (unlikely(err)) + goto out_children; + } + -+ if (a->src_dir != a->dst_dir) { -+ /* -+ * this temporary unlock is safe, -+ * because both dir->i_mutex are locked. -+ */ -+ di_write_unlock(a->dst_parent); -+ di_write_lock_parent(a->src_parent); -+ err = au_wr_dir_need_wh(a->src_dentry, -+ au_ftest_ren(a->flags, ISDIR), -+ &a->btgt); -+ di_write_unlock(a->src_parent); -+ di_write_lock2_parent(a->src_parent, a->dst_parent, /*isdir*/1); -+ au_fclr_ren(a->flags, ISSAMEDIR); -+ } else -+ err = au_wr_dir_need_wh(a->src_dentry, -+ au_ftest_ren(a->flags, ISDIR), -+ &a->btgt); ++ err = 0; ++ if (!a->exchange) { ++ if (a->src_dir != a->dst_dir) { ++ /* ++ * this temporary unlock is safe, ++ * because both dir->i_mutex are locked. ++ */ ++ di_write_unlock(a->dst_parent); ++ di_write_lock_parent(a->src_parent); ++ err = au_wr_dir_need_wh(a->src_dentry, ++ au_ftest_ren(a->auren_flags, ++ ISDIR_SRC), ++ &a->btgt); ++ di_write_unlock(a->src_parent); ++ di_write_lock2_parent(a->src_parent, a->dst_parent, ++ /*isdir*/1); ++ au_fclr_ren(a->auren_flags, ISSAMEDIR); ++ } else ++ err = au_wr_dir_need_wh(a->src_dentry, ++ au_ftest_ren(a->auren_flags, ++ ISDIR_SRC), ++ &a->btgt); ++ } + if (unlikely(err < 0)) + goto out_children; + if (err) -+ au_fset_ren(a->flags, WHSRC); ++ au_fset_ren(a->auren_flags, WHSRC); + + /* cpup src */ + if (a->src_btop != a->btgt) { -+ struct au_pin pin; -+ + err = au_pin(&pin, a->src_dentry, a->btgt, + au_opt_udba(a->src_dentry->d_sb), + AuPin_DI_LOCKED | AuPin_MNT_WRITE); @@ -21405,7 +21475,32 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + goto out_children; + a->src_btop = a->btgt; + a->src_h_dentry = au_h_dptr(a->src_dentry, a->btgt); -+ au_fset_ren(a->flags, WHSRC); ++ if (!a->exchange) ++ au_fset_ren(a->auren_flags, WHSRC); ++ } ++ ++ /* cpup dst */ ++ if (a->exchange && a->dst_inode ++ && a->dst_btop != a->btgt) { ++ err = au_pin(&pin, a->dst_dentry, a->btgt, ++ au_opt_udba(a->dst_dentry->d_sb), ++ AuPin_DI_LOCKED | AuPin_MNT_WRITE); ++ if (!err) { ++ struct au_cp_generic cpg = { ++ .dentry = a->dst_dentry, ++ .bdst = a->btgt, ++ .bsrc = a->dst_btop, ++ .len = -1, ++ .pin = &pin, ++ .flags = AuCpup_DTIME | AuCpup_HOPEN ++ }; ++ err = au_sio_cpup_simple(&cpg); ++ au_unpin(&pin); ++ } ++ if (unlikely(err)) ++ goto out_children; ++ a->dst_btop = a->btgt; ++ a->dst_h_dentry = au_h_dptr(a->dst_dentry, a->btgt); + } + + /* lock them all */ @@ -21414,12 +21509,14 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + /* leave the copied-up one */ + goto out_children; + -+ if (!au_opt_test(au_mntflags(a->dst_dir->i_sb), UDBA_NONE)) -+ err = au_may_ren(a); -+ else if (unlikely(a->dst_dentry->d_name.len > AUFS_MAX_NAMELEN)) -+ err = -ENAMETOOLONG; -+ if (unlikely(err)) -+ goto out_hdir; ++ if (!a->exchange) { ++ if (!au_opt_test(au_mntflags(a->dst_dir->i_sb), UDBA_NONE)) ++ err = au_may_ren(a); ++ else if (unlikely(a->dst_dentry->d_name.len > AUFS_MAX_NAMELEN)) ++ err = -ENAMETOOLONG; ++ if (unlikely(err)) ++ goto out_hdir; ++ } + + /* store timestamps to be revertible */ + au_ren_dt(a); @@ -21449,14 +21546,17 @@ diff -urN /usr/share/empty/fs/aufs/i_op_ren.c linux/fs/aufs/i_op_ren.c + au_set_dbtop(a->dst_dentry, a->dst_btop); + } +out_parent: -+ if (!err) -+ d_move(a->src_dentry, a->dst_dentry); -+ else { ++ if (!err) { ++ if (!a->exchange) ++ d_move(a->src_dentry, a->dst_dentry); ++ else ++ d_exchange(a->src_dentry, a->dst_dentry); ++ } else { + au_update_dbtop(a->dst_dentry); + if (!a->dst_inode) + d_drop(a->dst_dentry); + } -+ if (au_ftest_ren(a->flags, ISSAMEDIR)) ++ if (au_ftest_ren(a->auren_flags, ISSAMEDIR)) + di_write_unlock(a->dst_parent); + else + di_write_unlock2(a->src_parent, a->dst_parent); @@ -23156,8 +23256,8 @@ diff -urN /usr/share/empty/fs/aufs/mvdown.c linux/fs/aufs/mvdown.c +} diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c --- /usr/share/empty/fs/aufs/opts.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/opts.c 2016-10-09 16:55:36.496035060 +0200 -@@ -0,0 +1,1860 @@ ++++ linux/fs/aufs/opts.c 2016-12-17 12:28:17.598545045 +0100 +@@ -0,0 +1,1870 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -23584,6 +23684,10 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c + {AuWbrCreate_MFSV, "mfs:%d"}, + {AuWbrCreate_MFSV, "most-free-space:%d"}, + ++ /* top-down regardless the parent, and then mfs */ ++ {AuWbrCreate_TDMFS, "tdmfs:%d"}, ++ {AuWbrCreate_TDMFSV, "tdmfs:%d:%d"}, ++ + {AuWbrCreate_MFSRR, "mfsrr:%d"}, + {AuWbrCreate_MFSRRV, "mfsrr:%d:%d"}, + {AuWbrCreate_PMFS, "pmfs"}, @@ -23659,6 +23763,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c + create->wbr_create = err; + switch (err) { + case AuWbrCreate_MFSRRV: ++ case AuWbrCreate_TDMFSV: + case AuWbrCreate_PMFSRRV: + e = au_wbr_mfs_wmark(&args[0], str, create); + if (!e) @@ -23667,6 +23772,7 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c + err = e; + break; + case AuWbrCreate_MFSRR: ++ case AuWbrCreate_TDMFS: + case AuWbrCreate_PMFSRR: + e = au_wbr_mfs_wmark(&args[0], str, create); + if (unlikely(e)) { @@ -23877,10 +23983,12 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c + AuDbg("%d sec\n", u.create->mfs_second); + break; + case AuWbrCreate_MFSRR: ++ case AuWbrCreate_TDMFS: + AuDbg("%llu watermark\n", + u.create->mfsrr_watermark); + break; + case AuWbrCreate_MFSRRV: ++ case AuWbrCreate_TDMFSV: + case AuWbrCreate_PMFSRRV: + AuDbg("%llu watermark, %d sec\n", + u.create->mfsrr_watermark, @@ -24446,6 +24554,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c + switch (create->wbr_create) { + case AuWbrCreate_MFSRRV: + case AuWbrCreate_MFSRR: ++ case AuWbrCreate_TDMFS: ++ case AuWbrCreate_TDMFSV: + case AuWbrCreate_PMFSRR: + case AuWbrCreate_PMFSRRV: + sbinfo->si_wbr_mfs.mfsrr_watermark = create->mfsrr_watermark; @@ -25020,8 +25130,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.c linux/fs/aufs/opts.c +} diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h --- /usr/share/empty/fs/aufs/opts.h 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/opts.h 2016-10-09 16:55:36.496035060 +0200 -@@ -0,0 +1,211 @@ ++++ linux/fs/aufs/opts.h 2016-12-17 12:28:17.598545045 +0100 +@@ -0,0 +1,213 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -25123,6 +25233,8 @@ diff -urN /usr/share/empty/fs/aufs/opts.h linux/fs/aufs/opts.h + AuWbrCreate_MFSV, /* mfs with seconds */ + AuWbrCreate_MFSRR, /* mfs then rr */ + AuWbrCreate_MFSRRV, /* mfs then rr with seconds */ ++ AuWbrCreate_TDMFS, /* top down regardless parent and mfs */ ++ AuWbrCreate_TDMFSV, /* top down regardless parent and mfs */ + AuWbrCreate_PMFS, /* parent and mfs */ + AuWbrCreate_PMFSV, /* parent and mfs with seconds */ + AuWbrCreate_PMFSRR, /* parent, mfs and round-robin */ @@ -25809,7 +25921,7 @@ diff -urN /usr/share/empty/fs/aufs/poll.c linux/fs/aufs/poll.c +} diff -urN /usr/share/empty/fs/aufs/posix_acl.c linux/fs/aufs/posix_acl.c --- /usr/share/empty/fs/aufs/posix_acl.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/posix_acl.c 2016-10-09 16:55:36.496035060 +0200 ++++ linux/fs/aufs/posix_acl.c 2016-12-17 12:28:17.598545045 +0100 @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2014-2016 Junjiro R. Okajima @@ -25876,7 +25988,7 @@ diff -urN /usr/share/empty/fs/aufs/posix_acl.c linux/fs/aufs/posix_acl.c + int err; + ssize_t ssz; + struct dentry *dentry; -+ struct au_srxattr arg = { ++ struct au_sxattr arg = { + .type = AU_ACL_SET, + .u.acl_set = { + .acl = acl, @@ -25900,7 +26012,7 @@ diff -urN /usr/share/empty/fs/aufs/posix_acl.c linux/fs/aufs/posix_acl.c + } + } + -+ ssz = au_srxattr(dentry, inode, &arg); ++ ssz = au_sxattr(dentry, inode, &arg); + dput(dentry); + err = ssz; + if (ssz >= 0) @@ -27147,8 +27259,8 @@ diff -urN /usr/share/empty/fs/aufs/spl.h linux/fs/aufs/spl.h +#endif /* __AUFS_SPL_H__ */ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c --- /usr/share/empty/fs/aufs/super.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/super.c 2016-10-09 16:55:36.496035060 +0200 -@@ -0,0 +1,1038 @@ ++++ linux/fs/aufs/super.c 2016-12-17 12:28:17.598545045 +0100 +@@ -0,0 +1,1046 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -27269,15 +27381,31 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c + return err; +} + ++static void au_gen_fmt(char *fmt, int len __maybe_unused, const char *pat, ++ const char *append) ++{ ++ char *p; ++ ++ p = fmt; ++ while (*pat != ':') ++ *p++ = *pat++; ++ *p++ = *pat++; ++ strcpy(p, append); ++ AuDebugOn(strlen(fmt) >= len); ++} ++ +static void au_show_wbr_create(struct seq_file *m, int v, + struct au_sbinfo *sbinfo) +{ + const char *pat; ++ char fmt[32]; ++ struct au_wbr_mfs *mfs; + + AuRwMustAnyLock(&sbinfo->si_rwsem); + + seq_puts(m, ",create="); + pat = au_optstr_wbr_create(v); ++ mfs = &sbinfo->si_wbr_mfs; + switch (v) { + case AuWbrCreate_TDP: + case AuWbrCreate_RR: @@ -27285,36 +27413,28 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c + case AuWbrCreate_PMFS: + seq_puts(m, pat); + break; -+ case AuWbrCreate_MFSV: -+ seq_printf(m, /*pat*/"mfs:%lu", -+ jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire) -+ / MSEC_PER_SEC); ++ case AuWbrCreate_MFSRR: ++ case AuWbrCreate_TDMFS: ++ case AuWbrCreate_PMFSRR: ++ au_gen_fmt(fmt, sizeof(fmt), pat, "%llu"); ++ seq_printf(m, fmt, mfs->mfsrr_watermark); + break; ++ case AuWbrCreate_MFSV: + case AuWbrCreate_PMFSV: -+ seq_printf(m, /*pat*/"pmfs:%lu", -+ jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire) ++ au_gen_fmt(fmt, sizeof(fmt), pat, "%lu"); ++ seq_printf(m, fmt, ++ jiffies_to_msecs(mfs->mfs_expire) + / MSEC_PER_SEC); + break; -+ case AuWbrCreate_MFSRR: -+ seq_printf(m, /*pat*/"mfsrr:%llu", -+ sbinfo->si_wbr_mfs.mfsrr_watermark); -+ break; + case AuWbrCreate_MFSRRV: -+ seq_printf(m, /*pat*/"mfsrr:%llu:%lu", -+ sbinfo->si_wbr_mfs.mfsrr_watermark, -+ jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire) -+ / MSEC_PER_SEC); -+ break; -+ case AuWbrCreate_PMFSRR: -+ seq_printf(m, /*pat*/"pmfsrr:%llu", -+ sbinfo->si_wbr_mfs.mfsrr_watermark); -+ break; ++ case AuWbrCreate_TDMFSV: + case AuWbrCreate_PMFSRRV: -+ seq_printf(m, /*pat*/"pmfsrr:%llu:%lu", -+ sbinfo->si_wbr_mfs.mfsrr_watermark, -+ jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire) -+ / MSEC_PER_SEC); ++ au_gen_fmt(fmt, sizeof(fmt), pat, "%llu:%lu"); ++ seq_printf(m, fmt, mfs->mfsrr_watermark, ++ jiffies_to_msecs(mfs->mfs_expire) / MSEC_PER_SEC); + break; ++ default: ++ BUG(); + } +} + @@ -28074,7 +28194,7 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c + sb->s_maxbytes = 0; + sb->s_stack_depth = 1; + au_export_init(sb); -+ /* au_xattr_init(sb); */ ++ au_xattr_init(sb); + + err = alloc_root(sb); + if (unlikely(err)) { @@ -28189,8 +28309,8 @@ diff -urN /usr/share/empty/fs/aufs/super.c linux/fs/aufs/super.c +}; diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h --- /usr/share/empty/fs/aufs/super.h 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/super.h 2016-10-09 16:55:38.889431135 +0200 -@@ -0,0 +1,638 @@ ++++ linux/fs/aufs/super.h 2016-12-17 12:28:17.598545045 +0100 +@@ -0,0 +1,639 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -28448,6 +28568,7 @@ diff -urN /usr/share/empty/fs/aufs/super.h linux/fs/aufs/super.h +#define AuLock_IW (1 << 2) /* write-lock inode */ +#define AuLock_FLUSH (1 << 3) /* wait for 'nowait' tasks */ +#define AuLock_DIRS (1 << 4) /* target is a pair of dirs */ ++ /* except RENAME_EXCHANGE */ +#define AuLock_NOPLM (1 << 5) /* return err in plm mode */ +#define AuLock_NOPLMW (1 << 6) /* wait for plm mode ends */ +#define AuLock_GEN (1 << 7) /* test digen/iigen */ @@ -30489,8 +30610,8 @@ diff -urN /usr/share/empty/fs/aufs/vdir.c linux/fs/aufs/vdir.c +} diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c --- /usr/share/empty/fs/aufs/vfsub.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/vfsub.c 2016-10-09 16:55:36.496035060 +0200 -@@ -0,0 +1,884 @@ ++++ linux/fs/aufs/vfsub.c 2016-12-17 12:28:17.598545045 +0100 +@@ -0,0 +1,886 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -30516,7 +30637,9 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c +#include +#include +#include ++#ifdef CONFIG_AUFS_BR_FUSE +#include "../fs/mount.h" ++#endif +#include "aufs.h" + +#ifdef CONFIG_AUFS_BR_FUSE @@ -30876,7 +30999,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c + +int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry, + struct inode *dir, struct path *path, -+ struct inode **delegated_inode) ++ struct inode **delegated_inode, unsigned int flags) +{ + int err; + struct path tmp = { @@ -30897,7 +31020,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c + + lockdep_off(); + err = vfs_rename(src_dir, src_dentry, dir, path->dentry, -+ delegated_inode, /*flags*/0); ++ delegated_inode, flags); + lockdep_on(); + if (!err) { + int did; @@ -31377,7 +31500,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.c linux/fs/aufs/vfsub.c +} diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h --- /usr/share/empty/fs/aufs/vfsub.h 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/vfsub.h 2016-10-09 16:55:36.496035060 +0200 ++++ linux/fs/aufs/vfsub.h 2016-12-17 12:28:17.598545045 +0100 @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima @@ -31544,7 +31667,7 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h + struct path *path, struct inode **delegated_inode); +int vfsub_rename(struct inode *src_hdir, struct dentry *src_dentry, + struct inode *hdir, struct path *path, -+ struct inode **delegated_inode); ++ struct inode **delegated_inode, unsigned int flags); +int vfsub_mkdir(struct inode *dir, struct path *path, int mode); +int vfsub_rmdir(struct inode *dir, struct path *path); + @@ -31697,8 +31820,8 @@ diff -urN /usr/share/empty/fs/aufs/vfsub.h linux/fs/aufs/vfsub.h +#endif /* __AUFS_VFSUB_H__ */ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c --- /usr/share/empty/fs/aufs/wbr_policy.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/wbr_policy.c 2016-10-09 16:55:36.496035060 +0200 -@@ -0,0 +1,765 @@ ++++ linux/fs/aufs/wbr_policy.c 2016-12-17 12:28:17.598545045 +0100 +@@ -0,0 +1,830 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -32218,6 +32341,61 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c + +/* ---------------------------------------------------------------------- */ + ++/* top down regardless parent, and then mfs */ ++static int au_wbr_create_tdmfs(struct dentry *dentry, ++ unsigned int flags __maybe_unused) ++{ ++ int err; ++ aufs_bindex_t bwh, btail, bindex, bfound, bmfs; ++ unsigned long long watermark; ++ struct super_block *sb; ++ struct au_wbr_mfs *mfs; ++ struct au_branch *br; ++ struct dentry *parent; ++ ++ sb = dentry->d_sb; ++ mfs = &au_sbi(sb)->si_wbr_mfs; ++ mutex_lock(&mfs->mfs_lock); ++ if (time_after(jiffies, mfs->mfs_jiffy + mfs->mfs_expire) ++ || mfs->mfs_bindex < 0) ++ au_mfs(dentry, /*parent*/NULL); ++ watermark = mfs->mfsrr_watermark; ++ bmfs = mfs->mfs_bindex; ++ mutex_unlock(&mfs->mfs_lock); ++ ++ /* another style of au_wbr_create_exp() */ ++ bwh = au_dbwh(dentry); ++ parent = dget_parent(dentry); ++ btail = au_dbtaildir(parent); ++ if (bwh >= 0 && bwh < btail) ++ btail = bwh; ++ ++ err = au_wbr_nonopq(dentry, btail); ++ if (unlikely(err < 0)) ++ goto out; ++ btail = err; ++ bfound = -1; ++ for (bindex = 0; bindex <= btail; bindex++) { ++ br = au_sbr(sb, bindex); ++ if (au_br_rdonly(br)) ++ continue; ++ if (br->br_wbr->wbr_bytes > watermark) { ++ bfound = bindex; ++ break; ++ } ++ } ++ err = bfound; ++ if (err < 0) ++ err = bmfs; ++ ++out: ++ dput(parent); ++ AuDbg("b%d\n", err); ++ return err; ++} ++ ++/* ---------------------------------------------------------------------- */ ++ +/* most free space and then round robin */ +static int au_wbr_create_mfsrr(struct dentry *dentry, unsigned int flags) +{ @@ -32443,6 +32621,16 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c + .init = au_wbr_create_init_mfsrr, + .fin = au_wbr_create_fin_mfs + }, ++ [AuWbrCreate_TDMFS] = { ++ .create = au_wbr_create_tdmfs, ++ .init = au_wbr_create_init_mfs, ++ .fin = au_wbr_create_fin_mfs ++ }, ++ [AuWbrCreate_TDMFSV] = { ++ .create = au_wbr_create_tdmfs, ++ .init = au_wbr_create_init_mfs, ++ .fin = au_wbr_create_fin_mfs ++ }, + [AuWbrCreate_PMFS] = { + .create = au_wbr_create_pmfs, + .init = au_wbr_create_init_mfs, @@ -32466,8 +32654,8 @@ diff -urN /usr/share/empty/fs/aufs/wbr_policy.c linux/fs/aufs/wbr_policy.c +}; diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c --- /usr/share/empty/fs/aufs/whout.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/whout.c 2016-10-09 16:55:36.496035060 +0200 -@@ -0,0 +1,1060 @@ ++++ linux/fs/aufs/whout.c 2016-12-17 12:28:17.598545045 +0100 +@@ -0,0 +1,1061 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + * @@ -32661,7 +32849,8 @@ diff -urN /usr/share/empty/fs/aufs/whout.c linux/fs/aufs/whout.c + + /* under the same dir, no need to lock_rename() */ + delegated = NULL; -+ err = vfsub_rename(h_dir, h_dentry, h_dir, &h_path, &delegated); ++ err = vfsub_rename(h_dir, h_dentry, h_dir, &h_path, &delegated, ++ /*flags*/0); + AuTraceErr(err); + if (unlikely(err == -EWOULDBLOCK)) { + pr_warn("cannot retry for NFSv4 delegation" @@ -33933,8 +34122,8 @@ diff -urN /usr/share/empty/fs/aufs/wkq.h linux/fs/aufs/wkq.h +#endif /* __AUFS_WKQ_H__ */ diff -urN /usr/share/empty/fs/aufs/xattr.c linux/fs/aufs/xattr.c --- /usr/share/empty/fs/aufs/xattr.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux/fs/aufs/xattr.c 2016-10-09 16:55:36.496035060 +0200 -@@ -0,0 +1,347 @@ ++++ linux/fs/aufs/xattr.c 2016-12-17 12:28:17.598545045 +0100 +@@ -0,0 +1,332 @@ +/* + * Copyright (C) 2014-2016 Junjiro R. Okajima + * @@ -34201,8 +34390,9 @@ diff -urN /usr/share/empty/fs/aufs/xattr.c linux/fs/aufs/xattr.c + return au_lgxattr(dentry, &arg); +} + -+ssize_t aufs_getxattr(struct dentry *dentry, struct inode *inode __maybe_unused, -+ const char *name, void *value, size_t size) ++static ssize_t au_getxattr(struct dentry *dentry, ++ struct inode *inode __maybe_unused, ++ const char *name, void *value, size_t size) +{ + struct au_lgxattr arg = { + .type = AU_XATTR_GET, @@ -34216,10 +34406,11 @@ diff -urN /usr/share/empty/fs/aufs/xattr.c linux/fs/aufs/xattr.c + return au_lgxattr(dentry, &arg); +} + -+int aufs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, -+ const void *value, size_t size, int flags) ++static int au_setxattr(struct dentry *dentry, struct inode *inode, ++ const char *name, const void *value, size_t size, ++ int flags) +{ -+ struct au_srxattr arg = { ++ struct au_sxattr arg = { + .type = AU_XATTR_SET, + .u.set = { + .name = name, @@ -34229,59 +34420,42 @@ diff -urN /usr/share/empty/fs/aufs/xattr.c linux/fs/aufs/xattr.c + }, + }; + -+ return au_srxattr(dentry, inode, &arg); -+} -+ -+int aufs_removexattr(struct dentry *dentry, const char *name) -+{ -+ struct au_srxattr arg = { -+ .type = AU_XATTR_REMOVE, -+ .u.remove = { -+ .name = name -+ }, -+ }; -+ -+ return au_srxattr(dentry, d_inode(dentry), &arg); ++ return au_sxattr(dentry, inode, &arg); +} + +/* ---------------------------------------------------------------------- */ + -+#if 0 -+static size_t au_xattr_list(struct dentry *dentry, char *list, size_t list_size, -+ const char *name, size_t name_len, int type) -+{ -+ return aufs_listxattr(dentry, list, list_size); -+} -+ -+static int au_xattr_get(struct dentry *dentry, const char *name, void *buffer, -+ size_t size, int type) ++static int au_xattr_get(const struct xattr_handler *handler, ++ struct dentry *dentry, struct inode *inode, ++ const char *name, void *buffer, size_t size) +{ -+ return aufs_getxattr(dentry, name, buffer, size); ++ return au_getxattr(dentry, inode, name, buffer, size); +} + -+static int au_xattr_set(struct dentry *dentry, const char *name, -+ const void *value, size_t size, int flags, int type) ++static int au_xattr_set(const struct xattr_handler *handler, ++ struct dentry *dentry, struct inode *inode, ++ const char *name, const void *value, size_t size, ++ int flags) +{ -+ return aufs_setxattr(dentry, name, value, size, flags); ++ return au_setxattr(dentry, inode, name, value, size, flags); +} + +static const struct xattr_handler au_xattr_handler = { -+ /* no prefix, no flags */ -+ .list = au_xattr_list, ++ .name = "", ++ .prefix = "", + .get = au_xattr_get, + .set = au_xattr_set -+ /* why no remove? */ +}; + +static const struct xattr_handler *au_xattr_handlers[] = { -+ &au_xattr_handler ++ &au_xattr_handler, ++ NULL +}; + +void au_xattr_init(struct super_block *sb) +{ -+ /* sb->s_xattr = au_xattr_handlers; */ ++ sb->s_xattr = au_xattr_handlers; +} -+#endif diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c --- /usr/share/empty/fs/aufs/xino.c 1970-01-01 01:00:00.000000000 +0100 +++ linux/fs/aufs/xino.c 2016-10-09 16:55:36.496035060 +0200 @@ -35606,7 +35780,7 @@ diff -urN /usr/share/empty/fs/aufs/xino.c linux/fs/aufs/xino.c +} diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/linux/aufs_type.h --- /usr/share/empty/include/uapi/linux/aufs_type.h 1970-01-01 01:00:00.000000000 +0100 -+++ linux/include/uapi/linux/aufs_type.h 2016-12-11 21:22:05.903059512 +0100 ++++ linux/include/uapi/linux/aufs_type.h 2016-12-17 12:28:38.769494865 +0100 @@ -0,0 +1,419 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima @@ -35649,7 +35823,7 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin + +#include + -+#define AUFS_VERSION "4.x-rcN-20161010" ++#define AUFS_VERSION "4.9-20161219" + +/* todo? move this to linux-2.6.19/include/magic.h */ +#define AUFS_SUPER_MAGIC ('a' << 24 | 'u' << 16 | 'f' << 8 | 's') @@ -36027,10 +36201,10 @@ diff -urN /usr/share/empty/include/uapi/linux/aufs_type.h linux/include/uapi/lin +#define AUFS_CTL_FHSM_FD _IOW(AuCtlType, AuCtl_FHSM_FD, int) + +#endif /* __AUFS_TYPE_H__ */ -aufs4.x-rcN loopback patch +aufs4.9 loopback patch diff --git a/drivers/block/loop.c b/drivers/block/loop.c -index 005e292..e9e517d 100644 +index 6ee9235..f64161f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -551,7 +551,7 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq) @@ -36170,7 +36344,7 @@ index 005e292..e9e517d 100644 out: /* This is safe: open() is still holding a reference. */ module_put(THIS_MODULE); -@@ -1021,6 +1054,7 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer, +@@ -1021,6 +1054,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode, static int loop_clr_fd(struct loop_device *lo) { struct file *filp = lo->lo_backing_file; @@ -36209,10 +36383,10 @@ index fb2237c..c3888c5 100644 unsigned lo_blocksize; void *key_data; diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c -index 00475fb..01390e1 100644 +index d2a9a1d..d7519d0 100644 --- a/fs/aufs/f_op.c +++ b/fs/aufs/f_op.c -@@ -348,7 +348,7 @@ static ssize_t aufs_read_iter(struct kiocb *kio, struct iov_iter *iov_iter) +@@ -351,7 +351,7 @@ static ssize_t aufs_read_iter(struct kiocb *kio, struct iov_iter *iov_iter) if (IS_ERR(h_file)) goto out; @@ -36249,7 +36423,7 @@ diff --git a/fs/aufs/loop.h b/fs/aufs/loop.h index 48bf070..66afec7 100644 --- a/fs/aufs/loop.h +++ b/fs/aufs/loop.h -@@ -25,7 +25,11 @@ void au_warn_loopback(struct super_block *h_sb); +@@ -25,7 +25,11 @@ int au_loopback_init(void); void au_loopback_fin(void); @@ -36261,7 +36435,7 @@ index 48bf070..66afec7 100644 AuStubInt0(au_test_loopback_overlap, struct super_block *sb, struct dentry *h_adding) AuStubInt0(au_test_loopback_kthread, void) -@@ -33,6 +37,8 @@ AuStubVoid(au_warn_loopback, struct super_block *h_sb) +@@ -33,6 +37,8 @@ AuStubInt0(au_loopback_init, void) AuStubVoid(au_loopback_fin, void) @@ -36271,10 +36445,10 @@ index 48bf070..66afec7 100644 #endif /* __KERNEL__ */ diff --git a/fs/aufs/super.c b/fs/aufs/super.c -index 58a773c..75f212c 100644 +index 0082ce4..5085378 100644 --- a/fs/aufs/super.c +++ b/fs/aufs/super.c -@@ -831,7 +831,10 @@ static const struct super_operations aufs_sop = { +@@ -839,7 +839,10 @@ static int aufs_remount_fs(struct super_block *sb, int *flags, char *data) .statfs = aufs_statfs, .put_super = aufs_put_super, .sync_fs = aufs_sync_fs, @@ -36287,10 +36461,10 @@ index 58a773c..75f212c 100644 /* ---------------------------------------------------------------------- */ diff --git a/include/linux/fs.h b/include/linux/fs.h -index fc80663..0c4c6fa 100644 +index a903bc3..db820e3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h -@@ -1814,6 +1814,10 @@ struct super_operations { +@@ -1823,6 +1823,10 @@ struct super_operations { struct shrink_control *); long (*free_cached_objects)(struct super_block *, struct shrink_control *); -- 2.44.0