xref: /OK3568_Linux_fs/kernel/fs/ceph/ioctl.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef FS_CEPH_IOCTL_H
3*4882a593Smuzhiyun #define FS_CEPH_IOCTL_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/ioctl.h>
6*4882a593Smuzhiyun #include <linux/types.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #define CEPH_IOCTL_MAGIC 0x97
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun /*
11*4882a593Smuzhiyun  * CEPH_IOC_GET_LAYOUT - get file layout or dir layout policy
12*4882a593Smuzhiyun  * CEPH_IOC_SET_LAYOUT - set file layout
13*4882a593Smuzhiyun  * CEPH_IOC_SET_LAYOUT_POLICY - set dir layout policy
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * The file layout specifies how file data is striped over objects in
16*4882a593Smuzhiyun  * the distributed object store, which object pool they belong to (if
17*4882a593Smuzhiyun  * it differs from the default), and an optional 'preferred osd' to
18*4882a593Smuzhiyun  * store them on.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * Files get a new layout based on the policy set on the containing
21*4882a593Smuzhiyun  * directory or one of its ancestors.  The GET_LAYOUT ioctl will let
22*4882a593Smuzhiyun  * you examine the layout for a file or the policy on a directory.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * SET_LAYOUT will let you set a layout on a newly created file.  This
25*4882a593Smuzhiyun  * only works immediately after the file is created and before any
26*4882a593Smuzhiyun  * data is written to it.
27*4882a593Smuzhiyun  *
28*4882a593Smuzhiyun  * SET_LAYOUT_POLICY will let you set a layout policy (default layout)
29*4882a593Smuzhiyun  * on a directory that will apply to any new files created in that
30*4882a593Smuzhiyun  * directory (or any child directory that doesn't specify a layout of
31*4882a593Smuzhiyun  * its own).
32*4882a593Smuzhiyun  */
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun /* use u64 to align sanely on all archs */
35*4882a593Smuzhiyun struct ceph_ioctl_layout {
36*4882a593Smuzhiyun 	__u64 stripe_unit, stripe_count, object_size;
37*4882a593Smuzhiyun 	__u64 data_pool;
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun 	/* obsolete.  new values ignored, always return -1 */
40*4882a593Smuzhiyun 	__s64 preferred_osd;
41*4882a593Smuzhiyun };
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #define CEPH_IOC_GET_LAYOUT _IOR(CEPH_IOCTL_MAGIC, 1,		\
44*4882a593Smuzhiyun 				   struct ceph_ioctl_layout)
45*4882a593Smuzhiyun #define CEPH_IOC_SET_LAYOUT _IOW(CEPH_IOCTL_MAGIC, 2,		\
46*4882a593Smuzhiyun 				   struct ceph_ioctl_layout)
47*4882a593Smuzhiyun #define CEPH_IOC_SET_LAYOUT_POLICY _IOW(CEPH_IOCTL_MAGIC, 5,	\
48*4882a593Smuzhiyun 				   struct ceph_ioctl_layout)
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun /*
51*4882a593Smuzhiyun  * CEPH_IOC_GET_DATALOC - get location of file data in the cluster
52*4882a593Smuzhiyun  *
53*4882a593Smuzhiyun  * Extract identity, address of the OSD and object storing a given
54*4882a593Smuzhiyun  * file offset.
55*4882a593Smuzhiyun  */
56*4882a593Smuzhiyun struct ceph_ioctl_dataloc {
57*4882a593Smuzhiyun 	__u64 file_offset;           /* in+out: file offset */
58*4882a593Smuzhiyun 	__u64 object_offset;         /* out: offset in object */
59*4882a593Smuzhiyun 	__u64 object_no;             /* out: object # */
60*4882a593Smuzhiyun 	__u64 object_size;           /* out: object size */
61*4882a593Smuzhiyun 	char object_name[64];        /* out: object name */
62*4882a593Smuzhiyun 	__u64 block_offset;          /* out: offset in block */
63*4882a593Smuzhiyun 	__u64 block_size;            /* out: block length */
64*4882a593Smuzhiyun 	__s64 osd;                   /* out: osd # */
65*4882a593Smuzhiyun 	struct sockaddr_storage osd_addr; /* out: osd address */
66*4882a593Smuzhiyun };
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun #define CEPH_IOC_GET_DATALOC _IOWR(CEPH_IOCTL_MAGIC, 3,	\
69*4882a593Smuzhiyun 				   struct ceph_ioctl_dataloc)
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun /*
72*4882a593Smuzhiyun  * CEPH_IOC_LAZYIO - relax consistency
73*4882a593Smuzhiyun  *
74*4882a593Smuzhiyun  * Normally Ceph switches to synchronous IO when multiple clients have
75*4882a593Smuzhiyun  * the file open (and or more for write).  Reads and writes bypass the
76*4882a593Smuzhiyun  * page cache and go directly to the OSD.  Setting this flag on a file
77*4882a593Smuzhiyun  * descriptor will allow buffered IO for this file in cases where the
78*4882a593Smuzhiyun  * application knows it won't interfere with other nodes (or doesn't
79*4882a593Smuzhiyun  * care).
80*4882a593Smuzhiyun  */
81*4882a593Smuzhiyun #define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4)
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun /*
84*4882a593Smuzhiyun  * CEPH_IOC_SYNCIO - force synchronous IO
85*4882a593Smuzhiyun  *
86*4882a593Smuzhiyun  * This ioctl sets a file flag that forces the synchronous IO that
87*4882a593Smuzhiyun  * bypasses the page cache, even if it is not necessary.  This is
88*4882a593Smuzhiyun  * essentially the opposite behavior of IOC_LAZYIO.  This forces the
89*4882a593Smuzhiyun  * same read/write path as a file opened by multiple clients when one
90*4882a593Smuzhiyun  * or more of those clients is opened for write.
91*4882a593Smuzhiyun  *
92*4882a593Smuzhiyun  * Note that this type of sync IO takes a different path than a file
93*4882a593Smuzhiyun  * opened with O_SYNC/D_SYNC (writes hit the page cache and are
94*4882a593Smuzhiyun  * immediately flushed on page boundaries).  It is very similar to
95*4882a593Smuzhiyun  * O_DIRECT (writes bypass the page cache) excep that O_DIRECT writes
96*4882a593Smuzhiyun  * are not copied (user page must remain stable) and O_DIRECT writes
97*4882a593Smuzhiyun  * have alignment restrictions (on the buffer and file offset).
98*4882a593Smuzhiyun  */
99*4882a593Smuzhiyun #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun #endif
102