diff mbox series

ceph: check snap first in ceph_set_acl()

Message ID 20180902152109.11823-1-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show
Series ceph: check snap first in ceph_set_acl() | expand

Commit Message

Chengguang Xu Sept. 2, 2018, 3:21 p.m. UTC
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>
---
 fs/ceph/acl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Yan, Zheng Sept. 3, 2018, 5:22 a.m. UTC | #1
On Sun, Sep 2, 2018 at 11:25 PM Chengguang Xu <cgxu519@gmx.com> wrote:
>
> 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>
> ---
>  fs/ceph/acl.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
> index 027408d55aee..8a9b562ae4ca 100644
> --- a/fs/ceph/acl.c
> +++ b/fs/ceph/acl.c
> @@ -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;
> --
> 2.17.1
>

Applied, thanks

Yan, Zheng
diff mbox series

Patch

diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index 027408d55aee..8a9b562ae4ca 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -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;