diff mbox

[5/5] ceph: fix ceph_set_acl()

Message ID 1392096612-11481-5-git-send-email-zheng.z.yan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yan, Zheng Feb. 11, 2014, 5:30 a.m. UTC
If acl is equivalent to file mode permission bits, ceph_set_acl()
needs to remove any existing acl xattr. Use __ceph_setxattr() to
handle both setting and removing acl xattr cases, it doesn't return
-ENODATA when there is no acl xattr.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 fs/ceph/acl.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Alex Elder Feb. 11, 2014, 6:06 p.m. UTC | #1
On 02/10/2014 11:30 PM, Yan, Zheng wrote:
> If acl is equivalent to file mode permission bits, ceph_set_acl()
> needs to remove any existing acl xattr. Use __ceph_setxattr() to
> handle both setting and removing acl xattr cases, it doesn't return
> -ENODATA when there is no acl xattr.

This looks good, however (continuing with our other
discussion) I assume that __set_xattr() will use a
null value rather than 0 value_len to determine whether
to remove the xattr.

And I'll continue to suggest better descriptions.  (I
realize English is not your native language but I
really think the description is important, to be
able to verify the code change matches what the
developer intended it to do.)  The problem here is
that ceph_set_acl() could return -ENODATA if it
attempted to remove a non-existent ACL attribute,
and that shouldn't happen.   (Right?)

Reviewed-by: Alex Elder <elder@linaro.org>

PS  Note that ceph_set_acl() can be made static, and its
    only caller, ceph_init_acl() has its return value
    ignored in all cases.  So in some respects this change
    not matter much.

> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
> ---
>  fs/ceph/acl.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
> index 4c2d452..accc9f2 100644
> --- a/fs/ceph/acl.c
> +++ b/fs/ceph/acl.c
> @@ -160,11 +160,7 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
>  			goto out_dput;
>  	}
>  
> -	if (value)
> -		ret = __ceph_setxattr(dentry, name, value, size, 0);
> -	else
> -		ret = __ceph_removexattr(dentry, name);
> -
> +	ret = __ceph_setxattr(dentry, name, value, size, 0);
>  	if (ret) {
>  		if (new_mode != old_mode) {
>  			newattrs.ia_mode = old_mode;
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index 4c2d452..accc9f2 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -160,11 +160,7 @@  int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 			goto out_dput;
 	}
 
-	if (value)
-		ret = __ceph_setxattr(dentry, name, value, size, 0);
-	else
-		ret = __ceph_removexattr(dentry, name);
-
+	ret = __ceph_setxattr(dentry, name, value, size, 0);
 	if (ret) {
 		if (new_mode != old_mode) {
 			newattrs.ia_mode = old_mode;