ceph: check snap first in ceph_set_acl()
authorChengguang Xu <cgxu519@gmx.com>
Sun, 2 Sep 2018 15:21:09 +0000 (23:21 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 22 Oct 2018 08:28:20 +0000 (10:28 +0200)
Do the snap check first in ceph_set_acl(), so we can avoid
unnecessary operations when the inode has snap.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/acl.c

index 027408d..8a9b562 100644 (file)
@@ -104,6 +104,11 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
        struct timespec64 old_ctime = inode->i_ctime;
        umode_t new_mode = inode->i_mode, old_mode = inode->i_mode;
 
+       if (ceph_snap(inode) != CEPH_NOSNAP) {
+               ret = -EROFS;
+               goto out;
+       }
+
        switch (type) {
        case ACL_TYPE_ACCESS:
                name = XATTR_NAME_POSIX_ACL_ACCESS;
@@ -138,11 +143,6 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
                        goto out_free;
        }
 
-       if (ceph_snap(inode) != CEPH_NOSNAP) {
-               ret = -EROFS;
-               goto out_free;
-       }
-
        if (new_mode != old_mode) {
                newattrs.ia_ctime = current_time(inode);
                newattrs.ia_mode = new_mode;