^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/fs/ceph/acl.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2013 Guangliang Zhao, <lucienchao@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/ceph/ceph_debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/posix_acl_xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/posix_acl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "super.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static inline void ceph_set_cached_acl(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int type, struct posix_acl *acl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct ceph_inode_info *ci = ceph_inode(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) spin_lock(&ci->i_ceph_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if (__ceph_caps_issued_mask_metric(ci, CEPH_CAP_XATTR_SHARED, 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) set_cached_acl(inode, type, acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) forget_cached_acl(inode, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) spin_unlock(&ci->i_ceph_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct posix_acl *ceph_get_acl(struct inode *inode, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned int retry_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) char *value = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct posix_acl *acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) case ACL_TYPE_ACCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) name = XATTR_NAME_POSIX_ACL_ACCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) case ACL_TYPE_DEFAULT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) name = XATTR_NAME_POSIX_ACL_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) retry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) size = __ceph_getxattr(inode, name, "", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (size > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) value = kzalloc(size, GFP_NOFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (!value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) size = __ceph_getxattr(inode, name, value, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if (size == -ERANGE && retry_cnt < 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) retry_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) kfree(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) value = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) goto retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (size > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) acl = posix_acl_from_xattr(&init_user_ns, value, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) } else if (size == -ENODATA || size == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) acl = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) pr_err_ratelimited("get acl %llx.%llx failed, err=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ceph_vinop(inode), size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) acl = ERR_PTR(-EIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) kfree(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) if (!IS_ERR(acl))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) ceph_set_cached_acl(inode, type, acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int ret = 0, size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) const char *name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) char *value = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct iattr newattrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct timespec64 old_ctime = inode->i_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) umode_t new_mode = inode->i_mode, old_mode = inode->i_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (ceph_snap(inode) != CEPH_NOSNAP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ret = -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) case ACL_TYPE_ACCESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) name = XATTR_NAME_POSIX_ACL_ACCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (acl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ret = posix_acl_update_mode(inode, &new_mode, &acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) case ACL_TYPE_DEFAULT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (!S_ISDIR(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ret = acl ? -EINVAL : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) name = XATTR_NAME_POSIX_ACL_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (acl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) size = posix_acl_xattr_size(acl->a_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) value = kmalloc(size, GFP_NOFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) if (!value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) ret = posix_acl_to_xattr(&init_user_ns, acl, value, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (new_mode != old_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) newattrs.ia_ctime = current_time(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) newattrs.ia_mode = new_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) ret = __ceph_setattr(inode, &newattrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) ret = __ceph_setxattr(inode, name, value, size, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (new_mode != old_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) newattrs.ia_ctime = old_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) newattrs.ia_mode = old_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) __ceph_setattr(inode, &newattrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) ceph_set_cached_acl(inode, type, acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) kfree(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct ceph_acl_sec_ctx *as_ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct posix_acl *acl, *default_acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) size_t val_size1 = 0, val_size2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct ceph_pagelist *pagelist = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) void *tmp_buf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) err = posix_acl_create(dir, mode, &default_acl, &acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (acl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) err = posix_acl_equiv_mode(acl, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (err == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) posix_acl_release(acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) acl = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (!default_acl && !acl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (acl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) val_size1 = posix_acl_xattr_size(acl->a_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) if (default_acl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) val_size2 = posix_acl_xattr_size(default_acl->a_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) tmp_buf = kmalloc(max(val_size1, val_size2), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (!tmp_buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) pagelist = ceph_pagelist_alloc(GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (!pagelist)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) err = ceph_pagelist_reserve(pagelist, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) ceph_pagelist_encode_32(pagelist, acl && default_acl ? 2 : 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (acl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) size_t len = strlen(XATTR_NAME_POSIX_ACL_ACCESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) err = ceph_pagelist_reserve(pagelist, len + val_size1 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ceph_pagelist_encode_string(pagelist, XATTR_NAME_POSIX_ACL_ACCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) err = posix_acl_to_xattr(&init_user_ns, acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) tmp_buf, val_size1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ceph_pagelist_encode_32(pagelist, val_size1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ceph_pagelist_append(pagelist, tmp_buf, val_size1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (default_acl) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) size_t len = strlen(XATTR_NAME_POSIX_ACL_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) err = ceph_pagelist_reserve(pagelist, len + val_size2 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) ceph_pagelist_encode_string(pagelist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) XATTR_NAME_POSIX_ACL_DEFAULT, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) err = posix_acl_to_xattr(&init_user_ns, default_acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) tmp_buf, val_size2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) ceph_pagelist_encode_32(pagelist, val_size2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ceph_pagelist_append(pagelist, tmp_buf, val_size2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) kfree(tmp_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) as_ctx->acl = acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) as_ctx->default_acl = default_acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) as_ctx->pagelist = pagelist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) out_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) posix_acl_release(acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) posix_acl_release(default_acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) kfree(tmp_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) if (pagelist)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) ceph_pagelist_release(pagelist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) void ceph_init_inode_acls(struct inode *inode, struct ceph_acl_sec_ctx *as_ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (!inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) ceph_set_cached_acl(inode, ACL_TYPE_ACCESS, as_ctx->acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) ceph_set_cached_acl(inode, ACL_TYPE_DEFAULT, as_ctx->default_acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }