]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ovl: don't cache acl on overlay layer
authorMiklos Szeredi <mszeredi@redhat.com>
Thu, 1 Sep 2016 09:11:59 +0000 (11:11 +0200)
committerShan Hai <shan.hai@oracle.com>
Fri, 4 Aug 2017 05:55:46 +0000 (13:55 +0800)
Some operations (setxattr/chmod) can make the cached acl stale.  We either
need to clear overlay's acl cache for the affected inode or prevent acl
caching on the overlay altogether.  Preventing caching has the following
advantages:

 - no double caching, less memory used

 - overlay cache doesn't go stale when fs clears it's own cache

Possible disadvantage is performance loss.  If that becomes a problem
get_acl() can be optimized for overlayfs.

This patch disables caching by pre setting i_*acl to a value that

  - has bit 0 set, so is_uncached_acl() will return true

  - is not equal to ACL_NOT_CACHED, so get_acl() will not overwrite it

The constant -3 was chosen for this purpose.

Fixes: 39a25b2b3762 ("ovl: define ->get_acl() for overlay inodes")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Orabug: 26401569

(backport upstream commit 2a3a2a3f35249412e35fbb48b743348c40373409)
use ACL_NOT_CACHED instead of ACL_DONT_CACHE since the is_uncached_acl
is not available in the current kernel.

Signed-off-by: Shan Hai <shan.hai@oracle.com>
Reviewed-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
fs/overlayfs/inode.c
include/linux/fs.h

index e32f7042d3cb5433883d8bc4ea950d298ad6736d..2d80a8dca35703e18d1492e882b2e2708465f3bb 100644 (file)
@@ -421,6 +421,9 @@ static void ovl_fill_inode(struct inode *inode, umode_t mode)
        inode->i_ino = get_next_ino();
        inode->i_mode = mode;
        inode->i_flags |= S_NOCMTIME;
+#ifdef CONFIG_FS_POSIX_ACL
+       inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
+#endif
 
        mode &= S_IFMT;
        switch (mode) {
index 85dc463cc8a4cc8368ed8d650043c2919d013d32..c7c49c5e3e59fbb4755f17f9611645011b132ac0 100644 (file)
@@ -574,6 +574,7 @@ static inline void mapping_allow_writable(struct address_space *mapping)
 
 struct posix_acl;
 #define ACL_NOT_CACHED ((void *)(-1))
+#define ACL_DONT_CACHE ((void *)(-3))
 
 #define IOP_FASTPERM   0x0001
 #define IOP_LOOKUP     0x0002