mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
staging: lustre: llite: break ll_getxattr_common into 2 functions
Split the function ll_getxattr_common into two functions. The code used for listing xattrs and ll_getxattr_common is placed into a new function ll_getxattr_list. This allows ll_listxattr to call directly ll_getxattr_list instead of going through ll_getxattr_common. This change is needed for the upcoming VFS move xattr_handler from [s|g]etxattr. Signed-off-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1beba52d46
commit
1e1f9ff406
@@ -217,69 +217,18 @@ int ll_removexattr(struct dentry *dentry, const char *name)
|
|||||||
OBD_MD_FLXATTRRM);
|
OBD_MD_FLXATTRRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int
|
||||||
int ll_getxattr_common(struct inode *inode, const char *name,
|
ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer,
|
||||||
void *buffer, size_t size, __u64 valid)
|
size_t size, __u64 valid)
|
||||||
{
|
{
|
||||||
|
struct ll_inode_info *lli = ll_i2info(inode);
|
||||||
struct ll_sb_info *sbi = ll_i2sbi(inode);
|
struct ll_sb_info *sbi = ll_i2sbi(inode);
|
||||||
struct ptlrpc_request *req = NULL;
|
struct ptlrpc_request *req = NULL;
|
||||||
struct mdt_body *body;
|
struct mdt_body *body;
|
||||||
int xattr_type, rc;
|
|
||||||
void *xdata;
|
void *xdata;
|
||||||
struct ll_inode_info *lli = ll_i2info(inode);
|
int rc;
|
||||||
|
|
||||||
CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
|
if (sbi->ll_xattr_cache_enabled && type != XATTR_ACL_ACCESS_T) {
|
||||||
PFID(ll_inode2fid(inode)), inode);
|
|
||||||
|
|
||||||
/* listxattr have slightly different behavior from of ext3:
|
|
||||||
* without 'user_xattr' ext3 will list all xattr names but
|
|
||||||
* filtered out "^user..*"; we list them all for simplicity.
|
|
||||||
*/
|
|
||||||
if (!name) {
|
|
||||||
xattr_type = XATTR_OTHER_T;
|
|
||||||
goto do_getxattr;
|
|
||||||
}
|
|
||||||
|
|
||||||
xattr_type = get_xattr_type(name);
|
|
||||||
rc = xattr_type_filter(sbi, xattr_type);
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
/* b15587: ignore security.capability xattr for now */
|
|
||||||
if ((xattr_type == XATTR_SECURITY_T &&
|
|
||||||
strcmp(name, "security.capability") == 0))
|
|
||||||
return -ENODATA;
|
|
||||||
|
|
||||||
/* LU-549: Disable security.selinux when selinux is disabled */
|
|
||||||
if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() &&
|
|
||||||
strcmp(name, "security.selinux") == 0)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
#ifdef CONFIG_FS_POSIX_ACL
|
|
||||||
/* posix acl is under protection of LOOKUP lock. when calling to this,
|
|
||||||
* we just have path resolution to the target inode, so we have great
|
|
||||||
* chance that cached ACL is uptodate.
|
|
||||||
*/
|
|
||||||
if (xattr_type == XATTR_ACL_ACCESS_T) {
|
|
||||||
struct posix_acl *acl;
|
|
||||||
|
|
||||||
spin_lock(&lli->lli_lock);
|
|
||||||
acl = posix_acl_dup(lli->lli_posix_acl);
|
|
||||||
spin_unlock(&lli->lli_lock);
|
|
||||||
|
|
||||||
if (!acl)
|
|
||||||
return -ENODATA;
|
|
||||||
|
|
||||||
rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
|
||||||
posix_acl_release(acl);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
if (xattr_type == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode))
|
|
||||||
return -ENODATA;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
do_getxattr:
|
|
||||||
if (sbi->ll_xattr_cache_enabled && xattr_type != XATTR_ACL_ACCESS_T) {
|
|
||||||
rc = ll_xattr_cache_get(inode, name, buffer, size, valid);
|
rc = ll_xattr_cache_get(inode, name, buffer, size, valid);
|
||||||
if (rc == -EAGAIN)
|
if (rc == -EAGAIN)
|
||||||
goto getxattr_nocache;
|
goto getxattr_nocache;
|
||||||
@@ -340,7 +289,7 @@ getxattr_nocache:
|
|||||||
}
|
}
|
||||||
|
|
||||||
out_xattr:
|
out_xattr:
|
||||||
if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) {
|
if (rc == -EOPNOTSUPP && type == XATTR_USER_T) {
|
||||||
LCONSOLE_INFO(
|
LCONSOLE_INFO(
|
||||||
"%s: disabling user_xattr feature because it is not supported on the server: rc = %d\n",
|
"%s: disabling user_xattr feature because it is not supported on the server: rc = %d\n",
|
||||||
ll_get_fsname(inode->i_sb, NULL, 0), rc);
|
ll_get_fsname(inode->i_sb, NULL, 0), rc);
|
||||||
@@ -351,6 +300,58 @@ out:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int ll_getxattr_common(struct inode *inode, const char *name,
|
||||||
|
void *buffer, size_t size)
|
||||||
|
{
|
||||||
|
struct ll_sb_info *sbi = ll_i2sbi(inode);
|
||||||
|
int xattr_type, rc;
|
||||||
|
struct ll_inode_info *lli = ll_i2info(inode);
|
||||||
|
|
||||||
|
CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
|
||||||
|
PFID(ll_inode2fid(inode)), inode);
|
||||||
|
|
||||||
|
xattr_type = get_xattr_type(name);
|
||||||
|
rc = xattr_type_filter(sbi, xattr_type);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
/* b15587: ignore security.capability xattr for now */
|
||||||
|
if ((xattr_type == XATTR_SECURITY_T &&
|
||||||
|
strcmp(name, "security.capability") == 0))
|
||||||
|
return -ENODATA;
|
||||||
|
|
||||||
|
/* LU-549: Disable security.selinux when selinux is disabled */
|
||||||
|
if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() &&
|
||||||
|
strcmp(name, "security.selinux") == 0)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
#ifdef CONFIG_FS_POSIX_ACL
|
||||||
|
/* posix acl is under protection of LOOKUP lock. when calling to this,
|
||||||
|
* we just have path resolution to the target inode, so we have great
|
||||||
|
* chance that cached ACL is uptodate.
|
||||||
|
*/
|
||||||
|
if (xattr_type == XATTR_ACL_ACCESS_T) {
|
||||||
|
struct posix_acl *acl;
|
||||||
|
|
||||||
|
spin_lock(&lli->lli_lock);
|
||||||
|
acl = posix_acl_dup(lli->lli_posix_acl);
|
||||||
|
spin_unlock(&lli->lli_lock);
|
||||||
|
|
||||||
|
if (!acl)
|
||||||
|
return -ENODATA;
|
||||||
|
|
||||||
|
rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||||
|
posix_acl_release(acl);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
if (xattr_type == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode))
|
||||||
|
return -ENODATA;
|
||||||
|
#endif
|
||||||
|
return ll_xattr_list(inode, name, xattr_type, buffer, size,
|
||||||
|
OBD_MD_FLXATTR);
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode,
|
ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode,
|
||||||
const char *name, void *buffer, size_t size)
|
const char *name, void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
@@ -439,7 +440,7 @@ out:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ll_getxattr_common(inode, name, buffer, size, OBD_MD_FLXATTR);
|
return ll_getxattr_common(inode, name, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
|
ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
|
||||||
@@ -457,7 +458,8 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
|
|||||||
|
|
||||||
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LISTXATTR, 1);
|
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LISTXATTR, 1);
|
||||||
|
|
||||||
rc = ll_getxattr_common(inode, NULL, buffer, size, OBD_MD_FLXATTRLS);
|
rc = ll_xattr_list(inode, NULL, XATTR_OTHER_T, buffer, size,
|
||||||
|
OBD_MD_FLXATTRLS);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user