ext2: cache NULL when both default_acl and acl are NULL
authorChengguang Xu <cgxu519@gmx.com>
Fri, 31 Aug 2018 14:33:48 +0000 (22:33 +0800)
committerJan Kara <jack@suse.cz>
Mon, 3 Sep 2018 09:05:03 +0000 (11:05 +0200)
default_acl and acl of newly created inode will be initiated as
ACL_NOT_CACHED in vfs function inode_init_always() and later will be
updated by calling xxx_init_acl() in specific filesystems.  However,
when default_acl and acl are NULL, then they keep the value of
ACL_NOT_CACHED. This patch changes the code to cache NULL for acl /
default_acl in this case to save unnecessary ACL lookup in future.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext2/acl.c

index 224c04a..cf4c77f 100644 (file)
@@ -256,11 +256,15 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
        if (default_acl) {
                error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
                posix_acl_release(default_acl);
+       } else {
+               inode->i_default_acl = NULL;
        }
        if (acl) {
                if (!error)
                        error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
                posix_acl_release(acl);
+       } else {
+               inode->i_acl = NULL;
        }
        return error;
 }