helpers for acl caching + switch to those
helpers: get_cached_acl(inode, type), set_cached_acl(inode, type, acl), forget_cached_acl(inode, type). ubifs/xattr.c needed includes reordered, the rest is a plain switchover. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
		
					parent
					
						
							
								06b16e9f68
							
						
					
				
			
			
				commit
				
					
						073aaa1b14
					
				
			
		
					 10 changed files with 153 additions and 331 deletions
				
			
		| 
						 | 
					@ -29,51 +29,28 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_FS_POSIX_ACL
 | 
					#ifdef CONFIG_FS_POSIX_ACL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void btrfs_update_cached_acl(struct inode *inode,
 | 
					 | 
				
			||||||
				    struct posix_acl **p_acl,
 | 
					 | 
				
			||||||
				    struct posix_acl *acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*p_acl && *p_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		posix_acl_release(*p_acl);
 | 
					 | 
				
			||||||
	*p_acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
 | 
					static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int size;
 | 
						int size;
 | 
				
			||||||
	const char *name;
 | 
						const char *name;
 | 
				
			||||||
	char *value = NULL;
 | 
						char *value = NULL;
 | 
				
			||||||
	struct posix_acl *acl = NULL, **p_acl;
 | 
						struct posix_acl *acl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						acl = get_cached_acl(inode, type);
 | 
				
			||||||
 | 
						if (acl != ACL_NOT_CACHED)
 | 
				
			||||||
 | 
							return acl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (type) {
 | 
						switch (type) {
 | 
				
			||||||
	case ACL_TYPE_ACCESS:
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
		name = POSIX_ACL_XATTR_ACCESS;
 | 
							name = POSIX_ACL_XATTR_ACCESS;
 | 
				
			||||||
		p_acl = &inode->i_acl;
 | 
					 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case ACL_TYPE_DEFAULT:
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
		name = POSIX_ACL_XATTR_DEFAULT;
 | 
							name = POSIX_ACL_XATTR_DEFAULT;
 | 
				
			||||||
		p_acl = &inode->i_default_acl;
 | 
					 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return ERR_PTR(-EINVAL);
 | 
							BUG();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Handle the cached NULL acl case without locking */
 | 
					 | 
				
			||||||
	acl = ACCESS_ONCE(*p_acl);
 | 
					 | 
				
			||||||
	if (!acl)
 | 
					 | 
				
			||||||
		return acl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	acl = *p_acl;
 | 
					 | 
				
			||||||
	if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		return acl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	size = __btrfs_getxattr(inode, name, "", 0);
 | 
						size = __btrfs_getxattr(inode, name, "", 0);
 | 
				
			||||||
	if (size > 0) {
 | 
						if (size > 0) {
 | 
				
			||||||
		value = kzalloc(size, GFP_NOFS);
 | 
							value = kzalloc(size, GFP_NOFS);
 | 
				
			||||||
| 
						 | 
					@ -82,13 +59,13 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
 | 
				
			||||||
		size = __btrfs_getxattr(inode, name, value, size);
 | 
							size = __btrfs_getxattr(inode, name, value, size);
 | 
				
			||||||
		if (size > 0) {
 | 
							if (size > 0) {
 | 
				
			||||||
			acl = posix_acl_from_xattr(value, size);
 | 
								acl = posix_acl_from_xattr(value, size);
 | 
				
			||||||
			btrfs_update_cached_acl(inode, p_acl, acl);
 | 
								set_cached_acl(inode, type, acl);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		kfree(value);
 | 
							kfree(value);
 | 
				
			||||||
	} else if (size == -ENOENT || size == -ENODATA || size == 0) {
 | 
						} else if (size == -ENOENT || size == -ENODATA || size == 0) {
 | 
				
			||||||
		/* FIXME, who returns -ENOENT?  I think nobody */
 | 
							/* FIXME, who returns -ENOENT?  I think nobody */
 | 
				
			||||||
		acl = NULL;
 | 
							acl = NULL;
 | 
				
			||||||
		btrfs_update_cached_acl(inode, p_acl, acl);
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		acl = ERR_PTR(-EIO);
 | 
							acl = ERR_PTR(-EIO);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -121,7 +98,6 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret, size = 0;
 | 
						int ret, size = 0;
 | 
				
			||||||
	const char *name;
 | 
						const char *name;
 | 
				
			||||||
	struct posix_acl **p_acl;
 | 
					 | 
				
			||||||
	char *value = NULL;
 | 
						char *value = NULL;
 | 
				
			||||||
	mode_t mode;
 | 
						mode_t mode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -141,13 +117,11 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 | 
				
			||||||
		ret = 0;
 | 
							ret = 0;
 | 
				
			||||||
		inode->i_mode = mode;
 | 
							inode->i_mode = mode;
 | 
				
			||||||
		name = POSIX_ACL_XATTR_ACCESS;
 | 
							name = POSIX_ACL_XATTR_ACCESS;
 | 
				
			||||||
		p_acl = &inode->i_acl;
 | 
					 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case ACL_TYPE_DEFAULT:
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
		if (!S_ISDIR(inode->i_mode))
 | 
							if (!S_ISDIR(inode->i_mode))
 | 
				
			||||||
			return acl ? -EINVAL : 0;
 | 
								return acl ? -EINVAL : 0;
 | 
				
			||||||
		name = POSIX_ACL_XATTR_DEFAULT;
 | 
							name = POSIX_ACL_XATTR_DEFAULT;
 | 
				
			||||||
		p_acl = &inode->i_default_acl;
 | 
					 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
| 
						 | 
					@ -172,7 +146,7 @@ out:
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!ret)
 | 
						if (!ret)
 | 
				
			||||||
		btrfs_update_cached_acl(inode, p_acl, acl);
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -125,30 +125,6 @@ fail:
 | 
				
			||||||
	return ERR_PTR(-EINVAL);
 | 
						return ERR_PTR(-EINVAL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline struct posix_acl *
 | 
					 | 
				
			||||||
ext2_iget_acl(struct inode *inode, struct posix_acl **i_acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct posix_acl *acl = ACL_NOT_CACHED;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*i_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		acl = posix_acl_dup(*i_acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return acl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline void
 | 
					 | 
				
			||||||
ext2_iset_acl(struct inode *inode, struct posix_acl **i_acl,
 | 
					 | 
				
			||||||
		   struct posix_acl *acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*i_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		posix_acl_release(*i_acl);
 | 
					 | 
				
			||||||
	*i_acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * inode->i_mutex: don't care
 | 
					 * inode->i_mutex: don't care
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -163,23 +139,19 @@ ext2_get_acl(struct inode *inode, int type)
 | 
				
			||||||
	if (!test_opt(inode->i_sb, POSIX_ACL))
 | 
						if (!test_opt(inode->i_sb, POSIX_ACL))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch(type) {
 | 
						acl = get_cached_acl(inode, type);
 | 
				
			||||||
		case ACL_TYPE_ACCESS:
 | 
						if (acl != ACL_NOT_CACHED)
 | 
				
			||||||
			acl = ext2_iget_acl(inode, &inode->i_acl);
 | 
							return acl;
 | 
				
			||||||
			if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
				return acl;
 | 
					 | 
				
			||||||
			name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case ACL_TYPE_DEFAULT:
 | 
						switch (type) {
 | 
				
			||||||
			acl = ext2_iget_acl(inode, &inode->i_default_acl);
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
			if (acl != ACL_NOT_CACHED)
 | 
							name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
 | 
				
			||||||
				return acl;
 | 
							break;
 | 
				
			||||||
			name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT;
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
			break;
 | 
							name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
		default:
 | 
						default:
 | 
				
			||||||
			return ERR_PTR(-EINVAL);
 | 
							BUG();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	retval = ext2_xattr_get(inode, name_index, "", NULL, 0);
 | 
						retval = ext2_xattr_get(inode, name_index, "", NULL, 0);
 | 
				
			||||||
	if (retval > 0) {
 | 
						if (retval > 0) {
 | 
				
			||||||
| 
						 | 
					@ -196,17 +168,9 @@ ext2_get_acl(struct inode *inode, int type)
 | 
				
			||||||
		acl = ERR_PTR(retval);
 | 
							acl = ERR_PTR(retval);
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!IS_ERR(acl)) {
 | 
						if (!IS_ERR(acl))
 | 
				
			||||||
		switch(type) {
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
			case ACL_TYPE_ACCESS:
 | 
					 | 
				
			||||||
				ext2_iset_acl(inode, &inode->i_acl, acl);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case ACL_TYPE_DEFAULT:
 | 
					 | 
				
			||||||
				ext2_iset_acl(inode, &inode->i_default_acl, acl);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return acl;
 | 
						return acl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -261,17 +225,8 @@ ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
 | 
				
			||||||
	error = ext2_xattr_set(inode, name_index, "", value, size, 0);
 | 
						error = ext2_xattr_set(inode, name_index, "", value, size, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
	if (!error) {
 | 
						if (!error)
 | 
				
			||||||
		switch(type) {
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
			case ACL_TYPE_ACCESS:
 | 
					 | 
				
			||||||
				ext2_iset_acl(inode, &inode->i_acl, acl);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			case ACL_TYPE_DEFAULT:
 | 
					 | 
				
			||||||
				ext2_iset_acl(inode, &inode->i_default_acl, acl);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return error;
 | 
						return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,33 +126,6 @@ fail:
 | 
				
			||||||
	return ERR_PTR(-EINVAL);
 | 
						return ERR_PTR(-EINVAL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline struct posix_acl *
 | 
					 | 
				
			||||||
ext3_iget_acl(struct inode *inode, struct posix_acl **i_acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct posix_acl *acl = ACCESS_ONCE(*i_acl);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (acl) {
 | 
					 | 
				
			||||||
		spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
		acl = *i_acl;
 | 
					 | 
				
			||||||
		if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
			acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
		spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return acl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline void
 | 
					 | 
				
			||||||
ext3_iset_acl(struct inode *inode, struct posix_acl **i_acl,
 | 
					 | 
				
			||||||
                  struct posix_acl *acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*i_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		posix_acl_release(*i_acl);
 | 
					 | 
				
			||||||
	*i_acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Inode operation get_posix_acl().
 | 
					 * Inode operation get_posix_acl().
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -169,24 +142,21 @@ ext3_get_acl(struct inode *inode, int type)
 | 
				
			||||||
	if (!test_opt(inode->i_sb, POSIX_ACL))
 | 
						if (!test_opt(inode->i_sb, POSIX_ACL))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch(type) {
 | 
						acl = get_cached_acl(inode, type);
 | 
				
			||||||
		case ACL_TYPE_ACCESS:
 | 
						if (acl != ACL_NOT_CACHED)
 | 
				
			||||||
			acl = ext3_iget_acl(inode, &inode->i_acl);
 | 
							return acl;
 | 
				
			||||||
			if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
				return acl;
 | 
					 | 
				
			||||||
			name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case ACL_TYPE_DEFAULT:
 | 
						switch (type) {
 | 
				
			||||||
			acl = ext3_iget_acl(inode, &inode->i_default_acl);
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
			if (acl != ACL_NOT_CACHED)
 | 
							name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS;
 | 
				
			||||||
				return acl;
 | 
							break;
 | 
				
			||||||
			name_index = EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT;
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
			break;
 | 
							name_index = EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
		default:
 | 
						default:
 | 
				
			||||||
			return ERR_PTR(-EINVAL);
 | 
							BUG();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	retval = ext3_xattr_get(inode, name_index, "", NULL, 0);
 | 
						retval = ext3_xattr_get(inode, name_index, "", NULL, 0);
 | 
				
			||||||
	if (retval > 0) {
 | 
						if (retval > 0) {
 | 
				
			||||||
		value = kmalloc(retval, GFP_NOFS);
 | 
							value = kmalloc(retval, GFP_NOFS);
 | 
				
			||||||
| 
						 | 
					@ -202,17 +172,9 @@ ext3_get_acl(struct inode *inode, int type)
 | 
				
			||||||
		acl = ERR_PTR(retval);
 | 
							acl = ERR_PTR(retval);
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!IS_ERR(acl)) {
 | 
						if (!IS_ERR(acl))
 | 
				
			||||||
		switch(type) {
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
			case ACL_TYPE_ACCESS:
 | 
					 | 
				
			||||||
				ext3_iset_acl(inode, &inode->i_acl, acl);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case ACL_TYPE_DEFAULT:
 | 
					 | 
				
			||||||
				ext3_iset_acl(inode, &inode->i_default_acl, acl);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return acl;
 | 
						return acl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -269,17 +231,10 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
 | 
				
			||||||
				      value, size, 0);
 | 
									      value, size, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
	if (!error) {
 | 
					 | 
				
			||||||
		switch(type) {
 | 
					 | 
				
			||||||
			case ACL_TYPE_ACCESS:
 | 
					 | 
				
			||||||
				ext3_iset_acl(inode, &inode->i_acl, acl);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case ACL_TYPE_DEFAULT:
 | 
						if (!error)
 | 
				
			||||||
				ext3_iset_acl(inode, &inode->i_default_acl, acl);
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
				break;
 | 
					
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return error;
 | 
						return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,33 +126,6 @@ fail:
 | 
				
			||||||
	return ERR_PTR(-EINVAL);
 | 
						return ERR_PTR(-EINVAL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline struct posix_acl *
 | 
					 | 
				
			||||||
ext4_iget_acl(struct inode *inode, struct posix_acl **i_acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct posix_acl *acl = ACCESS_ONCE(*i_acl);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (acl) {
 | 
					 | 
				
			||||||
		spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
		acl = *i_acl;
 | 
					 | 
				
			||||||
		if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
			acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
		spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return acl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline void
 | 
					 | 
				
			||||||
ext4_iset_acl(struct inode *inode, struct posix_acl **i_acl,
 | 
					 | 
				
			||||||
		struct posix_acl *acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*i_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		posix_acl_release(*i_acl);
 | 
					 | 
				
			||||||
	*i_acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Inode operation get_posix_acl().
 | 
					 * Inode operation get_posix_acl().
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -169,23 +142,19 @@ ext4_get_acl(struct inode *inode, int type)
 | 
				
			||||||
	if (!test_opt(inode->i_sb, POSIX_ACL))
 | 
						if (!test_opt(inode->i_sb, POSIX_ACL))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						acl = get_cached_acl(inode, type);
 | 
				
			||||||
 | 
						if (acl != ACL_NOT_CACHED)
 | 
				
			||||||
 | 
							return acl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (type) {
 | 
						switch (type) {
 | 
				
			||||||
	case ACL_TYPE_ACCESS:
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
		acl = ext4_iget_acl(inode, &inode->i_acl);
 | 
					 | 
				
			||||||
		if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
			return acl;
 | 
					 | 
				
			||||||
		name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
 | 
							name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	case ACL_TYPE_DEFAULT:
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
		acl = ext4_iget_acl(inode, &inode->i_default_acl);
 | 
					 | 
				
			||||||
		if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
			return acl;
 | 
					 | 
				
			||||||
		name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT;
 | 
							name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return ERR_PTR(-EINVAL);
 | 
							BUG();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	retval = ext4_xattr_get(inode, name_index, "", NULL, 0);
 | 
						retval = ext4_xattr_get(inode, name_index, "", NULL, 0);
 | 
				
			||||||
	if (retval > 0) {
 | 
						if (retval > 0) {
 | 
				
			||||||
| 
						 | 
					@ -202,17 +171,9 @@ ext4_get_acl(struct inode *inode, int type)
 | 
				
			||||||
		acl = ERR_PTR(retval);
 | 
							acl = ERR_PTR(retval);
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!IS_ERR(acl)) {
 | 
						if (!IS_ERR(acl))
 | 
				
			||||||
		switch (type) {
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
		case ACL_TYPE_ACCESS:
 | 
					 | 
				
			||||||
			ext4_iset_acl(inode, &inode->i_acl, acl);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case ACL_TYPE_DEFAULT:
 | 
					 | 
				
			||||||
			ext4_iset_acl(inode, &inode->i_default_acl, acl);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return acl;
 | 
						return acl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -269,17 +230,9 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type,
 | 
				
			||||||
				      value, size, 0);
 | 
									      value, size, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
	if (!error) {
 | 
						if (!error)
 | 
				
			||||||
		switch (type) {
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
		case ACL_TYPE_ACCESS:
 | 
					 | 
				
			||||||
			ext4_iset_acl(inode, &inode->i_acl, acl);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		case ACL_TYPE_DEFAULT:
 | 
					 | 
				
			||||||
			ext4_iset_acl(inode, &inode->i_default_acl, acl);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return error;
 | 
						return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -156,47 +156,25 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
 | 
				
			||||||
	return ERR_PTR(-EINVAL);
 | 
						return ERR_PTR(-EINVAL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct posix_acl *jffs2_iget_acl(struct inode *inode, struct posix_acl **i_acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct posix_acl *acl = ACL_NOT_CACHED;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*i_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		acl = posix_acl_dup(*i_acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
	return acl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void jffs2_iset_acl(struct inode *inode, struct posix_acl **i_acl, struct posix_acl *acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*i_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		posix_acl_release(*i_acl);
 | 
					 | 
				
			||||||
	*i_acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
 | 
					static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct posix_acl *acl;
 | 
						struct posix_acl *acl;
 | 
				
			||||||
	char *value = NULL;
 | 
						char *value = NULL;
 | 
				
			||||||
	int rc, xprefix;
 | 
						int rc, xprefix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						acl = get_cached_acl(inode, type);
 | 
				
			||||||
 | 
						if (acl != ACL_NOT_CACHED)
 | 
				
			||||||
 | 
							return acl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (type) {
 | 
						switch (type) {
 | 
				
			||||||
	case ACL_TYPE_ACCESS:
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
		acl = jffs2_iget_acl(inode, &inode->i_acl);
 | 
					 | 
				
			||||||
		if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
			return acl;
 | 
					 | 
				
			||||||
		xprefix = JFFS2_XPREFIX_ACL_ACCESS;
 | 
							xprefix = JFFS2_XPREFIX_ACL_ACCESS;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case ACL_TYPE_DEFAULT:
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
		acl = jffs2_iget_acl(inode, &inode->i_default_acl);
 | 
					 | 
				
			||||||
		if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
			return acl;
 | 
					 | 
				
			||||||
		xprefix = JFFS2_XPREFIX_ACL_DEFAULT;
 | 
							xprefix = JFFS2_XPREFIX_ACL_DEFAULT;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return ERR_PTR(-EINVAL);
 | 
							BUG();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0);
 | 
						rc = do_jffs2_getxattr(inode, xprefix, "", NULL, 0);
 | 
				
			||||||
	if (rc > 0) {
 | 
						if (rc > 0) {
 | 
				
			||||||
| 
						 | 
					@ -214,16 +192,8 @@ static struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (value)
 | 
						if (value)
 | 
				
			||||||
		kfree(value);
 | 
							kfree(value);
 | 
				
			||||||
	if (!IS_ERR(acl)) {
 | 
						if (!IS_ERR(acl))
 | 
				
			||||||
		switch (type) {
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
		case ACL_TYPE_ACCESS:
 | 
					 | 
				
			||||||
			jffs2_iset_acl(inode, &inode->i_acl, acl);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case ACL_TYPE_DEFAULT:
 | 
					 | 
				
			||||||
			jffs2_iset_acl(inode, &inode->i_default_acl, acl);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return acl;
 | 
						return acl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -283,16 +253,8 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	rc = __jffs2_set_acl(inode, xprefix, acl);
 | 
						rc = __jffs2_set_acl(inode, xprefix, acl);
 | 
				
			||||||
	if (!rc) {
 | 
						if (!rc)
 | 
				
			||||||
		switch(type) {
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
		case ACL_TYPE_ACCESS:
 | 
					 | 
				
			||||||
			jffs2_iset_acl(inode, &inode->i_acl, acl);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case ACL_TYPE_DEFAULT:
 | 
					 | 
				
			||||||
			jffs2_iset_acl(inode, &inode->i_default_acl, acl);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -336,7 +298,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
 | 
				
			||||||
		*i_mode &= ~current_umask();
 | 
							*i_mode &= ~current_umask();
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		if (S_ISDIR(*i_mode))
 | 
							if (S_ISDIR(*i_mode))
 | 
				
			||||||
			jffs2_iset_acl(inode, &inode->i_default_acl, acl);
 | 
								set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		clone = posix_acl_clone(acl, GFP_KERNEL);
 | 
							clone = posix_acl_clone(acl, GFP_KERNEL);
 | 
				
			||||||
		if (!clone)
 | 
							if (!clone)
 | 
				
			||||||
| 
						 | 
					@ -347,7 +309,7 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
 | 
				
			||||||
			return rc;
 | 
								return rc;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (rc > 0)
 | 
							if (rc > 0)
 | 
				
			||||||
			jffs2_iset_acl(inode, &inode->i_acl, clone);
 | 
								set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		posix_acl_release(clone);
 | 
							posix_acl_release(clone);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										32
									
								
								fs/jfs/acl.c
									
										
									
									
									
								
							
							
						
						
									
										32
									
								
								fs/jfs/acl.c
									
										
									
									
									
								
							| 
						 | 
					@ -31,26 +31,24 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct posix_acl *acl;
 | 
						struct posix_acl *acl;
 | 
				
			||||||
	char *ea_name;
 | 
						char *ea_name;
 | 
				
			||||||
	struct posix_acl **p_acl;
 | 
					 | 
				
			||||||
	int size;
 | 
						int size;
 | 
				
			||||||
	char *value = NULL;
 | 
						char *value = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						acl = get_cached_acl(inode, type);
 | 
				
			||||||
 | 
						if (acl != ACL_NOT_CACHED)
 | 
				
			||||||
 | 
							return acl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch(type) {
 | 
						switch(type) {
 | 
				
			||||||
		case ACL_TYPE_ACCESS:
 | 
							case ACL_TYPE_ACCESS:
 | 
				
			||||||
			ea_name = POSIX_ACL_XATTR_ACCESS;
 | 
								ea_name = POSIX_ACL_XATTR_ACCESS;
 | 
				
			||||||
			p_acl = &inode->i_acl;
 | 
					 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case ACL_TYPE_DEFAULT:
 | 
							case ACL_TYPE_DEFAULT:
 | 
				
			||||||
			ea_name = POSIX_ACL_XATTR_DEFAULT;
 | 
								ea_name = POSIX_ACL_XATTR_DEFAULT;
 | 
				
			||||||
			p_acl = &inode->i_default_acl;
 | 
					 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			return ERR_PTR(-EINVAL);
 | 
								return ERR_PTR(-EINVAL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (*p_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		return posix_acl_dup(*p_acl);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	size = __jfs_getxattr(inode, ea_name, NULL, 0);
 | 
						size = __jfs_getxattr(inode, ea_name, NULL, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (size > 0) {
 | 
						if (size > 0) {
 | 
				
			||||||
| 
						 | 
					@ -61,17 +59,18 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (size < 0) {
 | 
						if (size < 0) {
 | 
				
			||||||
		if (size == -ENODATA) {
 | 
							if (size == -ENODATA)
 | 
				
			||||||
			*p_acl = NULL;
 | 
					 | 
				
			||||||
			acl = NULL;
 | 
								acl = NULL;
 | 
				
			||||||
		} else
 | 
							else
 | 
				
			||||||
			acl = ERR_PTR(size);
 | 
								acl = ERR_PTR(size);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		acl = posix_acl_from_xattr(value, size);
 | 
							acl = posix_acl_from_xattr(value, size);
 | 
				
			||||||
		if (!IS_ERR(acl))
 | 
					 | 
				
			||||||
			*p_acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
 | 
						if (!IS_ERR(acl)) {
 | 
				
			||||||
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
 | 
							posix_acl_release(acl);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return acl;
 | 
						return acl;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,7 +78,6 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
 | 
				
			||||||
		       struct posix_acl *acl)
 | 
							       struct posix_acl *acl)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char *ea_name;
 | 
						char *ea_name;
 | 
				
			||||||
	struct posix_acl **p_acl;
 | 
					 | 
				
			||||||
	int rc;
 | 
						int rc;
 | 
				
			||||||
	int size = 0;
 | 
						int size = 0;
 | 
				
			||||||
	char *value = NULL;
 | 
						char *value = NULL;
 | 
				
			||||||
| 
						 | 
					@ -90,11 +88,9 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
 | 
				
			||||||
	switch(type) {
 | 
						switch(type) {
 | 
				
			||||||
		case ACL_TYPE_ACCESS:
 | 
							case ACL_TYPE_ACCESS:
 | 
				
			||||||
			ea_name = POSIX_ACL_XATTR_ACCESS;
 | 
								ea_name = POSIX_ACL_XATTR_ACCESS;
 | 
				
			||||||
			p_acl = &inode->i_acl;
 | 
					 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case ACL_TYPE_DEFAULT:
 | 
							case ACL_TYPE_DEFAULT:
 | 
				
			||||||
			ea_name = POSIX_ACL_XATTR_DEFAULT;
 | 
								ea_name = POSIX_ACL_XATTR_DEFAULT;
 | 
				
			||||||
			p_acl = &inode->i_default_acl;
 | 
					 | 
				
			||||||
			if (!S_ISDIR(inode->i_mode))
 | 
								if (!S_ISDIR(inode->i_mode))
 | 
				
			||||||
				return acl ? -EACCES : 0;
 | 
									return acl ? -EACCES : 0;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					@ -114,11 +110,9 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!rc) {
 | 
						if (!rc)
 | 
				
			||||||
		if (*p_acl && (*p_acl != ACL_NOT_CACHED))
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
			posix_acl_release(*p_acl);
 | 
					
 | 
				
			||||||
		*p_acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -727,10 +727,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * We're changing the ACL.  Get rid of the cached one
 | 
							 * We're changing the ACL.  Get rid of the cached one
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		acl =inode->i_acl;
 | 
							forget_cached_acl(inode, ACL_TYPE_ACCESS);
 | 
				
			||||||
		if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
			posix_acl_release(acl);
 | 
					 | 
				
			||||||
		inode->i_acl = ACL_NOT_CACHED;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	} else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) {
 | 
						} else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) {
 | 
				
			||||||
| 
						 | 
					@ -746,10 +743,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * We're changing the default ACL.  Get rid of the cached one
 | 
							 * We're changing the default ACL.  Get rid of the cached one
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		acl = inode->i_default_acl;
 | 
							forget_cached_acl(inode, ACL_TYPE_DEFAULT);
 | 
				
			||||||
		if (acl && (acl != ACL_NOT_CACHED))
 | 
					 | 
				
			||||||
			posix_acl_release(acl);
 | 
					 | 
				
			||||||
		inode->i_default_acl = ACL_NOT_CACHED;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -188,29 +188,6 @@ static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
 | 
				
			||||||
	return ERR_PTR(-EINVAL);
 | 
						return ERR_PTR(-EINVAL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void iset_acl(struct inode *inode, struct posix_acl **i_acl,
 | 
					 | 
				
			||||||
			    struct posix_acl *acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*i_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		posix_acl_release(*i_acl);
 | 
					 | 
				
			||||||
	*i_acl = posix_acl_dup(acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline struct posix_acl *iget_acl(struct inode *inode,
 | 
					 | 
				
			||||||
					 struct posix_acl **i_acl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct posix_acl *acl = ACL_NOT_CACHED;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	spin_lock(&inode->i_lock);
 | 
					 | 
				
			||||||
	if (*i_acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		acl = posix_acl_dup(*i_acl);
 | 
					 | 
				
			||||||
	spin_unlock(&inode->i_lock);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return acl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Inode operation get_posix_acl().
 | 
					 * Inode operation get_posix_acl().
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -220,31 +197,29 @@ static inline struct posix_acl *iget_acl(struct inode *inode,
 | 
				
			||||||
struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
 | 
					struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char *name, *value;
 | 
						char *name, *value;
 | 
				
			||||||
	struct posix_acl *acl, **p_acl;
 | 
						struct posix_acl *acl;
 | 
				
			||||||
	int size;
 | 
						int size;
 | 
				
			||||||
	int retval;
 | 
						int retval;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						acl = get_cached_acl(inode, type);
 | 
				
			||||||
 | 
						if (acl != ACL_NOT_CACHED)
 | 
				
			||||||
 | 
							return acl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (type) {
 | 
						switch (type) {
 | 
				
			||||||
	case ACL_TYPE_ACCESS:
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
		name = POSIX_ACL_XATTR_ACCESS;
 | 
							name = POSIX_ACL_XATTR_ACCESS;
 | 
				
			||||||
		p_acl = &inode->i_acl;
 | 
					 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case ACL_TYPE_DEFAULT:
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
		name = POSIX_ACL_XATTR_DEFAULT;
 | 
							name = POSIX_ACL_XATTR_DEFAULT;
 | 
				
			||||||
		p_acl = &inode->i_default_acl;
 | 
					 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return ERR_PTR(-EINVAL);
 | 
							BUG();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	acl = iget_acl(inode, p_acl);
 | 
					 | 
				
			||||||
	if (acl != ACL_NOT_CACHED)
 | 
					 | 
				
			||||||
		return acl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	size = reiserfs_xattr_get(inode, name, NULL, 0);
 | 
						size = reiserfs_xattr_get(inode, name, NULL, 0);
 | 
				
			||||||
	if (size < 0) {
 | 
						if (size < 0) {
 | 
				
			||||||
		if (size == -ENODATA || size == -ENOSYS) {
 | 
							if (size == -ENODATA || size == -ENOSYS) {
 | 
				
			||||||
			*p_acl = NULL;
 | 
								set_cached_acl(inode, type, NULL);
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return ERR_PTR(size);
 | 
							return ERR_PTR(size);
 | 
				
			||||||
| 
						 | 
					@ -259,14 +234,13 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
 | 
				
			||||||
		/* This shouldn't actually happen as it should have
 | 
							/* This shouldn't actually happen as it should have
 | 
				
			||||||
		   been caught above.. but just in case */
 | 
							   been caught above.. but just in case */
 | 
				
			||||||
		acl = NULL;
 | 
							acl = NULL;
 | 
				
			||||||
		*p_acl = acl;
 | 
					 | 
				
			||||||
	} else if (retval < 0) {
 | 
						} else if (retval < 0) {
 | 
				
			||||||
		acl = ERR_PTR(retval);
 | 
							acl = ERR_PTR(retval);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		acl = posix_acl_from_disk(value, retval);
 | 
							acl = posix_acl_from_disk(value, retval);
 | 
				
			||||||
		if (!IS_ERR(acl))
 | 
					 | 
				
			||||||
			iset_acl(inode, p_acl, acl);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (!IS_ERR(acl))
 | 
				
			||||||
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
	return acl;
 | 
						return acl;
 | 
				
			||||||
| 
						 | 
					@ -284,7 +258,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char *name;
 | 
						char *name;
 | 
				
			||||||
	void *value = NULL;
 | 
						void *value = NULL;
 | 
				
			||||||
	struct posix_acl **p_acl;
 | 
					 | 
				
			||||||
	size_t size = 0;
 | 
						size_t size = 0;
 | 
				
			||||||
	int error;
 | 
						int error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -294,7 +267,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
 | 
				
			||||||
	switch (type) {
 | 
						switch (type) {
 | 
				
			||||||
	case ACL_TYPE_ACCESS:
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
		name = POSIX_ACL_XATTR_ACCESS;
 | 
							name = POSIX_ACL_XATTR_ACCESS;
 | 
				
			||||||
		p_acl = &inode->i_acl;
 | 
					 | 
				
			||||||
		if (acl) {
 | 
							if (acl) {
 | 
				
			||||||
			mode_t mode = inode->i_mode;
 | 
								mode_t mode = inode->i_mode;
 | 
				
			||||||
			error = posix_acl_equiv_mode(acl, &mode);
 | 
								error = posix_acl_equiv_mode(acl, &mode);
 | 
				
			||||||
| 
						 | 
					@ -309,7 +281,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case ACL_TYPE_DEFAULT:
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
		name = POSIX_ACL_XATTR_DEFAULT;
 | 
							name = POSIX_ACL_XATTR_DEFAULT;
 | 
				
			||||||
		p_acl = &inode->i_default_acl;
 | 
					 | 
				
			||||||
		if (!S_ISDIR(inode->i_mode))
 | 
							if (!S_ISDIR(inode->i_mode))
 | 
				
			||||||
			return acl ? -EACCES : 0;
 | 
								return acl ? -EACCES : 0;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					@ -342,7 +313,7 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
 | 
				
			||||||
	kfree(value);
 | 
						kfree(value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!error)
 | 
						if (!error)
 | 
				
			||||||
		iset_acl(inode, p_acl, acl);
 | 
							set_cached_acl(inode, type, acl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return error;
 | 
						return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,9 +55,9 @@
 | 
				
			||||||
 * ACL support is not implemented.
 | 
					 * ACL support is not implemented.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "ubifs.h"
 | 
				
			||||||
#include <linux/xattr.h>
 | 
					#include <linux/xattr.h>
 | 
				
			||||||
#include <linux/posix_acl_xattr.h>
 | 
					#include <linux/posix_acl_xattr.h>
 | 
				
			||||||
#include "ubifs.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Limit the number of extended attributes per inode so that the total size
 | 
					 * Limit the number of extended attributes per inode so that the total size
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,4 +83,68 @@ extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
 | 
				
			||||||
extern struct posix_acl *get_posix_acl(struct inode *, int);
 | 
					extern struct posix_acl *get_posix_acl(struct inode *, int);
 | 
				
			||||||
extern int set_posix_acl(struct inode *, int, struct posix_acl *);
 | 
					extern int set_posix_acl(struct inode *, int, struct posix_acl *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline struct posix_acl *get_cached_acl(struct inode *inode, int type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct posix_acl **p, *acl;
 | 
				
			||||||
 | 
						switch (type) {
 | 
				
			||||||
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
 | 
							p = &inode->i_acl;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
 | 
							p = &inode->i_default_acl;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return ERR_PTR(-EINVAL);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						acl = ACCESS_ONCE(*p);
 | 
				
			||||||
 | 
						if (acl) {
 | 
				
			||||||
 | 
							spin_lock(&inode->i_lock);
 | 
				
			||||||
 | 
							acl = *p;
 | 
				
			||||||
 | 
							if (acl != ACL_NOT_CACHED)
 | 
				
			||||||
 | 
								acl = posix_acl_dup(acl);
 | 
				
			||||||
 | 
							spin_unlock(&inode->i_lock);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return acl;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline void set_cached_acl(struct inode *inode,
 | 
				
			||||||
 | 
									  int type,
 | 
				
			||||||
 | 
									  struct posix_acl *acl)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct posix_acl *old = NULL;
 | 
				
			||||||
 | 
						spin_lock(&inode->i_lock);
 | 
				
			||||||
 | 
						switch (type) {
 | 
				
			||||||
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
 | 
							old = inode->i_acl;
 | 
				
			||||||
 | 
							inode->i_acl = posix_acl_dup(acl);
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
 | 
							old = inode->i_default_acl;
 | 
				
			||||||
 | 
							inode->i_default_acl = posix_acl_dup(acl);
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						spin_unlock(&inode->i_lock);
 | 
				
			||||||
 | 
						if (old != ACL_NOT_CACHED)
 | 
				
			||||||
 | 
							posix_acl_release(old);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline void forget_cached_acl(struct inode *inode, int type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct posix_acl *old = NULL;
 | 
				
			||||||
 | 
						spin_lock(&inode->i_lock);
 | 
				
			||||||
 | 
						switch (type) {
 | 
				
			||||||
 | 
						case ACL_TYPE_ACCESS:
 | 
				
			||||||
 | 
							old = inode->i_acl;
 | 
				
			||||||
 | 
							inode->i_acl = ACL_NOT_CACHED;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						case ACL_TYPE_DEFAULT:
 | 
				
			||||||
 | 
							old = inode->i_default_acl;
 | 
				
			||||||
 | 
							inode->i_default_acl = ACL_NOT_CACHED;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						spin_unlock(&inode->i_lock);
 | 
				
			||||||
 | 
						if (old != ACL_NOT_CACHED)
 | 
				
			||||||
 | 
							posix_acl_release(old);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif  /* __LINUX_POSIX_ACL_H */
 | 
					#endif  /* __LINUX_POSIX_ACL_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue