blob: 6621d27e64f54654ce852a3333d2cb60526b0b04 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -07002#include <linux/ceph/ceph_debug.h>
Yan, Zheng25e6bae2014-09-16 19:15:28 +08003#include <linux/ceph/pagelist.h>
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -07004
Sage Weil355da1e2009-10-06 11:31:08 -07005#include "super.h"
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -07006#include "mds_client.h"
7
8#include <linux/ceph/decode.h>
Sage Weil355da1e2009-10-06 11:31:08 -07009
10#include <linux/xattr.h>
Yan, Zhengac6713c2019-05-26 16:27:56 +080011#include <linux/security.h>
Linus Torvalds4db658e2014-01-28 18:06:18 -080012#include <linux/posix_acl_xattr.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090013#include <linux/slab.h>
Sage Weil355da1e2009-10-06 11:31:08 -070014
Alex Elder22891902012-01-23 15:49:28 -060015#define XATTR_CEPH_PREFIX "ceph."
16#define XATTR_CEPH_PREFIX_LEN (sizeof (XATTR_CEPH_PREFIX) - 1)
17
Yan, Zhengbcdfeb22014-02-11 13:04:19 +080018static int __remove_xattr(struct ceph_inode_info *ci,
19 struct ceph_inode_xattr *xattr);
20
Sage Weil355da1e2009-10-06 11:31:08 -070021static bool ceph_is_valid_xattr(const char *name)
22{
Alex Elder22891902012-01-23 15:49:28 -060023 return !strncmp(name, XATTR_CEPH_PREFIX, XATTR_CEPH_PREFIX_LEN) ||
Sage Weil355da1e2009-10-06 11:31:08 -070024 !strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) ||
25 !strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
26}
27
28/*
29 * These define virtual xattrs exposing the recursive directory
30 * statistics and layout metadata.
31 */
Alex Elder881a5fa2012-01-23 15:49:28 -060032struct ceph_vxattr {
Sage Weil355da1e2009-10-06 11:31:08 -070033 char *name;
Alex Elder3ce6cd12012-01-23 15:49:28 -060034 size_t name_size; /* strlen(name) + 1 (for '\0') */
Sage Weil355da1e2009-10-06 11:31:08 -070035 size_t (*getxattr_cb)(struct ceph_inode_info *ci, char *val,
36 size_t size);
Sage Weilf36e4472013-01-20 21:59:29 -080037 bool (*exists_cb)(struct ceph_inode_info *ci);
Yan, Zheng4e9906e2018-04-25 17:14:05 +080038 unsigned int flags;
Sage Weil355da1e2009-10-06 11:31:08 -070039};
40
Yan, Zheng4e9906e2018-04-25 17:14:05 +080041#define VXATTR_FLAG_READONLY (1<<0)
42#define VXATTR_FLAG_HIDDEN (1<<1)
Yan, Zheng49a9f4f2018-04-25 17:30:23 +080043#define VXATTR_FLAG_RSTAT (1<<2)
Yan, Zheng4e9906e2018-04-25 17:14:05 +080044
Sage Weil32ab0bd2013-01-19 16:46:32 -080045/* layouts */
46
47static bool ceph_vxattrcb_layout_exists(struct ceph_inode_info *ci)
48{
Yan, Zheng779fe0f2016-03-07 09:35:06 +080049 struct ceph_file_layout *fl = &ci->i_layout;
50 return (fl->stripe_unit > 0 || fl->stripe_count > 0 ||
51 fl->object_size > 0 || fl->pool_id >= 0 ||
52 rcu_dereference_raw(fl->pool_ns) != NULL);
Sage Weil32ab0bd2013-01-19 16:46:32 -080053}
54
55static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
Yan, Zheng1e5c6642014-03-24 13:00:54 +080056 size_t size)
Sage Weil32ab0bd2013-01-19 16:46:32 -080057{
Sage Weil32ab0bd2013-01-19 16:46:32 -080058 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
59 struct ceph_osd_client *osdc = &fsc->client->osdc;
Yan, Zheng779fe0f2016-03-07 09:35:06 +080060 struct ceph_string *pool_ns;
Yan, Zheng76271512016-02-03 21:24:49 +080061 s64 pool = ci->i_layout.pool_id;
Sage Weil32ab0bd2013-01-19 16:46:32 -080062 const char *pool_name;
Yan, Zheng779fe0f2016-03-07 09:35:06 +080063 const char *ns_field = " pool_namespace=";
Yan, Zheng1e5c6642014-03-24 13:00:54 +080064 char buf[128];
Yan, Zheng779fe0f2016-03-07 09:35:06 +080065 size_t len, total_len = 0;
66 int ret;
67
68 pool_ns = ceph_try_get_string(ci->i_layout.pool_ns);
Sage Weil32ab0bd2013-01-19 16:46:32 -080069
70 dout("ceph_vxattrcb_layout %p\n", &ci->vfs_inode);
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +020071 down_read(&osdc->lock);
Sage Weil32ab0bd2013-01-19 16:46:32 -080072 pool_name = ceph_pg_pool_name_by_id(osdc->osdmap, pool);
Yan, Zheng1e5c6642014-03-24 13:00:54 +080073 if (pool_name) {
Yan, Zheng779fe0f2016-03-07 09:35:06 +080074 len = snprintf(buf, sizeof(buf),
Yan, Zheng76271512016-02-03 21:24:49 +080075 "stripe_unit=%u stripe_count=%u object_size=%u pool=",
76 ci->i_layout.stripe_unit, ci->i_layout.stripe_count,
77 ci->i_layout.object_size);
Yan, Zheng779fe0f2016-03-07 09:35:06 +080078 total_len = len + strlen(pool_name);
Yan, Zheng1e5c6642014-03-24 13:00:54 +080079 } else {
Yan, Zheng779fe0f2016-03-07 09:35:06 +080080 len = snprintf(buf, sizeof(buf),
Yan, Zheng76271512016-02-03 21:24:49 +080081 "stripe_unit=%u stripe_count=%u object_size=%u pool=%lld",
82 ci->i_layout.stripe_unit, ci->i_layout.stripe_count,
83 ci->i_layout.object_size, (unsigned long long)pool);
Yan, Zheng779fe0f2016-03-07 09:35:06 +080084 total_len = len;
85 }
86
87 if (pool_ns)
88 total_len += strlen(ns_field) + pool_ns->len;
89
90 if (!size) {
91 ret = total_len;
92 } else if (total_len > size) {
93 ret = -ERANGE;
94 } else {
95 memcpy(val, buf, len);
96 ret = len;
97 if (pool_name) {
98 len = strlen(pool_name);
99 memcpy(val + ret, pool_name, len);
100 ret += len;
101 }
102 if (pool_ns) {
103 len = strlen(ns_field);
104 memcpy(val + ret, ns_field, len);
105 ret += len;
106 memcpy(val + ret, pool_ns->str, pool_ns->len);
107 ret += pool_ns->len;
Yan, Zheng1e5c6642014-03-24 13:00:54 +0800108 }
109 }
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200110 up_read(&osdc->lock);
Yan, Zheng779fe0f2016-03-07 09:35:06 +0800111 ceph_put_string(pool_ns);
Sage Weil32ab0bd2013-01-19 16:46:32 -0800112 return ret;
113}
114
Sage Weil695b7112013-01-20 22:08:33 -0800115static size_t ceph_vxattrcb_layout_stripe_unit(struct ceph_inode_info *ci,
116 char *val, size_t size)
117{
Yan, Zheng76271512016-02-03 21:24:49 +0800118 return snprintf(val, size, "%u", ci->i_layout.stripe_unit);
Sage Weil695b7112013-01-20 22:08:33 -0800119}
120
121static size_t ceph_vxattrcb_layout_stripe_count(struct ceph_inode_info *ci,
122 char *val, size_t size)
123{
Yan, Zheng76271512016-02-03 21:24:49 +0800124 return snprintf(val, size, "%u", ci->i_layout.stripe_count);
Sage Weil695b7112013-01-20 22:08:33 -0800125}
126
127static size_t ceph_vxattrcb_layout_object_size(struct ceph_inode_info *ci,
128 char *val, size_t size)
129{
Yan, Zheng76271512016-02-03 21:24:49 +0800130 return snprintf(val, size, "%u", ci->i_layout.object_size);
Sage Weil695b7112013-01-20 22:08:33 -0800131}
132
133static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,
134 char *val, size_t size)
135{
136 int ret;
137 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
138 struct ceph_osd_client *osdc = &fsc->client->osdc;
Yan, Zheng76271512016-02-03 21:24:49 +0800139 s64 pool = ci->i_layout.pool_id;
Sage Weil695b7112013-01-20 22:08:33 -0800140 const char *pool_name;
141
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200142 down_read(&osdc->lock);
Sage Weil695b7112013-01-20 22:08:33 -0800143 pool_name = ceph_pg_pool_name_by_id(osdc->osdmap, pool);
144 if (pool_name)
145 ret = snprintf(val, size, "%s", pool_name);
146 else
147 ret = snprintf(val, size, "%lld", (unsigned long long)pool);
Ilya Dryomov5aea3dc2016-04-28 16:07:26 +0200148 up_read(&osdc->lock);
Sage Weil695b7112013-01-20 22:08:33 -0800149 return ret;
150}
151
Yan, Zheng779fe0f2016-03-07 09:35:06 +0800152static size_t ceph_vxattrcb_layout_pool_namespace(struct ceph_inode_info *ci,
153 char *val, size_t size)
154{
155 int ret = 0;
156 struct ceph_string *ns = ceph_try_get_string(ci->i_layout.pool_ns);
157 if (ns) {
158 ret = snprintf(val, size, "%.*s", (int)ns->len, ns->str);
159 ceph_put_string(ns);
160 }
161 return ret;
162}
163
Sage Weil355da1e2009-10-06 11:31:08 -0700164/* directories */
165
Alex Elderaa4066e2012-01-23 15:49:28 -0600166static size_t ceph_vxattrcb_dir_entries(struct ceph_inode_info *ci, char *val,
Sage Weil355da1e2009-10-06 11:31:08 -0700167 size_t size)
168{
169 return snprintf(val, size, "%lld", ci->i_files + ci->i_subdirs);
170}
171
Alex Elderaa4066e2012-01-23 15:49:28 -0600172static size_t ceph_vxattrcb_dir_files(struct ceph_inode_info *ci, char *val,
Sage Weil355da1e2009-10-06 11:31:08 -0700173 size_t size)
174{
175 return snprintf(val, size, "%lld", ci->i_files);
176}
177
Alex Elderaa4066e2012-01-23 15:49:28 -0600178static size_t ceph_vxattrcb_dir_subdirs(struct ceph_inode_info *ci, char *val,
Sage Weil355da1e2009-10-06 11:31:08 -0700179 size_t size)
180{
181 return snprintf(val, size, "%lld", ci->i_subdirs);
182}
183
Alex Elderaa4066e2012-01-23 15:49:28 -0600184static size_t ceph_vxattrcb_dir_rentries(struct ceph_inode_info *ci, char *val,
Sage Weil355da1e2009-10-06 11:31:08 -0700185 size_t size)
186{
187 return snprintf(val, size, "%lld", ci->i_rfiles + ci->i_rsubdirs);
188}
189
Alex Elderaa4066e2012-01-23 15:49:28 -0600190static size_t ceph_vxattrcb_dir_rfiles(struct ceph_inode_info *ci, char *val,
Sage Weil355da1e2009-10-06 11:31:08 -0700191 size_t size)
192{
193 return snprintf(val, size, "%lld", ci->i_rfiles);
194}
195
Alex Elderaa4066e2012-01-23 15:49:28 -0600196static size_t ceph_vxattrcb_dir_rsubdirs(struct ceph_inode_info *ci, char *val,
Sage Weil355da1e2009-10-06 11:31:08 -0700197 size_t size)
198{
199 return snprintf(val, size, "%lld", ci->i_rsubdirs);
200}
201
Alex Elderaa4066e2012-01-23 15:49:28 -0600202static size_t ceph_vxattrcb_dir_rbytes(struct ceph_inode_info *ci, char *val,
Sage Weil355da1e2009-10-06 11:31:08 -0700203 size_t size)
204{
205 return snprintf(val, size, "%lld", ci->i_rbytes);
206}
207
Alex Elderaa4066e2012-01-23 15:49:28 -0600208static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val,
Sage Weil355da1e2009-10-06 11:31:08 -0700209 size_t size)
210{
David Disseldorp71880722019-05-15 16:56:39 +0200211 return snprintf(val, size, "%lld.%09ld", ci->i_rctime.tv_sec,
Arnd Bergmann9bbeab42018-07-13 22:18:36 +0200212 ci->i_rctime.tv_nsec);
Sage Weil355da1e2009-10-06 11:31:08 -0700213}
214
Yan, Zheng08796872019-01-09 11:07:02 +0800215/* dir pin */
216static bool ceph_vxattrcb_dir_pin_exists(struct ceph_inode_info *ci)
217{
218 return ci->i_dir_pin != -ENODATA;
219}
Luis Henriquesfb18a572018-01-05 10:47:18 +0000220
Yan, Zheng08796872019-01-09 11:07:02 +0800221static size_t ceph_vxattrcb_dir_pin(struct ceph_inode_info *ci, char *val,
222 size_t size)
223{
224 return snprintf(val, size, "%d", (int)ci->i_dir_pin);
225}
226
227/* quotas */
Luis Henriquesfb18a572018-01-05 10:47:18 +0000228static bool ceph_vxattrcb_quota_exists(struct ceph_inode_info *ci)
229{
Yan, Zhengf1919822018-04-08 09:54:39 +0800230 bool ret = false;
231 spin_lock(&ci->i_ceph_lock);
232 if ((ci->i_max_files || ci->i_max_bytes) &&
233 ci->i_vino.snap == CEPH_NOSNAP &&
234 ci->i_snap_realm &&
235 ci->i_snap_realm->ino == ci->i_vino.ino)
236 ret = true;
237 spin_unlock(&ci->i_ceph_lock);
238 return ret;
Luis Henriquesfb18a572018-01-05 10:47:18 +0000239}
240
241static size_t ceph_vxattrcb_quota(struct ceph_inode_info *ci, char *val,
242 size_t size)
243{
244 return snprintf(val, size, "max_bytes=%llu max_files=%llu",
245 ci->i_max_bytes, ci->i_max_files);
246}
247
248static size_t ceph_vxattrcb_quota_max_bytes(struct ceph_inode_info *ci,
249 char *val, size_t size)
250{
251 return snprintf(val, size, "%llu", ci->i_max_bytes);
252}
253
254static size_t ceph_vxattrcb_quota_max_files(struct ceph_inode_info *ci,
255 char *val, size_t size)
256{
257 return snprintf(val, size, "%llu", ci->i_max_files);
258}
Sage Weil32ab0bd2013-01-19 16:46:32 -0800259
David Disseldorp100cc612019-04-18 14:15:47 +0200260/* snapshots */
261static bool ceph_vxattrcb_snap_btime_exists(struct ceph_inode_info *ci)
262{
263 return (ci->i_snap_btime.tv_sec != 0 || ci->i_snap_btime.tv_nsec != 0);
264}
265
266static size_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val,
267 size_t size)
268{
269 return snprintf(val, size, "%lld.%09ld", ci->i_snap_btime.tv_sec,
270 ci->i_snap_btime.tv_nsec);
271}
272
Alex Eldereb788082012-01-23 15:49:28 -0600273#define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name
Sage Weil695b7112013-01-20 22:08:33 -0800274#define CEPH_XATTR_NAME2(_type, _name, _name2) \
275 XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
Alex Eldereb788082012-01-23 15:49:28 -0600276
Yan, Zheng49a9f4f2018-04-25 17:30:23 +0800277#define XATTR_NAME_CEPH(_type, _name, _flags) \
Sage Weil88601472013-01-31 11:53:27 -0800278 { \
279 .name = CEPH_XATTR_NAME(_type, _name), \
280 .name_size = sizeof (CEPH_XATTR_NAME(_type, _name)), \
281 .getxattr_cb = ceph_vxattrcb_ ## _type ## _ ## _name, \
Yan, Zheng49a9f4f2018-04-25 17:30:23 +0800282 .exists_cb = NULL, \
283 .flags = (VXATTR_FLAG_READONLY | _flags), \
Sage Weil88601472013-01-31 11:53:27 -0800284 }
Yan, Zheng49a9f4f2018-04-25 17:30:23 +0800285#define XATTR_RSTAT_FIELD(_type, _name) \
286 XATTR_NAME_CEPH(_type, _name, VXATTR_FLAG_RSTAT)
Sage Weil695b7112013-01-20 22:08:33 -0800287#define XATTR_LAYOUT_FIELD(_type, _name, _field) \
288 { \
289 .name = CEPH_XATTR_NAME2(_type, _name, _field), \
290 .name_size = sizeof (CEPH_XATTR_NAME2(_type, _name, _field)), \
291 .getxattr_cb = ceph_vxattrcb_ ## _name ## _ ## _field, \
Sage Weil695b7112013-01-20 22:08:33 -0800292 .exists_cb = ceph_vxattrcb_layout_exists, \
Yan, Zheng4e9906e2018-04-25 17:14:05 +0800293 .flags = VXATTR_FLAG_HIDDEN, \
Sage Weil695b7112013-01-20 22:08:33 -0800294 }
Luis Henriquesfb18a572018-01-05 10:47:18 +0000295#define XATTR_QUOTA_FIELD(_type, _name) \
296 { \
297 .name = CEPH_XATTR_NAME(_type, _name), \
298 .name_size = sizeof(CEPH_XATTR_NAME(_type, _name)), \
299 .getxattr_cb = ceph_vxattrcb_ ## _type ## _ ## _name, \
Luis Henriquesfb18a572018-01-05 10:47:18 +0000300 .exists_cb = ceph_vxattrcb_quota_exists, \
Yan, Zheng4e9906e2018-04-25 17:14:05 +0800301 .flags = VXATTR_FLAG_HIDDEN, \
Luis Henriquesfb18a572018-01-05 10:47:18 +0000302 }
Alex Eldereb788082012-01-23 15:49:28 -0600303
Alex Elder881a5fa2012-01-23 15:49:28 -0600304static struct ceph_vxattr ceph_dir_vxattrs[] = {
Sage Weil1f08f2b2013-01-20 22:07:12 -0800305 {
306 .name = "ceph.dir.layout",
307 .name_size = sizeof("ceph.dir.layout"),
308 .getxattr_cb = ceph_vxattrcb_layout,
Sage Weil1f08f2b2013-01-20 22:07:12 -0800309 .exists_cb = ceph_vxattrcb_layout_exists,
Yan, Zheng4e9906e2018-04-25 17:14:05 +0800310 .flags = VXATTR_FLAG_HIDDEN,
Sage Weil1f08f2b2013-01-20 22:07:12 -0800311 },
Sage Weil695b7112013-01-20 22:08:33 -0800312 XATTR_LAYOUT_FIELD(dir, layout, stripe_unit),
313 XATTR_LAYOUT_FIELD(dir, layout, stripe_count),
314 XATTR_LAYOUT_FIELD(dir, layout, object_size),
315 XATTR_LAYOUT_FIELD(dir, layout, pool),
Yan, Zheng779fe0f2016-03-07 09:35:06 +0800316 XATTR_LAYOUT_FIELD(dir, layout, pool_namespace),
Yan, Zheng49a9f4f2018-04-25 17:30:23 +0800317 XATTR_NAME_CEPH(dir, entries, 0),
318 XATTR_NAME_CEPH(dir, files, 0),
319 XATTR_NAME_CEPH(dir, subdirs, 0),
320 XATTR_RSTAT_FIELD(dir, rentries),
321 XATTR_RSTAT_FIELD(dir, rfiles),
322 XATTR_RSTAT_FIELD(dir, rsubdirs),
323 XATTR_RSTAT_FIELD(dir, rbytes),
324 XATTR_RSTAT_FIELD(dir, rctime),
Luis Henriquesfb18a572018-01-05 10:47:18 +0000325 {
Yan, Zheng08796872019-01-09 11:07:02 +0800326 .name = "ceph.dir.pin",
David Disseldorpe1b81432019-04-18 14:15:45 +0200327 .name_size = sizeof("ceph.dir.pin"),
Yan, Zheng08796872019-01-09 11:07:02 +0800328 .getxattr_cb = ceph_vxattrcb_dir_pin,
329 .exists_cb = ceph_vxattrcb_dir_pin_exists,
330 .flags = VXATTR_FLAG_HIDDEN,
331 },
332 {
Luis Henriquesfb18a572018-01-05 10:47:18 +0000333 .name = "ceph.quota",
334 .name_size = sizeof("ceph.quota"),
335 .getxattr_cb = ceph_vxattrcb_quota,
Luis Henriquesfb18a572018-01-05 10:47:18 +0000336 .exists_cb = ceph_vxattrcb_quota_exists,
Yan, Zheng4e9906e2018-04-25 17:14:05 +0800337 .flags = VXATTR_FLAG_HIDDEN,
Luis Henriquesfb18a572018-01-05 10:47:18 +0000338 },
339 XATTR_QUOTA_FIELD(quota, max_bytes),
340 XATTR_QUOTA_FIELD(quota, max_files),
David Disseldorp100cc612019-04-18 14:15:47 +0200341 {
342 .name = "ceph.snap.btime",
343 .name_size = sizeof("ceph.snap.btime"),
344 .getxattr_cb = ceph_vxattrcb_snap_btime,
345 .exists_cb = ceph_vxattrcb_snap_btime_exists,
346 .flags = VXATTR_FLAG_READONLY,
347 },
Alex Elder2c3dd4f2013-02-19 12:25:56 -0600348 { .name = NULL, 0 } /* Required table terminator */
Sage Weil355da1e2009-10-06 11:31:08 -0700349};
350
351/* files */
352
Alex Elder881a5fa2012-01-23 15:49:28 -0600353static struct ceph_vxattr ceph_file_vxattrs[] = {
Sage Weil32ab0bd2013-01-19 16:46:32 -0800354 {
355 .name = "ceph.file.layout",
356 .name_size = sizeof("ceph.file.layout"),
357 .getxattr_cb = ceph_vxattrcb_layout,
Sage Weil32ab0bd2013-01-19 16:46:32 -0800358 .exists_cb = ceph_vxattrcb_layout_exists,
Yan, Zheng4e9906e2018-04-25 17:14:05 +0800359 .flags = VXATTR_FLAG_HIDDEN,
Sage Weil32ab0bd2013-01-19 16:46:32 -0800360 },
Sage Weil695b7112013-01-20 22:08:33 -0800361 XATTR_LAYOUT_FIELD(file, layout, stripe_unit),
362 XATTR_LAYOUT_FIELD(file, layout, stripe_count),
363 XATTR_LAYOUT_FIELD(file, layout, object_size),
364 XATTR_LAYOUT_FIELD(file, layout, pool),
Yan, Zheng779fe0f2016-03-07 09:35:06 +0800365 XATTR_LAYOUT_FIELD(file, layout, pool_namespace),
David Disseldorp100cc612019-04-18 14:15:47 +0200366 {
367 .name = "ceph.snap.btime",
368 .name_size = sizeof("ceph.snap.btime"),
369 .getxattr_cb = ceph_vxattrcb_snap_btime,
370 .exists_cb = ceph_vxattrcb_snap_btime_exists,
371 .flags = VXATTR_FLAG_READONLY,
372 },
Alex Elder2c3dd4f2013-02-19 12:25:56 -0600373 { .name = NULL, 0 } /* Required table terminator */
Sage Weil355da1e2009-10-06 11:31:08 -0700374};
375
Alex Elder881a5fa2012-01-23 15:49:28 -0600376static struct ceph_vxattr *ceph_inode_vxattrs(struct inode *inode)
Sage Weil355da1e2009-10-06 11:31:08 -0700377{
378 if (S_ISDIR(inode->i_mode))
379 return ceph_dir_vxattrs;
380 else if (S_ISREG(inode->i_mode))
381 return ceph_file_vxattrs;
382 return NULL;
383}
384
Alex Elder881a5fa2012-01-23 15:49:28 -0600385static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
Sage Weil355da1e2009-10-06 11:31:08 -0700386 const char *name)
387{
Alex Elder881a5fa2012-01-23 15:49:28 -0600388 struct ceph_vxattr *vxattr = ceph_inode_vxattrs(inode);
Alex Elder06476a62012-01-23 15:49:27 -0600389
390 if (vxattr) {
391 while (vxattr->name) {
392 if (!strcmp(vxattr->name, name))
393 return vxattr;
394 vxattr++;
395 }
396 }
397
Sage Weil355da1e2009-10-06 11:31:08 -0700398 return NULL;
399}
400
401static int __set_xattr(struct ceph_inode_info *ci,
402 const char *name, int name_len,
403 const char *val, int val_len,
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800404 int flags, int update_xattr,
Sage Weil355da1e2009-10-06 11:31:08 -0700405 struct ceph_inode_xattr **newxattr)
406{
407 struct rb_node **p;
408 struct rb_node *parent = NULL;
409 struct ceph_inode_xattr *xattr = NULL;
410 int c;
411 int new = 0;
412
413 p = &ci->i_xattrs.index.rb_node;
414 while (*p) {
415 parent = *p;
416 xattr = rb_entry(parent, struct ceph_inode_xattr, node);
417 c = strncmp(name, xattr->name, min(name_len, xattr->name_len));
418 if (c < 0)
419 p = &(*p)->rb_left;
420 else if (c > 0)
421 p = &(*p)->rb_right;
422 else {
423 if (name_len == xattr->name_len)
424 break;
425 else if (name_len < xattr->name_len)
426 p = &(*p)->rb_left;
427 else
428 p = &(*p)->rb_right;
429 }
430 xattr = NULL;
431 }
432
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800433 if (update_xattr) {
434 int err = 0;
Luis Henriqueseeca9582017-04-28 11:14:04 +0100435
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800436 if (xattr && (flags & XATTR_CREATE))
437 err = -EEXIST;
438 else if (!xattr && (flags & XATTR_REPLACE))
439 err = -ENODATA;
440 if (err) {
441 kfree(name);
442 kfree(val);
Luis Henriqueseeca9582017-04-28 11:14:04 +0100443 kfree(*newxattr);
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800444 return err;
445 }
Yan, Zhengbcdfeb22014-02-11 13:04:19 +0800446 if (update_xattr < 0) {
447 if (xattr)
448 __remove_xattr(ci, xattr);
449 kfree(name);
Luis Henriqueseeca9582017-04-28 11:14:04 +0100450 kfree(*newxattr);
Yan, Zhengbcdfeb22014-02-11 13:04:19 +0800451 return 0;
452 }
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800453 }
454
Sage Weil355da1e2009-10-06 11:31:08 -0700455 if (!xattr) {
456 new = 1;
457 xattr = *newxattr;
458 xattr->name = name;
459 xattr->name_len = name_len;
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800460 xattr->should_free_name = update_xattr;
Sage Weil355da1e2009-10-06 11:31:08 -0700461
462 ci->i_xattrs.count++;
463 dout("__set_xattr count=%d\n", ci->i_xattrs.count);
464 } else {
465 kfree(*newxattr);
466 *newxattr = NULL;
467 if (xattr->should_free_val)
468 kfree((void *)xattr->val);
469
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800470 if (update_xattr) {
Sage Weil355da1e2009-10-06 11:31:08 -0700471 kfree((void *)name);
472 name = xattr->name;
473 }
474 ci->i_xattrs.names_size -= xattr->name_len;
475 ci->i_xattrs.vals_size -= xattr->val_len;
476 }
Sage Weil355da1e2009-10-06 11:31:08 -0700477 ci->i_xattrs.names_size += name_len;
478 ci->i_xattrs.vals_size += val_len;
479 if (val)
480 xattr->val = val;
481 else
482 xattr->val = "";
483
484 xattr->val_len = val_len;
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800485 xattr->dirty = update_xattr;
486 xattr->should_free_val = (val && update_xattr);
Sage Weil355da1e2009-10-06 11:31:08 -0700487
488 if (new) {
489 rb_link_node(&xattr->node, parent, p);
490 rb_insert_color(&xattr->node, &ci->i_xattrs.index);
491 dout("__set_xattr_val p=%p\n", p);
492 }
493
Yan, Zheng05729782019-05-27 16:15:41 +0800494 dout("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s\n",
495 ceph_vinop(&ci->vfs_inode), xattr, name_len, name, val_len, val);
Sage Weil355da1e2009-10-06 11:31:08 -0700496
497 return 0;
498}
499
500static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
501 const char *name)
502{
503 struct rb_node **p;
504 struct rb_node *parent = NULL;
505 struct ceph_inode_xattr *xattr = NULL;
Sage Weil17db1432011-01-13 15:27:29 -0800506 int name_len = strlen(name);
Sage Weil355da1e2009-10-06 11:31:08 -0700507 int c;
508
509 p = &ci->i_xattrs.index.rb_node;
510 while (*p) {
511 parent = *p;
512 xattr = rb_entry(parent, struct ceph_inode_xattr, node);
513 c = strncmp(name, xattr->name, xattr->name_len);
Sage Weil17db1432011-01-13 15:27:29 -0800514 if (c == 0 && name_len > xattr->name_len)
515 c = 1;
Sage Weil355da1e2009-10-06 11:31:08 -0700516 if (c < 0)
517 p = &(*p)->rb_left;
518 else if (c > 0)
519 p = &(*p)->rb_right;
520 else {
521 dout("__get_xattr %s: found %.*s\n", name,
522 xattr->val_len, xattr->val);
523 return xattr;
524 }
525 }
526
527 dout("__get_xattr %s: not found\n", name);
528
529 return NULL;
530}
531
532static void __free_xattr(struct ceph_inode_xattr *xattr)
533{
534 BUG_ON(!xattr);
535
536 if (xattr->should_free_name)
537 kfree((void *)xattr->name);
538 if (xattr->should_free_val)
539 kfree((void *)xattr->val);
540
541 kfree(xattr);
542}
543
544static int __remove_xattr(struct ceph_inode_info *ci,
545 struct ceph_inode_xattr *xattr)
546{
547 if (!xattr)
Yan, Zheng524186a2014-02-11 13:23:09 +0800548 return -ENODATA;
Sage Weil355da1e2009-10-06 11:31:08 -0700549
550 rb_erase(&xattr->node, &ci->i_xattrs.index);
551
552 if (xattr->should_free_name)
553 kfree((void *)xattr->name);
554 if (xattr->should_free_val)
555 kfree((void *)xattr->val);
556
557 ci->i_xattrs.names_size -= xattr->name_len;
558 ci->i_xattrs.vals_size -= xattr->val_len;
559 ci->i_xattrs.count--;
560 kfree(xattr);
561
562 return 0;
563}
564
Sage Weil355da1e2009-10-06 11:31:08 -0700565static char *__copy_xattr_names(struct ceph_inode_info *ci,
566 char *dest)
567{
568 struct rb_node *p;
569 struct ceph_inode_xattr *xattr = NULL;
570
571 p = rb_first(&ci->i_xattrs.index);
572 dout("__copy_xattr_names count=%d\n", ci->i_xattrs.count);
573
574 while (p) {
575 xattr = rb_entry(p, struct ceph_inode_xattr, node);
576 memcpy(dest, xattr->name, xattr->name_len);
577 dest[xattr->name_len] = '\0';
578
579 dout("dest=%s %p (%s) (%d/%d)\n", dest, xattr, xattr->name,
580 xattr->name_len, ci->i_xattrs.names_size);
581
582 dest += xattr->name_len + 1;
583 p = rb_next(p);
584 }
585
586 return dest;
587}
588
589void __ceph_destroy_xattrs(struct ceph_inode_info *ci)
590{
591 struct rb_node *p, *tmp;
592 struct ceph_inode_xattr *xattr = NULL;
593
594 p = rb_first(&ci->i_xattrs.index);
595
596 dout("__ceph_destroy_xattrs p=%p\n", p);
597
598 while (p) {
599 xattr = rb_entry(p, struct ceph_inode_xattr, node);
600 tmp = p;
601 p = rb_next(tmp);
602 dout("__ceph_destroy_xattrs next p=%p (%.*s)\n", p,
603 xattr->name_len, xattr->name);
604 rb_erase(tmp, &ci->i_xattrs.index);
605
606 __free_xattr(xattr);
607 }
608
609 ci->i_xattrs.names_size = 0;
610 ci->i_xattrs.vals_size = 0;
611 ci->i_xattrs.index_version = 0;
612 ci->i_xattrs.count = 0;
613 ci->i_xattrs.index = RB_ROOT;
614}
615
616static int __build_xattrs(struct inode *inode)
Sage Weilbe655592011-11-30 09:47:09 -0800617 __releases(ci->i_ceph_lock)
618 __acquires(ci->i_ceph_lock)
Sage Weil355da1e2009-10-06 11:31:08 -0700619{
620 u32 namelen;
621 u32 numattr = 0;
622 void *p, *end;
623 u32 len;
624 const char *name, *val;
625 struct ceph_inode_info *ci = ceph_inode(inode);
626 int xattr_version;
627 struct ceph_inode_xattr **xattrs = NULL;
Sage Weil63ff78b2009-11-01 17:51:15 -0800628 int err = 0;
Sage Weil355da1e2009-10-06 11:31:08 -0700629 int i;
630
631 dout("__build_xattrs() len=%d\n",
632 ci->i_xattrs.blob ? (int)ci->i_xattrs.blob->vec.iov_len : 0);
633
634 if (ci->i_xattrs.index_version >= ci->i_xattrs.version)
635 return 0; /* already built */
636
637 __ceph_destroy_xattrs(ci);
638
639start:
640 /* updated internal xattr rb tree */
641 if (ci->i_xattrs.blob && ci->i_xattrs.blob->vec.iov_len > 4) {
642 p = ci->i_xattrs.blob->vec.iov_base;
643 end = p + ci->i_xattrs.blob->vec.iov_len;
644 ceph_decode_32_safe(&p, end, numattr, bad);
645 xattr_version = ci->i_xattrs.version;
Sage Weilbe655592011-11-30 09:47:09 -0800646 spin_unlock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -0700647
Ilya Dryomov7e8a2952014-07-25 11:47:21 +0400648 xattrs = kcalloc(numattr, sizeof(struct ceph_inode_xattr *),
Sage Weil355da1e2009-10-06 11:31:08 -0700649 GFP_NOFS);
650 err = -ENOMEM;
651 if (!xattrs)
652 goto bad_lock;
Ilya Dryomov1a295bd2014-07-25 12:44:58 +0400653
Sage Weil355da1e2009-10-06 11:31:08 -0700654 for (i = 0; i < numattr; i++) {
655 xattrs[i] = kmalloc(sizeof(struct ceph_inode_xattr),
656 GFP_NOFS);
657 if (!xattrs[i])
658 goto bad_lock;
659 }
660
Sage Weilbe655592011-11-30 09:47:09 -0800661 spin_lock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -0700662 if (ci->i_xattrs.version != xattr_version) {
663 /* lost a race, retry */
664 for (i = 0; i < numattr; i++)
665 kfree(xattrs[i]);
666 kfree(xattrs);
Alan Cox21ec6ff2012-07-20 08:18:36 -0500667 xattrs = NULL;
Sage Weil355da1e2009-10-06 11:31:08 -0700668 goto start;
669 }
670 err = -EIO;
671 while (numattr--) {
672 ceph_decode_32_safe(&p, end, len, bad);
673 namelen = len;
674 name = p;
675 p += len;
676 ceph_decode_32_safe(&p, end, len, bad);
677 val = p;
678 p += len;
679
680 err = __set_xattr(ci, name, namelen, val, len,
Yan, Zhengfbc0b972014-02-11 13:01:19 +0800681 0, 0, &xattrs[numattr]);
Sage Weil355da1e2009-10-06 11:31:08 -0700682
683 if (err < 0)
684 goto bad;
685 }
686 kfree(xattrs);
687 }
688 ci->i_xattrs.index_version = ci->i_xattrs.version;
689 ci->i_xattrs.dirty = false;
690
691 return err;
692bad_lock:
Sage Weilbe655592011-11-30 09:47:09 -0800693 spin_lock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -0700694bad:
695 if (xattrs) {
696 for (i = 0; i < numattr; i++)
697 kfree(xattrs[i]);
698 kfree(xattrs);
699 }
700 ci->i_xattrs.names_size = 0;
701 return err;
702}
703
704static int __get_required_blob_size(struct ceph_inode_info *ci, int name_size,
705 int val_size)
706{
707 /*
708 * 4 bytes for the length, and additional 4 bytes per each xattr name,
709 * 4 bytes per each value
710 */
711 int size = 4 + ci->i_xattrs.count*(4 + 4) +
712 ci->i_xattrs.names_size +
713 ci->i_xattrs.vals_size;
714 dout("__get_required_blob_size c=%d names.size=%d vals.size=%d\n",
715 ci->i_xattrs.count, ci->i_xattrs.names_size,
716 ci->i_xattrs.vals_size);
717
718 if (name_size)
719 size += 4 + 4 + name_size + val_size;
720
721 return size;
722}
723
724/*
725 * If there are dirty xattrs, reencode xattrs into the prealloc_blob
726 * and swap into place.
727 */
728void __ceph_build_xattrs_blob(struct ceph_inode_info *ci)
729{
730 struct rb_node *p;
731 struct ceph_inode_xattr *xattr = NULL;
732 void *dest;
733
734 dout("__build_xattrs_blob %p\n", &ci->vfs_inode);
735 if (ci->i_xattrs.dirty) {
736 int need = __get_required_blob_size(ci, 0, 0);
737
738 BUG_ON(need > ci->i_xattrs.prealloc_blob->alloc_len);
739
740 p = rb_first(&ci->i_xattrs.index);
741 dest = ci->i_xattrs.prealloc_blob->vec.iov_base;
742
743 ceph_encode_32(&dest, ci->i_xattrs.count);
744 while (p) {
745 xattr = rb_entry(p, struct ceph_inode_xattr, node);
746
747 ceph_encode_32(&dest, xattr->name_len);
748 memcpy(dest, xattr->name, xattr->name_len);
749 dest += xattr->name_len;
750 ceph_encode_32(&dest, xattr->val_len);
751 memcpy(dest, xattr->val, xattr->val_len);
752 dest += xattr->val_len;
753
754 p = rb_next(p);
755 }
756
757 /* adjust buffer len; it may be larger than we need */
758 ci->i_xattrs.prealloc_blob->vec.iov_len =
759 dest - ci->i_xattrs.prealloc_blob->vec.iov_base;
760
Sage Weilb6c1d5b2009-12-07 12:17:17 -0800761 if (ci->i_xattrs.blob)
762 ceph_buffer_put(ci->i_xattrs.blob);
Sage Weil355da1e2009-10-06 11:31:08 -0700763 ci->i_xattrs.blob = ci->i_xattrs.prealloc_blob;
764 ci->i_xattrs.prealloc_blob = NULL;
765 ci->i_xattrs.dirty = false;
Sage Weil4a625be2010-08-22 15:03:56 -0700766 ci->i_xattrs.version++;
Sage Weil355da1e2009-10-06 11:31:08 -0700767 }
768}
769
Yan, Zheng315f2402016-03-07 10:34:50 +0800770static inline int __get_request_mask(struct inode *in) {
771 struct ceph_mds_request *req = current->journal_info;
772 int mask = 0;
773 if (req && req->r_target_inode == in) {
774 if (req->r_op == CEPH_MDS_OP_LOOKUP ||
775 req->r_op == CEPH_MDS_OP_LOOKUPINO ||
776 req->r_op == CEPH_MDS_OP_LOOKUPPARENT ||
777 req->r_op == CEPH_MDS_OP_GETATTR) {
778 mask = le32_to_cpu(req->r_args.getattr.mask);
779 } else if (req->r_op == CEPH_MDS_OP_OPEN ||
780 req->r_op == CEPH_MDS_OP_CREATE) {
781 mask = le32_to_cpu(req->r_args.open.mask);
782 }
783 }
784 return mask;
785}
786
Guangliang Zhao7221fe42013-11-11 15:18:03 +0800787ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value,
Sage Weil355da1e2009-10-06 11:31:08 -0700788 size_t size)
789{
Sage Weil355da1e2009-10-06 11:31:08 -0700790 struct ceph_inode_info *ci = ceph_inode(inode);
Sage Weil355da1e2009-10-06 11:31:08 -0700791 struct ceph_inode_xattr *xattr;
Alex Elder881a5fa2012-01-23 15:49:28 -0600792 struct ceph_vxattr *vxattr = NULL;
Yan, Zheng315f2402016-03-07 10:34:50 +0800793 int req_mask;
794 int err;
Sage Weil355da1e2009-10-06 11:31:08 -0700795
Sage Weil0bee82f2013-01-20 22:00:58 -0800796 /* let's see if a virtual xattr was requested */
797 vxattr = ceph_match_vxattr(inode, name);
Yan, Zheng29dccfa2016-03-12 13:32:16 +0800798 if (vxattr) {
Yan, Zheng49a9f4f2018-04-25 17:30:23 +0800799 int mask = 0;
800 if (vxattr->flags & VXATTR_FLAG_RSTAT)
801 mask |= CEPH_STAT_RSTAT;
802 err = ceph_do_getattr(inode, mask, true);
Yan, Zheng1684dd02017-06-14 15:54:56 +0800803 if (err)
804 return err;
Yan, Zheng29dccfa2016-03-12 13:32:16 +0800805 err = -ENODATA;
806 if (!(vxattr->exists_cb && !vxattr->exists_cb(ci)))
807 err = vxattr->getxattr_cb(ci, value, size);
majianpenga1dc1932013-06-19 14:58:10 +0800808 return err;
Sage Weil0bee82f2013-01-20 22:00:58 -0800809 }
810
Yan, Zheng315f2402016-03-07 10:34:50 +0800811 req_mask = __get_request_mask(inode);
812
majianpenga1dc1932013-06-19 14:58:10 +0800813 spin_lock(&ci->i_ceph_lock);
814 dout("getxattr %p ver=%lld index_ver=%lld\n", inode,
815 ci->i_xattrs.version, ci->i_xattrs.index_version);
816
Yan, Zheng508b32d2014-09-16 21:46:17 +0800817 if (ci->i_xattrs.version == 0 ||
Yan, Zheng315f2402016-03-07 10:34:50 +0800818 !((req_mask & CEPH_CAP_XATTR_SHARED) ||
819 __ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 1))) {
Sage Weilbe655592011-11-30 09:47:09 -0800820 spin_unlock(&ci->i_ceph_lock);
Yan, Zheng315f2402016-03-07 10:34:50 +0800821
822 /* security module gets xattr while filling trace */
Markus Elfringd37b1d92017-08-20 20:22:02 +0200823 if (current->journal_info) {
Yan, Zheng315f2402016-03-07 10:34:50 +0800824 pr_warn_ratelimited("sync getxattr %p "
825 "during filling trace\n", inode);
826 return -EBUSY;
827 }
828
Sage Weil355da1e2009-10-06 11:31:08 -0700829 /* get xattrs from mds (if we don't already have them) */
Yan, Zheng508b32d2014-09-16 21:46:17 +0800830 err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true);
Sage Weil355da1e2009-10-06 11:31:08 -0700831 if (err)
832 return err;
Yan, Zheng508b32d2014-09-16 21:46:17 +0800833 spin_lock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -0700834 }
835
Sage Weil355da1e2009-10-06 11:31:08 -0700836 err = __build_xattrs(inode);
837 if (err < 0)
838 goto out;
839
Sage Weil355da1e2009-10-06 11:31:08 -0700840 err = -ENODATA; /* == ENOATTR */
841 xattr = __get_xattr(ci, name);
Sage Weil0bee82f2013-01-20 22:00:58 -0800842 if (!xattr)
Sage Weil355da1e2009-10-06 11:31:08 -0700843 goto out;
Sage Weil355da1e2009-10-06 11:31:08 -0700844
845 err = -ERANGE;
846 if (size && size < xattr->val_len)
847 goto out;
848
849 err = xattr->val_len;
850 if (size == 0)
851 goto out;
852
853 memcpy(value, xattr->val, xattr->val_len);
854
Markus Elfringd37b1d92017-08-20 20:22:02 +0200855 if (current->journal_info &&
Yan, Zheng315f2402016-03-07 10:34:50 +0800856 !strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN))
857 ci->i_ceph_flags |= CEPH_I_SEC_INITED;
Sage Weil355da1e2009-10-06 11:31:08 -0700858out:
Sage Weilbe655592011-11-30 09:47:09 -0800859 spin_unlock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -0700860 return err;
861}
862
863ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
864{
David Howells2b0143b2015-03-17 22:25:59 +0000865 struct inode *inode = d_inode(dentry);
Sage Weil355da1e2009-10-06 11:31:08 -0700866 struct ceph_inode_info *ci = ceph_inode(inode);
Alex Elder881a5fa2012-01-23 15:49:28 -0600867 struct ceph_vxattr *vxattrs = ceph_inode_vxattrs(inode);
David Disseldorp2b2abca2019-04-18 14:15:48 +0200868 bool len_only = (size == 0);
Sage Weil355da1e2009-10-06 11:31:08 -0700869 u32 namelen;
870 int err;
Sage Weil355da1e2009-10-06 11:31:08 -0700871 int i;
872
Sage Weilbe655592011-11-30 09:47:09 -0800873 spin_lock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -0700874 dout("listxattr %p ver=%lld index_ver=%lld\n", inode,
875 ci->i_xattrs.version, ci->i_xattrs.index_version);
876
Yan, Zheng508b32d2014-09-16 21:46:17 +0800877 if (ci->i_xattrs.version == 0 ||
878 !__ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 1)) {
Sage Weilbe655592011-11-30 09:47:09 -0800879 spin_unlock(&ci->i_ceph_lock);
Yan, Zheng508b32d2014-09-16 21:46:17 +0800880 err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true);
Sage Weil355da1e2009-10-06 11:31:08 -0700881 if (err)
882 return err;
Yan, Zheng508b32d2014-09-16 21:46:17 +0800883 spin_lock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -0700884 }
885
Sage Weil355da1e2009-10-06 11:31:08 -0700886 err = __build_xattrs(inode);
887 if (err < 0)
888 goto out;
Alex Elder3ce6cd12012-01-23 15:49:28 -0600889
David Disseldorp2b2abca2019-04-18 14:15:48 +0200890 /* add 1 byte for each xattr due to the null termination */
Sage Weilb65917d2013-01-20 22:02:39 -0800891 namelen = ci->i_xattrs.names_size + ci->i_xattrs.count;
David Disseldorp2b2abca2019-04-18 14:15:48 +0200892 if (!len_only) {
893 if (namelen > size) {
894 err = -ERANGE;
895 goto out;
Sage Weil355da1e2009-10-06 11:31:08 -0700896 }
David Disseldorp2b2abca2019-04-18 14:15:48 +0200897 names = __copy_xattr_names(ci, names);
898 size -= namelen;
Sage Weilb65917d2013-01-20 22:02:39 -0800899 }
Sage Weil355da1e2009-10-06 11:31:08 -0700900
David Disseldorp2b2abca2019-04-18 14:15:48 +0200901
902 /* virtual xattr names, too */
903 if (vxattrs) {
904 for (i = 0; vxattrs[i].name; i++) {
905 size_t this_len;
906
907 if (vxattrs[i].flags & VXATTR_FLAG_HIDDEN)
908 continue;
909 if (vxattrs[i].exists_cb && !vxattrs[i].exists_cb(ci))
910 continue;
911
912 this_len = strlen(vxattrs[i].name) + 1;
913 namelen += this_len;
914 if (len_only)
915 continue;
916
917 if (this_len > size) {
918 err = -ERANGE;
919 goto out;
920 }
921
922 memcpy(names, vxattrs[i].name, this_len);
923 names += this_len;
924 size -= this_len;
925 }
926 }
927 err = namelen;
Sage Weil355da1e2009-10-06 11:31:08 -0700928out:
Sage Weilbe655592011-11-30 09:47:09 -0800929 spin_unlock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -0700930 return err;
931}
932
Andreas Gruenbachera26fecc2016-04-14 00:30:16 +0200933static int ceph_sync_setxattr(struct inode *inode, const char *name,
Sage Weil355da1e2009-10-06 11:31:08 -0700934 const char *value, size_t size, int flags)
935{
Andreas Gruenbachera26fecc2016-04-14 00:30:16 +0200936 struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
Sage Weil355da1e2009-10-06 11:31:08 -0700937 struct ceph_inode_info *ci = ceph_inode(inode);
Sage Weil355da1e2009-10-06 11:31:08 -0700938 struct ceph_mds_request *req;
Yehuda Sadeh3d14c5d2010-04-06 15:14:15 -0700939 struct ceph_mds_client *mdsc = fsc->mdsc;
Yan, Zheng25e6bae2014-09-16 19:15:28 +0800940 struct ceph_pagelist *pagelist = NULL;
Yan, Zheng04303d82016-04-21 12:11:54 +0800941 int op = CEPH_MDS_OP_SETXATTR;
Sage Weil355da1e2009-10-06 11:31:08 -0700942 int err;
Sage Weil355da1e2009-10-06 11:31:08 -0700943
Yan, Zheng0aeff372014-12-17 21:26:47 +0800944 if (size > 0) {
Yan, Zheng25e6bae2014-09-16 19:15:28 +0800945 /* copy value into pagelist */
Ilya Dryomov33165d42018-09-28 15:38:34 +0200946 pagelist = ceph_pagelist_alloc(GFP_NOFS);
Yan, Zheng25e6bae2014-09-16 19:15:28 +0800947 if (!pagelist)
Sage Weil355da1e2009-10-06 11:31:08 -0700948 return -ENOMEM;
Yan, Zheng25e6bae2014-09-16 19:15:28 +0800949
Yan, Zheng25e6bae2014-09-16 19:15:28 +0800950 err = ceph_pagelist_append(pagelist, value, size);
951 if (err)
952 goto out;
Yan, Zheng0aeff372014-12-17 21:26:47 +0800953 } else if (!value) {
Yan, Zheng04303d82016-04-21 12:11:54 +0800954 if (flags & CEPH_XATTR_REPLACE)
955 op = CEPH_MDS_OP_RMXATTR;
956 else
957 flags |= CEPH_XATTR_REMOVE;
Sage Weil355da1e2009-10-06 11:31:08 -0700958 }
959
960 dout("setxattr value=%.*s\n", (int)size, value);
961
962 /* do request */
Yan, Zheng04303d82016-04-21 12:11:54 +0800963 req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
Julia Lawall60d87732009-11-21 12:53:08 +0100964 if (IS_ERR(req)) {
965 err = PTR_ERR(req);
966 goto out;
967 }
Sanidhya Kashyapa149bb92015-03-21 12:54:58 -0400968
Sage Weil355da1e2009-10-06 11:31:08 -0700969 req->r_path2 = kstrdup(name, GFP_NOFS);
Sanidhya Kashyapa149bb92015-03-21 12:54:58 -0400970 if (!req->r_path2) {
971 ceph_mdsc_put_request(req);
972 err = -ENOMEM;
973 goto out;
974 }
Sage Weil355da1e2009-10-06 11:31:08 -0700975
Yan, Zheng04303d82016-04-21 12:11:54 +0800976 if (op == CEPH_MDS_OP_SETXATTR) {
977 req->r_args.setxattr.flags = cpu_to_le32(flags);
978 req->r_pagelist = pagelist;
979 pagelist = NULL;
980 }
Sage Weil355da1e2009-10-06 11:31:08 -0700981
Sanidhya Kashyapa149bb92015-03-21 12:54:58 -0400982 req->r_inode = inode;
983 ihold(inode);
984 req->r_num_caps = 1;
985 req->r_inode_drop = CEPH_CAP_XATTR_SHARED;
986
Sage Weil355da1e2009-10-06 11:31:08 -0700987 dout("xattr.ver (before): %lld\n", ci->i_xattrs.version);
Sage Weil752c8bd2013-02-05 13:52:29 -0800988 err = ceph_mdsc_do_request(mdsc, NULL, req);
Sage Weil355da1e2009-10-06 11:31:08 -0700989 ceph_mdsc_put_request(req);
990 dout("xattr.ver (after): %lld\n", ci->i_xattrs.version);
991
992out:
Yan, Zheng25e6bae2014-09-16 19:15:28 +0800993 if (pagelist)
994 ceph_pagelist_release(pagelist);
Sage Weil355da1e2009-10-06 11:31:08 -0700995 return err;
996}
997
Andreas Gruenbachera26fecc2016-04-14 00:30:16 +0200998int __ceph_setxattr(struct inode *inode, const char *name,
Guangliang Zhao7221fe42013-11-11 15:18:03 +0800999 const void *value, size_t size, int flags)
Sage Weil355da1e2009-10-06 11:31:08 -07001000{
Alex Elder881a5fa2012-01-23 15:49:28 -06001001 struct ceph_vxattr *vxattr;
Sage Weil355da1e2009-10-06 11:31:08 -07001002 struct ceph_inode_info *ci = ceph_inode(inode);
Andreas Gruenbachera26fecc2016-04-14 00:30:16 +02001003 struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
Yan, Zhengf66fd9f2015-06-10 17:26:13 +08001004 struct ceph_cap_flush *prealloc_cf = NULL;
Alex Elder18fa8b32012-01-23 15:49:28 -06001005 int issued;
Sage Weil355da1e2009-10-06 11:31:08 -07001006 int err;
Yan, Zhengfbc0b972014-02-11 13:01:19 +08001007 int dirty = 0;
Sage Weil355da1e2009-10-06 11:31:08 -07001008 int name_len = strlen(name);
1009 int val_len = size;
1010 char *newname = NULL;
1011 char *newval = NULL;
1012 struct ceph_inode_xattr *xattr = NULL;
Sage Weil355da1e2009-10-06 11:31:08 -07001013 int required_blob_size;
Yan, Zhengf1919822018-04-08 09:54:39 +08001014 bool check_realm = false;
Yan, Zheng604d1b02015-05-01 17:49:16 +08001015 bool lock_snap_rwsem = false;
Sage Weil355da1e2009-10-06 11:31:08 -07001016
Andreas Gruenbacher2cdeb1e2016-04-14 00:30:17 +02001017 if (ceph_snap(inode) != CEPH_NOSNAP)
1018 return -EROFS;
Sage Weil355da1e2009-10-06 11:31:08 -07001019
Alex Elder06476a62012-01-23 15:49:27 -06001020 vxattr = ceph_match_vxattr(inode, name);
Yan, Zhengf1919822018-04-08 09:54:39 +08001021 if (vxattr) {
Yan, Zheng4e9906e2018-04-25 17:14:05 +08001022 if (vxattr->flags & VXATTR_FLAG_READONLY)
Yan, Zhengf1919822018-04-08 09:54:39 +08001023 return -EOPNOTSUPP;
1024 if (value && !strncmp(vxattr->name, "ceph.quota", 10))
1025 check_realm = true;
1026 }
Sage Weil355da1e2009-10-06 11:31:08 -07001027
Sage Weil3adf6542013-01-31 11:53:41 -08001028 /* pass any unhandled ceph.* xattrs through to the MDS */
1029 if (!strncmp(name, XATTR_CEPH_PREFIX, XATTR_CEPH_PREFIX_LEN))
1030 goto do_sync_unlocked;
1031
Sage Weil355da1e2009-10-06 11:31:08 -07001032 /* preallocate memory for xattr name, value, index node */
1033 err = -ENOMEM;
Julia Lawall61413c22010-10-17 21:55:21 +02001034 newname = kmemdup(name, name_len + 1, GFP_NOFS);
Sage Weil355da1e2009-10-06 11:31:08 -07001035 if (!newname)
1036 goto out;
Sage Weil355da1e2009-10-06 11:31:08 -07001037
1038 if (val_len) {
Alex Elderb829c192012-01-23 15:49:27 -06001039 newval = kmemdup(value, val_len, GFP_NOFS);
Sage Weil355da1e2009-10-06 11:31:08 -07001040 if (!newval)
1041 goto out;
Sage Weil355da1e2009-10-06 11:31:08 -07001042 }
1043
1044 xattr = kmalloc(sizeof(struct ceph_inode_xattr), GFP_NOFS);
1045 if (!xattr)
1046 goto out;
1047
Yan, Zhengf66fd9f2015-06-10 17:26:13 +08001048 prealloc_cf = ceph_alloc_cap_flush();
1049 if (!prealloc_cf)
1050 goto out;
1051
Sage Weilbe655592011-11-30 09:47:09 -08001052 spin_lock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -07001053retry:
1054 issued = __ceph_caps_issued(ci, NULL);
Yan, Zheng508b32d2014-09-16 21:46:17 +08001055 if (ci->i_xattrs.version == 0 || !(issued & CEPH_CAP_XATTR_EXCL))
Sage Weil355da1e2009-10-06 11:31:08 -07001056 goto do_sync;
Yan, Zheng604d1b02015-05-01 17:49:16 +08001057
1058 if (!lock_snap_rwsem && !ci->i_head_snapc) {
1059 lock_snap_rwsem = true;
1060 if (!down_read_trylock(&mdsc->snap_rwsem)) {
1061 spin_unlock(&ci->i_ceph_lock);
1062 down_read(&mdsc->snap_rwsem);
1063 spin_lock(&ci->i_ceph_lock);
1064 goto retry;
1065 }
1066 }
1067
1068 dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued));
Sage Weil355da1e2009-10-06 11:31:08 -07001069 __build_xattrs(inode);
1070
1071 required_blob_size = __get_required_blob_size(ci, name_len, val_len);
1072
1073 if (!ci->i_xattrs.prealloc_blob ||
1074 required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) {
Alex Elder18fa8b32012-01-23 15:49:28 -06001075 struct ceph_buffer *blob;
Sage Weil355da1e2009-10-06 11:31:08 -07001076
Sage Weilbe655592011-11-30 09:47:09 -08001077 spin_unlock(&ci->i_ceph_lock);
Sage Weil355da1e2009-10-06 11:31:08 -07001078 dout(" preaallocating new blob size=%d\n", required_blob_size);
Sage Weilb6c1d5b2009-12-07 12:17:17 -08001079 blob = ceph_buffer_new(required_blob_size, GFP_NOFS);
Sage Weil355da1e2009-10-06 11:31:08 -07001080 if (!blob)
Yan, Zheng604d1b02015-05-01 17:49:16 +08001081 goto do_sync_unlocked;
Sage Weilbe655592011-11-30 09:47:09 -08001082 spin_lock(&ci->i_ceph_lock);
Sage Weilb6c1d5b2009-12-07 12:17:17 -08001083 if (ci->i_xattrs.prealloc_blob)
1084 ceph_buffer_put(ci->i_xattrs.prealloc_blob);
Sage Weil355da1e2009-10-06 11:31:08 -07001085 ci->i_xattrs.prealloc_blob = blob;
1086 goto retry;
1087 }
1088
Yan, Zhengbcdfeb22014-02-11 13:04:19 +08001089 err = __set_xattr(ci, newname, name_len, newval, val_len,
1090 flags, value ? 1 : -1, &xattr);
Alex Elder18fa8b32012-01-23 15:49:28 -06001091
Yan, Zhengfbc0b972014-02-11 13:01:19 +08001092 if (!err) {
Yan, Zhengf66fd9f2015-06-10 17:26:13 +08001093 dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL,
1094 &prealloc_cf);
Yan, Zhengfbc0b972014-02-11 13:01:19 +08001095 ci->i_xattrs.dirty = true;
Deepa Dinamanic2050a42016-09-14 07:48:06 -07001096 inode->i_ctime = current_time(inode);
Yan, Zhengfbc0b972014-02-11 13:01:19 +08001097 }
Alex Elder18fa8b32012-01-23 15:49:28 -06001098
Sage Weilbe655592011-11-30 09:47:09 -08001099 spin_unlock(&ci->i_ceph_lock);
Yan, Zheng604d1b02015-05-01 17:49:16 +08001100 if (lock_snap_rwsem)
1101 up_read(&mdsc->snap_rwsem);
Sage Weilfca65b42011-05-04 11:33:47 -07001102 if (dirty)
1103 __mark_inode_dirty(inode, dirty);
Yan, Zhengf66fd9f2015-06-10 17:26:13 +08001104 ceph_free_cap_flush(prealloc_cf);
Sage Weil355da1e2009-10-06 11:31:08 -07001105 return err;
1106
1107do_sync:
Sage Weilbe655592011-11-30 09:47:09 -08001108 spin_unlock(&ci->i_ceph_lock);
Sage Weil3adf6542013-01-31 11:53:41 -08001109do_sync_unlocked:
Yan, Zheng604d1b02015-05-01 17:49:16 +08001110 if (lock_snap_rwsem)
1111 up_read(&mdsc->snap_rwsem);
Yan, Zheng315f2402016-03-07 10:34:50 +08001112
1113 /* security module set xattr while filling trace */
Markus Elfringd37b1d92017-08-20 20:22:02 +02001114 if (current->journal_info) {
Yan, Zheng315f2402016-03-07 10:34:50 +08001115 pr_warn_ratelimited("sync setxattr %p "
1116 "during filling trace\n", inode);
1117 err = -EBUSY;
1118 } else {
Andreas Gruenbachera26fecc2016-04-14 00:30:16 +02001119 err = ceph_sync_setxattr(inode, name, value, size, flags);
Yan, Zhengf1919822018-04-08 09:54:39 +08001120 if (err >= 0 && check_realm) {
1121 /* check if snaprealm was created for quota inode */
1122 spin_lock(&ci->i_ceph_lock);
1123 if ((ci->i_max_files || ci->i_max_bytes) &&
1124 !(ci->i_snap_realm &&
1125 ci->i_snap_realm->ino == ci->i_vino.ino))
1126 err = -EOPNOTSUPP;
1127 spin_unlock(&ci->i_ceph_lock);
1128 }
Yan, Zheng315f2402016-03-07 10:34:50 +08001129 }
Sage Weil355da1e2009-10-06 11:31:08 -07001130out:
Yan, Zhengf66fd9f2015-06-10 17:26:13 +08001131 ceph_free_cap_flush(prealloc_cf);
Sage Weil355da1e2009-10-06 11:31:08 -07001132 kfree(newname);
1133 kfree(newval);
1134 kfree(xattr);
1135 return err;
1136}
1137
Andreas Gruenbacher2cdeb1e2016-04-14 00:30:17 +02001138static int ceph_get_xattr_handler(const struct xattr_handler *handler,
1139 struct dentry *dentry, struct inode *inode,
1140 const char *name, void *value, size_t size)
Guangliang Zhao7221fe42013-11-11 15:18:03 +08001141{
Andreas Gruenbacher2cdeb1e2016-04-14 00:30:17 +02001142 if (!ceph_is_valid_xattr(name))
1143 return -EOPNOTSUPP;
1144 return __ceph_getxattr(inode, name, value, size);
Guangliang Zhao7221fe42013-11-11 15:18:03 +08001145}
Yan, Zheng315f2402016-03-07 10:34:50 +08001146
Andreas Gruenbacher2cdeb1e2016-04-14 00:30:17 +02001147static int ceph_set_xattr_handler(const struct xattr_handler *handler,
Al Viro59301222016-05-27 10:19:30 -04001148 struct dentry *unused, struct inode *inode,
1149 const char *name, const void *value,
1150 size_t size, int flags)
Andreas Gruenbacher2cdeb1e2016-04-14 00:30:17 +02001151{
1152 if (!ceph_is_valid_xattr(name))
1153 return -EOPNOTSUPP;
Al Viro59301222016-05-27 10:19:30 -04001154 return __ceph_setxattr(inode, name, value, size, flags);
Andreas Gruenbacher2cdeb1e2016-04-14 00:30:17 +02001155}
1156
Wei Yongjun5130cce2016-10-17 15:11:29 +00001157static const struct xattr_handler ceph_other_xattr_handler = {
Andreas Gruenbacher2cdeb1e2016-04-14 00:30:17 +02001158 .prefix = "", /* match any name => handlers called with full name */
1159 .get = ceph_get_xattr_handler,
1160 .set = ceph_set_xattr_handler,
1161};
1162
Yan, Zheng315f2402016-03-07 10:34:50 +08001163#ifdef CONFIG_SECURITY
1164bool ceph_security_xattr_wanted(struct inode *in)
1165{
1166 return in->i_security != NULL;
1167}
1168
1169bool ceph_security_xattr_deadlock(struct inode *in)
1170{
1171 struct ceph_inode_info *ci;
1172 bool ret;
Markus Elfringd37b1d92017-08-20 20:22:02 +02001173 if (!in->i_security)
Yan, Zheng315f2402016-03-07 10:34:50 +08001174 return false;
1175 ci = ceph_inode(in);
1176 spin_lock(&ci->i_ceph_lock);
1177 ret = !(ci->i_ceph_flags & CEPH_I_SEC_INITED) &&
1178 !(ci->i_xattrs.version > 0 &&
1179 __ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 0));
1180 spin_unlock(&ci->i_ceph_lock);
1181 return ret;
1182}
Yan, Zhengac6713c2019-05-26 16:27:56 +08001183
1184#ifdef CONFIG_CEPH_FS_SECURITY_LABEL
1185int ceph_security_init_secctx(struct dentry *dentry, umode_t mode,
1186 struct ceph_acl_sec_ctx *as_ctx)
1187{
1188 struct ceph_pagelist *pagelist = as_ctx->pagelist;
1189 const char *name;
1190 size_t name_len;
1191 int err;
1192
1193 err = security_dentry_init_security(dentry, mode, &dentry->d_name,
1194 &as_ctx->sec_ctx,
1195 &as_ctx->sec_ctxlen);
1196 if (err < 0) {
1197 WARN_ON_ONCE(err != -EOPNOTSUPP);
1198 err = 0; /* do nothing */
1199 goto out;
1200 }
1201
1202 err = -ENOMEM;
1203 if (!pagelist) {
1204 pagelist = ceph_pagelist_alloc(GFP_KERNEL);
1205 if (!pagelist)
1206 goto out;
1207 err = ceph_pagelist_reserve(pagelist, PAGE_SIZE);
1208 if (err)
1209 goto out;
1210 ceph_pagelist_encode_32(pagelist, 1);
1211 }
1212
1213 /*
1214 * FIXME: Make security_dentry_init_security() generic. Currently
1215 * It only supports single security module and only selinux has
1216 * dentry_init_security hook.
1217 */
1218 name = XATTR_NAME_SELINUX;
1219 name_len = strlen(name);
1220 err = ceph_pagelist_reserve(pagelist,
1221 4 * 2 + name_len + as_ctx->sec_ctxlen);
1222 if (err)
1223 goto out;
1224
1225 if (as_ctx->pagelist) {
1226 /* update count of KV pairs */
1227 BUG_ON(pagelist->length <= sizeof(__le32));
1228 if (list_is_singular(&pagelist->head)) {
1229 le32_add_cpu((__le32*)pagelist->mapped_tail, 1);
1230 } else {
1231 struct page *page = list_first_entry(&pagelist->head,
1232 struct page, lru);
1233 void *addr = kmap_atomic(page);
1234 le32_add_cpu((__le32*)addr, 1);
1235 kunmap_atomic(addr);
1236 }
1237 } else {
1238 as_ctx->pagelist = pagelist;
1239 }
1240
1241 ceph_pagelist_encode_32(pagelist, name_len);
1242 ceph_pagelist_append(pagelist, name, name_len);
1243
1244 ceph_pagelist_encode_32(pagelist, as_ctx->sec_ctxlen);
1245 ceph_pagelist_append(pagelist, as_ctx->sec_ctx, as_ctx->sec_ctxlen);
1246
1247 err = 0;
1248out:
1249 if (pagelist && !as_ctx->pagelist)
1250 ceph_pagelist_release(pagelist);
1251 return err;
1252}
1253
1254void ceph_security_invalidate_secctx(struct inode *inode)
1255{
1256 security_inode_invalidate_secctx(inode);
1257}
1258
1259static int ceph_xattr_set_security_label(const struct xattr_handler *handler,
1260 struct dentry *unused, struct inode *inode,
1261 const char *key, const void *buf,
1262 size_t buflen, int flags)
1263{
1264 if (security_ismaclabel(key)) {
1265 const char *name = xattr_full_name(handler, key);
1266 return __ceph_setxattr(inode, name, buf, buflen, flags);
1267 }
1268 return -EOPNOTSUPP;
1269}
1270
1271static int ceph_xattr_get_security_label(const struct xattr_handler *handler,
1272 struct dentry *unused, struct inode *inode,
1273 const char *key, void *buf, size_t buflen)
1274{
1275 if (security_ismaclabel(key)) {
1276 const char *name = xattr_full_name(handler, key);
1277 return __ceph_getxattr(inode, name, buf, buflen);
1278 }
1279 return -EOPNOTSUPP;
1280}
1281
1282static const struct xattr_handler ceph_security_label_handler = {
1283 .prefix = XATTR_SECURITY_PREFIX,
1284 .get = ceph_xattr_get_security_label,
1285 .set = ceph_xattr_set_security_label,
1286};
1287#endif
Yan, Zheng315f2402016-03-07 10:34:50 +08001288#endif
Yan, Zheng5c31e922019-05-26 15:35:39 +08001289
1290void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx)
1291{
1292#ifdef CONFIG_CEPH_FS_POSIX_ACL
1293 posix_acl_release(as_ctx->acl);
1294 posix_acl_release(as_ctx->default_acl);
1295#endif
Yan, Zhengac6713c2019-05-26 16:27:56 +08001296#ifdef CONFIG_CEPH_FS_SECURITY_LABEL
1297 security_release_secctx(as_ctx->sec_ctx, as_ctx->sec_ctxlen);
1298#endif
Yan, Zheng5c31e922019-05-26 15:35:39 +08001299 if (as_ctx->pagelist)
1300 ceph_pagelist_release(as_ctx->pagelist);
1301}
Yan, Zhengac6713c2019-05-26 16:27:56 +08001302
1303/*
1304 * List of handlers for synthetic system.* attributes. Other
1305 * attributes are handled directly.
1306 */
1307const struct xattr_handler *ceph_xattr_handlers[] = {
1308#ifdef CONFIG_CEPH_FS_POSIX_ACL
1309 &posix_acl_access_xattr_handler,
1310 &posix_acl_default_xattr_handler,
1311#endif
1312#ifdef CONFIG_CEPH_FS_SECURITY_LABEL
1313 &ceph_security_label_handler,
1314#endif
1315 &ceph_other_xattr_handler,
1316 NULL,
1317};