Commits

Uelsk8s committed 3b536a3

update kernel-3.10

Comments (0)

Files changed (6)

var/vabs/kernel-3.10/src/patches/aufs3-base.patch

-aufs3.x-rcN base patch
+aufs3.10 base patch
 
 diff --git a/fs/file_table.c b/fs/file_table.c
-index cd4d87a..ca5948f 100644
+index 485dc0e..8db8096 100644
 --- a/fs/file_table.c
 +++ b/fs/file_table.c
 @@ -36,7 +36,7 @@ struct files_stat_struct files_stat = {
  /* SLAB cache for file structures */
  static struct kmem_cache *filp_cachep __read_mostly;
 diff --git a/fs/inode.c b/fs/inode.c
-index f5f7c06..0b99538 100644
+index 00d5fc3..f324521 100644
 --- a/fs/inode.c
 +++ b/fs/inode.c
 @@ -1498,7 +1498,7 @@ static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
  	if (inode->i_op->update_time)
  		return inode->i_op->update_time(inode, time, flags);
 diff --git a/fs/splice.c b/fs/splice.c
-index 718bd00..c717dbb 100644
+index d37431d..987346f 100644
 --- a/fs/splice.c
 +++ b/fs/splice.c
 @@ -1093,8 +1093,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
  {
  	ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
  				loff_t *, size_t, unsigned int);
-@@ -1121,9 +1121,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+@@ -1124,9 +1124,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.
   */
  	ssize_t (*splice_read)(struct file *, loff_t *,
  			       struct pipe_inode_info *, size_t, unsigned int);
 diff --git a/include/linux/fs.h b/include/linux/fs.h
-index 2c28271..5c49108 100644
+index 65c2be2..0148214 100644
 --- a/include/linux/fs.h
 +++ b/include/linux/fs.h
-@@ -2558,6 +2558,7 @@ extern int inode_change_ok(const struct inode *, struct iattr *);
+@@ -2574,6 +2574,7 @@ extern int inode_change_ok(const struct inode *, struct iattr *);
  extern int inode_newsize_ok(const struct inode *, loff_t offset);
  extern void setattr_copy(struct inode *inode, const struct iattr *attr);
  
  
  extern int generic_show_options(struct seq_file *m, struct dentry *root);
 diff --git a/include/linux/splice.h b/include/linux/splice.h
-index 09a545a..1ac5727 100644
+index 74575cb..bfc6fb6 100644
 --- a/include/linux/splice.h
 +++ b/include/linux/splice.h
-@@ -91,4 +91,10 @@ extern void splice_shrink_spd(struct splice_pipe_desc *);
+@@ -92,4 +92,10 @@ extern void splice_shrink_spd(struct splice_pipe_desc *);
  extern void spd_release_page(struct splice_pipe_desc *, unsigned int);
  
  extern const struct pipe_buf_operations page_cache_pipe_buf_ops;

var/vabs/kernel-3.10/src/patches/aufs3-kbuild.patch

-aufs3.x-rcN kbuild patch
+aufs3.10 kbuild patch
 
 diff --git a/fs/Kconfig b/fs/Kconfig
-index 780725a..d460c05 100644
+index c229f82..397b473 100644
 --- a/fs/Kconfig
 +++ b/fs/Kconfig
-@@ -211,6 +211,7 @@ source "fs/sysv/Kconfig"
- source "fs/ufs/Kconfig"
+@@ -212,6 +212,7 @@ source "fs/ufs/Kconfig"
  source "fs/exofs/Kconfig"
  source "fs/f2fs/Kconfig"
+ source "fs/efivarfs/Kconfig"
 +source "fs/aufs/Kconfig"
  
  endif # MISC_FILESYSTEMS
  
 diff --git a/fs/Makefile b/fs/Makefile
-index 9d53192..e70f08f 100644
+index 4fe6df3..4a57676 100644
 --- a/fs/Makefile
 +++ b/fs/Makefile
-@@ -127,3 +127,4 @@ obj-$(CONFIG_F2FS_FS)		+= f2fs/
- obj-y				+= exofs/ # Multiple modules
+@@ -126,3 +126,4 @@ obj-y				+= exofs/ # Multiple modules
  obj-$(CONFIG_CEPH_FS)		+= ceph/
  obj-$(CONFIG_PSTORE)		+= pstore/
+ obj-$(CONFIG_EFIVAR_FS)		+= efivarfs/
 +obj-$(CONFIG_AUFS_FS)           += aufs/
 diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
-index 5c8a1d2..fea7572 100644
+index bdc6e87..349600c 100644
 --- a/include/uapi/linux/Kbuild
 +++ b/include/uapi/linux/Kbuild
 @@ -56,6 +56,7 @@ header-y += atmppp.h

var/vabs/kernel-3.10/src/patches/aufs3-loopback.patch

-aufs3.x-rcN loopback patch
+aufs3.10 loopback patch
 
 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
-index 747bb2a..a776f2f 100644
+index d92d50f..9fb5490 100644
 --- a/drivers/block/loop.c
 +++ b/drivers/block/loop.c
-@@ -511,7 +511,7 @@ out:
+@@ -513,7 +513,7 @@ out:
  }
  
  struct switch_request {
  	struct completion wait;
  };
  
-@@ -573,7 +573,8 @@ static int loop_thread(void *data)
+@@ -575,7 +575,8 @@ static int loop_thread(void *data)
   * First it needs to flush existing IO, it does this by sending a magic
   * BIO down the pipe. The completion of this BIO does the actual switch.
   */
  {
  	struct switch_request w;
  	struct bio *bio = bio_alloc(GFP_KERNEL, 0);
-@@ -581,6 +582,7 @@ static int loop_switch(struct loop_device *lo, struct file *file)
+@@ -583,6 +584,7 @@ static int loop_switch(struct loop_device *lo, struct file *file)
  		return -ENOMEM;
  	init_completion(&w.wait);
  	w.file = file;
  	bio->bi_private = &w;
  	bio->bi_bdev = NULL;
  	loop_make_request(lo->lo_queue, bio);
-@@ -597,7 +599,7 @@ static int loop_flush(struct loop_device *lo)
+@@ -599,7 +601,7 @@ static int loop_flush(struct loop_device *lo)
  	if (!lo->lo_thread)
  		return 0;
  
  }
  
  /*
-@@ -616,6 +618,7 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
+@@ -618,6 +620,7 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
  	mapping = file->f_mapping;
  	mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
  	lo->lo_backing_file = file;
  	lo->lo_blocksize = S_ISBLK(mapping->host->i_mode) ?
  		mapping->host->i_bdev->bd_block_size : PAGE_SIZE;
  	lo->old_gfp_mask = mapping_gfp_mask(mapping);
-@@ -624,6 +627,13 @@ out:
+@@ -626,6 +629,13 @@ out:
  	complete(&p->wait);
  }
  
  
  /*
   * loop_change_fd switched the backing store of a loopback device to
-@@ -637,6 +647,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+@@ -639,6 +649,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
  			  unsigned int arg)
  {
  	struct file	*file, *old_file;
  	struct inode	*inode;
  	int		error;
  
-@@ -653,9 +664,16 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+@@ -655,9 +666,16 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
  	file = fget(arg);
  	if (!file)
  		goto out;
  
  	error = -EINVAL;
  
-@@ -667,17 +685,21 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
+@@ -669,17 +687,21 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
  		goto out_putf;
  
  	/* and ... switch */
   out:
  	return error;
  }
-@@ -820,7 +842,7 @@ static void loop_config_discard(struct loop_device *lo)
+@@ -822,7 +844,7 @@ static void loop_config_discard(struct loop_device *lo)
  static int loop_set_fd(struct loop_device *lo, fmode_t mode,
  		       struct block_device *bdev, unsigned int arg)
  {
  	struct inode	*inode;
  	struct address_space *mapping;
  	unsigned lo_blocksize;
-@@ -835,6 +857,12 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+@@ -837,6 +859,12 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
  	file = fget(arg);
  	if (!file)
  		goto out;
  
  	error = -EBUSY;
  	if (lo->lo_state != Lo_unbound)
-@@ -883,6 +911,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+@@ -885,6 +913,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
  	lo->lo_device = bdev;
  	lo->lo_flags = lo_flags;
  	lo->lo_backing_file = file;
  	lo->transfer = transfer_none;
  	lo->ioctl = NULL;
  	lo->lo_sizelimit = 0;
-@@ -929,6 +958,7 @@ out_clr:
+@@ -936,6 +965,7 @@ out_clr:
  	lo->lo_thread = NULL;
  	lo->lo_device = NULL;
  	lo->lo_backing_file = NULL;
  	lo->lo_flags = 0;
  	set_capacity(lo->lo_disk, 0);
  	invalidate_bdev(bdev);
-@@ -938,6 +968,8 @@ out_clr:
+@@ -945,6 +975,8 @@ out_clr:
  	lo->lo_state = Lo_unbound;
   out_putf:
  	fput(file);
   out:
  	/* This is safe: open() is still holding a reference. */
  	module_put(THIS_MODULE);
-@@ -984,6 +1016,7 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
+@@ -991,6 +1023,7 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
  static int loop_clr_fd(struct loop_device *lo)
  {
  	struct file *filp = lo->lo_backing_file;
  	gfp_t gfp = lo->old_gfp_mask;
  	struct block_device *bdev = lo->lo_device;
  
-@@ -1017,6 +1050,7 @@ static int loop_clr_fd(struct loop_device *lo)
+@@ -1024,6 +1057,7 @@ static int loop_clr_fd(struct loop_device *lo)
  
  	spin_lock_irq(&lo->lo_lock);
  	lo->lo_backing_file = NULL;
  	spin_unlock_irq(&lo->lo_lock);
  
  	loop_release_xfer(lo);
-@@ -1057,6 +1091,8 @@ static int loop_clr_fd(struct loop_device *lo)
+@@ -1066,6 +1100,8 @@ static int loop_clr_fd(struct loop_device *lo)
  	 * bd_mutex which is usually taken before lo_ctl_mutex.
  	 */
  	fput(filp);
  }
  
 diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c
-index 56924c5..b832bf8 100644
+index 3183dff..72135bc 100644
 --- a/fs/aufs/f_op.c
 +++ b/fs/aufs/f_op.c
-@@ -352,7 +352,7 @@ static ssize_t aufs_splice_read(struct file *file, loff_t *ppos,
+@@ -353,7 +353,7 @@ static ssize_t aufs_splice_read(struct file *file, loff_t *ppos,
  	err = -EINVAL;
  	h_file = au_hf_top(file);
  	get_file(h_file);
  
  #endif /* __KERNEL__ */
 diff --git a/fs/aufs/super.c b/fs/aufs/super.c
-index 2769194..97e8930 100644
+index 4f57ba0..786ffea 100644
 --- a/fs/aufs/super.c
 +++ b/fs/aufs/super.c
 @@ -811,7 +811,10 @@ static const struct super_operations aufs_sop = {
  
  /* ---------------------------------------------------------------------- */
 diff --git a/include/linux/fs.h b/include/linux/fs.h
-index 5c49108..f8e9fd4 100644
+index 0148214..1296163 100644
 --- a/include/linux/fs.h
 +++ b/include/linux/fs.h
-@@ -1614,6 +1614,10 @@ struct super_operations {
+@@ -1616,6 +1616,10 @@ struct super_operations {
  	int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
  	int (*nr_cached_objects)(struct super_block *);
  	void (*free_cached_objects)(struct super_block *, int);

var/vabs/kernel-3.10/src/patches/aufs3-proc_map.patch

-aufs3.x-rcN proc_map patch
+aufs3.10 proc_map patch
 
 diff --git a/fs/buffer.c b/fs/buffer.c
-index b4dcb34..7b6b475 100644
+index d2a4d1b..7e0240f 100644
 --- a/fs/buffer.c
 +++ b/fs/buffer.c
-@@ -2390,6 +2390,8 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
+@@ -2388,6 +2388,8 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
  	 * fault so this update may be superfluous but who really cares...
  	 */
  	file_update_time(vma->vm_file);
  
  #ifndef CONFIG_MMU
 diff --git a/kernel/fork.c b/kernel/fork.c
-index 1766d32..c17b93b 100644
+index 987b28a..02ab913d 100644
 --- a/kernel/fork.c
 +++ b/kernel/fork.c
-@@ -417,6 +417,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
+@@ -418,6 +418,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
  			struct address_space *mapping = file->f_mapping;
  
  			get_file(file);
  				atomic_dec(&inode->i_writecount);
  			mutex_lock(&mapping->i_mmap_mutex);
 diff --git a/mm/memory.c b/mm/memory.c
-index 494526a..97cc6c9 100644
+index 61a262b..d12e816 100644
 --- a/mm/memory.c
 +++ b/mm/memory.c
-@@ -3408,6 +3408,8 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
+@@ -3452,6 +3452,8 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
  		/* file_update_time outside page_lock */
  		if (vma->vm_file && !page_mkwrite)
  			file_update_time(vma->vm_file);
  		unlock_page(vmf.page);
  		if (anon)
 diff --git a/mm/mmap.c b/mm/mmap.c
-index 2664a47..a3b1f5d 100644
+index f681e18..0227ae5 100644
 --- a/mm/mmap.c
 +++ b/mm/mmap.c
-@@ -243,6 +243,8 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
+@@ -251,6 +251,8 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
  		vma->vm_ops->close(vma);
  	if (vma->vm_file)
  		fput(vma->vm_file);
  	mpol_put(vma_policy(vma));
  	kmem_cache_free(vm_area_cachep, vma);
  	return next;
-@@ -825,6 +827,8 @@ again:			remove_next = 1 + (end > next->vm_end);
+@@ -861,6 +863,8 @@ again:			remove_next = 1 + (end > next->vm_end);
  		if (file) {
  			uprobe_munmap(next, next->vm_start, next->vm_end);
  			fput(file);
  		}
  		if (next->anon_vma)
  			anon_vma_merge(vma, next);
-@@ -2385,6 +2389,8 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
+@@ -2442,6 +2446,8 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
  
  	if (new->vm_file)
  		get_file(new->vm_file);
  
  	if (new->vm_ops && new->vm_ops->open)
  		new->vm_ops->open(new);
-@@ -2404,6 +2410,8 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
+@@ -2461,6 +2467,8 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
  		new->vm_ops->close(new);
  	if (new->vm_file)
  		fput(new->vm_file);
  	unlink_anon_vmas(new);
   out_free_mpol:
  	mpol_put(pol);
-@@ -2803,6 +2811,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
+@@ -2860,6 +2868,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
  				goto out_free_mempol;
  			if (new_vma->vm_file)
  				get_file(new_vma->vm_file);
  				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 e193280..7cf8e31 100644
+index 298884d..d30faea 100644
 --- a/mm/nommu.c
 +++ b/mm/nommu.c
-@@ -650,6 +650,8 @@ static void __put_nommu_region(struct vm_region *region)
+@@ -651,6 +651,8 @@ static void __put_nommu_region(struct vm_region *region)
  
  		if (region->vm_file)
  			fput(region->vm_file);
  
  		/* IO memory and memory shared directly out of the pagecache
  		 * from ramfs/tmpfs mustn't be released here */
-@@ -808,6 +810,8 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
+@@ -809,6 +811,8 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
  		vma->vm_ops->close(vma);
  	if (vma->vm_file)
  		fput(vma->vm_file);
  	put_nommu_region(vma->vm_region);
  	kmem_cache_free(vm_area_cachep, vma);
  }
-@@ -1374,6 +1378,8 @@ unsigned long do_mmap_pgoff(struct file *file,
+@@ -1375,6 +1379,8 @@ unsigned long do_mmap_pgoff(struct file *file,
  				}
  			}
  			fput(region->vm_file);
  			kmem_cache_free(vm_region_jar, region);
  			region = pregion;
  			result = start;
-@@ -1450,9 +1456,13 @@ error_just_free:
+@@ -1451,9 +1457,13 @@ error_just_free:
  error:
  	if (region->vm_file)
  		fput(region->vm_file);

var/vabs/kernel-3.10/src/patches/aufs3-standalone.patch

-aufs3.x-rcN standalone patch
+aufs3.10 standalone patch
 
 diff --git a/fs/file_table.c b/fs/file_table.c
-index ca5948f..b553610 100644
+index 8db8096..e271e28 100644
 --- a/fs/file_table.c
 +++ b/fs/file_table.c
 @@ -37,6 +37,7 @@ struct files_stat_struct files_stat = {
  
  /* SLAB cache for file structures */
  static struct kmem_cache *filp_cachep __read_mostly;
-@@ -404,6 +405,8 @@ void file_sb_list_del(struct file *file)
+@@ -405,6 +406,8 @@ void file_sb_list_del(struct file *file)
  	}
  }
  
  
  /*
 diff --git a/fs/inode.c b/fs/inode.c
-index 0b99538..46a6995 100644
+index f324521..bff7670 100644
 --- a/fs/inode.c
 +++ b/fs/inode.c
 @@ -56,6 +56,7 @@ static struct hlist_head *inode_hashtable __read_mostly;
  /**
   *	touch_atime	-	update the access time
 diff --git a/fs/namespace.c b/fs/namespace.c
-index 50ca17d..1548ce4 100644
+index 7b1ca9b..51db6ad 100644
 --- a/fs/namespace.c
 +++ b/fs/namespace.c
-@@ -52,6 +52,7 @@ EXPORT_SYMBOL_GPL(fs_kobj);
+@@ -54,6 +54,7 @@ EXPORT_SYMBOL_GPL(fs_kobj);
   * tree or hash is modified or when a vfsmount structure is modified.
   */
  DEFINE_BRLOCK(vfsmount_lock);
  
  static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
  {
-@@ -425,6 +426,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
+@@ -427,6 +428,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
  	mnt_dec_writers(real_mount(mnt));
  	preempt_enable();
  }
  
  /**
   * mnt_drop_write - give up write access to a mount
-@@ -1413,6 +1415,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
+@@ -1456,6 +1458,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
  	}
  	return 0;
  }
  static int fsnotify_mark_destroy(void *ignored)
  {
 diff --git a/fs/open.c b/fs/open.c
-index 6835446..df2262a 100644
+index 8c74100..be563cd 100644
 --- a/fs/open.c
 +++ b/fs/open.c
 @@ -61,6 +61,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
  long vfs_truncate(struct path *path, loff_t length)
  {
 diff --git a/fs/splice.c b/fs/splice.c
-index c717dbb..f9c3c18 100644
+index 987346f..8d6a045 100644
 --- a/fs/splice.c
 +++ b/fs/splice.c
-@@ -1117,6 +1117,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
- 
- 	return splice_write(pipe, out, ppos, len, flags);
+@@ -1120,6 +1120,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+ 	file_end_write(out);
+ 	return ret;
  }
 +EXPORT_SYMBOL(do_splice_from);
  
  /*
   * Attempt to initiate a splice from a file to a pipe.
-@@ -1143,6 +1144,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
+@@ -1146,6 +1147,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
  
  	return splice_read(in, ppos, pipe, len, flags);
  }
  }
 +EXPORT_SYMBOL(cap_mmap_file);
 diff --git a/security/device_cgroup.c b/security/device_cgroup.c
-index 1c69e38..7392d19 100644
+index dd0dc57..9760ecb6 100644
 --- a/security/device_cgroup.c
 +++ b/security/device_cgroup.c
 @@ -7,6 +7,7 @@
  #include <linux/list.h>
  #include <linux/uaccess.h>
  #include <linux/seq_file.h>
-@@ -634,6 +635,7 @@ int __devcgroup_inode_permission(struct inode *inode, int mask)
+@@ -789,6 +790,7 @@ int __devcgroup_inode_permission(struct inode *inode, int mask)
  	return __devcgroup_check_permission(type, imajor(inode), iminor(inode),
  			access);
  }
  int devcgroup_inode_mknod(int mode, dev_t dev)
  {
 diff --git a/security/security.c b/security/security.c
-index 7b88c6a..5d00a30 100644
+index a3dce87..06a6ea6 100644
 --- a/security/security.c
 +++ b/security/security.c
 @@ -396,6 +396,7 @@ int security_path_rmdir(struct path *dir, struct dentry *dentry)

var/vabs/kernel-3.10/src/patches/aufs3.10-20130307.patch

 diff -Naur linux-3.10/Documentation/ABI/testing/debugfs-aufs linux-3.10.patched/Documentation/ABI/testing/debugfs-aufs
 --- linux-3.10/Documentation/ABI/testing/debugfs-aufs	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/ABI/testing/debugfs-aufs	2013-07-03 07:26:48.000000000 -0600
-@@ -0,0 +1,37 @@
++++ linux-3.10.patched/Documentation/ABI/testing/debugfs-aufs	2013-07-02 22:35:19.000000000 -0600
+@@ -0,0 +1,50 @@
 +What:		/debug/aufs/si_<id>/
 +Date:		March 2009
 +Contact:	J. R. Okajima <hooanon05@yahoo.co.jp>
 +		per aufs mount, where <id> is a unique id generated
 +		internally.
 +
++What:		/debug/aufs/si_<id>/plink
++Date:		Apr 2013
++Contact:	J. R. Okajima <hooanon05@yahoo.co.jp>
++Description:
++		It has three lines and shows the information about the
++		pseudo-link. The first line is a single number
++		representing a number of buckets. The second line is a
++		number of pseudo-links per buckets (separated by a
++		blank). The last line is a single number representing a
++		total number of psedo-links.
++		When the aufs mount option 'noplink' is specified, it
++		will show "1\n0\n0\n".
++
 +What:		/debug/aufs/si_<id>/xib
 +Date:		March 2009
 +Contact:	J. R. Okajima <hooanon05@yahoo.co.jp>
 +		will be empty. About XINO files, see the aufs manual.
 diff -Naur linux-3.10/Documentation/ABI/testing/sysfs-aufs linux-3.10.patched/Documentation/ABI/testing/sysfs-aufs
 --- linux-3.10/Documentation/ABI/testing/sysfs-aufs	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/ABI/testing/sysfs-aufs	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/ABI/testing/sysfs-aufs	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,24 @@
 +What:		/sys/fs/aufs/si_<id>/
 +Date:		March 2009
 +		will be empty. About XINO files, see the aufs manual.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/README linux-3.10.patched/Documentation/filesystems/aufs/README
 --- linux-3.10/Documentation/filesystems/aufs/README	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/README	2013-07-03 07:26:48.000000000 -0600
-@@ -0,0 +1,339 @@
++++ linux-3.10.patched/Documentation/filesystems/aufs/README	2013-07-02 22:35:19.000000000 -0600
+@@ -0,0 +1,345 @@
 +
 +Aufs3 -- advanced multi layered unification filesystem version 3.x
 +http://aufs.sf.net
 +
 +o aufs3-linux tree
 +$ git clone --reference /your/linux/git/tree \
-+	git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-linux.git \
++	git://git.code.sf.net/p/aufs/aufs3-linux 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
 +
 +o aufs3-standalone tree
-+$ git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git \
++$ git clone git://git.code.sf.net/p/aufs/aufs3-standalone \
 +	aufs3-standalone.git
 +$ cd aufs3-standalone.git
 +$ git checkout origin/aufs3.0
 +
 +o aufs-util tree
-+$ git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs-util.git \
++$ git clone git://git.code.sf.net/p/aufs/aufs-util \
 +	aufs-util.git
 +$ cd aufs-util.git
 +$ git checkout origin/aufs3.0
 +Max Lekomcev (DOM-TV project) made a donation (2011/7, 12, 2012/3, 6 and
 +11).
 +Sam Liddicott made a donation (2011/9).
++Era Scarecrow made a donation (2013/4).
++Bor Ratajc made a donation (2013/4).
++Alessandro Gorreta made a donation (2013/4).
++POIRETTE Marc made a donation (2013/4).
++Alessandro Gorreta made a donation (2013/4).
++lauri kasvandik made a donation (2013/5).
 +
 +Thank you very much.
 +Donations are always, including future donations, very important and
 +# End: ;
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/01intro.txt linux-3.10.patched/Documentation/filesystems/aufs/design/01intro.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/01intro.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/01intro.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/01intro.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,162 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +about it. But currently I have implemented it in kernel space.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/02struct.txt linux-3.10.patched/Documentation/filesystems/aufs/design/02struct.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/02struct.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/02struct.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/02struct.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,226 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +dir, aufs reverts it after copy-up.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/03lookup.txt linux-3.10.patched/Documentation/filesystems/aufs/design/03lookup.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/03lookup.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/03lookup.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/03lookup.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,106 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +   by over-mounting something (or another method).
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/04branch.txt linux-3.10.patched/Documentation/filesystems/aufs/design/04branch.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/04branch.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/04branch.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/04branch.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,76 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +    same named entry on the upper branch.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/05wbr_policy.txt linux-3.10.patched/Documentation/filesystems/aufs/design/05wbr_policy.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/05wbr_policy.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/05wbr_policy.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/05wbr_policy.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,65 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +  copyup policy.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/06mmap.txt linux-3.10.patched/Documentation/filesystems/aufs/design/06mmap.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/06mmap.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/06mmap.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/06mmap.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,47 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +switching the approach.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/07export.txt linux-3.10.patched/Documentation/filesystems/aufs/design/07export.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/07export.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/07export.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/07export.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,59 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +  lookup_one_len(), vfs_getattr(), encode_fh() and others.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/08shwh.txt linux-3.10.patched/Documentation/filesystems/aufs/design/08shwh.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/08shwh.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/08shwh.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/08shwh.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,53 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +initramfs will use it to replace the old one at the next boot.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/10dynop.txt linux-3.10.patched/Documentation/filesystems/aufs/design/10dynop.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/10dynop.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/10dynop.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/10dynop.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,47 @@
 +
 +# Copyright (C) 2010-2013 Junjiro R. Okajima
 +vm_operations_struct for regular files only.
 diff -Naur linux-3.10/Documentation/filesystems/aufs/design/99plan.txt linux-3.10.patched/Documentation/filesystems/aufs/design/99plan.txt
 --- linux-3.10/Documentation/filesystems/aufs/design/99plan.txt	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/Documentation/filesystems/aufs/design/99plan.txt	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/Documentation/filesystems/aufs/design/99plan.txt	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,96 @@
 +
 +# Copyright (C) 2005-2013 Junjiro R. Okajima
 +Otherwise from /new.
 diff -Naur linux-3.10/fs/aufs/Kconfig linux-3.10.patched/fs/aufs/Kconfig
 --- linux-3.10/fs/aufs/Kconfig	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/fs/aufs/Kconfig	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/fs/aufs/Kconfig	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,202 @@
 +config AUFS_FS
 +	tristate "Aufs (Advanced multi layered unification filesystem) support"
 +endif
 diff -Naur linux-3.10/fs/aufs/Makefile linux-3.10.patched/fs/aufs/Makefile
 --- linux-3.10/fs/aufs/Makefile	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/fs/aufs/Makefile	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/fs/aufs/Makefile	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,42 @@
 +
 +include ${src}/magic.mk
 +aufs-$(CONFIG_AUFS_MAGIC_SYSRQ) += sysrq.o
 diff -Naur linux-3.10/fs/aufs/aufs.h linux-3.10.patched/fs/aufs/aufs.h
 --- linux-3.10/fs/aufs/aufs.h	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/fs/aufs/aufs.h	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/fs/aufs/aufs.h	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,60 @@
 +/*
 + * Copyright (C) 2005-2013 Junjiro R. Okajima
 +#endif /* __AUFS_H__ */
 diff -Naur linux-3.10/fs/aufs/branch.c linux-3.10.patched/fs/aufs/branch.c
 --- linux-3.10/fs/aufs/branch.c	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/fs/aufs/branch.c	2013-07-03 07:26:48.000000000 -0600
-@@ -0,0 +1,1172 @@
++++ linux-3.10.patched/fs/aufs/branch.c	2013-07-02 22:35:19.000000000 -0600
+@@ -0,0 +1,1213 @@
 +/*
 + * Copyright (C) 2005-2013 Junjiro R. Okajima
 + *
 +/*
 + * free a single branch
 + */
++
++/* prohibit rmdir to the root of the branch */
++/* todo: another new flag? */
++static void au_br_dflags_force(struct au_branch *br)
++{
++	struct dentry *h_dentry;
++
++	h_dentry = au_br_dentry(br);
++	spin_lock(&h_dentry->d_lock);
++	br->br_dflags = h_dentry->d_flags & DCACHE_MOUNTED;
++	h_dentry->d_flags |= DCACHE_MOUNTED;
++	spin_unlock(&h_dentry->d_lock);
++}
++
++/* restore its d_flags */
++static void au_br_dflags_restore(struct au_branch *br)
++{
++	struct dentry *h_dentry;
++
++	if (br->br_dflags)
++		return;
++
++	h_dentry = au_br_dentry(br);
++	spin_lock(&h_dentry->d_lock);
++	h_dentry->d_flags &= ~DCACHE_MOUNTED;
++	spin_unlock(&h_dentry->d_lock);
++}
++
 +static void au_br_do_free(struct au_branch *br)
 +{
 +	int i;
 +		else
 +			break;
 +
++	au_br_dflags_restore(br);
++
 +	/* recursive lock, s_umount of branch's */
 +	lockdep_off();
-+	mntput(br->br_mnt);
++	path_put(&br->br_path);
 +	lockdep_on();
 +	kfree(wbr);
 +	kfree(br);
 + * initialize or clean the whiteouts for an adding branch
 + */
 +static int au_br_init_wh(struct super_block *sb, struct au_branch *br,
-+			 int new_perm, struct dentry *h_root)
++			 int new_perm)
 +{
 +	int err, old_perm;
 +	aufs_bindex_t bindex;
 +	struct au_wbr *wbr;
 +	struct au_hinode *hdir;
 +
++	err = vfsub_mnt_want_write(au_br_mnt(br));
++	if (unlikely(err))
++		goto out;
++
 +	wbr = br->br_wbr;
 +	old_perm = br->br_perm;
 +	br->br_perm = new_perm;
 +		hdir = au_hi(sb->s_root->d_inode, bindex);
 +		au_hn_imtx_lock_nested(hdir, AuLsc_I_PARENT);
 +	} else {
-+		h_mtx = &h_root->d_inode->i_mutex;
++		h_mtx = &au_br_dentry(br)->d_inode->i_mutex;
 +		mutex_lock_nested(h_mtx, AuLsc_I_PARENT);
 +	}
 +	if (!wbr)
-+		err = au_wh_init(h_root, br, sb);
++		err = au_wh_init(br, sb);
 +	else {
 +		wbr_wh_write_lock(wbr);
-+		err = au_wh_init(h_root, br, sb);
++		err = au_wh_init(br, sb);
 +		wbr_wh_write_unlock(wbr);
 +	}
 +	if (hdir)
 +		au_hn_imtx_unlock(hdir);
 +	else
 +		mutex_unlock(h_mtx);
++	vfsub_mnt_drop_write(au_br_mnt(br));
 +	br->br_perm = old_perm;
 +
 +	if (!err && wbr && !au_br_writable(new_perm)) {
 +		br->br_wbr = NULL;
 +	}
 +
++out:
 +	return err;
 +}
 +
 +static int au_wbr_init(struct au_branch *br, struct super_block *sb,
-+		       int perm, struct path *path)
++		       int perm)
 +{
 +	int err;
 +	struct kstatfs kst;
 +	struct au_wbr *wbr;
-+	struct dentry *h_dentry;
 +
 +	wbr = br->br_wbr;
 +	au_rw_init(&wbr->wbr_wh_rwsem);
 +	 * a limit for rmdir/rename a dir
 +	 * cf. AUFS_MAX_NAMELEN in include/linux/aufs_type.h
 +	 */
-+	err = vfs_statfs(path, &kst);
++	err = vfs_statfs(&br->br_path, &kst);
 +	if (unlikely(err))
 +		goto out;
 +	err = -EINVAL;
-+	h_dentry = path->dentry;
 +	if (kst.f_namelen >= NAME_MAX)
-+		err = au_br_init_wh(sb, br, perm, h_dentry);
++		err = au_br_init_wh(sb, br, perm);
 +	else
 +		pr_err("%.*s(%s), unsupported namelen %ld\n",
-+		       AuDLNPair(h_dentry), au_sbtype(h_dentry->d_sb),
-+		       kst.f_namelen);
++		       AuDLNPair(au_br_dentry(br)),
++		       au_sbtype(au_br_dentry(br)->d_sb), kst.f_namelen);
 +
 +out:
 +	return err;
 +	memset(&br->br_xino, 0, sizeof(br->br_xino));
 +	mutex_init(&br->br_xino.xi_nondir_mtx);
 +	br->br_perm = add->perm;
-+	br->br_mnt = add->path.mnt; /* set first, mntget() later */
++	BUILD_BUG_ON(sizeof(br->br_dflags)
++		     != sizeof(br->br_path.dentry->d_flags));
++	br->br_dflags = DCACHE_MOUNTED;
++	br->br_path = add->path; /* set first, path_get() later */
 +	spin_lock_init(&br->br_dykey_lock);
 +	memset(br->br_dykey, 0, sizeof(br->br_dykey));
 +	atomic_set(&br->br_count, 0);
 +	AuDebugOn(br->br_id < 0);
 +
 +	if (au_br_writable(add->perm)) {
-+		err = au_wbr_init(br, sb, add->perm, &add->path);
++		err = au_wbr_init(br, sb, add->perm);
 +		if (unlikely(err))
 +			goto out_err;
 +	}
 +	}
 +
 +	sysaufs_br_init(br);
-+	mntget(add->path.mnt);
++	path_get(&br->br_path);
 +	goto out; /* success */
 +
 +out_err:
-+	br->br_mnt = NULL;
++	memset(&br->br_path, 0, sizeof(br->br_path));
 +out:
 +	return err;
 +}
 +		iinfo->ii_bstart = 0;
 +}
 +
-+static void au_br_do_add(struct super_block *sb, struct dentry *h_dentry,
-+			 struct au_branch *br, aufs_bindex_t bindex)
++static void au_br_do_add(struct super_block *sb, struct au_branch *br,
++			 aufs_bindex_t bindex)
 +{
-+	struct dentry *root;
++	struct dentry *root, *h_dentry;
 +	struct inode *root_inode;
 +	aufs_bindex_t bend, amount;
 +
++	au_br_dflags_force(br);
++
 +	root = sb->s_root;
 +	root_inode = root->d_inode;
 +	bend = au_sbend(sb);
 +	amount = bend + 1 - bindex;
++	h_dentry = au_br_dentry(br);
 +	au_sbilist_lock();
 +	au_br_do_add_brp(au_sbi(sb), bindex, br, bend, amount);
 +	au_br_do_add_hdp(au_di(root), bindex, bend, amount);
 +	}
 +
 +	add_bindex = add->bindex;
-+	h_dentry = add->path.dentry;
 +	if (!remount)
-+		au_br_do_add(sb, h_dentry, add_branch, add_bindex);
++		au_br_do_add(sb, add_branch, add_bindex);
 +	else {
 +		sysaufs_brs_del(sb, add_bindex);
-+		au_br_do_add(sb, h_dentry, add_branch, add_bindex);
++		au_br_do_add(sb, add_branch, add_bindex);
 +		sysaufs_brs_add(sb, add_bindex);
 +	}
 +
++	h_dentry = add->path.dentry;
 +	if (!add_bindex) {
 +		au_cpup_attr_all(root_inode, /*force*/1);
 +		sb->s_maxbytes = h_dentry->d_sb->s_maxbytes;
 +		goto out;
 +	}
 +	br = au_sbr(sb, bindex);
++	AuDebugOn(!path_equal(&br->br_path, &del->h_path));
 +	i = atomic_read(&br->br_count);
 +	if (unlikely(i)) {
 +		AuVerbose(verbose, "%d file(s) opened\n", i);
 +
 +out_wh:
 +	/* revert */
-+	rerr = au_br_init_wh(sb, br, br->br_perm, del->h_path.dentry);
++	rerr = au_br_init_wh(sb, br, br->br_perm);
 +	if (rerr)
 +		pr_warn("failed re-creating base whiteout, %s. (%d)\n",
 +			del->pathname, rerr);
 +{
 +	int err, rerr;
 +	aufs_bindex_t bindex;
-+	struct path path;
 +	struct dentry *root;
 +	struct au_branch *br;
 +
 +		goto out;
 +
 +	br = au_sbr(sb, bindex);
++	AuDebugOn(mod->h_root != au_br_dentry(br));
 +	if (br->br_perm == mod->perm)
 +		return 0; /* success */
 +
 +	if (au_br_writable(br->br_perm)) {
 +		/* remove whiteout base */
-+		err = au_br_init_wh(sb, br, mod->perm, mod->h_root);
++		err = au_br_init_wh(sb, br, mod->perm);
 +		if (unlikely(err))
 +			goto out;
 +
 +				rerr = -ENOMEM;
 +				br->br_wbr = kmalloc(sizeof(*br->br_wbr),
 +						     GFP_NOFS);
-+				if (br->br_wbr) {
-+					path.mnt = br->br_mnt;
-+					path.dentry = mod->h_root;
-+					rerr = au_wbr_init(br, sb, br->br_perm,
-+							   &path);
-+				}
++				if (br->br_wbr)
++					rerr = au_wbr_init(br, sb, br->br_perm);
 +				if (unlikely(rerr)) {
 +					AuIOErr("nested error %d (%d)\n",
 +						rerr, err);
 +		err = -ENOMEM;
 +		br->br_wbr = kmalloc(sizeof(*br->br_wbr), GFP_NOFS);
 +		if (br->br_wbr) {
-+			path.mnt = br->br_mnt;
-+			path.dentry = mod->h_root;
-+			err = au_wbr_init(br, sb, mod->perm, &path);
++			err = au_wbr_init(br, sb, mod->perm);
 +			if (unlikely(err)) {
 +				kfree(br->br_wbr);
 +				br->br_wbr = NULL;
 +	}
 +
 +	if (!err) {
++		if ((br->br_perm & AuBrAttr_UNPIN)
++		    && !(mod->perm & AuBrAttr_UNPIN))
++			au_br_dflags_force(br);
++		else if (!(br->br_perm & AuBrAttr_UNPIN)
++			 && (mod->perm & AuBrAttr_UNPIN))
++			au_br_dflags_restore(br);
 +		*do_refresh |= need_sigen_inc(br->br_perm, mod->perm);
 +		br->br_perm = mod->perm;
 +	}
 +}
 diff -Naur linux-3.10/fs/aufs/branch.h linux-3.10.patched/fs/aufs/branch.h
 --- linux-3.10/fs/aufs/branch.h	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/fs/aufs/branch.h	2013-07-03 07:26:48.000000000 -0600
-@@ -0,0 +1,236 @@
++++ linux-3.10.patched/fs/aufs/branch.h	2013-07-02 22:35:19.000000000 -0600
+@@ -0,0 +1,255 @@
 +/*
 + * Copyright (C) 2005-2013 Junjiro R. Okajima
 + *
 +	aufs_bindex_t		br_id;
 +
 +	int			br_perm;
-+	struct vfsmount		*br_mnt;
++	unsigned int		br_dflags;
++	struct path		br_path;
 +	spinlock_t		br_dykey_lock;
 +	struct au_dykey		*br_dykey[AuBrDynOp];
 +	atomic_t		br_count;
 +
 +/* ---------------------------------------------------------------------- */
 +
++static inline struct vfsmount *au_br_mnt(struct au_branch *br)
++{
++	return br->br_path.mnt;
++}
++
++static inline struct dentry *au_br_dentry(struct au_branch *br)
++{
++	return br->br_path.dentry;
++}
++
++static inline struct super_block *au_br_sb(struct au_branch *br)
++{
++	return au_br_mnt(br)->mnt_sb;
++}
++
 +/* branch permissions and attributes */
 +#define AuBrPerm_RW		1		/* writable, hardlinkable wh */
 +#define AuBrPerm_RO		(1 << 1)	/* readonly */
 +
 +#define AuBrWAttr_NoLinkWH	(1 << 4)	/* un-hardlinkable whiteouts */
 +
++#define AuBrAttr_UNPIN		(1 << 5)	/* rename-able top dir of
++						   branch */
++
 +static inline int au_br_writable(int brperm)
 +{
 +	return brperm & AuBrPerm_RW;
 +
 +static inline int au_br_rdonly(struct au_branch *br)
 +{
-+	return ((br->br_mnt->mnt_sb->s_flags & MS_RDONLY)
++	return ((au_br_sb(br)->s_flags & MS_RDONLY)
 +		|| !au_br_writable(br->br_perm))
 +		? -EROFS : 0;
 +}
 +static inline
 +struct vfsmount *au_sbr_mnt(struct super_block *sb, aufs_bindex_t bindex)
 +{
-+	return au_sbr(sb, bindex)->br_mnt;
++	return au_br_mnt(au_sbr(sb, bindex));
 +}
 +
 +static inline
 +struct super_block *au_sbr_sb(struct super_block *sb, aufs_bindex_t bindex)
 +{
-+	return au_sbr_mnt(sb, bindex)->mnt_sb;
++	return au_br_sb(au_sbr(sb, bindex));
 +}
 +
 +static inline void au_sbr_put(struct super_block *sb, aufs_bindex_t bindex)
 +#endif /* __AUFS_BRANCH_H__ */
 diff -Naur linux-3.10/fs/aufs/conf.mk linux-3.10.patched/fs/aufs/conf.mk
 --- linux-3.10/fs/aufs/conf.mk	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/fs/aufs/conf.mk	2013-07-03 07:26:48.000000000 -0600
++++ linux-3.10.patched/fs/aufs/conf.mk	2013-07-02 22:35:19.000000000 -0600
 @@ -0,0 +1,38 @@
 +
 +AuConfStr = CONFIG_AUFS_FS=${CONFIG_AUFS_FS}
 +-include ${srctree}/${src}/conf_priv.mk
 diff -Naur linux-3.10/fs/aufs/cpup.c linux-3.10.patched/fs/aufs/cpup.c
 --- linux-3.10/fs/aufs/cpup.c	1969-12-31 17:00:00.000000000 -0700
-+++ linux-3.10.patched/fs/aufs/cpup.c	2013-07-03 07:26:48.000000000 -0600
-@@ -0,0 +1,1085 @@
++++ linux-3.10.patched/fs/aufs/cpup.c	2013-07-02 22:35:19.000000000 -0600
+@@ -0,0 +1,1247 @@
 +/*
 + * Copyright (C) 2005-2013 Junjiro R. Okajima
 + *
 +#include <linux/mm.h>
 +#include "aufs.h"
 +
-+void au_cpup_attr_flags(struct inode *dst, struct inode *src)
++void au_cpup_attr_flags(struct inode *dst, unsigned int iflags)
 +{
 +	const unsigned int mask = S_DEAD | S_SWAPFILE | S_PRIVATE
 +		| S_NOATIME | S_NOCMTIME;
 +
-+	dst->i_flags |= src->i_flags & ~mask;
++	BUILD_BUG_ON(sizeof(iflags) != sizeof(dst->i_flags));
++
++	dst->i_flags |= iflags & ~mask;
 +	if (au_test_fs_notime(dst->i_sb))
 +		dst->i_flags |= S_NOATIME | S_NOCMTIME;
 +}
 +	inode->i_uid = h_inode->i_uid;
 +	inode->i_gid = h_inode->i_gid;
 +	au_cpup_attr_timesizes(inode);
-+	au_cpup_attr_flags(inode, h_inode);
++	au_cpup_attr_flags(inode, h_inode->i_flags);
 +}
 +
 +void au_cpup_igen(struct inode *inode, struct inode *h_inode)
 +
 +/* ---------------------------------------------------------------------- */
 +
++/* internal use only */
++struct au_cpup_reg_attr {
++	int		valid;
++	struct kstat	st;
++	unsigned int	iflags; /* inode->i_flags */
++};
++
 +static noinline_for_stack
-+int cpup_iattr(struct dentry *dst, aufs_bindex_t bindex, struct dentry *h_src)
++int cpup_iattr(struct dentry *dst, aufs_bindex_t bindex, struct dentry *h_src,
++	       struct au_cpup_reg_attr *h_src_attr)
 +{
 +	int err, sbits;
 +	struct iattr ia;
 +	struct path h_path;
 +	struct inode *h_isrc, *h_idst;
++	struct kstat *h_st;
 +
 +	h_path.dentry = au_h_dptr(dst, bindex);
 +	h_idst = h_path.dentry->d_inode;
 +	ia.ia_valid = ATTR_FORCE | ATTR_UID | ATTR_GID
 +		| ATTR_ATIME | ATTR_MTIME
 +		| ATTR_ATIME_SET | ATTR_MTIME_SET;
-+	ia.ia_uid = h_isrc->i_uid;
-+	ia.ia_gid = h_isrc->i_gid;
-+	ia.ia_atime = h_isrc->i_atime;
-+	ia.ia_mtime = h_isrc->i_mtime;
-+	if (h_idst->i_mode != h_isrc->i_mode
-+	    && !S_ISLNK(h_idst->i_mode)) {
-+		ia.ia_valid |= ATTR_MODE;
-+		ia.ia_mode = h_isrc->i_mode;
++	if (h_src_attr && h_src_attr->valid) {
++		h_st = &h_src_attr->st;
++		ia.ia_uid = h_st->uid;
++		ia.ia_gid = h_st->gid;
++		ia.ia_atime = h_st->atime;
++		ia.ia_mtime = h_st->mtime;
++		if (h_idst->i_mode != h_st->mode
++		    && !S_ISLNK(h_idst->i_mode)) {
++			ia.ia_valid |= ATTR_MODE;
++			ia.ia_mode = h_st->mode;
++		}
++		sbits = !!(h_st->mode & (S_ISUID | S_ISGID));
++		au_cpup_attr_flags(h_idst, h_src_attr->iflags);
++	} else {
++		ia.ia_uid = h_isrc->i_uid;
++		ia.ia_gid = h_isrc->i_gid;
++		ia.ia_atime = h_isrc->i_atime;
++		ia.ia_mtime = h_isrc->i_mtime;
++		if (h_idst->i_mode != h_isrc->i_mode
++		    && !S_ISLNK(h_idst->i_mode)) {
++			ia.ia_valid |= ATTR_MODE;
++			ia.ia_mode = h_isrc->i_mode;
++		}
++		sbits = !!(h_isrc->i_mode & (S_ISUID | S_ISGID));
++		au_cpup_attr_flags(h_idst, h_isrc->i_flags);
 +	}
-+	sbits = !!(h_isrc->i_mode & (S_ISUID | S_ISGID));
-+	au_cpup_attr_flags(h_idst, h_isrc);
 +	err = vfsub_notify_change(&h_path, &ia);
 +
 +	/* is this nfs only? */
 +	return err;
 +}
 +
++/* internal use only */
++struct au_cpup_basic {
++	struct dentry *dentry;
++	aufs_bindex_t bdst, bsrc;
++	loff_t len;
++};
++
 +/*
 + * to support a sparse file which is opened with O_APPEND,
 + * we need to close the file.
 + */
-+static int au_cp_regular(struct dentry *dentry, aufs_bindex_t bdst,
-+			 aufs_bindex_t bsrc, loff_t len)
++static int au_cp_regular(struct au_cpup_basic *basic)
 +{
 +	int err, i;
 +	enum { SRC, DST };
 +		void *label, *label_file;
 +	} *f, file[] = {
 +		{
-+			.bindex = bsrc,
++			.bindex = basic->bsrc,
 +			.flags = O_RDONLY | O_NOATIME | O_LARGEFILE,
 +			.file = NULL,
 +			.label = &&out,
 +			.label_file = &&out_src
 +		},
 +		{
-+			.bindex = bdst,
++			.bindex = basic->bdst,
 +			.flags = O_WRONLY | O_NOATIME | O_LARGEFILE,
 +			.file = NULL,
 +			.label = &&out_src,
 +	struct super_block *sb;
 +
 +	/* bsrc branch can be ro/rw. */
-+	sb = dentry->d_sb;
++	sb = basic->dentry->d_sb;
 +	f = file;
 +	for (i = 0; i < 2; i++, f++) {
-+		f->dentry = au_h_dptr(dentry, f->bindex);
-+		f->file = au_h_open(dentry, f->bindex, f->flags, /*file*/NULL);
++		f->dentry = au_h_dptr(basic->dentry, f->bindex);
++		f->file = au_h_open(basic->dentry, f->bindex, f->flags,
++				    /*file*/NULL);
 +		err = PTR_ERR(f->file);
 +		if (IS_ERR(f->file))
 +			goto *f->label;
 +
 +	/* try stopping to update while we copyup */
 +	IMustLock(file[SRC].dentry->d_inode);
-+	err = au_copy_file(file[DST].file, file[SRC].file, len);
++	err = au_copy_file(file[DST].file, file[SRC].file, basic->len);
 +
 +out_dst:
 +	fput(file[DST].file);
 +	return err;
 +}
 +
-+static int au_do_cpup_regular(struct dentry *dentry, aufs_bindex_t bdst,
-+			      aufs_bindex_t bsrc, loff_t len,
-+			      struct inode *h_dir, struct path *h_path)
++static int au_do_cpup_regular(struct au_cpup_basic *basic, struct au_pin *pin,
++			      struct au_cpup_reg_attr *h_src_attr)
 +{
 +	int err, rerr;
 +	loff_t l;
++	struct path h_path;
++	struct inode *h_src_inode;
 +
 +	err = 0;
-+	l = i_size_read(au_h_iptr(dentry->d_inode, bsrc));
-+	if (len == -1 || l < len)
-+		len = l;
-+	if (len)
-+		err = au_cp_regular(dentry, bdst, bsrc, len);
-+	if (!err)
-+		goto out; /* success */
++	h_src_inode = au_h_iptr(basic->dentry->d_inode, basic->bsrc);
++	l = i_size_read(h_src_inode);
++	if (basic->len == -1 || l < basic->len)
++		basic->len = l;
++	if (basic->len) {
++		/* try stopping to update while we are referencing */
++		mutex_lock_nested(&h_src_inode->i_mutex, AuLsc_I_CHILD);
++		au_pin_hdir_unlock(pin);
 +
-+	rerr = vfsub_unlink(h_dir, h_path, /*force*/0);
-+	if (rerr) {
-+		AuIOErr("failed unlinking cpup-ed %.*s(%d, %d)\n",
-+			AuDLNPair(h_path->dentry), err, rerr);
-+		err = -EIO;
++		h_path.dentry = au_h_dptr(basic->dentry, basic->bsrc);
++		h_path.mnt = au_sbr_mnt(basic->dentry->d_sb, basic->bsrc);
++		h_src_attr->iflags = h_src_inode->i_flags;
++		err = vfs_getattr(&h_path, &h_src_attr->st);
++		if (unlikely(err)) {
++			mutex_unlock(&h_src_inode->i_mutex);
++			goto out;
++		}
++		h_src_attr->valid = 1;
++		err = au_cp_regular(basic);
++		mutex_unlock(&h_src_inode->i_mutex);
++		rerr = au_pin_hdir_relock(pin);
++		if (!err && rerr)
++			err = rerr;
 +	}
 +
 +out:
 +	return err;
 +}
 +
-+/* return with the lower dst inode is locked */
 +static noinline_for_stack
-+int cpup_entry(struct dentry *dentry, aufs_bindex_t bdst,
-+	       aufs_bindex_t bsrc, loff_t len, unsigned int flags,
-+	       struct dentry *dst_parent)
++int cpup_entry(struct au_cpup_basic *basic, unsigned int flags,
++	       struct dentry *dst_parent, struct au_pin *pin,
++	       struct au_cpup_reg_attr *h_src_attr)
 +{
 +	int err;
 +	umode_t mode;
 +	struct super_block *sb;
 +
 +	/* bsrc branch can be ro/rw. */
-+	h_src = au_h_dptr(dentry, bsrc);
++	h_src = au_h_dptr(basic->dentry, basic->bsrc);
 +	h_inode = h_src->d_inode;
-+	AuDebugOn(h_inode != au_h_iptr(dentry->d_inode, bsrc));
++	AuDebugOn(h_inode != au_h_iptr(basic->dentry->d_inode, basic->bsrc));
 +
 +	/* try stopping to be referenced while we are creating */
-+	h_dst = au_h_dptr(dentry, bdst);
++	h_dst = au_h_dptr(basic->dentry, basic->bdst);
++	if (au_ftest_cpup(flags, RENAME))
++		AuDebugOn(strncmp(h_dst->d_name.name, AUFS_WH_PFX,
++				  AUFS_WH_PFX_LEN));
 +	h_parent = h_dst->d_parent; /* dir inode is locked */
 +	h_dir = h_parent->d_inode;
 +	IMustLock(h_dir);
 +	AuDebugOn(h_parent != h_dst->d_parent);
 +
-+	sb = dentry->d_sb;
-+	h_path.mnt = au_sbr_mnt(sb, bdst);
++	sb = basic->dentry->d_sb;
++	h_path.mnt = au_sbr_mnt(sb, basic->bdst);
 +	if (do_dt) {
 +		h_path.dentry = h_parent;
 +		au_dtime_store(&dt, dst_parent, &h_path);
 +	mode = h_inode->i_mode;
 +	switch (mode & S_IFMT) {
 +	case S_IFREG:
-+		/* try stopping to update while we are referencing */
-+		IMustLock(h_inode);
 +		err = vfsub_create(h_dir, &h_path, mode | S_IWUSR,
 +				   /*want_excl*/true);
 +		if (!err)
-+			err = au_do_cpup_regular
-+				(dentry, bdst, bsrc, len,
-+				 au_h_iptr(dst_parent->d_inode, bdst), &h_path);
++			err = au_do_cpup_regular(basic, pin, h_src_attr);
 +		break;
 +	case S_IFDIR:
 +		isdir = 1;
 +			 * strange behaviour from the users view,
 +			 * particularry setattr case
 +			 */
-+			if (au_ibstart(dst_parent->d_inode) == bdst)
++			if (au_ibstart(dst_parent->d_inode) == basic->bdst)
 +				au_cpup_attr_nlink(dst_parent->d_inode,
 +						   /*force*/1);
-+			au_cpup_attr_nlink(dentry->d_inode, /*force*/1);
++			au_cpup_attr_nlink(basic->dentry->d_inode, /*force*/1);
 +		}
 +		break;
 +	case S_IFLNK:
 +	    && au_opt_test(mnt_flags, XINO)
 +	    && h_inode->i_nlink == 1
 +	    /* todo: unnecessary? */
-+	    /* && dentry->d_inode->i_nlink == 1 */
-+	    && bdst < bsrc
++	    /* && basic->dentry->d_inode->i_nlink == 1 */
++	    && basic->bdst < basic->bsrc
 +	    && !au_ftest_cpup(flags, KEEPLINO))
-+		au_xino_write(sb, bsrc, h_inode->i_ino, /*ino*/0);
++		au_xino_write(sb, basic->bsrc, h_inode->i_ino, /*ino*/0);
 +		/* ignore this error */
 +
 +	if (do_dt)
 +	return err;
 +}
 +
++static int au_do_ren_after_cpup(struct dentry *dentry, aufs_bindex_t bdst,
++				struct path *h_path)
++{
++	int err;
++	struct dentry *h_dentry, *h_parent;
++	struct inode *h_dir;
++
++	h_dentry = dget(au_h_dptr(dentry, bdst));
++	au_set_h_dptr(dentry, bdst, NULL);
++	err = au_lkup_neg(dentry, bdst, /*wh*/0);
++	if (unlikely(err)) {
++		au_set_h_dptr(dentry, bdst, h_dentry);
++		goto out;
++	}
++
++	h_path->dentry = dget(au_h_dptr(dentry, bdst));
++	au_set_h_dptr(dentry, bdst, h_dentry);
++	h_parent = h_dentry->d_parent; /* dir inode is locked */
++	h_dir = h_parent->d_inode;
++	IMustLock(h_dir);
++	AuDbg("%.*s %.*s\n", AuDLNPair(h_dentry), AuDLNPair(h_path->dentry));
++	err = vfsub_rename(h_dir, h_dentry, h_dir, h_path);
++	dput(h_path->dentry);
++
++out:
++	return err;
++}
++
 +/*
 + * copyup the @dentry from @bsrc to @bdst.
 + * the caller must set the both of lower dentries.
 + * @len is for truncating when it is -1 copyup the entire file.
 + * in link/rename cases, @dst_parent may be different from the real one.
 + */
-+static int au_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
-+			  aufs_bindex_t bsrc, loff_t len, unsigned int flags,
-+			  struct dentry *dst_parent)
++static int au_cpup_single(struct au_cpup_basic *basic, unsigned int flags,
++			  struct dentry *dst_parent, struct au_pin *pin)
 +{
 +	int err, rerr;
 +	aufs_bindex_t old_ibstart;
 +	struct dentry *h_src, *h_dst, *h_parent;
 +	struct inode *dst_inode, *h_dir, *inode;
 +	struct super_block *sb;
++	struct au_branch *br;
++	struct au_cpup_reg_attr h_src_attr = {
++		.valid = 0
++	};
 +
-+	AuDebugOn(bsrc <= bdst);
++	AuDebugOn(basic->bsrc <= basic->bdst);
 +
-+	sb = dentry->d_sb;
-+	h_path.mnt = au_sbr_mnt(sb, bdst);
-+	h_dst = au_h_dptr(dentry, bdst);
++	sb = basic->dentry->d_sb;
++	br = au_sbr(sb, basic->bdst);
++	h_path.mnt = au_br_mnt(br);
++	h_dst = au_h_dptr(basic->dentry, basic->bdst);
 +	h_parent = h_dst->d_parent; /* dir inode is locked */
 +	h_dir = h_parent->d_inode;
 +	IMustLock(h_dir);
 +
-+	h_src = au_h_dptr(dentry, bsrc);
-+	inode = dentry->d_inode;
++	h_src = au_h_dptr(basic->dentry, basic->bsrc);
++	inode = basic->dentry->d_inode;
 +
 +	if (!dst_parent)
-+		dst_parent = dget_parent(dentry);
++		dst_parent = dget_parent(basic->dentry);
 +	else
 +		dget(dst_parent);
 +
 +	plink = !!au_opt_test(au_mntflags(sb), PLINK);
-+	dst_inode = au_h_iptr(inode, bdst);
++	dst_inode = au_h_iptr(inode, basic->bdst);
 +	if (dst_inode) {
 +		if (unlikely(!plink)) {
 +			err = -EIO;
 +			AuIOErr("hi%lu(i%lu) exists on b%d "
 +				"but plink is disabled\n",
-+				dst_inode->i_ino, inode->i_ino, bdst);
++				dst_inode->i_ino, inode->i_ino, basic->bdst);
 +			goto out;
 +		}
 +
 +		if (dst_inode->i_nlink) {
 +			const int do_dt = au_ftest_cpup(flags, DTIME);
 +
-+			h_src = au_plink_lkup(inode, bdst);
++			h_src = au_plink_lkup(inode, basic->bdst);
 +			err = PTR_ERR(h_src);
 +			if (IS_ERR(h_src))
 +				goto out;
 +				h_path.dentry = h_parent;
 +				au_dtime_store(&dt, dst_parent, &h_path);
 +			}
++
 +			h_path.dentry = h_dst;
 +			err = vfsub_link(h_src, h_dir, &h_path);
++			if (!err && au_ftest_cpup(flags, RENAME))
++				err = au_do_ren_after_cpup
++					(basic->dentry, basic->bdst, &h_path);
 +			if (do_dt)
 +				au_dtime_revert(&dt);
 +			dput(h_src);
 +			au_update_ibrange(inode, /*do_put_zero*/1);
 +	}
 +
++	isdir = S_ISDIR(inode->i_mode);
 +	old_ibstart = au_ibstart(inode);
-+	err = cpup_entry(dentry, bdst, bsrc, len, flags, dst_parent);
++	err = cpup_entry(basic, flags, dst_parent, pin, &h_src_attr);
 +	if (unlikely(err))
-+		goto out;
++		goto out_rev;
 +	dst_inode = h_dst->d_inode;
 +	mutex_lock_nested(&dst_inode->i_mutex, AuLsc_I_CHILD2);
++	/* todo: necessary? */
++	/* au_pin_hdir_unlock(pin); */
 +
-+	err = cpup_iattr(dentry, bdst, h_src);
-+	isdir = S_ISDIR(dst_inode->i_mode);
-+	if (!err) {
-+		if (bdst < old_ibstart) {
-+			if (S_ISREG(inode->i_mode)) {
-+				err = au_dy_iaop(inode, bdst, dst_inode);
-+				if (unlikely(err))
-+					goto out_rev;
++	err = cpup_iattr(basic->dentry, basic->bdst, h_src, &h_src_attr);
++	if (unlikely(err)) {
++		/* todo: necessary? */
++		/* au_pin_hdir_relock(pin); */ /* ignore an error */
++		mutex_unlock(&dst_inode->i_mutex);
++		goto out_rev;
++	}
++
++	if (basic->bdst < old_ibstart) {
++		if (S_ISREG(inode->i_mode)) {
++			err = au_dy_iaop(inode, basic->bdst, dst_inode);
++			if (unlikely(err)) {
++				/* au_pin_hdir_relock(pin); ignore an error */
++				mutex_unlock(&dst_inode->i_mutex);
++				goto out_rev;
 +			}
-+			au_set_ibstart(inode, bdst);
 +		}
-+		au_set_h_iptr(inode, bdst, au_igrab(dst_inode),
-+			      au_hi_flags(inode, isdir));
-+		mutex_unlock(&dst_inode->i_mutex);
-+		if (!isdir
-+		    && h_src->d_inode->i_nlink > 1
-+		    && plink)
-+			au_plink_append(inode, bdst, h_dst);
-+		goto out; /* success */
++		au_set_ibstart(inode, basic->bdst);
++	}
++	au_set_h_iptr(inode, basic->bdst, au_igrab(dst_inode),
++		      au_hi_flags(inode, isdir));
++
++	/* todo: necessary? */
++	/* err = au_pin_hdir_relock(pin); */
++	mutex_unlock(&dst_inode->i_mutex);
++	if (unlikely(err))
++		goto out_rev;
++
++	if (!isdir
++	    && h_src->d_inode->i_nlink > 1
++	    && plink)
++		au_plink_append(inode, basic->bdst, h_dst);
++
++	if (au_ftest_cpup(flags, RENAME)) {
++		h_path.dentry = h_dst;
++		err = au_do_ren_after_cpup(basic->dentry, basic->bdst, &h_path);
 +	}
++	if (!err)
++		goto out; /* success */
 +
 +	/* revert */
 +out_rev:
 +	h_path.dentry = h_parent;
-+	mutex_unlock(&dst_inode->i_mutex);
 +	au_dtime_store(&dt, dst_parent, &h_path);
 +	h_path.dentry = h_dst;
-+	if (!isdir)
-+		rerr = vfsub_unlink(h_dir, &h_path, /*force*/0);
-+	else
-+		rerr = vfsub_rmdir(h_dir, &h_path);
++	rerr = 0;
++	if (h_dst->d_inode) {
++		if (!isdir)
++			rerr = vfsub_unlink(h_dir, &h_path, /*force*/0);
++		else
++			rerr = vfsub_rmdir(h_dir, &h_path);
++	}
 +	au_dtime_revert(&dt);
 +	if (rerr) {
 +		AuIOErr("failed removing broken entry(%d, %d)\n", err, rerr);
 +		err = -EIO;
 +	}
-+
 +out:
 +	dput(dst_parent);
 +	return err;
 +
 +struct au_cpup_single_args {
 +	int *errp;
-+	struct dentry *dentry;
-+	aufs_bindex_t bdst, bsrc;
-+	loff_t len;
++	struct au_cpup_basic *basic;
 +	unsigned int flags;
 +	struct dentry *dst_parent;
++	struct au_pin *pin;
 +};
 +
 +static void au_call_cpup_single(void *args)
 +{
 +	struct au_cpup_single_args *a = args;
-+	*a->errp = au_cpup_single(a->dentry, a->bdst, a->bsrc, a->len,
-+				  a->flags, a->dst_parent);
++
++	au_pin_hdir_acquire_nest(a->pin);
++	*a->errp = au_cpup_single(a->basic, a->flags, a->dst_parent, a->pin);
++	au_pin_hdir_release(a->pin);
 +}
 +
 +/*
 + * testing CAP_MKNOD is for generic fs,
 + * but CAP_FSETID is for xfs only, currently.
 + */
-+static int au_cpup_sio_test(struct super_block *sb, umode_t mode)
++static int au_cpup_sio_test(struct au_pin *pin, umode_t mode)
 +{
 +	int do_sio;
++	struct super_block *sb;
++	struct inode *h_dir;
 +
 +	do_sio = 0;
++	sb = au_pinned_parent(pin)->d_sb;
 +	if (!au_wkq_test()
 +	    && (!au_sbi(sb)->si_plink_maint_pid
 +		|| au_plink_maint(sb, AuLock_NOPLM))) {
 +		if (!do_sio)
 +			do_sio = ((mode & (S_ISUID | S_ISGID))
 +				  && !capable(CAP_FSETID));
++		/* this workaround may be removed in the future */
++		if (!do_sio) {
++			h_dir = au_pinned_h_dir(pin);
++			do_sio = h_dir->i_mode & S_ISVTX;
++		}
 +	}
 +
 +	return do_sio;
 +
 +int au_sio_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
 +		       aufs_bindex_t bsrc, loff_t len, unsigned int flags,
-+		       struct dentry *dst_parent)
++		       struct dentry *dst_parent, struct au_pin *pin)
 +{
 +	int err, wkq_err;
 +	struct dentry *h_dentry;
++	struct au_cpup_basic basic = {
++		.dentry	= dentry,
++		.bdst	= bdst,
++		.bsrc	= bsrc,
++		.len	= len
++	};
 +
 +	h_dentry = au_h_dptr(dentry, bsrc);
-+	if (!au_cpup_sio_test(dentry->d_sb, h_dentry->d_inode->i_mode))
-+		err = au_cpup_single(dentry, bdst, bsrc, len, flags,
-+				     dst_parent);
++	if (!au_cpup_sio_test(pin, h_dentry->d_inode->i_mode))
++		err = au_cpup_single(&basic, flags, dst_parent, pin);
 +	else {
 +		struct au_cpup_single_args args = {
 +			.errp		= &err,
-+			.dentry		= dentry,
-+			.bdst		= bdst,
-+			.bsrc		= bsrc,
-+			.len		= len,
++			.basic		= &basic,
 +			.flags		= flags,
-+			.dst_parent	= dst_parent
++			.dst_parent	= dst_parent,
++			.pin		= pin
 +		};
 +		wkq_err = au_wkq_wait(au_call_cpup_single, &args);
 +		if (unlikely(wkq_err))
 + * using au_cpup_single().
 + */
 +static int au_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+			  unsigned int flags)
++			  unsigned int flags, struct au_pin *pin)
 +{
 +	int err;
 +	aufs_bindex_t bsrc, bend;
++	struct dentry *h_dentry;
 +
++	DiMustWriteLock(dentry);
 +	bend = au_dbend(dentry);
-+	for (bsrc = bdst + 1; bsrc <= bend; bsrc++)
-+		if (au_h_dptr(dentry, bsrc))
++	for (bsrc = bdst + 1; bsrc <= bend; bsrc++) {
++		h_dentry = au_h_dptr(dentry, bsrc);
++		if (h_dentry) {
++			AuDebugOn(!h_dentry->d_inode);
 +			break;
++		}
++	}
++	AuDebugOn(bsrc > bend);
 +
-+	err = au_lkup_neg(dentry, bdst);
++	err = au_lkup_neg(dentry, bdst, /*wh*/1);
 +	if (!err) {
-+		err = au_cpup_single(dentry, bdst, bsrc, len, flags, NULL);
++		struct au_cpup_basic basic = {
++			.dentry	= dentry,
++			.bdst	= bdst,
++			.bsrc	= bsrc,
++			.len	= len
++		};
++		err = au_cpup_single(&basic, flags | AuCpup_RENAME, NULL, pin);
 +		if (!err)
 +			return 0; /* success */
 +
 +	aufs_bindex_t bdst;
 +	loff_t len;
 +	unsigned int flags;
++	struct au_pin *pin;
 +};
 +
 +static void au_call_cpup_simple(void *args)
 +{
 +	struct au_cpup_simple_args *a = args;
-+	*a->errp = au_cpup_simple(a->dentry, a->bdst, a->len, a->flags);
++
++	au_pin_hdir_acquire_nest(a->pin);
++	*a->errp = au_cpup_simple(a->dentry, a->bdst, a->len, a->flags, a->pin);
++	au_pin_hdir_release(a->pin);
 +}
 +
 +int au_sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+		       unsigned int flags)
++		       unsigned int flags, struct au_pin *pin)
 +{
 +	int err, wkq_err;
 +	struct dentry *parent;
 +	parent = dget_parent(dentry);
 +	h_dir = au_h_iptr(parent->d_inode, bdst);
 +	if (!au_test_h_perm_sio(h_dir, MAY_EXEC | MAY_WRITE)
-+	    && !au_cpup_sio_test(dentry->d_sb, dentry->d_inode->i_mode))
-+		err = au_cpup_simple(dentry, bdst, len, flags);
++	    && !au_cpup_sio_test(pin, dentry->d_inode->i_mode))
++		err = au_cpup_simple(dentry, bdst, len, flags, pin);
 +	else {
 +		struct au_cpup_simple_args args = {
 +			.errp		= &err,
 +			.dentry		= dentry,
 +			.bdst		= bdst,
 +			.len		= len,
-+			.flags		= flags
++			.flags		= flags,
++			.pin		= pin
 +		};
 +		wkq_err = au_wkq_wait(au_call_cpup_simple, &args);
 +		if (unlikely(wkq_err))
 +	return err;
 +}
 +
++/* generalized cpup_simple() with h_open_pre/post() calls */
++int au_sio_cpup_simple_h_open(struct dentry *dentry, aufs_bindex_t bdst,
++			      loff_t len, unsigned int flags,
++			      struct au_pin *pin, aufs_bindex_t bsrc)
++{
++	int err;
++	struct file *h_file;
++
++	h_file = au_h_open_pre(dentry, bsrc);
++	if (IS_ERR(h_file))
++		err = PTR_ERR(h_file);
++	else {
++		err = au_sio_cpup_simple(dentry, bdst, len, flags, pin);
++		au_h_open_post(dentry, bsrc, h_file);
++	}
++
++	return err;
++}
++
 +/* ---------------------------------------------------------------------- */
 +
 +/*
 + */
 +static int au_do_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst,
 +			 struct dentry *wh_dentry, struct file *file,
-+			 loff_t len)
++			 loff_t len, struct au_pin *pin)
 +{
 +	int err;
-+	aufs_bindex_t bstart;
++	struct au_cpup_basic basic = {
++		.dentry	= dentry,
++		.bdst	= bdst,
++		.bsrc	= -1,
++		.len	= len
++	};
 +	struct au_dinfo *dinfo;
 +	struct dentry *h_d_dst, *h_d_start;
 +	struct au_hdentry *hdp;
 +	dinfo = au_di(dentry);
 +	AuRwMustWriteLock(&dinfo->di_rwsem);
 +
-+	bstart = dinfo->di_bstart;
++	basic.bsrc = dinfo->di_bstart;
 +	hdp = dinfo->di_hdentry;
 +	h_d_dst = hdp[0 + bdst].hd_dentry;
 +	dinfo->di_bstart = bdst;
 +	hdp[0 + bdst].hd_dentry = wh_dentry;
++	h_d_start = NULL;
 +	if (file) {
-+		h_d_start = hdp[0 + bstart].hd_dentry;
-+		hdp[0 + bstart].hd_dentry = au_hf_top(file)->f_dentry;
++		h_d_start = hdp[0 + basic.bsrc].hd_dentry;
++		hdp[0 + basic.bsrc].hd_dentry = au_hf_top(file)->f_dentry;
 +	}
-+	err = au_cpup_single(dentry, bdst, bstart, len, !AuCpup_DTIME,
-+			     /*h_parent*/NULL);
++	err = au_cpup_single(&basic, !AuCpup_DTIME, /*h_parent*/NULL, pin);
 +	if (file) {
 +		if (!err)
 +			err = au_reopen_nondir(file);
-+		hdp[0 + bstart].hd_dentry = h_d_start;
++		hdp[0 + basic.bsrc].hd_dentry = h_d_start;
 +	}
 +	hdp[0 + bdst].hd_dentry = h_d_dst;
-+	dinfo->di_bstart = bstart;
++	dinfo->di_bstart = basic.bsrc;
 +
 +	return err;
 +}
 +
 +static int au_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
-+		      struct file *file)
++		      struct file *file, struct au_pin *pin)
 +{
 +	int err;
 +	struct au_dtime dt;
 +		goto out;
 +
 +	h_path.dentry = h_parent;
-+	h_path.mnt = br->br_mnt;
++	h_path.mnt = au_br_mnt(br);
 +	au_dtime_store(&dt, parent, &h_path);
-+	err = au_do_cpup_wh(dentry, bdst, wh_dentry, file, len);
++	err = au_do_cpup_wh(dentry, bdst, wh_dentry, file, len, pin);
 +	if (unlikely(err))
 +		goto out_wh;
 +