hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/ceph/acl.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/fs/ceph/acl.c
34 *
45 * 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.
196 */
207
218 #include <linux/ceph/ceph_debug.h>
....@@ -35,7 +22,7 @@
3522 struct ceph_inode_info *ci = ceph_inode(inode);
3623
3724 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))
3926 set_cached_acl(inode, type, acl);
4027 else
4128 forget_cached_acl(inode, type);
....@@ -104,6 +91,11 @@
10491 struct timespec64 old_ctime = inode->i_ctime;
10592 umode_t new_mode = inode->i_mode, old_mode = inode->i_mode;
10693
94
+ if (ceph_snap(inode) != CEPH_NOSNAP) {
95
+ ret = -EROFS;
96
+ goto out;
97
+ }
98
+
10799 switch (type) {
108100 case ACL_TYPE_ACCESS:
109101 name = XATTR_NAME_POSIX_ACL_ACCESS;
....@@ -138,11 +130,6 @@
138130 goto out_free;
139131 }
140132
141
- if (ceph_snap(inode) != CEPH_NOSNAP) {
142
- ret = -EROFS;
143
- goto out_free;
144
- }
145
-
146133 if (new_mode != old_mode) {
147134 newattrs.ia_ctime = current_time(inode);
148135 newattrs.ia_mode = new_mode;
....@@ -172,7 +159,7 @@
172159 }
173160
174161 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)
176163 {
177164 struct posix_acl *acl, *default_acl;
178165 size_t val_size1 = 0, val_size2 = 0;
....@@ -206,10 +193,9 @@
206193 tmp_buf = kmalloc(max(val_size1, val_size2), GFP_KERNEL);
207194 if (!tmp_buf)
208195 goto out_err;
209
- pagelist = kmalloc(sizeof(struct ceph_pagelist), GFP_KERNEL);
196
+ pagelist = ceph_pagelist_alloc(GFP_KERNEL);
210197 if (!pagelist)
211198 goto out_err;
212
- ceph_pagelist_init(pagelist);
213199
214200 err = ceph_pagelist_reserve(pagelist, PAGE_SIZE);
215201 if (err)
....@@ -236,8 +222,8 @@
236222 err = ceph_pagelist_reserve(pagelist, len + val_size2 + 8);
237223 if (err)
238224 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);
241227 err = posix_acl_to_xattr(&init_user_ns, default_acl,
242228 tmp_buf, val_size2);
243229 if (err < 0)
....@@ -248,9 +234,9 @@
248234
249235 kfree(tmp_buf);
250236
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;
254240 return 0;
255241
256242 out_err:
....@@ -262,18 +248,10 @@
262248 return err;
263249 }
264250
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)
266252 {
267253 if (!inode)
268254 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);
279257 }