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