18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef FS_CEPH_IOCTL_H
38c2ecf20Sopenharmony_ci#define FS_CEPH_IOCTL_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/ioctl.h>
68c2ecf20Sopenharmony_ci#include <linux/types.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#define CEPH_IOCTL_MAGIC 0x97
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/*
118c2ecf20Sopenharmony_ci * CEPH_IOC_GET_LAYOUT - get file layout or dir layout policy
128c2ecf20Sopenharmony_ci * CEPH_IOC_SET_LAYOUT - set file layout
138c2ecf20Sopenharmony_ci * CEPH_IOC_SET_LAYOUT_POLICY - set dir layout policy
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * The file layout specifies how file data is striped over objects in
168c2ecf20Sopenharmony_ci * the distributed object store, which object pool they belong to (if
178c2ecf20Sopenharmony_ci * it differs from the default), and an optional 'preferred osd' to
188c2ecf20Sopenharmony_ci * store them on.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * Files get a new layout based on the policy set on the containing
218c2ecf20Sopenharmony_ci * directory or one of its ancestors.  The GET_LAYOUT ioctl will let
228c2ecf20Sopenharmony_ci * you examine the layout for a file or the policy on a directory.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * SET_LAYOUT will let you set a layout on a newly created file.  This
258c2ecf20Sopenharmony_ci * only works immediately after the file is created and before any
268c2ecf20Sopenharmony_ci * data is written to it.
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * SET_LAYOUT_POLICY will let you set a layout policy (default layout)
298c2ecf20Sopenharmony_ci * on a directory that will apply to any new files created in that
308c2ecf20Sopenharmony_ci * directory (or any child directory that doesn't specify a layout of
318c2ecf20Sopenharmony_ci * its own).
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* use u64 to align sanely on all archs */
358c2ecf20Sopenharmony_cistruct ceph_ioctl_layout {
368c2ecf20Sopenharmony_ci	__u64 stripe_unit, stripe_count, object_size;
378c2ecf20Sopenharmony_ci	__u64 data_pool;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	/* obsolete.  new values ignored, always return -1 */
408c2ecf20Sopenharmony_ci	__s64 preferred_osd;
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define CEPH_IOC_GET_LAYOUT _IOR(CEPH_IOCTL_MAGIC, 1,		\
448c2ecf20Sopenharmony_ci				   struct ceph_ioctl_layout)
458c2ecf20Sopenharmony_ci#define CEPH_IOC_SET_LAYOUT _IOW(CEPH_IOCTL_MAGIC, 2,		\
468c2ecf20Sopenharmony_ci				   struct ceph_ioctl_layout)
478c2ecf20Sopenharmony_ci#define CEPH_IOC_SET_LAYOUT_POLICY _IOW(CEPH_IOCTL_MAGIC, 5,	\
488c2ecf20Sopenharmony_ci				   struct ceph_ioctl_layout)
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/*
518c2ecf20Sopenharmony_ci * CEPH_IOC_GET_DATALOC - get location of file data in the cluster
528c2ecf20Sopenharmony_ci *
538c2ecf20Sopenharmony_ci * Extract identity, address of the OSD and object storing a given
548c2ecf20Sopenharmony_ci * file offset.
558c2ecf20Sopenharmony_ci */
568c2ecf20Sopenharmony_cistruct ceph_ioctl_dataloc {
578c2ecf20Sopenharmony_ci	__u64 file_offset;           /* in+out: file offset */
588c2ecf20Sopenharmony_ci	__u64 object_offset;         /* out: offset in object */
598c2ecf20Sopenharmony_ci	__u64 object_no;             /* out: object # */
608c2ecf20Sopenharmony_ci	__u64 object_size;           /* out: object size */
618c2ecf20Sopenharmony_ci	char object_name[64];        /* out: object name */
628c2ecf20Sopenharmony_ci	__u64 block_offset;          /* out: offset in block */
638c2ecf20Sopenharmony_ci	__u64 block_size;            /* out: block length */
648c2ecf20Sopenharmony_ci	__s64 osd;                   /* out: osd # */
658c2ecf20Sopenharmony_ci	struct sockaddr_storage osd_addr; /* out: osd address */
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define CEPH_IOC_GET_DATALOC _IOWR(CEPH_IOCTL_MAGIC, 3,	\
698c2ecf20Sopenharmony_ci				   struct ceph_ioctl_dataloc)
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/*
728c2ecf20Sopenharmony_ci * CEPH_IOC_LAZYIO - relax consistency
738c2ecf20Sopenharmony_ci *
748c2ecf20Sopenharmony_ci * Normally Ceph switches to synchronous IO when multiple clients have
758c2ecf20Sopenharmony_ci * the file open (and or more for write).  Reads and writes bypass the
768c2ecf20Sopenharmony_ci * page cache and go directly to the OSD.  Setting this flag on a file
778c2ecf20Sopenharmony_ci * descriptor will allow buffered IO for this file in cases where the
788c2ecf20Sopenharmony_ci * application knows it won't interfere with other nodes (or doesn't
798c2ecf20Sopenharmony_ci * care).
808c2ecf20Sopenharmony_ci */
818c2ecf20Sopenharmony_ci#define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/*
848c2ecf20Sopenharmony_ci * CEPH_IOC_SYNCIO - force synchronous IO
858c2ecf20Sopenharmony_ci *
868c2ecf20Sopenharmony_ci * This ioctl sets a file flag that forces the synchronous IO that
878c2ecf20Sopenharmony_ci * bypasses the page cache, even if it is not necessary.  This is
888c2ecf20Sopenharmony_ci * essentially the opposite behavior of IOC_LAZYIO.  This forces the
898c2ecf20Sopenharmony_ci * same read/write path as a file opened by multiple clients when one
908c2ecf20Sopenharmony_ci * or more of those clients is opened for write.
918c2ecf20Sopenharmony_ci *
928c2ecf20Sopenharmony_ci * Note that this type of sync IO takes a different path than a file
938c2ecf20Sopenharmony_ci * opened with O_SYNC/D_SYNC (writes hit the page cache and are
948c2ecf20Sopenharmony_ci * immediately flushed on page boundaries).  It is very similar to
958c2ecf20Sopenharmony_ci * O_DIRECT (writes bypass the page cache) excep that O_DIRECT writes
968c2ecf20Sopenharmony_ci * are not copied (user page must remain stable) and O_DIRECT writes
978c2ecf20Sopenharmony_ci * have alignment restrictions (on the buffer and file offset).
988c2ecf20Sopenharmony_ci */
998c2ecf20Sopenharmony_ci#define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#endif
102