1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
296c57adeSLinus Torvalds #include <linux/ceph/ceph_debug.h>
38f4e91deSSage Weil #include <linux/in.h>
48f4e91deSSage Weil
58f4e91deSSage Weil #include "super.h"
63d14c5d2SYehuda Sadeh #include "mds_client.h"
73d14c5d2SYehuda Sadeh #include "ioctl.h"
808c1ac50SIlya Dryomov #include <linux/ceph/striper.h>
9f061fedaSJeff Layton #include <linux/fscrypt.h>
108f4e91deSSage Weil
118f4e91deSSage Weil /*
128f4e91deSSage Weil * ioctls
138f4e91deSSage Weil */
148f4e91deSSage Weil
158f4e91deSSage Weil /*
168f4e91deSSage Weil * get and set the file layout
178f4e91deSSage Weil */
ceph_ioctl_get_layout(struct file * file,void __user * arg)188f4e91deSSage Weil static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
198f4e91deSSage Weil {
20496ad9aaSAl Viro struct ceph_inode_info *ci = ceph_inode(file_inode(file));
218f4e91deSSage Weil struct ceph_ioctl_layout l;
228f4e91deSSage Weil int err;
238f4e91deSSage Weil
24508b32d8SYan, Zheng err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false);
258f4e91deSSage Weil if (!err) {
267627151eSYan, Zheng l.stripe_unit = ci->i_layout.stripe_unit;
277627151eSYan, Zheng l.stripe_count = ci->i_layout.stripe_count;
287627151eSYan, Zheng l.object_size = ci->i_layout.object_size;
297627151eSYan, Zheng l.data_pool = ci->i_layout.pool_id;
3024c149adSJeff Layton l.preferred_osd = -1;
318f4e91deSSage Weil if (copy_to_user(arg, &l, sizeof(l)))
328f4e91deSSage Weil return -EFAULT;
338f4e91deSSage Weil }
348f4e91deSSage Weil
358f4e91deSSage Weil return err;
368f4e91deSSage Weil }
378f4e91deSSage Weil
__validate_layout(struct ceph_mds_client * mdsc,struct ceph_ioctl_layout * l)38e49bf4c5SSage Weil static long __validate_layout(struct ceph_mds_client *mdsc,
39e49bf4c5SSage Weil struct ceph_ioctl_layout *l)
40e49bf4c5SSage Weil {
41e49bf4c5SSage Weil int i, err;
42e49bf4c5SSage Weil
43e49bf4c5SSage Weil /* validate striping parameters */
44e49bf4c5SSage Weil if ((l->object_size & ~PAGE_MASK) ||
45e49bf4c5SSage Weil (l->stripe_unit & ~PAGE_MASK) ||
460bc62284SYan, Zheng ((unsigned)l->stripe_unit != 0 &&
4745f2e081SSage Weil ((unsigned)l->object_size % (unsigned)l->stripe_unit)))
48e49bf4c5SSage Weil return -EINVAL;
49e49bf4c5SSage Weil
50e49bf4c5SSage Weil /* make sure it's a valid data pool */
51e49bf4c5SSage Weil mutex_lock(&mdsc->mutex);
52e49bf4c5SSage Weil err = -EINVAL;
53e49bf4c5SSage Weil for (i = 0; i < mdsc->mdsmap->m_num_data_pg_pools; i++)
54e49bf4c5SSage Weil if (mdsc->mdsmap->m_data_pg_pools[i] == l->data_pool) {
55e49bf4c5SSage Weil err = 0;
56e49bf4c5SSage Weil break;
57e49bf4c5SSage Weil }
58e49bf4c5SSage Weil mutex_unlock(&mdsc->mutex);
59e49bf4c5SSage Weil if (err)
60e49bf4c5SSage Weil return err;
61e49bf4c5SSage Weil
62e49bf4c5SSage Weil return 0;
63e49bf4c5SSage Weil }
64e49bf4c5SSage Weil
ceph_ioctl_set_layout(struct file * file,void __user * arg)658f4e91deSSage Weil static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
668f4e91deSSage Weil {
67496ad9aaSAl Viro struct inode *inode = file_inode(file);
68*985b9ee8SXiubo Li struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(inode->i_sb)->mdsc;
698f4e91deSSage Weil struct ceph_mds_request *req;
708f4e91deSSage Weil struct ceph_ioctl_layout l;
71496ad9aaSAl Viro struct ceph_inode_info *ci = ceph_inode(file_inode(file));
72a35eca95SGreg Farnum struct ceph_ioctl_layout nl;
73e49bf4c5SSage Weil int err;
748f4e91deSSage Weil
758f4e91deSSage Weil if (copy_from_user(&l, arg, sizeof(l)))
768f4e91deSSage Weil return -EFAULT;
778f4e91deSSage Weil
78a35eca95SGreg Farnum /* validate changed params against current layout */
79508b32d8SYan, Zheng err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false);
80702aeb1fSSage Weil if (err)
81a35eca95SGreg Farnum return err;
82a35eca95SGreg Farnum
83702aeb1fSSage Weil memset(&nl, 0, sizeof(nl));
84a35eca95SGreg Farnum if (l.stripe_count)
85a35eca95SGreg Farnum nl.stripe_count = l.stripe_count;
86702aeb1fSSage Weil else
877627151eSYan, Zheng nl.stripe_count = ci->i_layout.stripe_count;
88a35eca95SGreg Farnum if (l.stripe_unit)
89a35eca95SGreg Farnum nl.stripe_unit = l.stripe_unit;
90702aeb1fSSage Weil else
917627151eSYan, Zheng nl.stripe_unit = ci->i_layout.stripe_unit;
92a35eca95SGreg Farnum if (l.object_size)
93a35eca95SGreg Farnum nl.object_size = l.object_size;
94702aeb1fSSage Weil else
957627151eSYan, Zheng nl.object_size = ci->i_layout.object_size;
96a35eca95SGreg Farnum if (l.data_pool)
97a35eca95SGreg Farnum nl.data_pool = l.data_pool;
98702aeb1fSSage Weil else
997627151eSYan, Zheng nl.data_pool = ci->i_layout.pool_id;
100702aeb1fSSage Weil
101702aeb1fSSage Weil /* this is obsolete, and always -1 */
10224c149adSJeff Layton nl.preferred_osd = -1;
103a35eca95SGreg Farnum
104e49bf4c5SSage Weil err = __validate_layout(mdsc, &nl);
1058f4e91deSSage Weil if (err)
1068f4e91deSSage Weil return err;
1078f4e91deSSage Weil
1088f4e91deSSage Weil req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETLAYOUT,
1098f4e91deSSage Weil USE_AUTH_MDS);
1108f4e91deSSage Weil if (IS_ERR(req))
1118f4e91deSSage Weil return PTR_ERR(req);
11270b666c3SSage Weil req->r_inode = inode;
11370b666c3SSage Weil ihold(inode);
1143bd58143SYan, Zheng req->r_num_caps = 1;
1153bd58143SYan, Zheng
1168f4e91deSSage Weil req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL;
1178f4e91deSSage Weil
1188f4e91deSSage Weil req->r_args.setlayout.layout.fl_stripe_unit =
1198f4e91deSSage Weil cpu_to_le32(l.stripe_unit);
1208f4e91deSSage Weil req->r_args.setlayout.layout.fl_stripe_count =
1218f4e91deSSage Weil cpu_to_le32(l.stripe_count);
1228f4e91deSSage Weil req->r_args.setlayout.layout.fl_object_size =
1238f4e91deSSage Weil cpu_to_le32(l.object_size);
1248f4e91deSSage Weil req->r_args.setlayout.layout.fl_pg_pool = cpu_to_le32(l.data_pool);
1258f4e91deSSage Weil
126752c8bdcSSage Weil err = ceph_mdsc_do_request(mdsc, NULL, req);
1278f4e91deSSage Weil ceph_mdsc_put_request(req);
1288f4e91deSSage Weil return err;
1298f4e91deSSage Weil }
1308f4e91deSSage Weil
1318f4e91deSSage Weil /*
132571dba52SGreg Farnum * Set a layout policy on a directory inode. All items in the tree
133571dba52SGreg Farnum * rooted at this inode will inherit this layout on creation,
134571dba52SGreg Farnum * (It doesn't apply retroactively )
135571dba52SGreg Farnum * unless a subdirectory has its own layout policy.
136571dba52SGreg Farnum */
ceph_ioctl_set_layout_policy(struct file * file,void __user * arg)137571dba52SGreg Farnum static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
138571dba52SGreg Farnum {
139496ad9aaSAl Viro struct inode *inode = file_inode(file);
140571dba52SGreg Farnum struct ceph_mds_request *req;
141571dba52SGreg Farnum struct ceph_ioctl_layout l;
142e49bf4c5SSage Weil int err;
143*985b9ee8SXiubo Li struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(inode->i_sb)->mdsc;
144571dba52SGreg Farnum
145571dba52SGreg Farnum /* copy and validate */
146571dba52SGreg Farnum if (copy_from_user(&l, arg, sizeof(l)))
147571dba52SGreg Farnum return -EFAULT;
148571dba52SGreg Farnum
149e49bf4c5SSage Weil err = __validate_layout(mdsc, &l);
150571dba52SGreg Farnum if (err)
151571dba52SGreg Farnum return err;
152571dba52SGreg Farnum
153571dba52SGreg Farnum req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETDIRLAYOUT,
154571dba52SGreg Farnum USE_AUTH_MDS);
155571dba52SGreg Farnum
156571dba52SGreg Farnum if (IS_ERR(req))
157571dba52SGreg Farnum return PTR_ERR(req);
15870b666c3SSage Weil req->r_inode = inode;
15970b666c3SSage Weil ihold(inode);
1603bd58143SYan, Zheng req->r_num_caps = 1;
161571dba52SGreg Farnum
162571dba52SGreg Farnum req->r_args.setlayout.layout.fl_stripe_unit =
163571dba52SGreg Farnum cpu_to_le32(l.stripe_unit);
164571dba52SGreg Farnum req->r_args.setlayout.layout.fl_stripe_count =
165571dba52SGreg Farnum cpu_to_le32(l.stripe_count);
166571dba52SGreg Farnum req->r_args.setlayout.layout.fl_object_size =
167571dba52SGreg Farnum cpu_to_le32(l.object_size);
168571dba52SGreg Farnum req->r_args.setlayout.layout.fl_pg_pool =
169571dba52SGreg Farnum cpu_to_le32(l.data_pool);
170571dba52SGreg Farnum
171571dba52SGreg Farnum err = ceph_mdsc_do_request(mdsc, inode, req);
172571dba52SGreg Farnum ceph_mdsc_put_request(req);
173571dba52SGreg Farnum return err;
174571dba52SGreg Farnum }
175571dba52SGreg Farnum
176571dba52SGreg Farnum /*
1778f4e91deSSage Weil * Return object name, size/offset information, and location (OSD
1788f4e91deSSage Weil * number, network address) for a given file offset.
1798f4e91deSSage Weil */
ceph_ioctl_get_dataloc(struct file * file,void __user * arg)1808f4e91deSSage Weil static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
1818f4e91deSSage Weil {
1828f4e91deSSage Weil struct ceph_ioctl_dataloc dl;
183496ad9aaSAl Viro struct inode *inode = file_inode(file);
1848f4e91deSSage Weil struct ceph_inode_info *ci = ceph_inode(inode);
1853d14c5d2SYehuda Sadeh struct ceph_osd_client *osdc =
186*985b9ee8SXiubo Li &ceph_sb_to_fs_client(inode->i_sb)->client->osdc;
1877c13cb64SIlya Dryomov struct ceph_object_locator oloc;
188281dbe5dSIlya Dryomov CEPH_DEFINE_OID_ONSTACK(oid);
189dccbf080SIlya Dryomov u32 xlen;
1908f4e91deSSage Weil u64 tmp;
19151042122SSage Weil struct ceph_pg pgid;
192457712a0SSage Weil int r;
1938f4e91deSSage Weil
1948f4e91deSSage Weil /* copy and validate */
1958f4e91deSSage Weil if (copy_from_user(&dl, arg, sizeof(dl)))
1968f4e91deSSage Weil return -EFAULT;
1978f4e91deSSage Weil
1985aea3dcdSIlya Dryomov down_read(&osdc->lock);
199dccbf080SIlya Dryomov ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, 1,
200dccbf080SIlya Dryomov &dl.object_no, &dl.object_offset, &xlen);
2018f4e91deSSage Weil dl.file_offset -= dl.object_offset;
2027627151eSYan, Zheng dl.object_size = ci->i_layout.object_size;
2037627151eSYan, Zheng dl.block_size = ci->i_layout.stripe_unit;
2048f4e91deSSage Weil
2058f4e91deSSage Weil /* block_offset = object_offset % block_size */
2068f4e91deSSage Weil tmp = dl.object_offset;
2078f4e91deSSage Weil dl.block_offset = do_div(tmp, dl.block_size);
2088f4e91deSSage Weil
2098f4e91deSSage Weil snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
2108f4e91deSSage Weil ceph_ino(inode), dl.object_no);
21141766f87SAlex Elder
2127627151eSYan, Zheng oloc.pool = ci->i_layout.pool_id;
213779fe0fbSYan, Zheng oloc.pool_ns = ceph_try_get_string(ci->i_layout.pool_ns);
214d30291b9SIlya Dryomov ceph_oid_printf(&oid, "%s", dl.object_name);
2157c13cb64SIlya Dryomov
216d9591f5eSIlya Dryomov r = ceph_object_locator_to_pg(osdc->osdmap, &oid, &oloc, &pgid);
217779fe0fbSYan, Zheng
218779fe0fbSYan, Zheng ceph_oloc_destroy(&oloc);
2192fbcbff1Smajianpeng if (r < 0) {
2205aea3dcdSIlya Dryomov up_read(&osdc->lock);
2212fbcbff1Smajianpeng return r;
2222fbcbff1Smajianpeng }
2238f4e91deSSage Weil
224f81f1633SIlya Dryomov dl.osd = ceph_pg_to_acting_primary(osdc->osdmap, &pgid);
2258f4e91deSSage Weil if (dl.osd >= 0) {
2268f4e91deSSage Weil struct ceph_entity_addr *a =
2278f4e91deSSage Weil ceph_osd_addr(osdc->osdmap, dl.osd);
2288f4e91deSSage Weil if (a)
2298f4e91deSSage Weil memcpy(&dl.osd_addr, &a->in_addr, sizeof(dl.osd_addr));
2308f4e91deSSage Weil } else {
2318f4e91deSSage Weil memset(&dl.osd_addr, 0, sizeof(dl.osd_addr));
2328f4e91deSSage Weil }
2335aea3dcdSIlya Dryomov up_read(&osdc->lock);
2348f4e91deSSage Weil
2358f4e91deSSage Weil /* send result back to user */
2368f4e91deSSage Weil if (copy_to_user(arg, &dl, sizeof(dl)))
2378f4e91deSSage Weil return -EFAULT;
2388f4e91deSSage Weil
2398f4e91deSSage Weil return 0;
2408f4e91deSSage Weil }
2418f4e91deSSage Weil
ceph_ioctl_lazyio(struct file * file)2428c6e9229SSage Weil static long ceph_ioctl_lazyio(struct file *file)
2438c6e9229SSage Weil {
2448c6e9229SSage Weil struct ceph_file_info *fi = file->private_data;
245496ad9aaSAl Viro struct inode *inode = file_inode(file);
2468c6e9229SSage Weil struct ceph_inode_info *ci = ceph_inode(inode);
247*985b9ee8SXiubo Li struct ceph_mds_client *mdsc = ceph_inode_to_fs_client(inode)->mdsc;
2488c6e9229SSage Weil
2498c6e9229SSage Weil if ((fi->fmode & CEPH_FILE_MODE_LAZY) == 0) {
250be655596SSage Weil spin_lock(&ci->i_ceph_lock);
2518c6e9229SSage Weil fi->fmode |= CEPH_FILE_MODE_LAZY;
252774a6a11SYan, Zheng ci->i_nr_by_mode[ffs(CEPH_FILE_MODE_LAZY)]++;
253719a2514SYan, Zheng __ceph_touch_fmode(ci, mdsc, fi->fmode);
254be655596SSage Weil spin_unlock(&ci->i_ceph_lock);
2558c6e9229SSage Weil dout("ioctl_layzio: file %p marked lazy\n", file);
2568c6e9229SSage Weil
257e4b731ccSXiubo Li ceph_check_caps(ci, 0);
2588c6e9229SSage Weil } else {
2598c6e9229SSage Weil dout("ioctl_layzio: file %p already lazy\n", file);
2608c6e9229SSage Weil }
2618c6e9229SSage Weil return 0;
2628c6e9229SSage Weil }
2638c6e9229SSage Weil
ceph_ioctl_syncio(struct file * file)2644918b6d1SSage Weil static long ceph_ioctl_syncio(struct file *file)
2654918b6d1SSage Weil {
2664918b6d1SSage Weil struct ceph_file_info *fi = file->private_data;
2674918b6d1SSage Weil
2684918b6d1SSage Weil fi->flags |= CEPH_F_SYNC;
2694918b6d1SSage Weil return 0;
2704918b6d1SSage Weil }
2714918b6d1SSage Weil
vet_mds_for_fscrypt(struct file * file)272f061fedaSJeff Layton static int vet_mds_for_fscrypt(struct file *file)
273f061fedaSJeff Layton {
274f061fedaSJeff Layton int i, ret = -EOPNOTSUPP;
275f061fedaSJeff Layton struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(file_inode(file)->i_sb);
276f061fedaSJeff Layton
277f061fedaSJeff Layton mutex_lock(&mdsc->mutex);
278f061fedaSJeff Layton for (i = 0; i < mdsc->max_sessions; i++) {
279f061fedaSJeff Layton struct ceph_mds_session *s = mdsc->sessions[i];
280f061fedaSJeff Layton
281f061fedaSJeff Layton if (!s)
282f061fedaSJeff Layton continue;
283f061fedaSJeff Layton if (test_bit(CEPHFS_FEATURE_ALTERNATE_NAME, &s->s_features))
284f061fedaSJeff Layton ret = 0;
285f061fedaSJeff Layton break;
286f061fedaSJeff Layton }
287f061fedaSJeff Layton mutex_unlock(&mdsc->mutex);
288f061fedaSJeff Layton return ret;
289f061fedaSJeff Layton }
290f061fedaSJeff Layton
ceph_set_encryption_policy(struct file * file,unsigned long arg)291f061fedaSJeff Layton static long ceph_set_encryption_policy(struct file *file, unsigned long arg)
292f061fedaSJeff Layton {
293f061fedaSJeff Layton int ret, got = 0;
294f061fedaSJeff Layton struct inode *inode = file_inode(file);
295f061fedaSJeff Layton struct ceph_inode_info *ci = ceph_inode(inode);
296f061fedaSJeff Layton
29794af0470SJeff Layton /* encrypted directories can't have striped layout */
29894af0470SJeff Layton if (ci->i_layout.stripe_count > 1)
29994af0470SJeff Layton return -EINVAL;
30094af0470SJeff Layton
301f061fedaSJeff Layton ret = vet_mds_for_fscrypt(file);
302f061fedaSJeff Layton if (ret)
303f061fedaSJeff Layton return ret;
304f061fedaSJeff Layton
305f061fedaSJeff Layton /*
306f061fedaSJeff Layton * Ensure we hold these caps so that we _know_ that the rstats check
307f061fedaSJeff Layton * in the empty_dir check is reliable.
308f061fedaSJeff Layton */
309f061fedaSJeff Layton ret = ceph_get_caps(file, CEPH_CAP_FILE_SHARED, 0, -1, &got);
310f061fedaSJeff Layton if (ret)
311f061fedaSJeff Layton return ret;
312f061fedaSJeff Layton
313f061fedaSJeff Layton ret = fscrypt_ioctl_set_policy(file, (const void __user *)arg);
314f061fedaSJeff Layton if (got)
315f061fedaSJeff Layton ceph_put_cap_refs(ci, got);
316f061fedaSJeff Layton
317f061fedaSJeff Layton return ret;
318f061fedaSJeff Layton }
319f061fedaSJeff Layton
ceph_ioctl_cmd_name(const unsigned int cmd)320b7b53361SXiubo Li static const char *ceph_ioctl_cmd_name(const unsigned int cmd)
321b7b53361SXiubo Li {
322b7b53361SXiubo Li switch (cmd) {
323b7b53361SXiubo Li case CEPH_IOC_GET_LAYOUT:
324b7b53361SXiubo Li return "get_layout";
325b7b53361SXiubo Li case CEPH_IOC_SET_LAYOUT:
326b7b53361SXiubo Li return "set_layout";
327b7b53361SXiubo Li case CEPH_IOC_SET_LAYOUT_POLICY:
328b7b53361SXiubo Li return "set_layout_policy";
329b7b53361SXiubo Li case CEPH_IOC_GET_DATALOC:
330b7b53361SXiubo Li return "get_dataloc";
331b7b53361SXiubo Li case CEPH_IOC_LAZYIO:
332b7b53361SXiubo Li return "lazyio";
333b7b53361SXiubo Li case CEPH_IOC_SYNCIO:
334b7b53361SXiubo Li return "syncio";
335b7b53361SXiubo Li case FS_IOC_SET_ENCRYPTION_POLICY:
336b7b53361SXiubo Li return "set_encryption_policy";
337b7b53361SXiubo Li case FS_IOC_GET_ENCRYPTION_POLICY:
338b7b53361SXiubo Li return "get_encryption_policy";
339b7b53361SXiubo Li case FS_IOC_GET_ENCRYPTION_POLICY_EX:
340b7b53361SXiubo Li return "get_encryption_policy_ex";
341b7b53361SXiubo Li case FS_IOC_ADD_ENCRYPTION_KEY:
342b7b53361SXiubo Li return "add_encryption_key";
343b7b53361SXiubo Li case FS_IOC_REMOVE_ENCRYPTION_KEY:
344b7b53361SXiubo Li return "remove_encryption_key";
345b7b53361SXiubo Li case FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS:
346b7b53361SXiubo Li return "remove_encryption_key_all_users";
347b7b53361SXiubo Li case FS_IOC_GET_ENCRYPTION_KEY_STATUS:
348b7b53361SXiubo Li return "get_encryption_key_status";
349b7b53361SXiubo Li case FS_IOC_GET_ENCRYPTION_NONCE:
350b7b53361SXiubo Li return "get_encryption_nonce";
351b7b53361SXiubo Li default:
352b7b53361SXiubo Li return "unknown";
353b7b53361SXiubo Li }
354b7b53361SXiubo Li }
355b7b53361SXiubo Li
ceph_ioctl(struct file * file,unsigned int cmd,unsigned long arg)3568f4e91deSSage Weil long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
3578f4e91deSSage Weil {
358f061fedaSJeff Layton int ret;
359f061fedaSJeff Layton
360b7b53361SXiubo Li dout("ioctl file %p cmd %s arg %lu\n", file,
361b7b53361SXiubo Li ceph_ioctl_cmd_name(cmd), arg);
3628f4e91deSSage Weil switch (cmd) {
3638f4e91deSSage Weil case CEPH_IOC_GET_LAYOUT:
3648f4e91deSSage Weil return ceph_ioctl_get_layout(file, (void __user *)arg);
3658f4e91deSSage Weil
3668f4e91deSSage Weil case CEPH_IOC_SET_LAYOUT:
3678f4e91deSSage Weil return ceph_ioctl_set_layout(file, (void __user *)arg);
3688f4e91deSSage Weil
369571dba52SGreg Farnum case CEPH_IOC_SET_LAYOUT_POLICY:
370571dba52SGreg Farnum return ceph_ioctl_set_layout_policy(file, (void __user *)arg);
371571dba52SGreg Farnum
3728f4e91deSSage Weil case CEPH_IOC_GET_DATALOC:
3738f4e91deSSage Weil return ceph_ioctl_get_dataloc(file, (void __user *)arg);
3748c6e9229SSage Weil
3758c6e9229SSage Weil case CEPH_IOC_LAZYIO:
3768c6e9229SSage Weil return ceph_ioctl_lazyio(file);
3774918b6d1SSage Weil
3784918b6d1SSage Weil case CEPH_IOC_SYNCIO:
3794918b6d1SSage Weil return ceph_ioctl_syncio(file);
380f061fedaSJeff Layton
381f061fedaSJeff Layton case FS_IOC_SET_ENCRYPTION_POLICY:
382f061fedaSJeff Layton return ceph_set_encryption_policy(file, arg);
383f061fedaSJeff Layton
384f061fedaSJeff Layton case FS_IOC_GET_ENCRYPTION_POLICY:
385f061fedaSJeff Layton ret = vet_mds_for_fscrypt(file);
386f061fedaSJeff Layton if (ret)
387f061fedaSJeff Layton return ret;
388f061fedaSJeff Layton return fscrypt_ioctl_get_policy(file, (void __user *)arg);
389f061fedaSJeff Layton
390f061fedaSJeff Layton case FS_IOC_GET_ENCRYPTION_POLICY_EX:
391f061fedaSJeff Layton ret = vet_mds_for_fscrypt(file);
392f061fedaSJeff Layton if (ret)
393f061fedaSJeff Layton return ret;
394f061fedaSJeff Layton return fscrypt_ioctl_get_policy_ex(file, (void __user *)arg);
395f061fedaSJeff Layton
396f061fedaSJeff Layton case FS_IOC_ADD_ENCRYPTION_KEY:
397f061fedaSJeff Layton ret = vet_mds_for_fscrypt(file);
398f061fedaSJeff Layton if (ret)
399f061fedaSJeff Layton return ret;
400f061fedaSJeff Layton return fscrypt_ioctl_add_key(file, (void __user *)arg);
401f061fedaSJeff Layton
402f061fedaSJeff Layton case FS_IOC_REMOVE_ENCRYPTION_KEY:
403f061fedaSJeff Layton return fscrypt_ioctl_remove_key(file, (void __user *)arg);
404f061fedaSJeff Layton
405f061fedaSJeff Layton case FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS:
406f061fedaSJeff Layton return fscrypt_ioctl_remove_key_all_users(file,
407f061fedaSJeff Layton (void __user *)arg);
408f061fedaSJeff Layton
409f061fedaSJeff Layton case FS_IOC_GET_ENCRYPTION_KEY_STATUS:
410f061fedaSJeff Layton return fscrypt_ioctl_get_key_status(file, (void __user *)arg);
411f061fedaSJeff Layton
412f061fedaSJeff Layton case FS_IOC_GET_ENCRYPTION_NONCE:
413f061fedaSJeff Layton ret = vet_mds_for_fscrypt(file);
414f061fedaSJeff Layton if (ret)
415f061fedaSJeff Layton return ret;
416f061fedaSJeff Layton return fscrypt_ioctl_get_nonce(file, (void __user *)arg);
4178f4e91deSSage Weil }
418571dba52SGreg Farnum
4198f4e91deSSage Weil return -ENOTTY;
4208f4e91deSSage Weil }
421