ceph: rename struct ceph_acls_info to ceph_acl_sec_ctx
Also rename ceph_release_acls_info() to ceph_release_acl_sec_ctx(). And move their definitions to different files. This is preparation for security label support. Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Родитель
057297812d
Коммит
5c31e92dff
|
@ -159,7 +159,7 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
||||||
struct ceph_acls_info *info)
|
struct ceph_acl_sec_ctx *as_ctx)
|
||||||
{
|
{
|
||||||
struct posix_acl *acl, *default_acl;
|
struct posix_acl *acl, *default_acl;
|
||||||
size_t val_size1 = 0, val_size2 = 0;
|
size_t val_size1 = 0, val_size2 = 0;
|
||||||
|
@ -234,9 +234,9 @@ int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
||||||
|
|
||||||
kfree(tmp_buf);
|
kfree(tmp_buf);
|
||||||
|
|
||||||
info->acl = acl;
|
as_ctx->acl = acl;
|
||||||
info->default_acl = default_acl;
|
as_ctx->default_acl = default_acl;
|
||||||
info->pagelist = pagelist;
|
as_ctx->pagelist = pagelist;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_err:
|
out_err:
|
||||||
|
@ -248,18 +248,10 @@ out_err:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ceph_init_inode_acls(struct inode* inode, struct ceph_acls_info *info)
|
void ceph_init_inode_acls(struct inode *inode, struct ceph_acl_sec_ctx *as_ctx)
|
||||||
{
|
{
|
||||||
if (!inode)
|
if (!inode)
|
||||||
return;
|
return;
|
||||||
ceph_set_cached_acl(inode, ACL_TYPE_ACCESS, info->acl);
|
ceph_set_cached_acl(inode, ACL_TYPE_ACCESS, as_ctx->acl);
|
||||||
ceph_set_cached_acl(inode, ACL_TYPE_DEFAULT, info->default_acl);
|
ceph_set_cached_acl(inode, ACL_TYPE_DEFAULT, as_ctx->default_acl);
|
||||||
}
|
|
||||||
|
|
||||||
void ceph_release_acls_info(struct ceph_acls_info *info)
|
|
||||||
{
|
|
||||||
posix_acl_release(info->acl);
|
|
||||||
posix_acl_release(info->default_acl);
|
|
||||||
if (info->pagelist)
|
|
||||||
ceph_pagelist_release(info->pagelist);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -825,7 +825,7 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
|
||||||
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
||||||
struct ceph_mds_client *mdsc = fsc->mdsc;
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
||||||
struct ceph_mds_request *req;
|
struct ceph_mds_request *req;
|
||||||
struct ceph_acls_info acls = {};
|
struct ceph_acl_sec_ctx as_ctx = {};
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (ceph_snap(dir) != CEPH_NOSNAP)
|
if (ceph_snap(dir) != CEPH_NOSNAP)
|
||||||
|
@ -836,7 +836,7 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ceph_pre_init_acls(dir, &mode, &acls);
|
err = ceph_pre_init_acls(dir, &mode, &as_ctx);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -855,9 +855,9 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
|
||||||
req->r_args.mknod.rdev = cpu_to_le32(rdev);
|
req->r_args.mknod.rdev = cpu_to_le32(rdev);
|
||||||
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
|
||||||
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
||||||
if (acls.pagelist) {
|
if (as_ctx.pagelist) {
|
||||||
req->r_pagelist = acls.pagelist;
|
req->r_pagelist = as_ctx.pagelist;
|
||||||
acls.pagelist = NULL;
|
as_ctx.pagelist = NULL;
|
||||||
}
|
}
|
||||||
err = ceph_mdsc_do_request(mdsc, dir, req);
|
err = ceph_mdsc_do_request(mdsc, dir, req);
|
||||||
if (!err && !req->r_reply_info.head->is_dentry)
|
if (!err && !req->r_reply_info.head->is_dentry)
|
||||||
|
@ -865,10 +865,10 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
|
||||||
ceph_mdsc_put_request(req);
|
ceph_mdsc_put_request(req);
|
||||||
out:
|
out:
|
||||||
if (!err)
|
if (!err)
|
||||||
ceph_init_inode_acls(d_inode(dentry), &acls);
|
ceph_init_inode_acls(d_inode(dentry), &as_ctx);
|
||||||
else
|
else
|
||||||
d_drop(dentry);
|
d_drop(dentry);
|
||||||
ceph_release_acls_info(&acls);
|
ceph_release_acl_sec_ctx(&as_ctx);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,7 +927,7 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||||
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
||||||
struct ceph_mds_client *mdsc = fsc->mdsc;
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
||||||
struct ceph_mds_request *req;
|
struct ceph_mds_request *req;
|
||||||
struct ceph_acls_info acls = {};
|
struct ceph_acl_sec_ctx as_ctx = {};
|
||||||
int err = -EROFS;
|
int err = -EROFS;
|
||||||
int op;
|
int op;
|
||||||
|
|
||||||
|
@ -950,7 +950,7 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
mode |= S_IFDIR;
|
mode |= S_IFDIR;
|
||||||
err = ceph_pre_init_acls(dir, &mode, &acls);
|
err = ceph_pre_init_acls(dir, &mode, &as_ctx);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -967,9 +967,9 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||||
req->r_args.mkdir.mode = cpu_to_le32(mode);
|
req->r_args.mkdir.mode = cpu_to_le32(mode);
|
||||||
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
|
||||||
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
||||||
if (acls.pagelist) {
|
if (as_ctx.pagelist) {
|
||||||
req->r_pagelist = acls.pagelist;
|
req->r_pagelist = as_ctx.pagelist;
|
||||||
acls.pagelist = NULL;
|
as_ctx.pagelist = NULL;
|
||||||
}
|
}
|
||||||
err = ceph_mdsc_do_request(mdsc, dir, req);
|
err = ceph_mdsc_do_request(mdsc, dir, req);
|
||||||
if (!err &&
|
if (!err &&
|
||||||
|
@ -979,10 +979,10 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||||
ceph_mdsc_put_request(req);
|
ceph_mdsc_put_request(req);
|
||||||
out:
|
out:
|
||||||
if (!err)
|
if (!err)
|
||||||
ceph_init_inode_acls(d_inode(dentry), &acls);
|
ceph_init_inode_acls(d_inode(dentry), &as_ctx);
|
||||||
else
|
else
|
||||||
d_drop(dentry);
|
d_drop(dentry);
|
||||||
ceph_release_acls_info(&acls);
|
ceph_release_acl_sec_ctx(&as_ctx);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -437,7 +437,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
|
||||||
struct ceph_mds_client *mdsc = fsc->mdsc;
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
||||||
struct ceph_mds_request *req;
|
struct ceph_mds_request *req;
|
||||||
struct dentry *dn;
|
struct dentry *dn;
|
||||||
struct ceph_acls_info acls = {};
|
struct ceph_acl_sec_ctx as_ctx = {};
|
||||||
int mask;
|
int mask;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
|
||||||
if (flags & O_CREAT) {
|
if (flags & O_CREAT) {
|
||||||
if (ceph_quota_is_max_files_exceeded(dir))
|
if (ceph_quota_is_max_files_exceeded(dir))
|
||||||
return -EDQUOT;
|
return -EDQUOT;
|
||||||
err = ceph_pre_init_acls(dir, &mode, &acls);
|
err = ceph_pre_init_acls(dir, &mode, &as_ctx);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -460,16 +460,16 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
|
||||||
req = prepare_open_request(dir->i_sb, flags, mode);
|
req = prepare_open_request(dir->i_sb, flags, mode);
|
||||||
if (IS_ERR(req)) {
|
if (IS_ERR(req)) {
|
||||||
err = PTR_ERR(req);
|
err = PTR_ERR(req);
|
||||||
goto out_acl;
|
goto out_ctx;
|
||||||
}
|
}
|
||||||
req->r_dentry = dget(dentry);
|
req->r_dentry = dget(dentry);
|
||||||
req->r_num_caps = 2;
|
req->r_num_caps = 2;
|
||||||
if (flags & O_CREAT) {
|
if (flags & O_CREAT) {
|
||||||
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL;
|
||||||
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
||||||
if (acls.pagelist) {
|
if (as_ctx.pagelist) {
|
||||||
req->r_pagelist = acls.pagelist;
|
req->r_pagelist = as_ctx.pagelist;
|
||||||
acls.pagelist = NULL;
|
as_ctx.pagelist = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
|
||||||
} else {
|
} else {
|
||||||
dout("atomic_open finish_open on dn %p\n", dn);
|
dout("atomic_open finish_open on dn %p\n", dn);
|
||||||
if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
|
if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
|
||||||
ceph_init_inode_acls(d_inode(dentry), &acls);
|
ceph_init_inode_acls(d_inode(dentry), &as_ctx);
|
||||||
file->f_mode |= FMODE_CREATED;
|
file->f_mode |= FMODE_CREATED;
|
||||||
}
|
}
|
||||||
err = finish_open(file, dentry, ceph_open);
|
err = finish_open(file, dentry, ceph_open);
|
||||||
|
@ -516,8 +516,8 @@ out_req:
|
||||||
if (!req->r_err && req->r_target_inode)
|
if (!req->r_err && req->r_target_inode)
|
||||||
ceph_put_fmode(ceph_inode(req->r_target_inode), req->r_fmode);
|
ceph_put_fmode(ceph_inode(req->r_target_inode), req->r_fmode);
|
||||||
ceph_mdsc_put_request(req);
|
ceph_mdsc_put_request(req);
|
||||||
out_acl:
|
out_ctx:
|
||||||
ceph_release_acls_info(&acls);
|
ceph_release_acl_sec_ctx(&as_ctx);
|
||||||
dout("atomic_open result=%d\n", err);
|
dout("atomic_open result=%d\n", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -929,6 +929,14 @@ extern void __ceph_build_xattrs_blob(struct ceph_inode_info *ci);
|
||||||
extern void __ceph_destroy_xattrs(struct ceph_inode_info *ci);
|
extern void __ceph_destroy_xattrs(struct ceph_inode_info *ci);
|
||||||
extern const struct xattr_handler *ceph_xattr_handlers[];
|
extern const struct xattr_handler *ceph_xattr_handlers[];
|
||||||
|
|
||||||
|
struct ceph_acl_sec_ctx {
|
||||||
|
#ifdef CONFIG_CEPH_FS_POSIX_ACL
|
||||||
|
void *default_acl;
|
||||||
|
void *acl;
|
||||||
|
#endif
|
||||||
|
struct ceph_pagelist *pagelist;
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_SECURITY
|
#ifdef CONFIG_SECURITY
|
||||||
extern bool ceph_security_xattr_deadlock(struct inode *in);
|
extern bool ceph_security_xattr_deadlock(struct inode *in);
|
||||||
extern bool ceph_security_xattr_wanted(struct inode *in);
|
extern bool ceph_security_xattr_wanted(struct inode *in);
|
||||||
|
@ -943,21 +951,17 @@ static inline bool ceph_security_xattr_wanted(struct inode *in)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* acl.c */
|
void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx);
|
||||||
struct ceph_acls_info {
|
|
||||||
void *default_acl;
|
|
||||||
void *acl;
|
|
||||||
struct ceph_pagelist *pagelist;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/* acl.c */
|
||||||
#ifdef CONFIG_CEPH_FS_POSIX_ACL
|
#ifdef CONFIG_CEPH_FS_POSIX_ACL
|
||||||
|
|
||||||
struct posix_acl *ceph_get_acl(struct inode *, int);
|
struct posix_acl *ceph_get_acl(struct inode *, int);
|
||||||
int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type);
|
int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type);
|
||||||
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
||||||
struct ceph_acls_info *info);
|
struct ceph_acl_sec_ctx *as_ctx);
|
||||||
void ceph_init_inode_acls(struct inode *inode, struct ceph_acls_info *info);
|
void ceph_init_inode_acls(struct inode *inode,
|
||||||
void ceph_release_acls_info(struct ceph_acls_info *info);
|
struct ceph_acl_sec_ctx *as_ctx);
|
||||||
|
|
||||||
static inline void ceph_forget_all_cached_acls(struct inode *inode)
|
static inline void ceph_forget_all_cached_acls(struct inode *inode)
|
||||||
{
|
{
|
||||||
|
@ -970,15 +974,12 @@ static inline void ceph_forget_all_cached_acls(struct inode *inode)
|
||||||
#define ceph_set_acl NULL
|
#define ceph_set_acl NULL
|
||||||
|
|
||||||
static inline int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
static inline int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
||||||
struct ceph_acls_info *info)
|
struct ceph_acl_sec_ctx *as_ctx)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline void ceph_init_inode_acls(struct inode *inode,
|
static inline void ceph_init_inode_acls(struct inode *inode,
|
||||||
struct ceph_acls_info *info)
|
struct ceph_acl_sec_ctx *as_ctx)
|
||||||
{
|
|
||||||
}
|
|
||||||
static inline void ceph_release_acls_info(struct ceph_acls_info *info)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
static inline int ceph_acl_chmod(struct dentry *dentry, struct inode *inode)
|
static inline int ceph_acl_chmod(struct dentry *dentry, struct inode *inode)
|
||||||
|
|
|
@ -1197,3 +1197,13 @@ bool ceph_security_xattr_deadlock(struct inode *in)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_CEPH_FS_POSIX_ACL
|
||||||
|
posix_acl_release(as_ctx->acl);
|
||||||
|
posix_acl_release(as_ctx->default_acl);
|
||||||
|
#endif
|
||||||
|
if (as_ctx->pagelist)
|
||||||
|
ceph_pagelist_release(as_ctx->pagelist);
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче