Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1355945

Re: [PATCH v18 21/22] ext4: Add richacl support

From Christoph Hellwig <hch@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH v18 21/22] ext4: Add richacl support
Date 2016-03-11 15:30 +0100
Message-ID <rbweK-7tE-3@gated-at.bofh.it> (permalink)
References <r7rdD-tJ-3@gated-at.bofh.it> <r7rdD-tJ-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


> +static inline int
> +ext4_acl_chmod(struct inode *inode, umode_t mode)
> +{
> +	if (IS_RICHACL(inode))
> +		return richacl_chmod(inode, inode->i_mode);
> +	return posix_acl_chmod(inode, inode->i_mode);
> +}

Thi isn't ext4-specific and potentially duplicated in every caller.
Please provide this as a common helper.

Also while we're at it, the mode argument is ignore and the function
always uses inode->i_mode instead.

> +ext4_get_richacl(struct inode *inode)
> +{
> +	const int name_index = EXT4_XATTR_INDEX_RICHACL;
> +	void *value = NULL;
> +	struct richacl *acl = NULL;
> +	int retval;
> +
> +	retval = ext4_xattr_get(inode, name_index, "", NULL, 0);
> +	if (retval > 0) {
> +		value = kmalloc(retval, GFP_NOFS);
> +		if (!value)
> +			return ERR_PTR(-ENOMEM);
> +		retval = ext4_xattr_get(inode, name_index, "", value, retval);
> +	}
> +	if (retval > 0) {
> +		acl = richacl_from_xattr(&init_user_ns, value, retval);
> +		if (acl == ERR_PTR(-EINVAL))
> +			acl = ERR_PTR(-EIO);

Shouldn't richacl_from_xattr return the error pointer that ->get_richacl
callers expect?

> +static int
> +__ext4_set_richacl(handle_t *handle, struct inode *inode, struct richacl *acl)
> +{
> +	const int name_index = EXT4_XATTR_INDEX_RICHACL;
> +	umode_t mode = inode->i_mode;
> +	int retval, size;
> +	void *value;
> +
> +	if (richacl_equiv_mode(acl, &mode) == 0) {
> +		inode->i_ctime = ext4_current_time(inode);
> +		inode->i_mode = mode;
> +		ext4_mark_inode_dirty(handle, inode);
> +		return __ext4_remove_richacl(handle, inode);
> +	}

Should this check for a NULL acl instead of special casing that
in ext4_set_richacl?

> +int
> +ext4_init_richacl(handle_t *handle, struct inode *inode, struct inode *dir)
> +{
> +	struct richacl *acl = richacl_create(&inode->i_mode, dir);
> +	int error;
> +
> +	error = PTR_ERR(acl);
> +	if (IS_ERR(acl))
> +		return error;

	if (IS_ERR(acl))
		return PTR_ERR(acl);

> +	if (acl) {
> +		error = __ext4_set_richacl(handle, inode, acl);
> +		richacl_put(acl);
> +	}

Shouldn't richacl_create return NULL if the ACL is equivalent to the
mode bits instead of letting every filesystem figure that out on it's
own?

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v18 21/22] ext4: Add richacl support Christoph Hellwig <hch@infradead.org> - 2016-03-11 15:30 +0100
  Re: [PATCH v18 21/22] ext4: Add richacl support Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-14 00:10 +0100
    Re: [PATCH v18 21/22] ext4: Add richacl support Christoph Hellwig <hch@infradead.org> - 2016-03-15 08:20 +0100
      Re: [PATCH v18 21/22] ext4: Add richacl support Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-16 23:40 +0100
  Re: [PATCH v18 21/22] ext4: Add richacl support Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-14 01:00 +0100
  Re: [PATCH v18 21/22] ext4: Add richacl support Andreas Gruenbacher <agruenba@redhat.com> - 2016-03-14 14:10 +0100
    Re: [PATCH v18 21/22] ext4: Add richacl support Christoph Hellwig <hch@infradead.org> - 2016-03-15 08:30 +0100

csiph-web