[packages/kernel/LINUX_4_4] - up to 4.4.258; rediff all patches that didn't apply with --fuzz=0
arekm
arekm at pld-linux.org
Wed Feb 24 17:46:16 CET 2021
commit c2806d43fb36f7c3c1c033adfbb0a53d6d06d38b
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Wed Feb 24 17:45:45 2021 +0100
- up to 4.4.258; rediff all patches that didn't apply with --fuzz=0
kernel-atm-vbr.patch | 36 +-
kernel-atmdd.patch | 42 +-
kernel-aufs4+vserver.patch | 16 +-
kernel-aufs4.patch | 16456 ++++++++++++++++++------------------
kernel-esfq.patch | 38 +-
kernel-imq.patch | 225 +-
kernel-layer7.patch | 3595 ++++----
kernel-libata-ahci-pm.patch | 682 +-
kernel-owner-xid.patch | 18 +-
kernel-pom-ng-IPV4OPTSSTRIP.patch | 29 +-
kernel-rndis_host-wm5.patch | 13 +-
kernel-small_fixes.patch | 54 +-
kernel-virtio-gl-accel.patch | 55 +-
kernel-vserver-2.3.patch | 8960 ++++++++++----------
kernel-zph.patch | 45 +-
kernel.spec | 4 +-
16 files changed, 14970 insertions(+), 15298 deletions(-)
---
diff --git a/kernel.spec b/kernel.spec
index 4eed94a2..2a09908d 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -72,7 +72,7 @@
%define rel 1
%define basever 4.4
-%define postver .257
+%define postver .258
# define this to '-%{basever}' for longterm branch
%define versuffix -%{basever}
@@ -124,7 +124,7 @@ Source0: http://www.kernel.org/pub/linux/kernel/v4.x/linux-%{basever}.tar.xz
# Source0-md5: 9a78fa2eb6c68ca5a40ed5af08142599
%if "%{postver}" != ".0"
Patch0: http://www.kernel.org/pub/linux/kernel/v4.x/patch-%{version}.xz
-# Patch0-md5: edc8fddea5c158ee5ca994a2e1fe549c
+# Patch0-md5: b990ccbec6ede740ea9b4d4a75a52a2b
%endif
Source1: kernel.sysconfig
diff --git a/kernel-atm-vbr.patch b/kernel-atm-vbr.patch
index 28dc14b8..ceb8536b 100644
--- a/kernel-atm-vbr.patch
+++ b/kernel-atm-vbr.patch
@@ -1,11 +1,7 @@
-Index: linux/include/linux/atm.h
-===================================================================
-RCS file: /afs/cmf/project/cvsroot/linux/include/linux/atm.h,v
-retrieving revision 1.2
-diff -u -r1.2 atm.h
---- linux/include/uapi/linux/atm.h 12 Feb 2003 20:56:33 -0000 1.2
-+++ linux/include/uapi/linux/atm.h 9 Apr 2003 12:08:38 -0000
-@@ -72,7 +72,7 @@
+diff -urNp -x '*.orig' linux-4.4/include/uapi/linux/atm.h linux-4.4/include/uapi/linux/atm.h
+--- linux-4.4/include/uapi/linux/atm.h 2016-01-11 00:01:32.000000000 +0100
++++ linux-4.4/include/uapi/linux/atm.h 2021-02-24 16:54:31.052582170 +0100
+@@ -70,7 +70,7 @@
/* connection identifier range; socket must be
bound or connected */
#define SO_ATMQOS __SO_ENCODE(SOL_ATM,2,struct atm_qos)
@@ -14,7 +10,7 @@ diff -u -r1.2 atm.h
#define SO_ATMSAP __SO_ENCODE(SOL_ATM,3,struct atm_sap)
/* Service Access Point */
#define SO_ATMPVC __SO_ENCODE(SOL_ATM,4,struct sockaddr_atmpvc)
-@@ -127,9 +127,11 @@
+@@ -126,9 +126,11 @@
#define ATM_NONE 0 /* no traffic */
#define ATM_UBR 1
#define ATM_CBR 2
@@ -27,7 +23,7 @@ diff -u -r1.2 atm.h
#define ATM_MAX_PCR -1 /* maximum available PCR */
-@@ -140,6 +142,11 @@
+@@ -139,6 +141,11 @@ struct atm_trafprm {
int min_pcr; /* minimum PCR in cells per second */
int max_cdv; /* maximum CDV in microseconds */
int max_sdu; /* maximum SDU in bytes */
@@ -39,8 +35,8 @@ diff -u -r1.2 atm.h
/* extra params for ABR */
unsigned int icr; /* Initial Cell Rate (24-bit) */
unsigned int tbe; /* Transient Buffer Exposure (24-bit) */
-@@ -243,4 +251,37 @@
- };
+@@ -238,4 +245,37 @@ struct atmif_sioc {
+
typedef unsigned short atm_backend_t;
+struct atm_trafprm_compat {
@@ -77,14 +73,10 @@ diff -u -r1.2 atm.h
+#define SO_ATMQOS_COMPAT __SO_ENCODE(SOL_ATM,2,struct atm_qos_compat)
+ /* Quality of Service setting (no vbr support) */
#endif /* _UAPI_LINUX_ATM_H */
-Index: linux/net/atm/common.c
-===================================================================
-RCS file: /afs/cmf/project/cvsroot/linux/net/atm/common.c,v
-retrieving revision 1.13
-diff -u -r1.13 common.c
---- linux/net/atm/common.c 17 Mar 2003 16:13:12 -0000 1.13
-+++ linux/net/atm/common.c 9 Apr 2003 12:10:28 -0000
-@@ -1085,6 +1085,43 @@
+diff -urNp -x '*.orig' linux-4.4/net/atm/common.c linux-4.4/net/atm/common.c
+--- linux-4.4/net/atm/common.c 2016-01-11 00:01:32.000000000 +0100
++++ linux-4.4/net/atm/common.c 2021-02-24 16:54:31.052582170 +0100
+@@ -752,6 +752,43 @@ int vcc_setsockopt(struct socket *sock,
vcc = ATM_SD(sock);
switch (optname) {
@@ -128,7 +120,7 @@ diff -u -r1.13 common.c
case SO_ATMQOS:
{
struct atm_qos qos;
-@@ -1132,6 +1169,31 @@
+@@ -800,6 +837,31 @@ int vcc_getsockopt(struct socket *sock,
vcc = ATM_SD(sock);
switch (optname) {
@@ -158,5 +150,5 @@ diff -u -r1.13 common.c
+ -EFAULT : 0;
+ }
case SO_ATMQOS:
- if (!test_bit(ATM_VF_HASQOS,&vcc->flags))
+ if (!test_bit(ATM_VF_HASQOS, &vcc->flags))
return -EINVAL;
diff --git a/kernel-atmdd.patch b/kernel-atmdd.patch
index a380fce1..6810f8d7 100644
--- a/kernel-atmdd.patch
+++ b/kernel-atmdd.patch
@@ -1,22 +1,10 @@
-diff -urN linux-2.4.25/drivers/atm/Makefile linux-2.4.25-atmdd/drivers/atm/Makefile
---- linux-2.4.25/drivers/atm/Makefile 2004-02-23 15:18:29.000000000 +0100
-+++ linux-2.4.25-atmdd/drivers/atm/Makefile 2004-02-29 22:51:26.000000000 +0100
-@@ -31,6 +31,7 @@
- endif
-
- obj-$(CONFIG_ATM_DUMMY) += adummy.o
-+obj-$(CONFIG_ATM_DD) += atmdd.o
- obj-$(CONFIG_ATM_TCP) += atmtcp.o
- obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o
- obj-$(CONFIG_ATM_LANAI) += lanai.o
-diff -urN linux-2.4.25/drivers/atm/Kconfig linux-2.4.25-atmdd/drivers/atm/Kconfig
---- linux-2.4.25/drivers/atm/Kcnfig 2003-08-25 13:44:41.000000000 +0200
-+++ linux-2.4.25-atmdd/drivers/atm/Kconfig 2004-02-29 22:52:59.000000000 +0100
-@@ -4,6 +4,14 @@
- default y
+diff -urNp -x '*.orig' linux-4.4/drivers/atm/Kconfig linux-4.4/drivers/atm/Kconfig
+--- linux-4.4/drivers/atm/Kconfig 2021-02-24 16:54:46.609738341 +0100
++++ linux-4.4/drivers/atm/Kconfig 2021-02-24 16:54:59.230135495 +0100
+@@ -14,6 +14,14 @@ menuconfig ATM_DRIVERS
if ATM_DRIVERS && NETDEVICES && ATM
-+
+
+config ATM_DD
+ tristate "ATM loopback"
+ depends on INET && ATM
@@ -24,12 +12,24 @@ diff -urN linux-2.4.25/drivers/atm/Kconfig linux-2.4.25-atmdd/drivers/atm/Kconfi
+ This is an example atm driver. It does not require any actual ATM
+ hardware. It supports AAL5 and AAL0. Frames are merely looped back
+ to the sender on the same VC they were sent.
-
++
config ATM_DUMMY
tristate "Dummy ATM driver"
-diff -urN linux-2.4.25/drivers/atm/atmdd.c linux-2.4.25-atmdd/drivers/atm/atmdd.c
---- linux-2.4.25/drivers/atm/atmdd.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.4.25-atmdd/drivers/atm/atmdd.c 2004-02-29 22:58:11.000000000 +0100
+ help
+diff -urNp -x '*.orig' linux-4.4/drivers/atm/Makefile linux-4.4/drivers/atm/Makefile
+--- linux-4.4/drivers/atm/Makefile 2016-01-11 00:01:32.000000000 +0100
++++ linux-4.4/drivers/atm/Makefile 2021-02-24 16:54:59.226802057 +0100
+@@ -25,6 +25,7 @@ ifeq ($(CONFIG_ATM_IDT77252_USE_SUNI),y)
+ endif
+
+ obj-$(CONFIG_ATM_DUMMY) += adummy.o
++obj-$(CONFIG_ATM_DD) += atmdd.o
+ obj-$(CONFIG_ATM_TCP) += atmtcp.o
+ obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o
+ obj-$(CONFIG_ATM_LANAI) += lanai.o
+diff -urNp -x '*.orig' linux-4.4/drivers/atm/atmdd.c linux-4.4/drivers/atm/atmdd.c
+--- linux-4.4/drivers/atm/atmdd.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/drivers/atm/atmdd.c 2021-02-24 16:54:59.230135495 +0100
@@ -0,0 +1,921 @@
+/*
+#######################################################################
diff --git a/kernel-aufs4+vserver.patch b/kernel-aufs4+vserver.patch
index 4aa67b00..b0c6db58 100644
--- a/kernel-aufs4+vserver.patch
+++ b/kernel-aufs4+vserver.patch
@@ -1,7 +1,8 @@
---- linux.aufs/fs/aufs/cpup.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/cpup.c 2013-08-23 23:59:39.631583456 +0200
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/cpup.c linux-4.4/fs/aufs/cpup.c
+--- linux-4.4/fs/aufs/cpup.c 2021-02-24 17:34:51.474972460 +0100
++++ linux-4.4/fs/aufs/cpup.c 2021-02-24 17:35:02.431992330 +0100
@@ -24,9 +24,9 @@
- #include <linux/mm.h>
+ #include <linux/task_work.h>
#include "aufs.h"
-void au_cpup_attr_flags(struct inode *dst, unsigned int iflags)
@@ -12,7 +13,7 @@
| S_NOATIME | S_NOCMTIME | S_AUTOMOUNT;
BUILD_BUG_ON(sizeof(iflags) != sizeof(dst->i_flags));
-@@ -155,7 +155,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+@@ -159,7 +159,7 @@ void au_dtime_revert(struct au_dtime *dt
struct au_cpup_reg_attr {
int valid;
struct kstat st;
@@ -21,9 +22,10 @@
};
static noinline_for_stack
---- linux.aufs/fs/aufs/cpup.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/cpup.h 2013-08-23 23:59:39.634916914 +0200
-@@ -31,7 +31,7 @@ diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/cpup.h linux-4.4/fs/aufs/cpup.h
+--- linux-4.4/fs/aufs/cpup.h 2021-02-24 17:34:51.474972460 +0100
++++ linux-4.4/fs/aufs/cpup.h 2021-02-24 17:35:02.431992330 +0100
+@@ -30,7 +30,7 @@ struct inode;
struct file;
struct au_pin;
diff --git a/kernel-aufs4.patch b/kernel-aufs4.patch
index 31d98cda..66ac583d 100644
--- a/kernel-aufs4.patch
+++ b/kernel-aufs4.patch
@@ -1,965 +1,6 @@
-aufs4.4 kbuild patch
-
-diff --git a/fs/Kconfig b/fs/Kconfig
-index 6ce72d8..4aa31ea 100644
---- a/fs/Kconfig
-+++ b/fs/Kconfig
-@@ -221,6 +221,7 @@ source "fs/pstore/Kconfig"
- source "fs/sysv/Kconfig"
- source "fs/ufs/Kconfig"
- source "fs/exofs/Kconfig"
-+source "fs/aufs/Kconfig"
-
- endif # MISC_FILESYSTEMS
-
-diff --git a/fs/Makefile b/fs/Makefile
-index 79f5225..a7c7f16 100644
---- a/fs/Makefile
-+++ b/fs/Makefile
-@@ -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 c2e5d6c..d736c11 100644
---- a/include/uapi/linux/Kbuild
-+++ b/include/uapi/linux/Kbuild
-@@ -59,6 +59,7 @@ header-y += atmsvc.h
- header-y += atm_tcp.h
- header-y += atm_zatm.h
- header-y += audit.h
-+header-y += aufs_type.h
- header-y += auto_fs4.h
- header-y += auto_fs.h
- header-y += auxvec.h
-aufs4.4 base patch
-
-diff --git a/MAINTAINERS b/MAINTAINERS
-index 233f834..c250892 100644
---- a/MAINTAINERS
-+++ b/MAINTAINERS
-@@ -2029,6 +2029,19 @@ F: include/linux/audit.h
- F: include/uapi/linux/audit.h
- F: kernel/audit*
-
-+AUFS (advanced multi layered unification filesystem) FILESYSTEM
-+M: "J. R. Okajima" <hooanon05g at gmail.com>
-+L: linux-unionfs at vger.kernel.org
-+L: aufs-users at lists.sourceforge.net (members only)
-+W: http://aufs.sourceforge.net
-+T: git://github.com/sfjro/aufs4-linux.git
-+S: Supported
-+F: Documentation/filesystems/aufs/
-+F: Documentation/ABI/testing/debugfs-aufs
-+F: Documentation/ABI/testing/sysfs-aufs
-+F: fs/aufs/
-+F: include/uapi/linux/aufs_type.h
-+
- AUXILIARY DISPLAY DRIVERS
- M: Miguel Ojeda Sandonis <miguel.ojeda.sandonis at gmail.com>
- W: http://miguelojeda.es/auxdisplay.htm
-diff --git a/drivers/block/loop.c b/drivers/block/loop.c
-index 423f4ca..abfdd2b 100644
---- a/drivers/block/loop.c
-+++ b/drivers/block/loop.c
-@@ -706,6 +706,24 @@ static inline int is_loop_device(struct file *file)
- return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
- }
-
-+/*
-+ * for AUFS
-+ * no get/put for file.
-+ */
-+struct file *loop_backing_file(struct super_block *sb)
-+{
-+ struct file *ret;
-+ struct loop_device *l;
-+
-+ ret = NULL;
-+ if (MAJOR(sb->s_dev) == LOOP_MAJOR) {
-+ l = sb->s_bdev->bd_disk->private_data;
-+ ret = l->lo_backing_file;
-+ }
-+ return ret;
-+}
-+EXPORT_SYMBOL(loop_backing_file);
-+
- /* loop sysfs attributes */
-
- static ssize_t loop_attr_show(struct device *dev, char *page,
-diff --git a/fs/dcache.c b/fs/dcache.c
-index 5c33aeb..8aa7f26 100644
---- a/fs/dcache.c
-+++ b/fs/dcache.c
-@@ -1167,7 +1167,7 @@ enum d_walk_ret {
- *
- * The @enter() and @finish() callbacks are called with d_lock held.
- */
--static void d_walk(struct dentry *parent, void *data,
-+void d_walk(struct dentry *parent, void *data,
- enum d_walk_ret (*enter)(void *, struct dentry *),
- void (*finish)(void *))
- {
-diff --git a/fs/read_write.c b/fs/read_write.c
-index 819ef3f..fd0414e 100644
---- a/fs/read_write.c
-+++ b/fs/read_write.c
-@@ -494,6 +494,28 @@ ssize_t __vfs_write(struct file *file, const char __user *p, size_t count,
- }
- EXPORT_SYMBOL(__vfs_write);
-
-+vfs_readf_t vfs_readf(struct file *file)
-+{
-+ const struct file_operations *fop = file->f_op;
-+
-+ if (fop->read)
-+ return fop->read;
-+ if (fop->read_iter)
-+ return new_sync_read;
-+ return ERR_PTR(-ENOSYS);
-+}
-+
-+vfs_writef_t vfs_writef(struct file *file)
-+{
-+ const struct file_operations *fop = file->f_op;
-+
-+ if (fop->write)
-+ return fop->write;
-+ if (fop->write_iter)
-+ return new_sync_write;
-+ return ERR_PTR(-ENOSYS);
-+}
-+
- ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos)
- {
- mm_segment_t old_fs;
-diff --git a/fs/splice.c b/fs/splice.c
-index 4cf700d..30a091d 100644
---- a/fs/splice.c
-+++ b/fs/splice.c
-@@ -1110,8 +1110,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
- /*
- * Attempt to initiate a splice from pipe to file.
- */
--static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-- loff_t *ppos, size_t len, unsigned int flags)
-+long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-+ loff_t *ppos, size_t len, unsigned int flags)
- {
- ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
- loff_t *, size_t, unsigned int);
-@@ -1127,9 +1127,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.
- */
--static long do_splice_to(struct file *in, loff_t *ppos,
-- struct pipe_inode_info *pipe, size_t len,
-- unsigned int flags)
-+long do_splice_to(struct file *in, loff_t *ppos,
-+ struct pipe_inode_info *pipe, size_t len,
-+ unsigned int flags)
- {
- ssize_t (*splice_read)(struct file *, loff_t *,
- struct pipe_inode_info *, size_t, unsigned int);
-diff --git a/include/linux/file.h b/include/linux/file.h
-index f87d308..9a290b3 100644
---- a/include/linux/file.h
-+++ b/include/linux/file.h
-@@ -19,6 +19,7 @@ struct dentry;
- struct path;
- extern struct file *alloc_file(struct path *, fmode_t mode,
- const struct file_operations *fop);
-+extern struct file *get_empty_filp(void);
-
- static inline void fput_light(struct file *file, int fput_needed)
- {
-diff --git a/include/linux/fs.h b/include/linux/fs.h
-index 3aa5142..8d48506 100644
---- a/include/linux/fs.h
-+++ b/include/linux/fs.h
-@@ -1672,6 +1672,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
- struct iovec *fast_pointer,
- struct iovec **ret_pointer);
-
-+typedef ssize_t (*vfs_readf_t)(struct file *, char __user *, size_t, loff_t *);
-+typedef ssize_t (*vfs_writef_t)(struct file *, const char __user *, size_t,
-+ loff_t *);
-+vfs_readf_t vfs_readf(struct file *file);
-+vfs_writef_t vfs_writef(struct file *file);
-+
- 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 *);
-diff --git a/include/linux/splice.h b/include/linux/splice.h
-index da2751d..2e0fca6 100644
---- a/include/linux/splice.h
-+++ b/include/linux/splice.h
-@@ -83,4 +83,10 @@ extern void splice_shrink_spd(struct splice_pipe_desc *);
- extern void spd_release_page(struct splice_pipe_desc *, unsigned int);
-
- extern const struct pipe_buf_operations page_cache_pipe_buf_ops;
-+
-+extern long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-+ loff_t *ppos, size_t len, unsigned int flags);
-+extern long do_splice_to(struct file *in, loff_t *ppos,
-+ struct pipe_inode_info *pipe, size_t len,
-+ unsigned int flags);
- #endif
-aufs4.4 mmap patch
-
-diff --git a/fs/proc/base.c b/fs/proc/base.c
-index 4bd5d31..aa41f2a 100644
---- a/fs/proc/base.c
-+++ b/fs/proc/base.c
-@@ -1921,7 +1921,7 @@ static int proc_map_files_get_link(struct dentry *dentry, struct path *path)
- down_read(&mm->mmap_sem);
- vma = find_exact_vma(mm, vm_start, vm_end);
- if (vma && vma->vm_file) {
-- *path = vma->vm_file->f_path;
-+ *path = vma_pr_or_file(vma)->f_path;
- path_get(path);
- rc = 0;
- }
-diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
-index f8595e8..cb8eda0 100644
---- a/fs/proc/nommu.c
-+++ b/fs/proc/nommu.c
-@@ -45,7 +45,10 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
- file = region->vm_file;
-
- if (file) {
-- struct inode *inode = file_inode(region->vm_file);
-+ struct inode *inode;
-+
-+ file = vmr_pr_or_file(region);
-+ inode = file_inode(file);
- dev = inode->i_sb->s_dev;
- ino = inode->i_ino;
- }
-diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
-index 187b3b5..e03793e 100644
---- a/fs/proc/task_mmu.c
-+++ b/fs/proc/task_mmu.c
-@@ -281,7 +281,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
- const char *name = NULL;
-
- if (file) {
-- struct inode *inode = file_inode(vma->vm_file);
-+ struct inode *inode;
-+
-+ file = vma_pr_or_file(vma);
-+ inode = file_inode(file);
- dev = inode->i_sb->s_dev;
- ino = inode->i_ino;
- pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
-@@ -1505,7 +1508,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
- struct proc_maps_private *proc_priv = &numa_priv->proc_maps;
- struct vm_area_struct *vma = v;
- struct numa_maps *md = &numa_priv->md;
-- struct file *file = vma->vm_file;
-+ struct file *file = vma_pr_or_file(vma);
- struct mm_struct *mm = vma->vm_mm;
- struct mm_walk walk = {
- .hugetlb_entry = gather_hugetlb_stats,
-diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
-index e0d64c9..7aa92db 100644
---- a/fs/proc/task_nommu.c
-+++ b/fs/proc/task_nommu.c
-@@ -160,7 +160,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
- file = vma->vm_file;
-
- if (file) {
-- struct inode *inode = file_inode(vma->vm_file);
-+ struct inode *inode;
-+
-+ file = vma_pr_or_file(vma);
-+ inode = file_inode(file);
- dev = inode->i_sb->s_dev;
- ino = inode->i_ino;
- pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
-diff --git a/include/linux/mm.h b/include/linux/mm.h
-index 00bad77..cc616b0 100644
---- a/include/linux/mm.h
-+++ b/include/linux/mm.h
-@@ -1183,6 +1183,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);
-+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__)
-+
-+#ifndef CONFIG_MMU
-+extern struct file *vmr_do_pr_or_file(struct vm_region *, const char[], int);
-+extern void vmr_do_fput(struct vm_region *, const char[], int);
-+
-+#define vmr_pr_or_file(region) vmr_do_pr_or_file(region, __func__, \
-+ __LINE__)
-+#define vmr_fput(region) vmr_do_fput(region, __func__, __LINE__)
-+#endif /* !CONFIG_MMU */
-+
- extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
- extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
- void *buf, int len, int write);
-diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
-index f8d1492..c3a3760 100644
---- a/include/linux/mm_types.h
-+++ b/include/linux/mm_types.h
-@@ -272,6 +272,7 @@ struct vm_region {
- unsigned long vm_top; /* region allocated to here */
- unsigned long vm_pgoff; /* the offset in vm_file corresponding to vm_start */
- struct file *vm_file; /* the backing file or NULL */
-+ struct file *vm_prfile; /* the virtual backing file or NULL */
-
- int vm_usage; /* region usage count (access under nommu_region_sem) */
- bool vm_icache_flushed : 1; /* true if the icache has been flushed for
-@@ -346,6 +347,7 @@ struct vm_area_struct {
- unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE
- units, *not* PAGE_CACHE_SIZE */
- struct file * vm_file; /* File we map to (can be NULL). */
-+ struct file *vm_prfile; /* shadow of vm_file */
- void * vm_private_data; /* was vm_pte (shared mem) */
-
- #ifndef CONFIG_MMU
-diff --git a/kernel/fork.c b/kernel/fork.c
-index 1155eac..c001ea4 100644
---- a/kernel/fork.c
-+++ b/kernel/fork.c
-@@ -465,7 +465,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
- struct inode *inode = file_inode(file);
- struct address_space *mapping = file->f_mapping;
-
-- get_file(file);
-+ vma_get_file(tmp);
- if (tmp->vm_flags & VM_DENYWRITE)
- atomic_dec(&inode->i_writecount);
- i_mmap_lock_write(mapping);
-diff --git a/mm/Makefile b/mm/Makefile
-index 2ed4319..e3a53f5 100644
---- a/mm/Makefile
-+++ b/mm/Makefile
-@@ -21,7 +21,7 @@ obj-y := filemap.o mempool.o oom_kill.o \
- mm_init.o mmu_context.o percpu.o slab_common.o \
- compaction.o vmacache.o \
- interval_tree.o list_lru.o workingset.o \
-- debug.o $(mmu-y)
-+ prfile.o debug.o $(mmu-y)
-
- obj-y += init-mm.o
-
-diff --git a/mm/filemap.c b/mm/filemap.c
-index 1bb0076..8eaece8 100644
---- a/mm/filemap.c
-+++ b/mm/filemap.c
-@@ -2128,7 +2128,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);
-- file_update_time(vma->vm_file);
-+ vma_file_update_time(vma);
- lock_page(page);
- if (page->mapping != inode->i_mapping) {
- unlock_page(page);
-diff --git a/mm/memory.c b/mm/memory.c
-index c387430..d434404 100644
---- a/mm/memory.c
-+++ b/mm/memory.c
-@@ -2035,7 +2035,7 @@ static inline int wp_page_reuse(struct mm_struct *mm,
- }
-
- if (!page_mkwrite)
-- file_update_time(vma->vm_file);
-+ vma_file_update_time(vma);
- }
-
- return VM_FAULT_WRITE;
-diff --git a/mm/mmap.c b/mm/mmap.c
-index 2ce04a6..f555c0a 100644
---- a/mm/mmap.c
-+++ b/mm/mmap.c
-@@ -275,7 +275,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)
-- fput(vma->vm_file);
-+ vma_fput(vma);
- mpol_put(vma_policy(vma));
- kmem_cache_free(vm_area_cachep, vma);
- return next;
-@@ -887,7 +887,7 @@ again: remove_next = 1 + (end > next->vm_end);
- if (remove_next) {
- if (file) {
- uprobe_munmap(next, next->vm_start, next->vm_end);
-- fput(file);
-+ vma_fput(vma);
- }
- if (next->anon_vma)
- anon_vma_merge(vma, next);
-@@ -1681,8 +1681,8 @@ out:
- return addr;
-
- unmap_and_free_vma:
-+ vma_fput(vma);
- vma->vm_file = NULL;
-- fput(file);
-
- /* Undo any partial mapping done by a device driver. */
- unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
-@@ -2488,7 +2488,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
- goto out_free_mpol;
-
- if (new->vm_file)
-- get_file(new->vm_file);
-+ vma_get_file(new);
-
- if (new->vm_ops && new->vm_ops->open)
- new->vm_ops->open(new);
-@@ -2507,7 +2507,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)
-- fput(new->vm_file);
-+ vma_fput(new);
- unlink_anon_vmas(new);
- out_free_mpol:
- mpol_put(vma_policy(new));
-@@ -2649,7 +2649,6 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
- struct vm_area_struct *vma;
- unsigned long populate = 0;
- unsigned long ret = -EINVAL;
-- struct file *file;
-
- pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. "
- "See Documentation/vm/remap_file_pages.txt.\n",
-@@ -2693,10 +2692,10 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
- munlock_vma_pages_range(vma, start, start + size);
- }
-
-- file = get_file(vma->vm_file);
-+ vma_get_file(vma);
- ret = do_mmap_pgoff(vma->vm_file, start, size,
- prot, flags, pgoff, &populate);
-- fput(file);
-+ vma_fput(vma);
- out:
- up_write(&mm->mmap_sem);
- if (populate)
-@@ -2966,7 +2965,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)
-- get_file(new_vma->vm_file);
-+ vma_get_file(new_vma);
- if (new_vma->vm_ops && new_vma->vm_ops->open)
- new_vma->vm_ops->open(new_vma);
- vma_link(mm, new_vma, prev, rb_link, rb_parent);
-diff --git a/mm/nommu.c b/mm/nommu.c
-index 92be862..29179f7 100644
---- a/mm/nommu.c
-+++ b/mm/nommu.c
-@@ -671,7 +671,7 @@ static void __put_nommu_region(struct vm_region *region)
- up_write(&nommu_region_sem);
-
- if (region->vm_file)
-- fput(region->vm_file);
-+ vmr_fput(region);
-
- /* IO memory and memory shared directly out of the pagecache
- * from ramfs/tmpfs mustn't be released here */
-@@ -829,7 +829,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)
-- fput(vma->vm_file);
-+ vma_fput(vma);
- put_nommu_region(vma->vm_region);
- kmem_cache_free(vm_area_cachep, vma);
- }
-@@ -1355,7 +1355,7 @@ unsigned long do_mmap(struct file *file,
- goto error_just_free;
- }
- }
-- fput(region->vm_file);
-+ vmr_fput(region);
- kmem_cache_free(vm_region_jar, region);
- region = pregion;
- result = start;
-@@ -1430,10 +1430,10 @@ error_just_free:
- up_write(&nommu_region_sem);
- error:
- if (region->vm_file)
-- fput(region->vm_file);
-+ vmr_fput(region);
- kmem_cache_free(vm_region_jar, region);
- if (vma->vm_file)
-- fput(vma->vm_file);
-+ vma_fput(vma);
- kmem_cache_free(vm_area_cachep, vma);
- return ret;
-
-diff --git a/mm/prfile.c b/mm/prfile.c
-new file mode 100644
-index 0000000..b323b8a
---- /dev/null
-+++ b/mm/prfile.c
-@@ -0,0 +1,86 @@
-+/*
-+ * Mainly for aufs which mmap(2) diffrent file and wants to print different path
-+ * in /proc/PID/maps.
-+ * Call these functions via macros defined in linux/mm.h.
-+ *
-+ * See Documentation/filesystems/aufs/design/06mmap.txt
-+ *
-+ * Copyright (c) 2014 Junjro R. Okajima
-+ * Copyright (c) 2014 Ian Campbell
-+ */
-+
-+#include <linux/mm.h>
-+#include <linux/file.h>
-+#include <linux/fs.h>
-+
-+/* #define PRFILE_TRACE */
-+static inline void prfile_trace(struct file *f, struct file *pr,
-+ const char func[], int line, const char func2[])
-+{
-+#ifdef PRFILE_TRACE
-+ if (pr)
-+ pr_info("%s:%d: %s, %s\n", func, line, func2,
-+ f ? (char *)f->f_path.dentry->d_name.name : "(null)");
-+#endif
-+}
-+
-+void vma_do_file_update_time(struct vm_area_struct *vma, const char func[],
-+ int line)
-+{
-+ struct file *f = vma->vm_file, *pr = vma->vm_prfile;
-+
-+ prfile_trace(f, pr, func, line, __func__);
-+ file_update_time(f);
-+ if (f && pr)
-+ file_update_time(pr);
-+}
-+
-+struct file *vma_do_pr_or_file(struct vm_area_struct *vma, const char func[],
-+ int line)
-+{
-+ struct file *f = vma->vm_file, *pr = vma->vm_prfile;
-+
-+ prfile_trace(f, pr, func, line, __func__);
-+ return (f && pr) ? pr : f;
-+}
-+
-+void vma_do_get_file(struct vm_area_struct *vma, const char func[], int line)
-+{
-+ struct file *f = vma->vm_file, *pr = vma->vm_prfile;
-+
-+ prfile_trace(f, pr, func, line, __func__);
-+ get_file(f);
-+ if (f && pr)
-+ get_file(pr);
-+}
-+
-+void vma_do_fput(struct vm_area_struct *vma, const char func[], int line)
-+{
-+ struct file *f = vma->vm_file, *pr = vma->vm_prfile;
-+
-+ prfile_trace(f, pr, func, line, __func__);
-+ fput(f);
-+ if (f && pr)
-+ fput(pr);
-+}
-+
-+#ifndef CONFIG_MMU
-+struct file *vmr_do_pr_or_file(struct vm_region *region, const char func[],
-+ int line)
-+{
-+ struct file *f = region->vm_file, *pr = region->vm_prfile;
-+
-+ prfile_trace(f, pr, func, line, __func__);
-+ return (f && pr) ? pr : f;
-+}
-+
-+void vmr_do_fput(struct vm_region *region, const char func[], int line)
-+{
-+ struct file *f = region->vm_file, *pr = region->vm_prfile;
-+
-+ prfile_trace(f, pr, func, line, __func__);
-+ fput(f);
-+ if (f && pr)
-+ fput(pr);
-+}
-+#endif /* !CONFIG_MMU */
-aufs4.4 standalone patch
-
-diff --git a/fs/dcache.c b/fs/dcache.c
-index 8aa7f26..f997345 100644
---- a/fs/dcache.c
-+++ b/fs/dcache.c
-@@ -1272,6 +1272,7 @@ rename_retry:
- seq = 1;
- goto again;
- }
-+EXPORT_SYMBOL(d_walk);
-
- /*
- * Search for at least 1 mount point in the dentry's subdirs.
-diff --git a/fs/exec.c b/fs/exec.c
-index b06623a..b9206c5 100644
---- a/fs/exec.c
-+++ b/fs/exec.c
-@@ -103,6 +103,7 @@ bool path_noexec(const struct path *path)
- return (path->mnt->mnt_flags & MNT_NOEXEC) ||
- (path->mnt->mnt_sb->s_iflags & SB_I_NOEXEC);
- }
-+EXPORT_SYMBOL(path_noexec);
-
- #ifdef CONFIG_USELIB
- /*
-diff --git a/fs/file_table.c b/fs/file_table.c
-index ad17e05..38e046a 100644
---- a/fs/file_table.c
-+++ b/fs/file_table.c
-@@ -147,6 +147,7 @@ over:
- }
- return ERR_PTR(-ENFILE);
- }
-+EXPORT_SYMBOL(get_empty_filp);
-
- /**
- * alloc_file - allocate and initialize a 'struct file'
-@@ -258,6 +259,7 @@ void flush_delayed_fput(void)
- {
- delayed_fput(NULL);
- }
-+EXPORT_SYMBOL(flush_delayed_fput);
-
- static DECLARE_DELAYED_WORK(delayed_fput_work, delayed_fput);
-
-@@ -300,6 +302,7 @@ void __fput_sync(struct file *file)
- }
-
- EXPORT_SYMBOL(fput);
-+EXPORT_SYMBOL(__fput_sync);
-
- void put_filp(struct file *file)
- {
-@@ -308,6 +311,7 @@ void put_filp(struct file *file)
- file_free(file);
- }
- }
-+EXPORT_SYMBOL(put_filp);
-
- void __init files_init(void)
- {
-diff --git a/fs/namespace.c b/fs/namespace.c
-index 0570729..ec560d8 100644
---- a/fs/namespace.c
-+++ b/fs/namespace.c
-@@ -463,6 +463,7 @@ void __mnt_drop_write(struct vfsmount *mnt)
- mnt_dec_writers(real_mount(mnt));
- preempt_enable();
- }
-+EXPORT_SYMBOL_GPL(__mnt_drop_write);
-
- /**
- * mnt_drop_write - give up write access to a mount
-@@ -1803,6 +1804,7 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
- }
- return 0;
- }
-+EXPORT_SYMBOL(iterate_mounts);
-
- static void cleanup_group_ids(struct mount *mnt, struct mount *end)
- {
-diff --git a/fs/notify/group.c b/fs/notify/group.c
-index d16b62c..06ca6bc 100644
---- a/fs/notify/group.c
-+++ b/fs/notify/group.c
-@@ -22,6 +22,7 @@
- #include <linux/srcu.h>
- #include <linux/rculist.h>
- #include <linux/wait.h>
-+#include <linux/module.h>
-
- #include <linux/fsnotify_backend.h>
- #include "fsnotify.h"
-@@ -72,6 +73,7 @@ void fsnotify_get_group(struct fsnotify_group *group)
- {
- atomic_inc(&group->refcnt);
- }
-+EXPORT_SYMBOL(fsnotify_get_group);
-
- /*
- * Drop a reference to a group. Free it if it's through.
-@@ -81,6 +83,7 @@ void fsnotify_put_group(struct fsnotify_group *group)
- if (atomic_dec_and_test(&group->refcnt))
- fsnotify_final_destroy_group(group);
- }
-+EXPORT_SYMBOL(fsnotify_put_group);
-
- /*
- * Create a new fsnotify_group and hold a reference for the group returned.
-@@ -109,6 +112,7 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
-
- return group;
- }
-+EXPORT_SYMBOL(fsnotify_alloc_group);
-
- int fsnotify_fasync(int fd, struct file *file, int on)
- {
-diff --git a/fs/notify/mark.c b/fs/notify/mark.c
-index fc0df44..325b5c6 100644
---- a/fs/notify/mark.c
-+++ b/fs/notify/mark.c
-@@ -109,6 +109,7 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
- mark->free_mark(mark);
- }
- }
-+EXPORT_SYMBOL(fsnotify_put_mark);
-
- /* Calculate mask of events for a list of marks */
- u32 fsnotify_recalc_mask(struct hlist_head *head)
-@@ -208,6 +209,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark,
- mutex_unlock(&group->mark_mutex);
- fsnotify_free_mark(mark);
- }
-+EXPORT_SYMBOL(fsnotify_destroy_mark);
-
- void fsnotify_destroy_marks(struct hlist_head *head, spinlock_t *lock)
- {
-@@ -392,6 +394,7 @@ err:
-
- return ret;
- }
-+EXPORT_SYMBOL(fsnotify_add_mark);
-
- int fsnotify_add_mark(struct fsnotify_mark *mark, struct fsnotify_group *group,
- struct inode *inode, struct vfsmount *mnt, int allow_dups)
-@@ -492,6 +495,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
- atomic_set(&mark->refcnt, 1);
- mark->free_mark = free_mark;
- }
-+EXPORT_SYMBOL(fsnotify_init_mark);
-
- static int fsnotify_mark_destroy(void *ignored)
- {
-diff --git a/fs/open.c b/fs/open.c
-index b6f1e96..4ab0d4e 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,
- mutex_unlock(&dentry->d_inode->i_mutex);
- return ret;
- }
-+EXPORT_SYMBOL(do_truncate);
-
- long vfs_truncate(struct path *path, loff_t length)
- {
-@@ -678,6 +679,7 @@ int open_check_o_direct(struct file *f)
- }
- return 0;
- }
-+EXPORT_SYMBOL(open_check_o_direct);
-
- static int do_dentry_open(struct file *f,
- struct inode *inode,
-diff --git a/fs/read_write.c b/fs/read_write.c
-index fd0414e..8ace6ec 100644
---- a/fs/read_write.c
-+++ b/fs/read_write.c
-@@ -504,6 +504,7 @@ vfs_readf_t vfs_readf(struct file *file)
- return new_sync_read;
- return ERR_PTR(-ENOSYS);
- }
-+EXPORT_SYMBOL(vfs_readf);
-
- vfs_writef_t vfs_writef(struct file *file)
- {
-@@ -515,6 +516,7 @@ vfs_writef_t vfs_writef(struct file *file)
- return new_sync_write;
- return ERR_PTR(-ENOSYS);
- }
-+EXPORT_SYMBOL(vfs_writef);
-
- 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 30a091d..c37c311 100644
---- a/fs/splice.c
-+++ b/fs/splice.c
-@@ -1123,6 +1123,7 @@ long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
-
- return splice_write(pipe, out, ppos, len, flags);
- }
-+EXPORT_SYMBOL(do_splice_from);
-
- /*
- * Attempt to initiate a splice from a file to a pipe.
-@@ -1149,6 +1150,7 @@ long do_splice_to(struct file *in, loff_t *ppos,
-
- return splice_read(in, ppos, pipe, len, flags);
- }
-+EXPORT_SYMBOL(do_splice_to);
-
- /**
- * splice_direct_to_actor - splices data directly between two non-pipes
-diff --git a/fs/xattr.c b/fs/xattr.c
-index 9b932b9..44c457a 100644
---- a/fs/xattr.c
-+++ b/fs/xattr.c
-@@ -207,6 +207,7 @@ vfs_getxattr_alloc(struct dentry *dentry, const char *name, char **xattr_value,
- *xattr_value = value;
- return error;
- }
-+EXPORT_SYMBOL(vfs_getxattr_alloc);
-
- /* Compare an extended attribute value with the given value */
- int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
-diff --git a/kernel/task_work.c b/kernel/task_work.c
-index 53fa971..f80d564 100644
---- a/kernel/task_work.c
-+++ b/kernel/task_work.c
-@@ -118,3 +118,4 @@ void task_work_run(void)
- } while (work);
- }
- }
-+EXPORT_SYMBOL(task_work_run);
-diff --git a/security/commoncap.c b/security/commoncap.c
-index 1832cf7..987ff5f 100644
---- a/security/commoncap.c
-+++ b/security/commoncap.c
-@@ -1053,12 +1053,14 @@ int cap_mmap_addr(unsigned long addr)
- }
- return ret;
- }
-+EXPORT_SYMBOL(cap_mmap_addr);
-
- int cap_mmap_file(struct file *file, unsigned long reqprot,
- unsigned long prot, unsigned long flags)
- {
- return 0;
- }
-+EXPORT_SYMBOL(cap_mmap_file);
-
- #ifdef CONFIG_SECURITY
-
-diff --git a/security/device_cgroup.c b/security/device_cgroup.c
-index 03c1652..b00aa76 100644
---- a/security/device_cgroup.c
-+++ b/security/device_cgroup.c
-@@ -7,6 +7,7 @@
- #include <linux/device_cgroup.h>
- #include <linux/cgroup.h>
- #include <linux/ctype.h>
-+#include <linux/export.h>
- #include <linux/list.h>
- #include <linux/uaccess.h>
- #include <linux/seq_file.h>
-@@ -849,6 +850,7 @@ int __devcgroup_inode_permission(struct inode *inode, int mask)
- return __devcgroup_check_permission(type, imajor(inode), iminor(inode),
- access);
- }
-+EXPORT_SYMBOL(__devcgroup_inode_permission);
-
- int devcgroup_inode_mknod(int mode, dev_t dev)
- {
-diff --git a/security/security.c b/security/security.c
-index 46f405c..54488b0 100644
---- a/security/security.c
-+++ b/security/security.c
-@@ -433,6 +433,7 @@ int security_path_rmdir(struct path *dir, struct dentry *dentry)
- return 0;
- return call_int_hook(path_rmdir, 0, dir, dentry);
- }
-+EXPORT_SYMBOL(security_path_rmdir);
-
- int security_path_unlink(struct path *dir, struct dentry *dentry)
- {
-@@ -449,6 +450,7 @@ int security_path_symlink(struct path *dir, struct dentry *dentry,
- return 0;
- return call_int_hook(path_symlink, 0, dir, dentry, old_name);
- }
-+EXPORT_SYMBOL(security_path_symlink);
-
- int security_path_link(struct dentry *old_dentry, struct path *new_dir,
- struct dentry *new_dentry)
-@@ -457,6 +459,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
- return 0;
- return call_int_hook(path_link, 0, old_dentry, new_dir, new_dentry);
- }
-+EXPORT_SYMBOL(security_path_link);
-
- int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
- struct path *new_dir, struct dentry *new_dentry,
-@@ -484,6 +487,7 @@ int security_path_truncate(struct path *path)
- return 0;
- return call_int_hook(path_truncate, 0, path);
- }
-+EXPORT_SYMBOL(security_path_truncate);
-
- int security_path_chmod(struct path *path, umode_t mode)
- {
-@@ -491,6 +495,7 @@ int security_path_chmod(struct path *path, umode_t mode)
- return 0;
- return call_int_hook(path_chmod, 0, path, mode);
- }
-+EXPORT_SYMBOL(security_path_chmod);
-
- int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
- {
-@@ -498,6 +503,7 @@ int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
- return 0;
- return call_int_hook(path_chown, 0, path, uid, gid);
- }
-+EXPORT_SYMBOL(security_path_chown);
-
- int security_path_chroot(struct path *path)
- {
-@@ -583,6 +589,7 @@ int security_inode_readlink(struct dentry *dentry)
- return 0;
- return call_int_hook(inode_readlink, 0, dentry);
- }
-+EXPORT_SYMBOL(security_inode_readlink);
-
- int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
- bool rcu)
-@@ -598,6 +605,7 @@ int security_inode_permission(struct inode *inode, int mask)
- return 0;
- return call_int_hook(inode_permission, 0, inode, mask);
- }
-+EXPORT_SYMBOL(security_inode_permission);
-
- int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
- {
-@@ -736,6 +744,7 @@ int security_file_permission(struct file *file, int mask)
-
- return fsnotify_perm(file, mask);
- }
-+EXPORT_SYMBOL(security_file_permission);
-
- int security_file_alloc(struct file *file)
- {
-@@ -795,6 +804,7 @@ int security_mmap_file(struct file *file, unsigned long prot,
- return ret;
- return ima_file_mmap(file, prot);
- }
-+EXPORT_SYMBOL(security_mmap_file);
-
- int security_mmap_addr(unsigned long addr)
- {
-diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Documentation/ABI/testing/debugfs-aufs
---- /usr/share/empty/Documentation/ABI/testing/debugfs-aufs 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/ABI/testing/debugfs-aufs 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/ABI/testing/debugfs-aufs linux-4.4/Documentation/ABI/testing/debugfs-aufs
+--- linux-4.4/Documentation/ABI/testing/debugfs-aufs 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/ABI/testing/debugfs-aufs 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,50 @@
+What: /debug/aufs/si_<id>/
+Date: March 2009
@@ -1011,9 +52,9 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/debugfs-aufs linux/Document
+ be created.
+ When the aufs mount option 'noxino' is specified, it
+ will be empty. About XINO files, see the aufs manual.
-diff -urN /usr/share/empty/Documentation/ABI/testing/sysfs-aufs linux/Documentation/ABI/testing/sysfs-aufs
---- /usr/share/empty/Documentation/ABI/testing/sysfs-aufs 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/ABI/testing/sysfs-aufs 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/ABI/testing/sysfs-aufs linux-4.4/Documentation/ABI/testing/sysfs-aufs
+--- linux-4.4/Documentation/ABI/testing/sysfs-aufs 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/ABI/testing/sysfs-aufs 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,31 @@
+What: /sys/fs/aufs/si_<id>/
+Date: March 2009
@@ -1046,9 +87,404 @@ diff -urN /usr/share/empty/Documentation/ABI/testing/sysfs-aufs linux/Documentat
+ even if it is the default path.
+ When the aufs mount option 'noxino' is specified, it
+ will be empty. About XINO files, see the aufs manual.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt linux/Documentation/filesystems/aufs/design/01intro.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/01intro.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/README linux-4.4/Documentation/filesystems/aufs/README
+--- linux-4.4/Documentation/filesystems/aufs/README 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/README 2021-02-24 17:28:14.398807954 +0100
+@@ -0,0 +1,391 @@
++
++Aufs4 -- advanced multi layered unification filesystem version 4.x
++http://aufs.sf.net
++Junjiro R. Okajima
++
++
++0. Introduction
++----------------------------------------
++In the early days, aufs was entirely re-designed and re-implemented
++Unionfs Version 1.x series. Adding many original ideas, approaches,
++improvements and implementations, it becomes totally different from
++Unionfs while keeping the basic features.
++Recently, Unionfs Version 2.x series begin taking some of the same
++approaches to aufs1's.
++Unionfs is being developed by Professor Erez Zadok at Stony Brook
++University and his team.
++
++Aufs4 supports linux-4.0 and later, and for linux-3.x series try aufs3.
++If you want older kernel version support, try aufs2-2.6.git or
++aufs2-standalone.git repository, aufs1 from CVS on SourceForge.
++
++Note: it becomes clear that "Aufs was rejected. Let's give it up."
++ According to Christoph Hellwig, linux rejects all union-type
++ filesystems but UnionMount.
++<http://marc.info/?l=linux-kernel&m=123938533724484&w=2>
++
++PS. Al Viro seems have a plan to merge aufs as well as overlayfs and
++ UnionMount, and he pointed out an issue around a directory mutex
++ lock and aufs addressed it. But it is still unsure whether aufs will
++ be merged (or any other union solution).
++<http://marc.info/?l=linux-kernel&m=136312705029295&w=1>
++
++
++1. Features
++----------------------------------------
++- unite several directories into a single virtual filesystem. The member
++ directory is called as a branch.
++- you can specify the permission flags to the branch, which are 'readonly',
++ 'readwrite' and 'whiteout-able.'
++- by upper writable branch, internal copyup and whiteout, files/dirs on
++ readonly branch are modifiable logically.
++- dynamic branch manipulation, add, del.
++- etc...
++
++Also there are many enhancements in aufs, such as:
++- test only the highest one for the directory permission (dirperm1)
++- copyup on open (coo=)
++- 'move' policy for copy-up between two writable branches, after
++ checking free space.
++- xattr, acl
++- readdir(3) in userspace.
++- keep inode number by external inode number table
++- keep the timestamps of file/dir in internal copyup operation
++- seekable directory, supporting NFS readdir.
++- whiteout is hardlinked in order to reduce the consumption of inodes
++ on branch
++- do not copyup, nor create a whiteout when it is unnecessary
++- revert a single systemcall when an error occurs in aufs
++- remount interface instead of ioctl
++- maintain /etc/mtab by an external command, /sbin/mount.aufs.
++- loopback mounted filesystem as a branch
++- kernel thread for removing the dir who has a plenty of whiteouts
++- support copyup sparse file (a file which has a 'hole' in it)
++- default permission flags for branches
++- selectable permission flags for ro branch, whether whiteout can
++ exist or not
++- export via NFS.
++- support <sysfs>/fs/aufs and <debugfs>/aufs.
++- support multiple writable branches, some policies to select one
++ among multiple writable branches.
++- a new semantics for link(2) and rename(2) to support multiple
++ writable branches.
++- no glibc changes are required.
++- pseudo hardlink (hardlink over branches)
++- allow a direct access manually to a file on branch, e.g. bypassing aufs.
++ including NFS or remote filesystem branch.
++- userspace wrapper for pathconf(3)/fpathconf(3) with _PC_LINK_MAX.
++- and more...
++
++Currently these features are dropped temporary from aufs4.
++See design/08plan.txt in detail.
++- nested mount, i.e. aufs as readonly no-whiteout branch of another aufs
++ (robr)
++- statistics of aufs thread (/sys/fs/aufs/stat)
++
++Features or just an idea in the future (see also design/*.txt),
++- reorder the branch index without del/re-add.
++- permanent xino files for NFSD
++- an option for refreshing the opened files after add/del branches
++- light version, without branch manipulation. (unnecessary?)
++- copyup in userspace
++- inotify in userspace
++- readv/writev
++
++
++2. Download
++----------------------------------------
++There are three GIT trees for aufs4, aufs4-linux.git,
++aufs4-standalone.git, and aufs-util.git. Note that there is no "4" in
++"aufs-util.git."
++While the aufs-util is always necessary, you need either of aufs4-linux
++or aufs4-standalone.
++
++The aufs4-linux tree includes the whole linux mainline GIT tree,
++git://git.kernel.org/.../torvalds/linux.git.
++And you cannot select CONFIG_AUFS_FS=m for this version, eg. you cannot
++build aufs4 as an external kernel module.
++Several extra patches are not included in this tree. Only
++aufs4-standalone tree contains them. They are described in the later
++section "Configuration and Compilation."
++
++On the other hand, the aufs4-standalone tree has only aufs source files
++and necessary patches, and you can select CONFIG_AUFS_FS=m.
++But you need to apply all aufs patches manually.
++
++You will find GIT branches whose name is in form of "aufs4.x" where "x"
++represents the linux kernel version, "linux-4.x". For instance,
++"aufs4.0" is for linux-4.0. For latest "linux-4.x-rcN", use
++"aufs4.x-rcN" branch.
++
++o aufs4-linux tree
++$ git clone --reference /your/linux/git/tree \
++ git://github.com/sfjro/aufs4-linux.git aufs4-linux.git
++- if you don't have linux GIT tree, then remove "--reference ..."
++$ cd aufs4-linux.git
++$ git checkout origin/aufs4.0
++
++Or You may want to directly git-pull aufs into your linux GIT tree, and
++leave the patch-work to GIT.
++$ cd /your/linux/git/tree
++$ git remote add aufs4 git://github.com/sfjro/aufs4-linux.git
++$ git fetch aufs4
++$ git checkout -b my4.0 v4.0
++$ (add your local change...)
++$ git pull aufs4 aufs4.0
++- now you have v4.0 + your_changes + aufs4.0 in you my4.0 branch.
++- you may need to solve some conflicts between your_changes and
++ aufs4.0. in this case, git-rerere is recommended so that you can
++ solve the similar conflicts automatically when you upgrade to 4.1 or
++ later in the future.
++
++o aufs4-standalone tree
++$ git clone git://github.com/sfjro/aufs4-standalone.git aufs4-standalone.git
++$ cd aufs4-standalone.git
++$ git checkout origin/aufs4.0
++
++o aufs-util tree
++$ git clone git://git.code.sf.net/p/aufs/aufs-util aufs-util.git
++- note that the public aufs-util.git is on SourceForge instead of
++ GitHUB.
++$ cd aufs-util.git
++$ git checkout origin/aufs4.0
++
++Note: The 4.x-rcN branch is to be used with `rc' kernel versions ONLY.
++The minor version number, 'x' in '4.x', of aufs may not always
++follow the minor version number of the kernel.
++Because changes in the kernel that cause the use of a new
++minor version number do not always require changes to aufs-util.
++
++Since aufs-util has its own minor version number, you may not be
++able to find a GIT branch in aufs-util for your kernel's
++exact minor version number.
++In this case, you should git-checkout the branch for the
++nearest lower number.
++
++For (an unreleased) example:
++If you are using "linux-4.10" and the "aufs4.10" branch
++does not exist in aufs-util repository, then "aufs4.9", "aufs4.8"
++or something numerically smaller is the branch for your kernel.
++
++Also you can view all branches by
++ $ git branch -a
++
++
++3. Configuration and Compilation
++----------------------------------------
++Make sure you have git-checkout'ed the correct branch.
++
++For aufs4-linux tree,
++- enable CONFIG_AUFS_FS.
++- set other aufs configurations if necessary.
++
++For aufs4-standalone tree,
++There are several ways to build.
++
++1.
++- apply ./aufs4-kbuild.patch to your kernel source files.
++- apply ./aufs4-base.patch too.
++- apply ./aufs4-mmap.patch too.
++- apply ./aufs4-standalone.patch too, if you have a plan to set
++ CONFIG_AUFS_FS=m. otherwise you don't need ./aufs4-standalone.patch.
++- copy ./{Documentation,fs,include/uapi/linux/aufs_type.h} files to your
++ kernel source tree. Never copy $PWD/include/uapi/linux/Kbuild.
++- enable CONFIG_AUFS_FS, you can select either
++ =m or =y.
++- and build your kernel as usual.
++- install the built kernel.
++ Note: Since linux-3.9, every filesystem module requires an alias
++ "fs-<fsname>". You should make sure that "fs-aufs" is listed in your
++ modules.aliases file if you set CONFIG_AUFS_FS=m.
++- install the header files too by "make headers_install" to the
++ directory where you specify. By default, it is $PWD/usr.
++ "make help" shows a brief note for headers_install.
++- and reboot your system.
++
++2.
++- module only (CONFIG_AUFS_FS=m).
++- apply ./aufs4-base.patch to your kernel source files.
++- apply ./aufs4-mmap.patch too.
++- apply ./aufs4-standalone.patch too.
++- build your kernel, don't forget "make headers_install", and reboot.
++- edit ./config.mk and set other aufs configurations if necessary.
++ Note: You should read $PWD/fs/aufs/Kconfig carefully which describes
++ every aufs configurations.
++- build the module by simple "make".
++ Note: Since linux-3.9, every filesystem module requires an alias
++ "fs-<fsname>". You should make sure that "fs-aufs" is listed in your
++ modules.aliases file.
++- you can specify ${KDIR} make variable which points to your kernel
++ source tree.
++- install the files
++ + run "make install" to install the aufs module, or copy the built
++ $PWD/aufs.ko to /lib/modules/... and run depmod -a (or reboot simply).
++ + run "make install_headers" (instead of headers_install) to install
++ the modified aufs header file (you can specify DESTDIR which is
++ available in aufs standalone version's Makefile only), or copy
++ $PWD/usr/include/linux/aufs_type.h to /usr/include/linux or wherever
++ you like manually. By default, the target directory is $PWD/usr.
++- no need to apply aufs4-kbuild.patch, nor copying source files to your
++ kernel source tree.
++
++Note: The header file aufs_type.h is necessary to build aufs-util
++ as well as "make headers_install" in the kernel source tree.
++ headers_install is subject to be forgotten, but it is essentially
++ necessary, not only for building aufs-util.
++ You may not meet problems without headers_install in some older
++ version though.
++
++And then,
++- read README in aufs-util, build and install it
++- note that your distribution may contain an obsoleted version of
++ aufs_type.h in /usr/include/linux or something. When you build aufs
++ utilities, make sure that your compiler refers the correct aufs header
++ file which is built by "make headers_install."
++- if you want to use readdir(3) in userspace or pathconf(3) wrapper,
++ then run "make install_ulib" too. And refer to the aufs manual in
++ detail.
++
++There several other patches in aufs4-standalone.git. They are all
++optional. When you meet some problems, they will help you.
++- aufs4-loopback.patch
++ Supports a nested loopback mount in a branch-fs. This patch is
++ unnecessary until aufs produces a message like "you may want to try
++ another patch for loopback file".
++- vfs-ino.patch
++ Modifies a system global kernel internal function get_next_ino() in
++ order to stop assigning 0 for an inode-number. Not directly related to
++ aufs, but recommended generally.
++- tmpfs-idr.patch
++ Keeps the tmpfs inode number as the lowest value. Effective to reduce
++ the size of aufs XINO files for tmpfs branch. Also it prevents the
++ duplication of inode number, which is important for backup tools and
++ other utilities. When you find aufs XINO files for tmpfs branch
++ growing too much, try this patch.
++- lockdep-debug.patch
++ Because aufs is not only an ordinary filesystem (callee of VFS), but
++ also a caller of VFS functions for branch filesystems, subclassing of
++ the internal locks for LOCKDEP is necessary. LOCKDEP is a debugging
++ feature of linux kernel. If you enable CONFIG_LOCKDEP, then you will
++ need to apply this debug patch to expand several constant values.
++ If don't know what LOCKDEP, then you don't have apply this patch.
++
++
++4. Usage
++----------------------------------------
++At first, make sure aufs-util are installed, and please read the aufs
++manual, aufs.5 in aufs-util.git tree.
++$ man -l aufs.5
++
++And then,
++$ mkdir /tmp/rw /tmp/aufs
++# mount -t aufs -o br=/tmp/rw:${HOME} none /tmp/aufs
++
++Here is another example. The result is equivalent.
++# mount -t aufs -o br=/tmp/rw=rw:${HOME}=ro none /tmp/aufs
++ Or
++# mount -t aufs -o br:/tmp/rw none /tmp/aufs
++# mount -o remount,append:${HOME} /tmp/aufs
++
++Then, you can see whole tree of your home dir through /tmp/aufs. If
++you modify a file under /tmp/aufs, the one on your home directory is
++not affected, instead the same named file will be newly created under
++/tmp/rw. And all of your modification to a file will be applied to
++the one under /tmp/rw. This is called the file based Copy on Write
++(COW) method.
++Aufs mount options are described in aufs.5.
++If you run chroot or something and make your aufs as a root directory,
++then you need to customize the shutdown script. See the aufs manual in
++detail.
++
++Additionally, there are some sample usages of aufs which are a
++diskless system with network booting, and LiveCD over NFS.
++See sample dir in CVS tree on SourceForge.
++
++
++5. Contact
++----------------------------------------
++When you have any problems or strange behaviour in aufs, please let me
++know with:
++- /proc/mounts (instead of the output of mount(8))
++- /sys/module/aufs/*
++- /sys/fs/aufs/* (if you have them)
++- /debug/aufs/* (if you have them)
++- linux kernel version
++ if your kernel is not plain, for example modified by distributor,
++ the url where i can download its source is necessary too.
++- aufs version which was printed at loading the module or booting the
++ system, instead of the date you downloaded.
++- configuration (define/undefine CONFIG_AUFS_xxx)
++- kernel configuration or /proc/config.gz (if you have it)
++- behaviour which you think to be incorrect
++- actual operation, reproducible one is better
++- mailto: aufs-users at lists.sourceforge.net
++
++Usually, I don't watch the Public Areas(Bugs, Support Requests, Patches,
++and Feature Requests) on SourceForge. Please join and write to
++aufs-users ML.
++
++
++6. Acknowledgements
++----------------------------------------
++Thanks to everyone who have tried and are using aufs, whoever
++have reported a bug or any feedback.
++
++Especially donators:
++Tomas Matejicek(slax.org) made a donation (much more than once).
++ Since Apr 2010, Tomas M (the author of Slax and Linux Live
++ scripts) is making "doubling" donations.
++ Unfortunately I cannot list all of the donators, but I really
++ appreciate.
++ It ends Aug 2010, but the ordinary donation URL is still available.
++ <http://sourceforge.net/donate/index.php?group_id=167503>
++Dai Itasaka made a donation (2007/8).
++Chuck Smith made a donation (2008/4, 10 and 12).
++Henk Schoneveld made a donation (2008/9).
++Chih-Wei Huang, ASUS, CTC donated Eee PC 4G (2008/10).
++Francois Dupoux made a donation (2008/11).
++Bruno Cesar Ribas and Luis Carlos Erpen de Bona, C3SL serves public
++ aufs2 GIT tree (2009/2).
++William Grant made a donation (2009/3).
++Patrick Lane made a donation (2009/4).
++The Mail Archive (mail-archive.com) made donations (2009/5).
++Nippy Networks (Ed Wildgoose) made a donation (2009/7).
++New Dream Network, LLC (www.dreamhost.com) made a donation (2009/11).
++Pavel Pronskiy made a donation (2011/2).
++Iridium and Inmarsat satellite phone retailer (www.mailasail.com), Nippy
++ Networks (Ed Wildgoose) made a donation for hardware (2011/3).
++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).
++"pemasu from Finland" made a donation (2013/7).
++The Parted Magic Project made a donation (2013/9 and 11).
++Pavel Barta made a donation (2013/10).
++Nikolay Pertsev made a donation (2014/5).
++James B made a donation (2014/7 and 2015/7).
++Stefano Di Biase made a donation (2014/8).
++Daniel Epellei made a donation (2015/1).
++OmegaPhil made a donation (2016/1).
++
++Thank you very much.
++Donations are always, including future donations, very important and
++helpful for me to keep on developing aufs.
++
++
++7.
++----------------------------------------
++If you are an experienced user, no explanation is needed. Aufs is
++just a linux filesystem.
++
++
++Enjoy!
++
++# Local variables: ;
++# mode: text;
++# End: ;
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/01intro.txt linux-4.4/Documentation/filesystems/aufs/design/01intro.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/01intro.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/01intro.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,170 @@
+
+# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1220,9 +656,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/01intro.txt lin
+Some people may think it is better to pass such work to user space
+helper, instead of doing in kernel space. Actually I am still thinking
+about it. But currently I have implemented it in kernel space.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt linux/Documentation/filesystems/aufs/design/02struct.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/02struct.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/02struct.txt linux-4.4/Documentation/filesystems/aufs/design/02struct.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/02struct.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/02struct.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,258 @@
+
+# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1482,9 +918,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/02struct.txt li
+- etc.
+
+For this purpose, use "aumvdown" command in aufs-util.git.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03atomic_open.txt linux/Documentation/filesystems/aufs/design/03atomic_open.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/03atomic_open.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/03atomic_open.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/03atomic_open.txt linux-4.4/Documentation/filesystems/aufs/design/03atomic_open.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/03atomic_open.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/03atomic_open.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,85 @@
+
+# Copyright (C) 2015-2016 Junjiro R. Okajima
@@ -1571,9 +1007,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03atomic_open.t
+ ->atomic_open() are lost. in the ordinary case, the checks are
+ done by VFS:do_last(), lookup_open() and atomic_open(). some can
+ be implemented in aufs, but not all I am afraid.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt linux/Documentation/filesystems/aufs/design/03lookup.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/03lookup.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/03lookup.txt linux-4.4/Documentation/filesystems/aufs/design/03lookup.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/03lookup.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/03lookup.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,113 @@
+
+# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1688,9 +1124,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/03lookup.txt li
+ test, and skip the revalidation in step 4. It is useful and improves
+ aufs performance when system surely hide the aufs branches from user,
+ by over-mounting something (or another method).
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt linux/Documentation/filesystems/aufs/design/04branch.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/04branch.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/04branch.txt linux-4.4/Documentation/filesystems/aufs/design/04branch.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/04branch.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/04branch.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,74 @@
+
+# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1766,9 +1202,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/04branch.txt li
+ - a file on the branch is mmap-ed.
+ - a regular file on the branch is opened for write and there is no
+ same named entry on the upper branch.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.txt linux/Documentation/filesystems/aufs/design/05wbr_policy.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/05wbr_policy.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/05wbr_policy.txt linux-4.4/Documentation/filesystems/aufs/design/05wbr_policy.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/05wbr_policy.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/05wbr_policy.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,64 @@
+
+# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -1834,9 +1270,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/05wbr_policy.tx
+ where the source and the target exists and selects the higher
+ one. If the selected branch is readonly, then aufs follows the
+ copyup policy.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06fhsm.txt linux/Documentation/filesystems/aufs/design/06fhsm.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/06fhsm.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/06fhsm.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/06fhsm.txt linux-4.4/Documentation/filesystems/aufs/design/06fhsm.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/06fhsm.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/06fhsm.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,120 @@
+
+# Copyright (C) 2011-2016 Junjiro R. Okajima
@@ -1958,9 +1394,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06fhsm.txt linu
+
+And of course, in every step, an error may happen. So the operation
+should restore the original file state after an error happens.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt linux/Documentation/filesystems/aufs/design/06mmap.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/06mmap.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/06mmap.txt linux-4.4/Documentation/filesystems/aufs/design/06mmap.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/06mmap.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/06mmap.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,72 @@
+
+# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -2034,9 +1470,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06mmap.txt linu
+ equivalent to vm_prfile described above.
+
+I have to give up this "looks-smater" approach.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt linux/Documentation/filesystems/aufs/design/06xattr.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/06xattr.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/06xattr.txt linux-4.4/Documentation/filesystems/aufs/design/06xattr.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/06xattr.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/06xattr.txt 2021-02-24 17:28:14.395474512 +0100
@@ -0,0 +1,96 @@
+
+# Copyright (C) 2014-2016 Junjiro R. Okajima
@@ -2134,9 +1570,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/06xattr.txt lin
+Some contradiction may happen I am afraid.
+Do we need another attribute to stop copying XATTR? I am unsure. For
+now, aufs implements the branch attributes to ignore the error.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt linux/Documentation/filesystems/aufs/design/07export.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/07export.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/07export.txt linux-4.4/Documentation/filesystems/aufs/design/07export.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/07export.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/07export.txt 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,58 @@
+
+# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -2196,9 +1632,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/07export.txt li
+ convert it into ESTALE for NFSD.
+- readdir(): call lockdep_on/off() because filldir in NFSD calls
+ lookup_one_len(), vfs_getattr(), encode_fh() and others.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt linux/Documentation/filesystems/aufs/design/08shwh.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/08shwh.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/08shwh.txt linux-4.4/Documentation/filesystems/aufs/design/08shwh.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/08shwh.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/08shwh.txt 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,52 @@
+
+# Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -2252,9 +1688,9 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/08shwh.txt linu
+
+This new squashfs archive can be stored on the boot device and the
+initramfs will use it to replace the old one at the next boot.
-diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt linux/Documentation/filesystems/aufs/design/10dynop.txt
---- /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux/Documentation/filesystems/aufs/design/10dynop.txt 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/Documentation/filesystems/aufs/design/10dynop.txt linux-4.4/Documentation/filesystems/aufs/design/10dynop.txt
+--- linux-4.4/Documentation/filesystems/aufs/design/10dynop.txt 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/Documentation/filesystems/aufs/design/10dynop.txt 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,47 @@
+
+# Copyright (C) 2010-2016 Junjiro R. Okajima
@@ -2303,404 +1739,491 @@ diff -urN /usr/share/empty/Documentation/filesystems/aufs/design/10dynop.txt lin
+XIP (DAX) mainly.
+Currently this approach is applied to address_space_operations for
+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-02-28 11:26:32.569971135 +0100
-@@ -0,0 +1,391 @@
-+
-+Aufs4 -- advanced multi layered unification filesystem version 4.x
-+http://aufs.sf.net
-+Junjiro R. Okajima
-+
-+
-+0. Introduction
-+----------------------------------------
-+In the early days, aufs was entirely re-designed and re-implemented
-+Unionfs Version 1.x series. Adding many original ideas, approaches,
-+improvements and implementations, it becomes totally different from
-+Unionfs while keeping the basic features.
-+Recently, Unionfs Version 2.x series begin taking some of the same
-+approaches to aufs1's.
-+Unionfs is being developed by Professor Erez Zadok at Stony Brook
-+University and his team.
-+
-+Aufs4 supports linux-4.0 and later, and for linux-3.x series try aufs3.
-+If you want older kernel version support, try aufs2-2.6.git or
-+aufs2-standalone.git repository, aufs1 from CVS on SourceForge.
-+
-+Note: it becomes clear that "Aufs was rejected. Let's give it up."
-+ According to Christoph Hellwig, linux rejects all union-type
-+ filesystems but UnionMount.
-+<http://marc.info/?l=linux-kernel&m=123938533724484&w=2>
-+
-+PS. Al Viro seems have a plan to merge aufs as well as overlayfs and
-+ UnionMount, and he pointed out an issue around a directory mutex
-+ lock and aufs addressed it. But it is still unsure whether aufs will
-+ be merged (or any other union solution).
-+<http://marc.info/?l=linux-kernel&m=136312705029295&w=1>
-+
-+
-+1. Features
-+----------------------------------------
-+- unite several directories into a single virtual filesystem. The member
-+ directory is called as a branch.
-+- you can specify the permission flags to the branch, which are 'readonly',
-+ 'readwrite' and 'whiteout-able.'
-+- by upper writable branch, internal copyup and whiteout, files/dirs on
-+ readonly branch are modifiable logically.
-+- dynamic branch manipulation, add, del.
-+- etc...
-+
-+Also there are many enhancements in aufs, such as:
-+- test only the highest one for the directory permission (dirperm1)
-+- copyup on open (coo=)
-+- 'move' policy for copy-up between two writable branches, after
-+ checking free space.
-+- xattr, acl
-+- readdir(3) in userspace.
-+- keep inode number by external inode number table
-+- keep the timestamps of file/dir in internal copyup operation
-+- seekable directory, supporting NFS readdir.
-+- whiteout is hardlinked in order to reduce the consumption of inodes
-+ on branch
-+- do not copyup, nor create a whiteout when it is unnecessary
-+- revert a single systemcall when an error occurs in aufs
-+- remount interface instead of ioctl
-+- maintain /etc/mtab by an external command, /sbin/mount.aufs.
-+- loopback mounted filesystem as a branch
-+- kernel thread for removing the dir who has a plenty of whiteouts
-+- support copyup sparse file (a file which has a 'hole' in it)
-+- default permission flags for branches
-+- selectable permission flags for ro branch, whether whiteout can
-+ exist or not
-+- export via NFS.
-+- support <sysfs>/fs/aufs and <debugfs>/aufs.
-+- support multiple writable branches, some policies to select one
-+ among multiple writable branches.
-+- a new semantics for link(2) and rename(2) to support multiple
-+ writable branches.
-+- no glibc changes are required.
-+- pseudo hardlink (hardlink over branches)
-+- allow a direct access manually to a file on branch, e.g. bypassing aufs.
-+ including NFS or remote filesystem branch.
-+- userspace wrapper for pathconf(3)/fpathconf(3) with _PC_LINK_MAX.
-+- and more...
-+
-+Currently these features are dropped temporary from aufs4.
-+See design/08plan.txt in detail.
-+- nested mount, i.e. aufs as readonly no-whiteout branch of another aufs
-+ (robr)
-+- statistics of aufs thread (/sys/fs/aufs/stat)
-+
-+Features or just an idea in the future (see also design/*.txt),
-+- reorder the branch index without del/re-add.
-+- permanent xino files for NFSD
-+- an option for refreshing the opened files after add/del branches
-+- light version, without branch manipulation. (unnecessary?)
-+- copyup in userspace
-+- inotify in userspace
-+- readv/writev
-+
-+
-+2. Download
-+----------------------------------------
-+There are three GIT trees for aufs4, aufs4-linux.git,
-+aufs4-standalone.git, and aufs-util.git. Note that there is no "4" in
-+"aufs-util.git."
-+While the aufs-util is always necessary, you need either of aufs4-linux
-+or aufs4-standalone.
-+
-+The aufs4-linux tree includes the whole linux mainline GIT tree,
-+git://git.kernel.org/.../torvalds/linux.git.
-+And you cannot select CONFIG_AUFS_FS=m for this version, eg. you cannot
-+build aufs4 as an external kernel module.
-+Several extra patches are not included in this tree. Only
-+aufs4-standalone tree contains them. They are described in the later
-+section "Configuration and Compilation."
-+
-+On the other hand, the aufs4-standalone tree has only aufs source files
-+and necessary patches, and you can select CONFIG_AUFS_FS=m.
-+But you need to apply all aufs patches manually.
-+
-+You will find GIT branches whose name is in form of "aufs4.x" where "x"
-+represents the linux kernel version, "linux-4.x". For instance,
-+"aufs4.0" is for linux-4.0. For latest "linux-4.x-rcN", use
-+"aufs4.x-rcN" branch.
-+
-+o aufs4-linux tree
-+$ git clone --reference /your/linux/git/tree \
-+ git://github.com/sfjro/aufs4-linux.git aufs4-linux.git
-+- if you don't have linux GIT tree, then remove "--reference ..."
-+$ cd aufs4-linux.git
-+$ git checkout origin/aufs4.0
-+
-+Or You may want to directly git-pull aufs into your linux GIT tree, and
-+leave the patch-work to GIT.
-+$ cd /your/linux/git/tree
-+$ git remote add aufs4 git://github.com/sfjro/aufs4-linux.git
-+$ git fetch aufs4
-+$ git checkout -b my4.0 v4.0
-+$ (add your local change...)
-+$ git pull aufs4 aufs4.0
-+- now you have v4.0 + your_changes + aufs4.0 in you my4.0 branch.
-+- you may need to solve some conflicts between your_changes and
-+ aufs4.0. in this case, git-rerere is recommended so that you can
-+ solve the similar conflicts automatically when you upgrade to 4.1 or
-+ later in the future.
-+
-+o aufs4-standalone tree
-+$ git clone git://github.com/sfjro/aufs4-standalone.git aufs4-standalone.git
-+$ cd aufs4-standalone.git
-+$ git checkout origin/aufs4.0
-+
-+o aufs-util tree
-+$ git clone git://git.code.sf.net/p/aufs/aufs-util aufs-util.git
-+- note that the public aufs-util.git is on SourceForge instead of
-+ GitHUB.
-+$ cd aufs-util.git
-+$ git checkout origin/aufs4.0
-+
-+Note: The 4.x-rcN branch is to be used with `rc' kernel versions ONLY.
-+The minor version number, 'x' in '4.x', of aufs may not always
-+follow the minor version number of the kernel.
-+Because changes in the kernel that cause the use of a new
-+minor version number do not always require changes to aufs-util.
-+
-+Since aufs-util has its own minor version number, you may not be
-+able to find a GIT branch in aufs-util for your kernel's
-+exact minor version number.
-+In this case, you should git-checkout the branch for the
-+nearest lower number.
-+
-+For (an unreleased) example:
-+If you are using "linux-4.10" and the "aufs4.10" branch
-+does not exist in aufs-util repository, then "aufs4.9", "aufs4.8"
-+or something numerically smaller is the branch for your kernel.
-+
-+Also you can view all branches by
-+ $ git branch -a
-+
+diff -urNp -x '*.orig' linux-4.4/MAINTAINERS linux-4.4/MAINTAINERS
+--- linux-4.4/MAINTAINERS 2021-02-24 17:28:00.965039120 +0100
++++ linux-4.4/MAINTAINERS 2021-02-24 17:28:14.382140747 +0100
+@@ -2029,6 +2029,19 @@ F: include/linux/audit.h
+ F: include/uapi/linux/audit.h
+ F: kernel/audit*
+
++AUFS (advanced multi layered unification filesystem) FILESYSTEM
++M: "J. R. Okajima" <hooanon05g at gmail.com>
++L: linux-unionfs at vger.kernel.org
++L: aufs-users at lists.sourceforge.net (members only)
++W: http://aufs.sourceforge.net
++T: git://github.com/sfjro/aufs4-linux.git
++S: Supported
++F: Documentation/filesystems/aufs/
++F: Documentation/ABI/testing/debugfs-aufs
++F: Documentation/ABI/testing/sysfs-aufs
++F: fs/aufs/
++F: include/uapi/linux/aufs_type.h
+
-+3. Configuration and Compilation
-+----------------------------------------
-+Make sure you have git-checkout'ed the correct branch.
+ AUXILIARY DISPLAY DRIVERS
+ M: Miguel Ojeda Sandonis <miguel.ojeda.sandonis at gmail.com>
+ W: http://miguelojeda.es/auxdisplay.htm
+diff -urNp -x '*.orig' linux-4.4/drivers/block/loop.c linux-4.4/drivers/block/loop.c
+--- linux-4.4/drivers/block/loop.c 2021-02-24 17:28:03.251779927 +0100
++++ linux-4.4/drivers/block/loop.c 2021-02-24 17:28:14.418808602 +0100
+@@ -563,7 +563,7 @@ static int do_req_filebacked(struct loop
+ }
+
+ struct switch_request {
+- struct file *file;
++ struct file *file, *virt_file;
+ struct completion wait;
+ };
+
+@@ -589,6 +589,7 @@ static void do_loop_switch(struct loop_d
+ mapping = file->f_mapping;
+ mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
+ lo->lo_backing_file = file;
++ lo->lo_backing_virt_file = p->virt_file;
+ lo->lo_blocksize = S_ISBLK(mapping->host->i_mode) ?
+ mapping->host->i_bdev->bd_block_size : PAGE_SIZE;
+ lo->old_gfp_mask = mapping_gfp_mask(mapping);
+@@ -601,11 +602,13 @@ static void do_loop_switch(struct loop_d
+ * First it needs to flush existing IO, it does this by sending a magic
+ * BIO down the pipe. The completion of this BIO does the actual switch.
+ */
+-static int loop_switch(struct loop_device *lo, struct file *file)
++static int loop_switch(struct loop_device *lo, struct file *file,
++ struct file *virt_file)
+ {
+ struct switch_request w;
+
+ w.file = file;
++ w.virt_file = virt_file;
+
+ /* freeze queue and wait for completion of scheduled requests */
+ blk_mq_freeze_queue(lo->lo_queue);
+@@ -627,7 +630,16 @@ static int loop_flush(struct loop_device
+ /* loop not yet configured, no running thread, nothing to flush */
+ if (lo->lo_state != Lo_bound)
+ return 0;
+- return loop_switch(lo, NULL);
++ return loop_switch(lo, NULL, NULL);
++}
+
-+For aufs4-linux tree,
-+- enable CONFIG_AUFS_FS.
-+- set other aufs configurations if necessary.
++static struct file *loop_real_file(struct file *file)
++{
++ struct file *f = NULL;
+
-+For aufs4-standalone tree,
-+There are several ways to build.
++ if (file->f_path.dentry->d_sb->s_op->real_loop)
++ f = file->f_path.dentry->d_sb->s_op->real_loop(file);
++ return f;
+ }
+
+ static void loop_reread_partitions(struct loop_device *lo,
+@@ -694,6 +706,7 @@ static int loop_change_fd(struct loop_de
+ unsigned int arg)
+ {
+ struct file *file, *old_file;
++ struct file *f, *virt_file = NULL, *old_virt_file;
+ struct inode *inode;
+ int error;
+
+@@ -710,6 +723,12 @@ static int loop_change_fd(struct loop_de
+ file = fget(arg);
+ if (!file)
+ goto out;
++ f = loop_real_file(file);
++ if (f) {
++ virt_file = file;
++ file = f;
++ get_file(file);
++ }
+
+ error = loop_validate_file(file, bdev);
+ if (error)
+@@ -717,6 +736,7 @@ static int loop_change_fd(struct loop_de
+
+ inode = file->f_mapping->host;
+ old_file = lo->lo_backing_file;
++ old_virt_file = lo->lo_backing_virt_file;
+
+ error = -EINVAL;
+
+@@ -725,21 +745,43 @@ static int loop_change_fd(struct loop_de
+ goto out_putf;
+
+ /* and ... switch */
+- error = loop_switch(lo, file);
++ error = loop_switch(lo, file, virt_file);
+ if (error)
+ goto out_putf;
+
+ fput(old_file);
++ if (old_virt_file)
++ fput(old_virt_file);
+ if (lo->lo_flags & LO_FLAGS_PARTSCAN)
+ loop_reread_partitions(lo, bdev);
+ return 0;
+
+ out_putf:
+ fput(file);
++ if (virt_file)
++ fput(virt_file);
+ out:
+ return error;
+ }
+
++/*
++ * for AUFS
++ * no get/put for file.
++ */
++struct file *loop_backing_file(struct super_block *sb)
++{
++ struct file *ret;
++ struct loop_device *l;
+
-+1.
-+- apply ./aufs4-kbuild.patch to your kernel source files.
-+- apply ./aufs4-base.patch too.
-+- apply ./aufs4-mmap.patch too.
-+- apply ./aufs4-standalone.patch too, if you have a plan to set
-+ CONFIG_AUFS_FS=m. otherwise you don't need ./aufs4-standalone.patch.
-+- copy ./{Documentation,fs,include/uapi/linux/aufs_type.h} files to your
-+ kernel source tree. Never copy $PWD/include/uapi/linux/Kbuild.
-+- enable CONFIG_AUFS_FS, you can select either
-+ =m or =y.
-+- and build your kernel as usual.
-+- install the built kernel.
-+ Note: Since linux-3.9, every filesystem module requires an alias
-+ "fs-<fsname>". You should make sure that "fs-aufs" is listed in your
-+ modules.aliases file if you set CONFIG_AUFS_FS=m.
-+- install the header files too by "make headers_install" to the
-+ directory where you specify. By default, it is $PWD/usr.
-+ "make help" shows a brief note for headers_install.
-+- and reboot your system.
++ ret = NULL;
++ if (MAJOR(sb->s_dev) == LOOP_MAJOR) {
++ l = sb->s_bdev->bd_disk->private_data;
++ ret = l->lo_backing_file;
++ }
++ return ret;
++}
++EXPORT_SYMBOL(loop_backing_file);
+
-+2.
-+- module only (CONFIG_AUFS_FS=m).
-+- apply ./aufs4-base.patch to your kernel source files.
-+- apply ./aufs4-mmap.patch too.
-+- apply ./aufs4-standalone.patch too.
-+- build your kernel, don't forget "make headers_install", and reboot.
-+- edit ./config.mk and set other aufs configurations if necessary.
-+ Note: You should read $PWD/fs/aufs/Kconfig carefully which describes
-+ every aufs configurations.
-+- build the module by simple "make".
-+ Note: Since linux-3.9, every filesystem module requires an alias
-+ "fs-<fsname>". You should make sure that "fs-aufs" is listed in your
-+ modules.aliases file.
-+- you can specify ${KDIR} make variable which points to your kernel
-+ source tree.
-+- install the files
-+ + run "make install" to install the aufs module, or copy the built
-+ $PWD/aufs.ko to /lib/modules/... and run depmod -a (or reboot simply).
-+ + run "make install_headers" (instead of headers_install) to install
-+ the modified aufs header file (you can specify DESTDIR which is
-+ available in aufs standalone version's Makefile only), or copy
-+ $PWD/usr/include/linux/aufs_type.h to /usr/include/linux or wherever
-+ you like manually. By default, the target directory is $PWD/usr.
-+- no need to apply aufs4-kbuild.patch, nor copying source files to your
-+ kernel source tree.
+ /* loop sysfs attributes */
+
+ static ssize_t loop_attr_show(struct device *dev, char *page,
+@@ -898,7 +940,7 @@ static int loop_prepare_queue(struct loo
+ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
+ struct block_device *bdev, unsigned int arg)
+ {
+- struct file *file;
++ struct file *file, *f, *virt_file = NULL;
+ struct inode *inode;
+ struct address_space *mapping;
+ unsigned lo_blocksize;
+@@ -913,6 +955,12 @@ static int loop_set_fd(struct loop_devic
+ file = fget(arg);
+ if (!file)
+ goto out;
++ f = loop_real_file(file);
++ if (f) {
++ virt_file = file;
++ file = f;
++ get_file(file);
++ }
+
+ error = -EBUSY;
+ if (lo->lo_state != Lo_unbound)
+@@ -950,6 +998,7 @@ static int loop_set_fd(struct loop_devic
+ lo->lo_flags = lo_flags;
+ lo->lo_xid = vx_current_xid();
+ lo->lo_backing_file = file;
++ lo->lo_backing_virt_file = virt_file;
+ lo->transfer = NULL;
+ lo->ioctl = NULL;
+ lo->lo_sizelimit = 0;
+@@ -982,6 +1031,8 @@ static int loop_set_fd(struct loop_devic
+
+ out_putf:
+ fput(file);
++ if (virt_file)
++ fput(virt_file);
+ out:
+ /* This is safe: open() is still holding a reference. */
+ module_put(THIS_MODULE);
+@@ -1028,6 +1079,7 @@ loop_init_xfer(struct loop_device *lo, s
+ static int loop_clr_fd(struct loop_device *lo)
+ {
+ struct file *filp = lo->lo_backing_file;
++ struct file *virt_filp = lo->lo_backing_virt_file;
+ gfp_t gfp = lo->old_gfp_mask;
+ struct block_device *bdev = lo->lo_device;
+
+@@ -1059,6 +1111,7 @@ static int loop_clr_fd(struct loop_devic
+ spin_lock_irq(&lo->lo_lock);
+ lo->lo_state = Lo_rundown;
+ lo->lo_backing_file = NULL;
++ lo->lo_backing_virt_file = NULL;
+ spin_unlock_irq(&lo->lo_lock);
+
+ loop_release_xfer(lo);
+@@ -1104,6 +1157,8 @@ static int loop_clr_fd(struct loop_devic
+ * bd_mutex which is usually taken before lo_ctl_mutex.
+ */
+ fput(filp);
++ if (virt_filp)
++ fput(virt_filp);
+ return 0;
+ }
+
+diff -urNp -x '*.orig' linux-4.4/drivers/block/loop.h linux-4.4/drivers/block/loop.h
+--- linux-4.4/drivers/block/loop.h 2021-02-24 17:28:03.251779927 +0100
++++ linux-4.4/drivers/block/loop.h 2021-02-24 17:28:14.418808602 +0100
+@@ -47,7 +47,7 @@ struct loop_device {
+ int (*ioctl)(struct loop_device *, int cmd,
+ unsigned long arg);
+
+- struct file * lo_backing_file;
++ struct file * lo_backing_file, *lo_backing_virt_file;
+ struct block_device *lo_device;
+ unsigned lo_blocksize;
+ void *key_data;
+diff -urNp -x '*.orig' linux-4.4/fs/Kconfig linux-4.4/fs/Kconfig
+--- linux-4.4/fs/Kconfig 2016-01-11 00:01:32.000000000 +0100
++++ linux-4.4/fs/Kconfig 2021-02-24 17:28:14.378807305 +0100
+@@ -221,6 +221,7 @@ source "fs/pstore/Kconfig"
+ source "fs/sysv/Kconfig"
+ source "fs/ufs/Kconfig"
+ source "fs/exofs/Kconfig"
++source "fs/aufs/Kconfig"
+
+ endif # MISC_FILESYSTEMS
+
+diff -urNp -x '*.orig' linux-4.4/fs/Makefile linux-4.4/fs/Makefile
+--- linux-4.4/fs/Makefile 2016-01-11 00:01:32.000000000 +0100
++++ linux-4.4/fs/Makefile 2021-02-24 17:28:14.378807305 +0100
+@@ -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 -urNp -x '*.orig' linux-4.4/fs/aufs/Kconfig linux-4.4/fs/aufs/Kconfig
+--- linux-4.4/fs/aufs/Kconfig 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/Kconfig 2021-02-24 17:28:14.408808278 +0100
+@@ -0,0 +1,185 @@
++config AUFS_FS
++ tristate "Aufs (Advanced multi layered unification filesystem) support"
++ help
++ Aufs is a stackable unification filesystem such as Unionfs,
++ which unifies several directories and provides a merged single
++ directory.
++ In the early days, aufs was entirely re-designed and
++ re-implemented Unionfs Version 1.x series. Introducing many
++ original ideas, approaches and improvements, it becomes totally
++ different from Unionfs while keeping the basic features.
+
-+Note: The header file aufs_type.h is necessary to build aufs-util
-+ as well as "make headers_install" in the kernel source tree.
-+ headers_install is subject to be forgotten, but it is essentially
-+ necessary, not only for building aufs-util.
-+ You may not meet problems without headers_install in some older
-+ version though.
++if AUFS_FS
++choice
++ prompt "Maximum number of branches"
++ default AUFS_BRANCH_MAX_127
++ help
++ Specifies the maximum number of branches (or member directories)
++ in a single aufs. The larger value consumes more system
++ resources and has a minor impact to performance.
++config AUFS_BRANCH_MAX_127
++ bool "127"
++ help
++ Specifies the maximum number of branches (or member directories)
++ in a single aufs. The larger value consumes more system
++ resources and has a minor impact to performance.
++config AUFS_BRANCH_MAX_511
++ bool "511"
++ help
++ Specifies the maximum number of branches (or member directories)
++ in a single aufs. The larger value consumes more system
++ resources and has a minor impact to performance.
++config AUFS_BRANCH_MAX_1023
++ bool "1023"
++ help
++ Specifies the maximum number of branches (or member directories)
++ in a single aufs. The larger value consumes more system
++ resources and has a minor impact to performance.
++config AUFS_BRANCH_MAX_32767
++ bool "32767"
++ help
++ Specifies the maximum number of branches (or member directories)
++ in a single aufs. The larger value consumes more system
++ resources and has a minor impact to performance.
++endchoice
+
-+And then,
-+- read README in aufs-util, build and install it
-+- note that your distribution may contain an obsoleted version of
-+ aufs_type.h in /usr/include/linux or something. When you build aufs
-+ utilities, make sure that your compiler refers the correct aufs header
-+ file which is built by "make headers_install."
-+- if you want to use readdir(3) in userspace or pathconf(3) wrapper,
-+ then run "make install_ulib" too. And refer to the aufs manual in
-+ detail.
++config AUFS_SBILIST
++ bool
++ depends on AUFS_MAGIC_SYSRQ || PROC_FS
++ default y
++ help
++ Automatic configuration for internal use.
++ When aufs supports Magic SysRq or /proc, enabled automatically.
+
-+There several other patches in aufs4-standalone.git. They are all
-+optional. When you meet some problems, they will help you.
-+- aufs4-loopback.patch
-+ Supports a nested loopback mount in a branch-fs. This patch is
-+ unnecessary until aufs produces a message like "you may want to try
-+ another patch for loopback file".
-+- vfs-ino.patch
-+ Modifies a system global kernel internal function get_next_ino() in
-+ order to stop assigning 0 for an inode-number. Not directly related to
-+ aufs, but recommended generally.
-+- tmpfs-idr.patch
-+ Keeps the tmpfs inode number as the lowest value. Effective to reduce
-+ the size of aufs XINO files for tmpfs branch. Also it prevents the
-+ duplication of inode number, which is important for backup tools and
-+ other utilities. When you find aufs XINO files for tmpfs branch
-+ growing too much, try this patch.
-+- lockdep-debug.patch
-+ Because aufs is not only an ordinary filesystem (callee of VFS), but
-+ also a caller of VFS functions for branch filesystems, subclassing of
-+ the internal locks for LOCKDEP is necessary. LOCKDEP is a debugging
-+ feature of linux kernel. If you enable CONFIG_LOCKDEP, then you will
-+ need to apply this debug patch to expand several constant values.
-+ If don't know what LOCKDEP, then you don't have apply this patch.
++config AUFS_HNOTIFY
++ bool "Detect direct branch access (bypassing aufs)"
++ help
++ If you want to modify files on branches directly, eg. bypassing aufs,
++ and want aufs to detect the changes of them fully, then enable this
++ option and use 'udba=notify' mount option.
++ Currently there is only one available configuration, "fsnotify".
++ It will have a negative impact to the performance.
++ See detail in aufs.5.
+
++choice
++ prompt "method" if AUFS_HNOTIFY
++ default AUFS_HFSNOTIFY
++config AUFS_HFSNOTIFY
++ bool "fsnotify"
++ select FSNOTIFY
++endchoice
+
-+4. Usage
-+----------------------------------------
-+At first, make sure aufs-util are installed, and please read the aufs
-+manual, aufs.5 in aufs-util.git tree.
-+$ man -l aufs.5
++config AUFS_EXPORT
++ bool "NFS-exportable aufs"
++ depends on EXPORTFS
++ help
++ If you want to export your mounted aufs via NFS, then enable this
++ option. There are several requirements for this configuration.
++ See detail in aufs.5.
+
-+And then,
-+$ mkdir /tmp/rw /tmp/aufs
-+# mount -t aufs -o br=/tmp/rw:${HOME} none /tmp/aufs
++config AUFS_INO_T_64
++ bool
++ depends on AUFS_EXPORT
++ depends on 64BIT && !(ALPHA || S390)
++ default y
++ help
++ Automatic configuration for internal use.
++ /* typedef unsigned long/int __kernel_ino_t */
++ /* alpha and s390x are int */
+
-+Here is another example. The result is equivalent.
-+# mount -t aufs -o br=/tmp/rw=rw:${HOME}=ro none /tmp/aufs
-+ Or
-+# mount -t aufs -o br:/tmp/rw none /tmp/aufs
-+# mount -o remount,append:${HOME} /tmp/aufs
++config AUFS_XATTR
++ bool "support for XATTR/EA (including Security Labels)"
++ help
++ If your branch fs supports XATTR/EA and you want to make them
++ available in aufs too, then enable this opsion and specify the
++ branch attributes for EA.
++ See detail in aufs.5.
+
-+Then, you can see whole tree of your home dir through /tmp/aufs. If
-+you modify a file under /tmp/aufs, the one on your home directory is
-+not affected, instead the same named file will be newly created under
-+/tmp/rw. And all of your modification to a file will be applied to
-+the one under /tmp/rw. This is called the file based Copy on Write
-+(COW) method.
-+Aufs mount options are described in aufs.5.
-+If you run chroot or something and make your aufs as a root directory,
-+then you need to customize the shutdown script. See the aufs manual in
-+detail.
++config AUFS_FHSM
++ bool "File-based Hierarchical Storage Management"
++ help
++ Hierarchical Storage Management (or HSM) is a well-known feature
++ in the storage world. Aufs provides this feature as file-based.
++ with multiple branches.
++ These multiple branches are prioritized, ie. the topmost one
++ should be the fastest drive and be used heavily.
+
-+Additionally, there are some sample usages of aufs which are a
-+diskless system with network booting, and LiveCD over NFS.
-+See sample dir in CVS tree on SourceForge.
++config AUFS_RDU
++ bool "Readdir in userspace"
++ help
++ Aufs has two methods to provide a merged view for a directory,
++ by a user-space library and by kernel-space natively. The latter
++ is always enabled but sometimes large and slow.
++ If you enable this option, install the library in aufs2-util
++ package, and set some environment variables for your readdir(3),
++ then the work will be handled in user-space which generally
++ shows better performance in most cases.
++ See detail in aufs.5.
+
++config AUFS_SHWH
++ bool "Show whiteouts"
++ help
++ If you want to make the whiteouts in aufs visible, then enable
++ this option and specify 'shwh' mount option. Although it may
++ sounds like philosophy or something, but in technically it
++ simply shows the name of whiteout with keeping its behaviour.
+
-+5. Contact
-+----------------------------------------
-+When you have any problems or strange behaviour in aufs, please let me
-+know with:
-+- /proc/mounts (instead of the output of mount(8))
-+- /sys/module/aufs/*
-+- /sys/fs/aufs/* (if you have them)
-+- /debug/aufs/* (if you have them)
-+- linux kernel version
-+ if your kernel is not plain, for example modified by distributor,
-+ the url where i can download its source is necessary too.
-+- aufs version which was printed at loading the module or booting the
-+ system, instead of the date you downloaded.
-+- configuration (define/undefine CONFIG_AUFS_xxx)
-+- kernel configuration or /proc/config.gz (if you have it)
-+- behaviour which you think to be incorrect
-+- actual operation, reproducible one is better
-+- mailto: aufs-users at lists.sourceforge.net
++config AUFS_BR_RAMFS
++ bool "Ramfs (initramfs/rootfs) as an aufs branch"
++ help
++ If you want to use ramfs as an aufs branch fs, then enable this
++ option. Generally tmpfs is recommended.
++ Aufs prohibited them to be a branch fs by default, because
++ initramfs becomes unusable after switch_root or something
++ generally. If you sets initramfs as an aufs branch and boot your
++ system by switch_root, you will meet a problem easily since the
++ files in initramfs may be inaccessible.
++ Unless you are going to use ramfs as an aufs branch fs without
++ switch_root or something, leave it N.
+
-+Usually, I don't watch the Public Areas(Bugs, Support Requests, Patches,
-+and Feature Requests) on SourceForge. Please join and write to
-+aufs-users ML.
++config AUFS_BR_FUSE
++ bool "Fuse fs as an aufs branch"
++ depends on FUSE_FS
++ select AUFS_POLL
++ help
++ If you want to use fuse-based userspace filesystem as an aufs
++ branch fs, then enable this option.
++ It implements the internal poll(2) operation which is
++ implemented by fuse only (curretnly).
+
++config AUFS_POLL
++ bool
++ help
++ Automatic configuration for internal use.
+
-+6. Acknowledgements
-+----------------------------------------
-+Thanks to everyone who have tried and are using aufs, whoever
-+have reported a bug or any feedback.
++config AUFS_BR_HFSPLUS
++ bool "Hfsplus as an aufs branch"
++ depends on HFSPLUS_FS
++ default y
++ help
++ If you want to use hfsplus fs as an aufs branch fs, then enable
++ this option. This option introduces a small overhead at
++ copying-up a file on hfsplus.
+
-+Especially donators:
-+Tomas Matejicek(slax.org) made a donation (much more than once).
-+ Since Apr 2010, Tomas M (the author of Slax and Linux Live
-+ scripts) is making "doubling" donations.
-+ Unfortunately I cannot list all of the donators, but I really
-+ appreciate.
-+ It ends Aug 2010, but the ordinary donation URL is still available.
-+ <http://sourceforge.net/donate/index.php?group_id=167503>
-+Dai Itasaka made a donation (2007/8).
-+Chuck Smith made a donation (2008/4, 10 and 12).
-+Henk Schoneveld made a donation (2008/9).
-+Chih-Wei Huang, ASUS, CTC donated Eee PC 4G (2008/10).
-+Francois Dupoux made a donation (2008/11).
-+Bruno Cesar Ribas and Luis Carlos Erpen de Bona, C3SL serves public
-+ aufs2 GIT tree (2009/2).
-+William Grant made a donation (2009/3).
-+Patrick Lane made a donation (2009/4).
-+The Mail Archive (mail-archive.com) made donations (2009/5).
-+Nippy Networks (Ed Wildgoose) made a donation (2009/7).
-+New Dream Network, LLC (www.dreamhost.com) made a donation (2009/11).
-+Pavel Pronskiy made a donation (2011/2).
-+Iridium and Inmarsat satellite phone retailer (www.mailasail.com), Nippy
-+ Networks (Ed Wildgoose) made a donation for hardware (2011/3).
-+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).
-+"pemasu from Finland" made a donation (2013/7).
-+The Parted Magic Project made a donation (2013/9 and 11).
-+Pavel Barta made a donation (2013/10).
-+Nikolay Pertsev made a donation (2014/5).
-+James B made a donation (2014/7 and 2015/7).
-+Stefano Di Biase made a donation (2014/8).
-+Daniel Epellei made a donation (2015/1).
-+OmegaPhil made a donation (2016/1).
++config AUFS_BDEV_LOOP
++ bool
++ depends on BLK_DEV_LOOP
++ default y
++ help
++ Automatic configuration for internal use.
++ Convert =[ym] into =y.
+
-+Thank you very much.
-+Donations are always, including future donations, very important and
-+helpful for me to keep on developing aufs.
++config AUFS_DEBUG
++ bool "Debug aufs"
++ help
++ Enable this to compile aufs internal debug code.
++ It will have a negative impact to the performance.
+
++config AUFS_MAGIC_SYSRQ
++ bool
++ depends on AUFS_DEBUG && MAGIC_SYSRQ
++ default y
++ help
++ Automatic configuration for internal use.
++ When aufs supports Magic SysRq, enabled automatically.
++endif
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/Makefile linux-4.4/fs/aufs/Makefile
+--- linux-4.4/fs/aufs/Makefile 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/Makefile 2021-02-24 17:28:14.408808278 +0100
+@@ -0,0 +1,44 @@
+
-+7.
-+----------------------------------------
-+If you are an experienced user, no explanation is needed. Aufs is
-+just a linux filesystem.
++include ${src}/magic.mk
++ifeq (${CONFIG_AUFS_FS},m)
++include ${src}/conf.mk
++endif
++-include ${src}/priv_def.mk
+
++# cf. include/linux/kernel.h
++# enable pr_debug
++ccflags-y += -DDEBUG
++# sparse requires the full pathname
++ifdef M
++ccflags-y += -include ${M}/../../include/uapi/linux/aufs_type.h
++else
++ccflags-y += -include ${srctree}/include/uapi/linux/aufs_type.h
++endif
+
-+Enjoy!
++obj-$(CONFIG_AUFS_FS) += aufs.o
++aufs-y := module.o sbinfo.o super.o branch.o xino.o sysaufs.o opts.o \
++ wkq.o vfsub.o dcsub.o \
++ cpup.o whout.o wbr_policy.o \
++ dinfo.o dentry.o \
++ dynop.o \
++ finfo.o file.o f_op.o \
++ dir.o vdir.o \
++ iinfo.o inode.o i_op.o i_op_add.o i_op_del.o i_op_ren.o \
++ mvdown.o ioctl.o
+
-+# Local variables: ;
-+# mode: text;
-+# End: ;
-diff -urN /usr/share/empty/fs/aufs/aufs.h linux/fs/aufs/aufs.h
---- /usr/share/empty/fs/aufs/aufs.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/aufs.h 2016-02-28 11:26:32.569971135 +0100
++# all are boolean
++aufs-$(CONFIG_PROC_FS) += procfs.o plink.o
++aufs-$(CONFIG_SYSFS) += sysfs.o
++aufs-$(CONFIG_DEBUG_FS) += dbgaufs.o
++aufs-$(CONFIG_AUFS_BDEV_LOOP) += loop.o
++aufs-$(CONFIG_AUFS_HNOTIFY) += hnotify.o
++aufs-$(CONFIG_AUFS_HFSNOTIFY) += hfsnotify.o
++aufs-$(CONFIG_AUFS_EXPORT) += export.o
++aufs-$(CONFIG_AUFS_XATTR) += xattr.o
++aufs-$(CONFIG_FS_POSIX_ACL) += posix_acl.o
++aufs-$(CONFIG_AUFS_FHSM) += fhsm.o
++aufs-$(CONFIG_AUFS_POLL) += poll.o
++aufs-$(CONFIG_AUFS_RDU) += rdu.o
++aufs-$(CONFIG_AUFS_BR_HFSPLUS) += hfsplus.o
++aufs-$(CONFIG_AUFS_DEBUG) += debug.o
++aufs-$(CONFIG_AUFS_MAGIC_SYSRQ) += sysrq.o
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/aufs.h linux-4.4/fs/aufs/aufs.h
+--- linux-4.4/fs/aufs/aufs.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/aufs.h 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -2761,9 +2284,9 @@ diff -urN /usr/share/empty/fs/aufs/aufs.h linux/fs/aufs/aufs.h
+
+#endif /* __KERNEL__ */
+#endif /* __AUFS_H__ */
-diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
---- /usr/share/empty/fs/aufs/branch.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/branch.c 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/branch.c linux-4.4/fs/aufs/branch.c
+--- linux-4.4/fs/aufs/branch.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/branch.c 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,1407 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -4172,9 +3695,9 @@ diff -urN /usr/share/empty/fs/aufs/branch.c linux/fs/aufs/branch.c
+
+ return err;
+}
-diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
---- /usr/share/empty/fs/aufs/branch.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/branch.h 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/branch.h linux-4.4/fs/aufs/branch.h
+--- linux-4.4/fs/aufs/branch.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/branch.h 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,279 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -4455,9 +3978,9 @@ diff -urN /usr/share/empty/fs/aufs/branch.h linux/fs/aufs/branch.h
+
+#endif /* __KERNEL__ */
+#endif /* __AUFS_BRANCH_H__ */
-diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
---- /usr/share/empty/fs/aufs/conf.mk 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/conf.mk 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/conf.mk linux-4.4/fs/aufs/conf.mk
+--- linux-4.4/fs/aufs/conf.mk 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/conf.mk 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,38 @@
+
+AuConfStr = CONFIG_AUFS_FS=${CONFIG_AUFS_FS}
@@ -4497,9 +4020,9 @@ diff -urN /usr/share/empty/fs/aufs/conf.mk linux/fs/aufs/conf.mk
+${obj}/sysfs.o: ${AuConfName}
+
+-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-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/cpup.c linux-4.4/fs/aufs/cpup.c
+--- linux-4.4/fs/aufs/cpup.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/cpup.c 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,1379 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -5880,9 +5403,9 @@ diff -urN /usr/share/empty/fs/aufs/cpup.c linux/fs/aufs/cpup.c
+ dput(parent);
+ return err;
+}
-diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
---- /usr/share/empty/fs/aufs/cpup.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/cpup.h 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/cpup.h linux-4.4/fs/aufs/cpup.h
+--- linux-4.4/fs/aufs/cpup.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/cpup.h 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -5978,9 +5501,9 @@ diff -urN /usr/share/empty/fs/aufs/cpup.h linux/fs/aufs/cpup.h
+
+#endif /* __KERNEL__ */
+#endif /* __AUFS_CPUP_H__ */
-diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
---- /usr/share/empty/fs/aufs/dbgaufs.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dbgaufs.c 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dbgaufs.c linux-4.4/fs/aufs/dbgaufs.c
+--- linux-4.4/fs/aufs/dbgaufs.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dbgaufs.c 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,432 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -6414,9 +5937,9 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.c linux/fs/aufs/dbgaufs.c
+ err = 0;
+ return err;
+}
-diff -urN /usr/share/empty/fs/aufs/dbgaufs.h linux/fs/aufs/dbgaufs.h
---- /usr/share/empty/fs/aufs/dbgaufs.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dbgaufs.h 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dbgaufs.h linux-4.4/fs/aufs/dbgaufs.h
+--- linux-4.4/fs/aufs/dbgaufs.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dbgaufs.h 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -6466,9 +5989,9 @@ diff -urN /usr/share/empty/fs/aufs/dbgaufs.h linux/fs/aufs/dbgaufs.h
+
+#endif /* __KERNEL__ */
+#endif /* __DBGAUFS_H__ */
-diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
---- /usr/share/empty/fs/aufs/dcsub.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dcsub.c 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dcsub.c linux-4.4/fs/aufs/dcsub.c
+--- linux-4.4/fs/aufs/dcsub.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dcsub.c 2021-02-24 17:28:14.398807954 +0100
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -6694,9 +6217,9 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.c linux/fs/aufs/dcsub.c
+
+ return path_is_under(path + 0, path + 1);
+}
-diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
---- /usr/share/empty/fs/aufs/dcsub.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dcsub.h 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dcsub.h linux-4.4/fs/aufs/dcsub.h
+--- linux-4.4/fs/aufs/dcsub.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dcsub.h 2021-02-24 17:28:14.402141395 +0100
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -6834,9 +6357,9 @@ diff -urN /usr/share/empty/fs/aufs/dcsub.h linux/fs/aufs/dcsub.h
+
+#endif /* __KERNEL__ */
+#endif /* __AUFS_DCSUB_H__ */
-diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
---- /usr/share/empty/fs/aufs/debug.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/debug.c 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/debug.c linux-4.4/fs/aufs/debug.c
+--- linux-4.4/fs/aufs/debug.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/debug.c 2021-02-24 17:28:14.402141395 +0100
@@ -0,0 +1,438 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -7276,9 +6799,9 @@ diff -urN /usr/share/empty/fs/aufs/debug.c linux/fs/aufs/debug.c
+
+ return 0;
+}
-diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
---- /usr/share/empty/fs/aufs/debug.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/debug.h 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/debug.h linux-4.4/fs/aufs/debug.h
+--- linux-4.4/fs/aufs/debug.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/debug.h 2021-02-24 17:28:14.402141395 +0100
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -7505,9 +7028,9 @@ diff -urN /usr/share/empty/fs/aufs/debug.h linux/fs/aufs/debug.h
+
+#endif /* __KERNEL__ */
+#endif /* __AUFS_DEBUG_H__ */
-diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
---- /usr/share/empty/fs/aufs/dentry.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dentry.c 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dentry.c linux-4.4/fs/aufs/dentry.c
+--- linux-4.4/fs/aufs/dentry.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dentry.c 2021-02-24 17:28:14.402141395 +0100
@@ -0,0 +1,1136 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -8645,9 +8168,9 @@ diff -urN /usr/share/empty/fs/aufs/dentry.c linux/fs/aufs/dentry.c
+const struct dentry_operations aufs_dop_noreval = {
+ .d_release = aufs_d_release
+};
-diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
---- /usr/share/empty/fs/aufs/dentry.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dentry.h 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dentry.h linux-4.4/fs/aufs/dentry.h
+--- linux-4.4/fs/aufs/dentry.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dentry.h 2021-02-24 17:28:14.402141395 +0100
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -8883,9 +8406,9 @@ diff -urN /usr/share/empty/fs/aufs/dentry.h linux/fs/aufs/dentry.h
+
+#endif /* __KERNEL__ */
+#endif /* __AUFS_DENTRY_H__ */
-diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
---- /usr/share/empty/fs/aufs/dinfo.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dinfo.c 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dinfo.c linux-4.4/fs/aufs/dinfo.c
+--- linux-4.4/fs/aufs/dinfo.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dinfo.c 2021-02-24 17:28:14.402141395 +0100
@@ -0,0 +1,550 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -9437,9 +8960,9 @@ diff -urN /usr/share/empty/fs/aufs/dinfo.c linux/fs/aufs/dinfo.c
+ return bindex;
+ return -1;
+}
-diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
---- /usr/share/empty/fs/aufs/dir.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dir.c 2016-02-28 11:26:32.569971135 +0100
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dir.c linux-4.4/fs/aufs/dir.c
+--- linux-4.4/fs/aufs/dir.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dir.c 2021-02-24 17:28:14.402141395 +0100
@@ -0,0 +1,758 @@
+/*
+ * Copyright (C) 2005-2016 Junjiro R. Okajima
@@ -10116,95 +9639,603 @@ diff -urN /usr/share/empty/fs/aufs/dir.c linux/fs/aufs/dir.c
+
+ SiMustAnyLock(dentry->d_sb);
+
-+ rdhash = au_sbi(dentry->d_sb)->si_rdhash;
-+ if (!rdhash)
-+ rdhash = au_rdhash_est(au_dir_size(/*file*/NULL, dentry));
-+ err = au_nhash_alloc(&whlist, rdhash, GFP_NOFS);
-+ if (unlikely(err))
++ rdhash = au_sbi(dentry->d_sb)->si_rdhash;
++ if (!rdhash)
++ rdhash = au_rdhash_est(au_dir_size(/*file*/NULL, dentry));
++ err = au_nhash_alloc(&whlist, rdhash, GFP_NOFS);
++ if (unlikely(err))
++ goto out;
++
++ arg.flags = 0;
++ arg.whlist = &whlist;
++ bstart = au_dbstart(dentry);
++ if (au_opt_test(au_mntflags(dentry->d_sb), SHWH))
++ au_fset_testempty(arg.flags, SHWH);
++ test_empty = do_test_empty;
++ if (au_opt_test(au_mntflags(dentry->d_sb), DIRPERM1))
++ test_empty = sio_test_empty;
++ arg.bindex = bstart;
++ err = test_empty(dentry, &arg);
++ if (unlikely(err))
++ goto out_whlist;
++
++ au_fset_testempty(arg.flags, WHONLY);
++ btail = au_dbtaildir(dentry);
++ for (bindex = bstart + 1; !err && bindex <= btail; bindex++) {
++ struct dentry *h_dentry;
++
++ h_dentry = au_h_dptr(dentry, bindex);
++ if (h_dentry && d_is_positive(h_dentry)) {
++ arg.bindex = bindex;
++ err = test_empty(dentry, &arg);
++ }
++ }
++
++out_whlist:
++ au_nhash_wh_free(&whlist);
++out:
++ return err;
++}
++
++int au_test_empty(struct dentry *dentry, struct au_nhash *whlist)
++{
++ int err;
++ struct test_empty_arg arg = {
++ .ctx = {
++ .actor = test_empty_cb
++ }
++ };
++ aufs_bindex_t bindex, btail;
++
++ err = 0;
++ arg.whlist = whlist;
++ arg.flags = AuTestEmpty_WHONLY;
++ if (au_opt_test(au_mntflags(dentry->d_sb), SHWH))
++ au_fset_testempty(arg.flags, SHWH);
++ btail = au_dbtaildir(dentry);
++ for (bindex = au_dbstart(dentry); !err && bindex <= btail; bindex++) {
++ struct dentry *h_dentry;
++
++ h_dentry = au_h_dptr(dentry, bindex);
++ if (h_dentry && d_is_positive(h_dentry)) {
++ arg.bindex = bindex;
++ err = sio_test_empty(dentry, &arg);
++ }
++ }
++
++ return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++const struct file_operations aufs_dir_fop = {
++ .owner = THIS_MODULE,
++ .llseek = default_llseek,
++ .read = generic_read_dir,
++ .iterate = aufs_iterate,
++ .unlocked_ioctl = aufs_ioctl_dir,
++#ifdef CONFIG_COMPAT
++ .compat_ioctl = aufs_compat_ioctl_dir,
++#endif
++ .open = aufs_open_dir,
++ .release = aufs_release_dir,
++ .flush = aufs_flush_dir,
++ .fsync = aufs_fsync_dir
++};
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dir.h linux-4.4/fs/aufs/dir.h
+--- linux-4.4/fs/aufs/dir.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dir.h 2021-02-24 17:28:14.402141395 +0100
+@@ -0,0 +1,131 @@
++/*
++ * Copyright (C) 2005-2016 Junjiro R. Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
++ */
++
++/*
++ * directory operations
++ */
++
++#ifndef __AUFS_DIR_H__
++#define __AUFS_DIR_H__
++
++#ifdef __KERNEL__
++
++#include <linux/fs.h>
++
++/* ---------------------------------------------------------------------- */
++
++/* need to be faster and smaller */
++
++struct au_nhash {
++ unsigned int nh_num;
++ struct hlist_head *nh_head;
++};
++
++struct au_vdir_destr {
++ unsigned char len;
++ unsigned char name[0];
++} __packed;
++
++struct au_vdir_dehstr {
++ struct hlist_node hash;
++ struct au_vdir_destr *str;
++} ____cacheline_aligned_in_smp;
++
++struct au_vdir_de {
++ ino_t de_ino;
++ unsigned char de_type;
++ /* caution: packed */
++ struct au_vdir_destr de_str;
++} __packed;
++
++struct au_vdir_wh {
++ struct hlist_node wh_hash;
++#ifdef CONFIG_AUFS_SHWH
++ ino_t wh_ino;
++ aufs_bindex_t wh_bindex;
++ unsigned char wh_type;
++#else
++ aufs_bindex_t wh_bindex;
++#endif
++ /* caution: packed */
++ struct au_vdir_destr wh_str;
++} __packed;
++
++union au_vdir_deblk_p {
++ unsigned char *deblk;
++ struct au_vdir_de *de;
++};
++
++struct au_vdir {
++ unsigned char **vd_deblk;
++ unsigned long vd_nblk;
++ struct {
++ unsigned long ul;
++ union au_vdir_deblk_p p;
++ } vd_last;
++
++ unsigned long vd_version;
++ unsigned int vd_deblk_sz;
++ unsigned long vd_jiffy;
++} ____cacheline_aligned_in_smp;
++
++/* ---------------------------------------------------------------------- */
++
++/* dir.c */
++extern const struct file_operations aufs_dir_fop;
++void au_add_nlink(struct inode *dir, struct inode *h_dir);
++void au_sub_nlink(struct inode *dir, struct inode *h_dir);
++loff_t au_dir_size(struct file *file, struct dentry *dentry);
++void au_dir_ts(struct inode *dir, aufs_bindex_t bsrc);
++int au_test_empty_lower(struct dentry *dentry);
++int au_test_empty(struct dentry *dentry, struct au_nhash *whlist);
++
++/* vdir.c */
++unsigned int au_rdhash_est(loff_t sz);
++int au_nhash_alloc(struct au_nhash *nhash, unsigned int num_hash, gfp_t gfp);
++void au_nhash_wh_free(struct au_nhash *whlist);
++int au_nhash_test_longer_wh(struct au_nhash *whlist, aufs_bindex_t btgt,
++ int limit);
++int au_nhash_test_known_wh(struct au_nhash *whlist, char *name, int nlen);
++int au_nhash_append_wh(struct au_nhash *whlist, char *name, int nlen, ino_t ino,
++ unsigned int d_type, aufs_bindex_t bindex,
++ unsigned char shwh);
++void au_vdir_free(struct au_vdir *vdir);
++int au_vdir_init(struct file *file);
++int au_vdir_fill_de(struct file *file, struct dir_context *ctx);
++
++/* ioctl.c */
++long aufs_ioctl_dir(struct file *file, unsigned int cmd, unsigned long arg);
++
++#ifdef CONFIG_AUFS_RDU
++/* rdu.c */
++long au_rdu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
++#ifdef CONFIG_COMPAT
++long au_rdu_compat_ioctl(struct file *file, unsigned int cmd,
++ unsigned long arg);
++#endif
++#else
++AuStub(long, au_rdu_ioctl, return -EINVAL, struct file *file,
++ unsigned int cmd, unsigned long arg)
++#ifdef CONFIG_COMPAT
++AuStub(long, au_rdu_compat_ioctl, return -EINVAL, struct file *file,
++ unsigned int cmd, unsigned long arg)
++#endif
++#endif
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DIR_H__ */
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dynop.c linux-4.4/fs/aufs/dynop.c
+--- linux-4.4/fs/aufs/dynop.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dynop.c 2021-02-24 17:28:14.402141395 +0100
+@@ -0,0 +1,369 @@
++/*
++ * Copyright (C) 2010-2016 Junjiro R. Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
++ */
++
++/*
++ * dynamically customizable operations for regular files
++ */
++
++#include "aufs.h"
++
++#define DyPrSym(key) AuDbgSym(key->dk_op.dy_hop)
++
++/*
++ * How large will these lists be?
++ * Usually just a few elements, 20-30 at most for each, I guess.
++ */
++static struct au_splhead dynop[AuDyLast];
++
++static struct au_dykey *dy_gfind_get(struct au_splhead *spl, const void *h_op)
++{
++ struct au_dykey *key, *tmp;
++ struct list_head *head;
++
++ key = NULL;
++ head = &spl->head;
++ rcu_read_lock();
++ list_for_each_entry_rcu(tmp, head, dk_list)
++ if (tmp->dk_op.dy_hop == h_op) {
++ key = tmp;
++ kref_get(&key->dk_kref);
++ break;
++ }
++ rcu_read_unlock();
++
++ return key;
++}
++
++static struct au_dykey *dy_bradd(struct au_branch *br, struct au_dykey *key)
++{
++ struct au_dykey **k, *found;
++ const void *h_op = key->dk_op.dy_hop;
++ int i;
++
++ found = NULL;
++ k = br->br_dykey;
++ for (i = 0; i < AuBrDynOp; i++)
++ if (k[i]) {
++ if (k[i]->dk_op.dy_hop == h_op) {
++ found = k[i];
++ break;
++ }
++ } else
++ break;
++ if (!found) {
++ spin_lock(&br->br_dykey_lock);
++ for (; i < AuBrDynOp; i++)
++ if (k[i]) {
++ if (k[i]->dk_op.dy_hop == h_op) {
++ found = k[i];
++ break;
++ }
++ } else {
++ k[i] = key;
++ break;
++ }
++ spin_unlock(&br->br_dykey_lock);
++ BUG_ON(i == AuBrDynOp); /* expand the array */
++ }
++
++ return found;
++}
++
++/* kref_get() if @key is already added */
++static struct au_dykey *dy_gadd(struct au_splhead *spl, struct au_dykey *key)
++{
++ struct au_dykey *tmp, *found;
++ struct list_head *head;
++ const void *h_op = key->dk_op.dy_hop;
++
++ found = NULL;
++ head = &spl->head;
++ spin_lock(&spl->spin);
++ list_for_each_entry(tmp, head, dk_list)
++ if (tmp->dk_op.dy_hop == h_op) {
++ kref_get(&tmp->dk_kref);
++ found = tmp;
++ break;
++ }
++ if (!found)
++ list_add_rcu(&key->dk_list, head);
++ spin_unlock(&spl->spin);
++
++ if (!found)
++ DyPrSym(key);
++ return found;
++}
++
++static void dy_free_rcu(struct rcu_head *rcu)
++{
++ struct au_dykey *key;
++
++ key = container_of(rcu, struct au_dykey, dk_rcu);
++ DyPrSym(key);
++ kfree(key);
++}
++
++static void dy_free(struct kref *kref)
++{
++ struct au_dykey *key;
++ struct au_splhead *spl;
++
++ key = container_of(kref, struct au_dykey, dk_kref);
++ spl = dynop + key->dk_op.dy_type;
++ au_spl_del_rcu(&key->dk_list, spl);
++ call_rcu(&key->dk_rcu, dy_free_rcu);
++}
++
++void au_dy_put(struct au_dykey *key)
++{
++ kref_put(&key->dk_kref, dy_free);
++}
++
++/* ---------------------------------------------------------------------- */
++
++#define DyDbgSize(cnt, op) AuDebugOn(cnt != sizeof(op)/sizeof(void *))
++
++#ifdef CONFIG_AUFS_DEBUG
++#define DyDbgDeclare(cnt) unsigned int cnt = 0
++#define DyDbgInc(cnt) do { cnt++; } while (0)
++#else
++#define DyDbgDeclare(cnt) do {} while (0)
++#define DyDbgInc(cnt) do {} while (0)
++#endif
++
++#define DySet(func, dst, src, h_op, h_sb) do { \
++ DyDbgInc(cnt); \
++ if (h_op->func) { \
++ if (src.func) \
++ dst.func = src.func; \
++ else \
++ AuDbg("%s %s\n", au_sbtype(h_sb), #func); \
++ } \
++} while (0)
++
++#define DySetForce(func, dst, src) do { \
++ AuDebugOn(!src.func); \
++ DyDbgInc(cnt); \
++ dst.func = src.func; \
++} while (0)
++
++#define DySetAop(func) \
++ DySet(func, dyaop->da_op, aufs_aop, h_aop, h_sb)
++#define DySetAopForce(func) \
++ DySetForce(func, dyaop->da_op, aufs_aop)
++
++static void dy_aop(struct au_dykey *key, const void *h_op,
++ struct super_block *h_sb __maybe_unused)
++{
++ struct au_dyaop *dyaop = (void *)key;
++ const struct address_space_operations *h_aop = h_op;
++ DyDbgDeclare(cnt);
++
++ AuDbg("%s\n", au_sbtype(h_sb));
++
++ DySetAop(writepage);
++ DySetAopForce(readpage); /* force */
++ DySetAop(writepages);
++ DySetAop(set_page_dirty);
++ DySetAop(readpages);
++ DySetAop(write_begin);
++ DySetAop(write_end);
++ DySetAop(bmap);
++ DySetAop(invalidatepage);
++ DySetAop(releasepage);
++ DySetAop(freepage);
++ /* this one will be changed according to an aufs mount option */
++ DySetAop(direct_IO);
++ DySetAop(migratepage);
++ DySetAop(launder_page);
++ DySetAop(is_partially_uptodate);
++ DySetAop(is_dirty_writeback);
++ DySetAop(error_remove_page);
++ DySetAop(swap_activate);
++ DySetAop(swap_deactivate);
++
++ DyDbgSize(cnt, *h_aop);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static void dy_bug(struct kref *kref)
++{
++ BUG();
++}
++
++static struct au_dykey *dy_get(struct au_dynop *op, struct au_branch *br)
++{
++ struct au_dykey *key, *old;
++ struct au_splhead *spl;
++ struct op {
++ unsigned int sz;
++ void (*set)(struct au_dykey *key, const void *h_op,
++ struct super_block *h_sb __maybe_unused);
++ };
++ static const struct op a[] = {
++ [AuDy_AOP] = {
++ .sz = sizeof(struct au_dyaop),
++ .set = dy_aop
++ }
++ };
++ const struct op *p;
++
++ spl = dynop + op->dy_type;
++ key = dy_gfind_get(spl, op->dy_hop);
++ if (key)
++ goto out_add; /* success */
++
++ p = a + op->dy_type;
++ key = kzalloc(p->sz, GFP_NOFS);
++ if (unlikely(!key)) {
++ key = ERR_PTR(-ENOMEM);
++ goto out;
++ }
++
++ key->dk_op.dy_hop = op->dy_hop;
++ kref_init(&key->dk_kref);
++ p->set(key, op->dy_hop, au_br_sb(br));
++ old = dy_gadd(spl, key);
++ if (old) {
++ kfree(key);
++ key = old;
++ }
++
++out_add:
++ old = dy_bradd(br, key);
++ if (old)
++ /* its ref-count should never be zero here */
++ kref_put(&key->dk_kref, dy_bug);
++out:
++ return key;
++}
++
++/* ---------------------------------------------------------------------- */
++/*
++ * Aufs prohibits O_DIRECT by defaut even if the branch supports it.
++ * This behaviour is necessary to return an error from open(O_DIRECT) instead
++ * of the succeeding I/O. The dio mount option enables O_DIRECT and makes
++ * open(O_DIRECT) always succeed, but the succeeding I/O may return an error.
++ * See the aufs manual in detail.
++ */
++static void dy_adx(struct au_dyaop *dyaop, int do_dx)
++{
++ if (!do_dx)
++ dyaop->da_op.direct_IO = NULL;
++ else
++ dyaop->da_op.direct_IO = aufs_aop.direct_IO;
++}
++
++static struct au_dyaop *dy_aget(struct au_branch *br,
++ const struct address_space_operations *h_aop,
++ int do_dx)
++{
++ struct au_dyaop *dyaop;
++ struct au_dynop op;
++
++ op.dy_type = AuDy_AOP;
++ op.dy_haop = h_aop;
++ dyaop = (void *)dy_get(&op, br);
++ if (IS_ERR(dyaop))
+ goto out;
++ dy_adx(dyaop, do_dx);
+
-+ arg.flags = 0;
-+ arg.whlist = &whlist;
-+ bstart = au_dbstart(dentry);
-+ if (au_opt_test(au_mntflags(dentry->d_sb), SHWH))
-+ au_fset_testempty(arg.flags, SHWH);
-+ test_empty = do_test_empty;
-+ if (au_opt_test(au_mntflags(dentry->d_sb), DIRPERM1))
-+ test_empty = sio_test_empty;
-+ arg.bindex = bstart;
-+ err = test_empty(dentry, &arg);
-+ if (unlikely(err))
-+ goto out_whlist;
++out:
++ return dyaop;
++}
+
-+ au_fset_testempty(arg.flags, WHONLY);
-+ btail = au_dbtaildir(dentry);
-+ for (bindex = bstart + 1; !err && bindex <= btail; bindex++) {
-+ struct dentry *h_dentry;
++int au_dy_iaop(struct inode *inode, aufs_bindex_t bindex,
++ struct inode *h_inode)
++{
++ int err, do_dx;
++ struct super_block *sb;
++ struct au_branch *br;
++ struct au_dyaop *dyaop;
+
-+ h_dentry = au_h_dptr(dentry, bindex);
-+ if (h_dentry && d_is_positive(h_dentry)) {
-+ arg.bindex = bindex;
-+ err = test_empty(dentry, &arg);
-+ }
-+ }
++ AuDebugOn(!S_ISREG(h_inode->i_mode));
++ IiMustWriteLock(inode);
++
++ sb = inode->i_sb;
++ br = au_sbr(sb, bindex);
++ do_dx = !!au_opt_test(au_mntflags(sb), DIO);
++ dyaop = dy_aget(br, h_inode->i_mapping->a_ops, do_dx);
++ err = PTR_ERR(dyaop);
++ if (IS_ERR(dyaop))
++ /* unnecessary to call dy_fput() */
++ goto out;
++
++ err = 0;
++ inode->i_mapping->a_ops = &dyaop->da_op;
+
-+out_whlist:
-+ au_nhash_wh_free(&whlist);
+out:
+ return err;
+}
+
-+int au_test_empty(struct dentry *dentry, struct au_nhash *whlist)
++/*
++ * Is it safe to replace a_ops during the inode/file is in operation?
++ * Yes, I hope so.
++ */
++int au_dy_irefresh(struct inode *inode)
+{
+ int err;
-+ struct test_empty_arg arg = {
-+ .ctx = {
-+ .actor = test_empty_cb
-+ }
-+ };
-+ aufs_bindex_t bindex, btail;
++ aufs_bindex_t bstart;
++ struct inode *h_inode;
+
+ err = 0;
-+ arg.whlist = whlist;
-+ arg.flags = AuTestEmpty_WHONLY;
-+ if (au_opt_test(au_mntflags(dentry->d_sb), SHWH))
-+ au_fset_testempty(arg.flags, SHWH);
-+ btail = au_dbtaildir(dentry);
-+ for (bindex = au_dbstart(dentry); !err && bindex <= btail; bindex++) {
-+ struct dentry *h_dentry;
-+
-+ h_dentry = au_h_dptr(dentry, bindex);
-+ if (h_dentry && d_is_positive(h_dentry)) {
-+ arg.bindex = bindex;
-+ err = sio_test_empty(dentry, &arg);
-+ }
++ if (S_ISREG(inode->i_mode)) {
++ bstart = au_ibstart(inode);
++ h_inode = au_h_iptr(inode, bstart);
++ err = au_dy_iaop(inode, bstart, h_inode);
+ }
-+
+ return err;
+}
+
++void au_dy_arefresh(int do_dx)
++{
++ struct au_splhead *spl;
++ struct list_head *head;
++ struct au_dykey *key;
++
++ spl = dynop + AuDy_AOP;
++ head = &spl->head;
++ spin_lock(&spl->spin);
++ list_for_each_entry(key, head, dk_list)
++ dy_adx((void *)key, do_dx);
++ spin_unlock(&spl->spin);
++}
++
+/* ---------------------------------------------------------------------- */
+
-+const struct file_operations aufs_dir_fop = {
-+ .owner = THIS_MODULE,
-+ .llseek = default_llseek,
-+ .read = generic_read_dir,
-+ .iterate = aufs_iterate,
-+ .unlocked_ioctl = aufs_ioctl_dir,
-+#ifdef CONFIG_COMPAT
-+ .compat_ioctl = aufs_compat_ioctl_dir,
-+#endif
-+ .open = aufs_open_dir,
-+ .release = aufs_release_dir,
-+ .flush = aufs_flush_dir,
-+ .fsync = aufs_fsync_dir
-+};
-diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
---- /usr/share/empty/fs/aufs/dir.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dir.h 2016-02-28 11:26:32.569971135 +0100
-@@ -0,0 +1,131 @@
++void __init au_dy_init(void)
++{
++ int i;
++
++ /* make sure that 'struct au_dykey *' can be any type */
++ BUILD_BUG_ON(offsetof(struct au_dyaop, da_key));
++
++ for (i = 0; i < AuDyLast; i++)
++ au_spl_init(dynop + i);
++}
++
++void au_dy_fin(void)
++{
++ int i;
++
++ for (i = 0; i < AuDyLast; i++)
++ WARN_ON(!list_empty(&dynop[i].head));
++}
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/dynop.h linux-4.4/fs/aufs/dynop.h
+--- linux-4.4/fs/aufs/dynop.h 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/dynop.h 2021-02-24 17:28:14.402141395 +0100
+@@ -0,0 +1,74 @@
+/*
-+ * Copyright (C) 2005-2016 Junjiro R. Okajima
++ * Copyright (C) 2010-2016 Junjiro R. Okajima
+ *
+ * This program, aufs is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
@@ -10221,498 +10252,904 @@ diff -urN /usr/share/empty/fs/aufs/dir.h linux/fs/aufs/dir.h
+ */
+
+/*
-+ * directory operations
++ * dynamically customizable operations (for regular files only)
+ */
+
-+#ifndef __AUFS_DIR_H__
-+#define __AUFS_DIR_H__
++#ifndef __AUFS_DYNOP_H__
++#define __AUFS_DYNOP_H__
+
+#ifdef __KERNEL__
+
+#include <linux/fs.h>
++#include <linux/kref.h>
++
++enum {AuDy_AOP, AuDyLast};
++
++struct au_dynop {
++ int dy_type;
++ union {
++ const void *dy_hop;
++ const struct address_space_operations *dy_haop;
++ };
++};
++
++struct au_dykey {
++ union {
++ struct list_head dk_list;
++ struct rcu_head dk_rcu;
++ };
++ struct au_dynop dk_op;
++
++ /*
++ * during I am in the branch local array, kref is gotten. when the
++ * branch is removed, kref is put.
++ */
++ struct kref dk_kref;
++};
++
++/* stop unioning since their sizes are very different from each other */
++struct au_dyaop {
++ struct au_dykey da_key;
++ struct address_space_operations da_op; /* not const */
++};
+
+/* ---------------------------------------------------------------------- */
+
-+/* need to be faster and smaller */
++/* dynop.c */
++struct au_branch;
++void au_dy_put(struct au_dykey *key);
++int au_dy_iaop(struct inode *inode, aufs_bindex_t bindex,
++ struct inode *h_inode);
++int au_dy_irefresh(struct inode *inode);
++void au_dy_arefresh(int do_dio);
+
-+struct au_nhash {
-+ unsigned int nh_num;
-+ struct hlist_head *nh_head;
++void __init au_dy_init(void);
++void au_dy_fin(void);
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_DYNOP_H__ */
+diff -urNp -x '*.orig' linux-4.4/fs/aufs/export.c linux-4.4/fs/aufs/export.c
+--- linux-4.4/fs/aufs/export.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-4.4/fs/aufs/export.c 2021-02-24 17:28:14.402141395 +0100
+@@ -0,0 +1,832 @@
++/*
++ * Copyright (C) 2005-2016 Junjiro R. Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program. If not, see <http://www.gnu.org/licenses/>.
++ */
++
++/*
++ * export via nfs
++ */
++
++#include <linux/exportfs.h>
++#include <linux/fs_struct.h>
++#include <linux/namei.h>
++#include <linux/nsproxy.h>
++#include <linux/random.h>
++#include <linux/writeback.h>
++#include "../fs/mount.h"
++#include "aufs.h"
++
++union conv {
++#ifdef CONFIG_AUFS_INO_T_64
++ __u32 a[2];
++#else
++ __u32 a[1];
++#endif
++ ino_t ino;
+};
+
-+struct au_vdir_destr {
-+ unsigned char len;
-+ unsigned char name[0];
-+} __packed;
++static ino_t decode_ino(__u32 *a)
++{
++ union conv u;
+
-+struct au_vdir_dehstr {
-+ struct hlist_node hash;
-+ struct au_vdir_destr *str;
-+} ____cacheline_aligned_in_smp;
++ BUILD_BUG_ON(sizeof(u.ino) != sizeof(u.a));
++ u.a[0] = a[0];
++#ifdef CONFIG_AUFS_INO_T_64
++ u.a[1] = a[1];
++#endif
++ return u.ino;
++}
+
-+struct au_vdir_de {
-+ ino_t de_ino;
-+ unsigned char de_type;
-+ /* caution: packed */
-+ struct au_vdir_destr de_str;
-+} __packed;
++static void encode_ino(__u32 *a, ino_t ino)
++{
++ union conv u;
+
-+struct au_vdir_wh {
-+ struct hlist_node wh_hash;
-+#ifdef CONFIG_AUFS_SHWH
-+ ino_t wh_ino;
-+ aufs_bindex_t wh_bindex;
-+ unsigned char wh_type;
++ u.ino = ino;
++ a[0] = u.a[0];
++#ifdef CONFIG_AUFS_INO_T_64
++ a[1] = u.a[1];
++#endif
++}
++
++/* NFS file handle */
++enum {
++ Fh_br_id,
++ Fh_sigen,
++#ifdef CONFIG_AUFS_INO_T_64
++ /* support 64bit inode number */
++ Fh_ino1,
++ Fh_ino2,
++ Fh_dir_ino1,
++ Fh_dir_ino2,
+#else
-+ aufs_bindex_t wh_bindex;
++ Fh_ino1,
++ Fh_dir_ino1,
+#endif
-+ /* caution: packed */
-+ struct au_vdir_destr wh_str;
-+} __packed;
++ Fh_igen,
++ Fh_h_type,
++ Fh_tail,
+
-+union au_vdir_deblk_p {
-+ unsigned char *deblk;
-+ struct au_vdir_de *de;
++ Fh_ino = Fh_ino1,
++ Fh_dir_ino = Fh_dir_ino1
+};
+
-+struct au_vdir {
-+ unsigned char **vd_deblk;
-+ unsigned long vd_nblk;
-+ struct {
-+ unsigned long ul;
-+ union au_vdir_deblk_p p;
-+ } vd_last;
++static int au_test_anon(struct dentry *dentry)
++{
++ /* note: read d_flags without d_lock */
++ return !!(dentry->d_flags & DCACHE_DISCONNECTED);
++}
+
-+ unsigned long vd_version;
-+ unsigned int vd_deblk_sz;
-+ unsigned long vd_jiffy;
-+} ____cacheline_aligned_in_smp;
++int au_test_nfsd(void)
++{
++ int ret;
++ struct task_struct *tsk = current;
++ char comm[sizeof(tsk->comm)];
++
++ ret = 0;
++ if (tsk->flags & PF_KTHREAD) {
++ get_task_comm(comm, tsk);
++ ret = !strcmp(comm, "nfsd");
++ }
++
++ return ret;
++}
+
+/* ---------------------------------------------------------------------- */
++/* inode generation external table */
+
-+/* dir.c */
-+extern const struct file_operations aufs_dir_fop;
-+void au_add_nlink(struct inode *dir, struct inode *h_dir);
-+void au_sub_nlink(struct inode *dir, struct inode *h_dir);
-+loff_t au_dir_size(struct file *file, struct dentry *dentry);
-+void au_dir_ts(struct inode *dir, aufs_bindex_t bsrc);
-+int au_test_empty_lower(struct dentry *dentry);
-+int au_test_empty(struct dentry *dentry, struct au_nhash *whlist);
++void au_xigen_inc(struct inode *inode)
++{
++ loff_t pos;
++ ssize_t sz;
++ __u32 igen;
++ struct super_block *sb;
++ struct au_sbinfo *sbinfo;
+
-+/* vdir.c */
-+unsigned int au_rdhash_est(loff_t sz);
-+int au_nhash_alloc(struct au_nhash *nhash, unsigned int num_hash, gfp_t gfp);
-+void au_nhash_wh_free(struct au_nhash *whlist);
-+int au_nhash_test_longer_wh(struct au_nhash *whlist, aufs_bindex_t btgt,
-+ int limit);
-+int au_nhash_test_known_wh(struct au_nhash *whlist, char *name, int nlen);
-+int au_nhash_append_wh(struct au_nhash *whlist, char *name, int nlen, ino_t ino,
-+ unsigned int d_type, aufs_bindex_t bindex,
-+ unsigned char shwh);
-+void au_vdir_free(struct au_vdir *vdir);
-+int au_vdir_init(struct file *file);
-+int au_vdir_fill_de(struct file *file, struct dir_context *ctx);
++ sb = inode->i_sb;
++ AuDebugOn(!au_opt_test(au_mntflags(sb), XINO));
+
-+/* ioctl.c */
-+long aufs_ioctl_dir(struct file *file, unsigned int cmd, unsigned long arg);
++ sbinfo = au_sbi(sb);
++ pos = inode->i_ino;
++ pos *= sizeof(igen);
++ igen = inode->i_generation + 1;
++ sz = xino_fwrite(sbinfo->si_xwrite, sbinfo->si_xigen, &igen,
++ sizeof(igen), &pos);
++ if (sz == sizeof(igen))
++ return; /* success */
+
-+#ifdef CONFIG_AUFS_RDU
-+/* rdu.c */
-+long au_rdu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
-+#ifdef CONFIG_COMPAT
-+long au_rdu_compat_ioctl(struct file *file, unsigned int cmd,
-+ unsigned long arg);
-+#endif
-+#else
-+AuStub(long, au_rdu_ioctl, return -EINVAL, struct file *file,
-+ unsigned int cmd, unsigned long arg)
-+#ifdef CONFIG_COMPAT
-+AuStub(long, au_rdu_compat_ioctl, return -EINVAL, struct file *file,
-+ unsigned int cmd, unsigned long arg)
-+#endif
-+#endif
++ if (unlikely(sz >= 0))
++ AuIOErr("xigen error (%zd)\n", sz);
++}
++
++int au_xigen_new(struct inode *inode)
++{
++ int err;
++ loff_t pos;
++ ssize_t sz;
++ struct super_block *sb;
++ struct au_sbinfo *sbinfo;
++ struct file *file;
++
++ err = 0;
++ /* todo: dirty, at mount time */
++ if (inode->i_ino == AUFS_ROOT_INO)
++ goto out;
++ sb = inode->i_sb;
++ SiMustAnyLock(sb);
++ if (unlikely(!au_opt_test(au_mntflags(sb), XINO)))
++ goto out;
++
++ err = -EFBIG;
++ pos = inode->i_ino;
++ if (unlikely(au_loff_max / sizeof(inode->i_generation) - 1 < pos)) {
++ AuIOErr1("too large i%lld\n", pos);
++ goto out;
++ }
++ pos *= sizeof(inode->i_generation);
++
++ err = 0;
++ sbinfo = au_sbi(sb);
++ file = sbinfo->si_xigen;
++ BUG_ON(!file);
++
++ if (vfsub_f_size_read(file)
++ < pos + sizeof(inode->i_generation)) {
++ inode->i_generation = atomic_inc_return(&sbinfo->si_xigen_next);
++ sz = xino_fwrite(sbinfo->si_xwrite, file, &inode->i_generation,
++ sizeof(inode->i_generation), &pos);
++ } else
++ sz = xino_fread(sbinfo->si_xread, file, &inode->i_generation,
++ sizeof(inode->i_generation), &pos);
++ if (sz == sizeof(inode->i_generation))
++ goto out; /* success */
++
++ err = sz;
++ if (unlikely(sz >= 0)) {
++ err = -EIO;
++ AuIOErr("xigen error (%zd)\n", sz);
++ }
++
++out:
++ return err;
++}
++
++int au_xigen_set(struct super_block *sb, struct file *base)
++{
++ int err;
++ struct au_sbinfo *sbinfo;
++ struct file *file;
++
++ SiMustWriteLock(sb);
++
++ sbinfo = au_sbi(sb);
++ file = au_xino_create2(base, sbinfo->si_xigen);
++ err = PTR_ERR(file);
++ if (IS_ERR(file))
++ goto out;
++ err = 0;
++ if (sbinfo->si_xigen)
++ fput(sbinfo->si_xigen);
++ sbinfo->si_xigen = file;
++
++out:
++ return err;
++}
++
++void au_xigen_clr(struct super_block *sb)
++{
++ struct au_sbinfo *sbinfo;
++
++ SiMustWriteLock(sb);
++
++ sbinfo = au_sbi(sb);
++ if (sbinfo->si_xigen) {
++ fput(sbinfo->si_xigen);
++ sbinfo->si_xigen = NULL;
++ }
++}
++
++/* ---------------------------------------------------------------------- */
++
++static struct dentry *decode_by_ino(struct super_block *sb, ino_t ino,
++ ino_t dir_ino)
++{
++ struct dentry *dentry, *d;
++ struct inode *inode;
++ unsigned int sigen;
++
++ dentry = NULL;
++ inode = ilookup(sb, ino);
++ if (!inode)
++ goto out;
++
++ dentry = ERR_PTR(-ESTALE);
++ sigen = au_sigen(sb);
++ if (unlikely(is_bad_inode(inode)
++ || IS_DEADDIR(inode)
++ || sigen != au_iigen(inode, NULL)))
++ goto out_iput;
++
++ dentry = NULL;
++ if (!dir_ino || S_ISDIR(inode->i_mode))
++ dentry = d_find_alias(inode);
++ else {
++ spin_lock(&inode->i_lock);
++ hlist_for_each_entry(d, &inode->i_dentry, d_u.d_alias) {
++ spin_lock(&d->d_lock);
++ if (!au_test_anon(d)
++ && d_inode(d->d_parent)->i_ino == dir_ino) {
++ dentry = dget_dlock(d);
++ spin_unlock(&d->d_lock);
++ break;
++ }
++ spin_unlock(&d->d_lock);
++ }
++ spin_unlock(&inode->i_lock);
++ }
++ if (unlikely(dentry && au_digen_test(dentry, sigen))) {
++ /* need to refresh */
++ dput(dentry);
++ dentry = NULL;
++ }
+
-+#endif /* __KERNEL__ */
-+#endif /* __AUFS_DIR_H__ */
-diff -urN /usr/share/empty/fs/aufs/dynop.c linux/fs/aufs/dynop.c
---- /usr/share/empty/fs/aufs/dynop.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux/fs/aufs/dynop.c 2016-02-28 11:26:32.569971135 +0100
-@@ -0,0 +1,369 @@
-+/*
-+ * Copyright (C) 2010-2016 Junjiro R. Okajima
-+ *
-+ * This program, aufs is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2 of the License, or
-+ * (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
-+ */
++out_iput:
++ iput(inode);
++out:
++ AuTraceErrPtr(dentry);
++ return dentry;
++}
+
-+/*
-+ * dynamically customizable operations for regular files
-+ */
++/* ---------------------------------------------------------------------- */
+
-+#include "aufs.h"
++/* todo: dirty? */
++/* if exportfs_decode_fh() passed vfsmount*, we could be happy */
+
-+#define DyPrSym(key) AuDbgSym(key->dk_op.dy_hop)
++struct au_compare_mnt_args {
++ /* input */
++ struct super_block *sb;
+
-+/*
-+ * How large will these lists be?
-+ * Usually just a few elements, 20-30 at most for each, I guess.
-+ */
-+static struct au_splhead dynop[AuDyLast];
++ /* output */
++ struct vfsmount *mnt;
++};
+
-+static struct au_dykey *dy_gfind_get(struct au_splhead *spl, const void *h_op)
++static int au_compare_mnt(struct vfsmount *mnt, void *arg)
+{
-+ struct au_dykey *key, *tmp;
-+ struct list_head *head;
++ struct au_compare_mnt_args *a = arg;
+
-+ key = NULL;
-+ head = &spl->head;
++ if (mnt->mnt_sb != a->sb)
++ return 0;
++ a->mnt = mntget(mnt);
++ return 1;
++}
++
++static struct vfsmount *au_mnt_get(struct super_block *sb)
++{
++ int err;
++ struct path root;
++ struct au_compare_mnt_args args = {
++ .sb = sb
++ };
++
<Skipped 33206 lines>
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/kernel.git/commitdiff/c2806d43fb36f7c3c1c033adfbb0a53d6d06d38b
More information about the pld-cvs-commit
mailing list