| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/fs/ceph/acl.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2013 Guangliang Zhao, <lucienchao@gmail.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or |
|---|
| 7 | | - * modify it under the terms of the GNU General Public |
|---|
| 8 | | - * License v2 as published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 13 | | - * General Public License for more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public |
|---|
| 16 | | - * License along with this program; if not, write to the |
|---|
| 17 | | - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|---|
| 18 | | - * Boston, MA 021110-1307, USA. |
|---|
| 19 | 6 | */ |
|---|
| 20 | 7 | |
|---|
| 21 | 8 | #include <linux/ceph/ceph_debug.h> |
|---|
| .. | .. |
|---|
| 35 | 22 | struct ceph_inode_info *ci = ceph_inode(inode); |
|---|
| 36 | 23 | |
|---|
| 37 | 24 | spin_lock(&ci->i_ceph_lock); |
|---|
| 38 | | - if (__ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 0)) |
|---|
| 25 | + if (__ceph_caps_issued_mask_metric(ci, CEPH_CAP_XATTR_SHARED, 0)) |
|---|
| 39 | 26 | set_cached_acl(inode, type, acl); |
|---|
| 40 | 27 | else |
|---|
| 41 | 28 | forget_cached_acl(inode, type); |
|---|
| .. | .. |
|---|
| 104 | 91 | struct timespec64 old_ctime = inode->i_ctime; |
|---|
| 105 | 92 | umode_t new_mode = inode->i_mode, old_mode = inode->i_mode; |
|---|
| 106 | 93 | |
|---|
| 94 | + if (ceph_snap(inode) != CEPH_NOSNAP) { |
|---|
| 95 | + ret = -EROFS; |
|---|
| 96 | + goto out; |
|---|
| 97 | + } |
|---|
| 98 | + |
|---|
| 107 | 99 | switch (type) { |
|---|
| 108 | 100 | case ACL_TYPE_ACCESS: |
|---|
| 109 | 101 | name = XATTR_NAME_POSIX_ACL_ACCESS; |
|---|
| .. | .. |
|---|
| 138 | 130 | goto out_free; |
|---|
| 139 | 131 | } |
|---|
| 140 | 132 | |
|---|
| 141 | | - if (ceph_snap(inode) != CEPH_NOSNAP) { |
|---|
| 142 | | - ret = -EROFS; |
|---|
| 143 | | - goto out_free; |
|---|
| 144 | | - } |
|---|
| 145 | | - |
|---|
| 146 | 133 | if (new_mode != old_mode) { |
|---|
| 147 | 134 | newattrs.ia_ctime = current_time(inode); |
|---|
| 148 | 135 | newattrs.ia_mode = new_mode; |
|---|
| .. | .. |
|---|
| 172 | 159 | } |
|---|
| 173 | 160 | |
|---|
| 174 | 161 | int ceph_pre_init_acls(struct inode *dir, umode_t *mode, |
|---|
| 175 | | - struct ceph_acls_info *info) |
|---|
| 162 | + struct ceph_acl_sec_ctx *as_ctx) |
|---|
| 176 | 163 | { |
|---|
| 177 | 164 | struct posix_acl *acl, *default_acl; |
|---|
| 178 | 165 | size_t val_size1 = 0, val_size2 = 0; |
|---|
| .. | .. |
|---|
| 206 | 193 | tmp_buf = kmalloc(max(val_size1, val_size2), GFP_KERNEL); |
|---|
| 207 | 194 | if (!tmp_buf) |
|---|
| 208 | 195 | goto out_err; |
|---|
| 209 | | - pagelist = kmalloc(sizeof(struct ceph_pagelist), GFP_KERNEL); |
|---|
| 196 | + pagelist = ceph_pagelist_alloc(GFP_KERNEL); |
|---|
| 210 | 197 | if (!pagelist) |
|---|
| 211 | 198 | goto out_err; |
|---|
| 212 | | - ceph_pagelist_init(pagelist); |
|---|
| 213 | 199 | |
|---|
| 214 | 200 | err = ceph_pagelist_reserve(pagelist, PAGE_SIZE); |
|---|
| 215 | 201 | if (err) |
|---|
| .. | .. |
|---|
| 236 | 222 | err = ceph_pagelist_reserve(pagelist, len + val_size2 + 8); |
|---|
| 237 | 223 | if (err) |
|---|
| 238 | 224 | goto out_err; |
|---|
| 239 | | - err = ceph_pagelist_encode_string(pagelist, |
|---|
| 240 | | - XATTR_NAME_POSIX_ACL_DEFAULT, len); |
|---|
| 225 | + ceph_pagelist_encode_string(pagelist, |
|---|
| 226 | + XATTR_NAME_POSIX_ACL_DEFAULT, len); |
|---|
| 241 | 227 | err = posix_acl_to_xattr(&init_user_ns, default_acl, |
|---|
| 242 | 228 | tmp_buf, val_size2); |
|---|
| 243 | 229 | if (err < 0) |
|---|
| .. | .. |
|---|
| 248 | 234 | |
|---|
| 249 | 235 | kfree(tmp_buf); |
|---|
| 250 | 236 | |
|---|
| 251 | | - info->acl = acl; |
|---|
| 252 | | - info->default_acl = default_acl; |
|---|
| 253 | | - info->pagelist = pagelist; |
|---|
| 237 | + as_ctx->acl = acl; |
|---|
| 238 | + as_ctx->default_acl = default_acl; |
|---|
| 239 | + as_ctx->pagelist = pagelist; |
|---|
| 254 | 240 | return 0; |
|---|
| 255 | 241 | |
|---|
| 256 | 242 | out_err: |
|---|
| .. | .. |
|---|
| 262 | 248 | return err; |
|---|
| 263 | 249 | } |
|---|
| 264 | 250 | |
|---|
| 265 | | -void ceph_init_inode_acls(struct inode* inode, struct ceph_acls_info *info) |
|---|
| 251 | +void ceph_init_inode_acls(struct inode *inode, struct ceph_acl_sec_ctx *as_ctx) |
|---|
| 266 | 252 | { |
|---|
| 267 | 253 | if (!inode) |
|---|
| 268 | 254 | return; |
|---|
| 269 | | - ceph_set_cached_acl(inode, ACL_TYPE_ACCESS, info->acl); |
|---|
| 270 | | - ceph_set_cached_acl(inode, ACL_TYPE_DEFAULT, info->default_acl); |
|---|
| 271 | | -} |
|---|
| 272 | | - |
|---|
| 273 | | -void ceph_release_acls_info(struct ceph_acls_info *info) |
|---|
| 274 | | -{ |
|---|
| 275 | | - posix_acl_release(info->acl); |
|---|
| 276 | | - posix_acl_release(info->default_acl); |
|---|
| 277 | | - if (info->pagelist) |
|---|
| 278 | | - ceph_pagelist_release(info->pagelist); |
|---|
| 255 | + ceph_set_cached_acl(inode, ACL_TYPE_ACCESS, as_ctx->acl); |
|---|
| 256 | + ceph_set_cached_acl(inode, ACL_TYPE_DEFAULT, as_ctx->default_acl); |
|---|
| 279 | 257 | } |
|---|