1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 28f4e91deSSage Weil #ifndef FS_CEPH_IOCTL_H 38f4e91deSSage Weil #define FS_CEPH_IOCTL_H 48f4e91deSSage Weil 58f4e91deSSage Weil #include <linux/ioctl.h> 68f4e91deSSage Weil #include <linux/types.h> 78f4e91deSSage Weil 81cd275f6SSage Weil #define CEPH_IOCTL_MAGIC 0x97 98f4e91deSSage Weil 106a8ea470SSage Weil /* 116a8ea470SSage Weil * CEPH_IOC_GET_LAYOUT - get file layout or dir layout policy 126a8ea470SSage Weil * CEPH_IOC_SET_LAYOUT - set file layout 136a8ea470SSage Weil * CEPH_IOC_SET_LAYOUT_POLICY - set dir layout policy 146a8ea470SSage Weil * 156a8ea470SSage Weil * The file layout specifies how file data is striped over objects in 166a8ea470SSage Weil * the distributed object store, which object pool they belong to (if 176a8ea470SSage Weil * it differs from the default), and an optional 'preferred osd' to 186a8ea470SSage Weil * store them on. 196a8ea470SSage Weil * 206a8ea470SSage Weil * Files get a new layout based on the policy set on the containing 216a8ea470SSage Weil * directory or one of its ancestors. The GET_LAYOUT ioctl will let 226a8ea470SSage Weil * you examine the layout for a file or the policy on a directory. 236a8ea470SSage Weil * 246a8ea470SSage Weil * SET_LAYOUT will let you set a layout on a newly created file. This 256a8ea470SSage Weil * only works immediately after the file is created and before any 266a8ea470SSage Weil * data is written to it. 276a8ea470SSage Weil * 286a8ea470SSage Weil * SET_LAYOUT_POLICY will let you set a layout policy (default layout) 296a8ea470SSage Weil * on a directory that will apply to any new files created in that 306a8ea470SSage Weil * directory (or any child directory that doesn't specify a layout of 316a8ea470SSage Weil * its own). 326a8ea470SSage Weil */ 336a8ea470SSage Weil 346a8ea470SSage Weil /* use u64 to align sanely on all archs */ 358f4e91deSSage Weil struct ceph_ioctl_layout { 368f4e91deSSage Weil __u64 stripe_unit, stripe_count, object_size; 378f4e91deSSage Weil __u64 data_pool; 38702aeb1fSSage Weil 39702aeb1fSSage Weil /* obsolete. new values ignored, always return -1 */ 4033d4909cSSage Weil __s64 preferred_osd; 418f4e91deSSage Weil }; 428f4e91deSSage Weil 438f4e91deSSage Weil #define CEPH_IOC_GET_LAYOUT _IOR(CEPH_IOCTL_MAGIC, 1, \ 448f4e91deSSage Weil struct ceph_ioctl_layout) 458f4e91deSSage Weil #define CEPH_IOC_SET_LAYOUT _IOW(CEPH_IOCTL_MAGIC, 2, \ 468f4e91deSSage Weil struct ceph_ioctl_layout) 47571dba52SGreg Farnum #define CEPH_IOC_SET_LAYOUT_POLICY _IOW(CEPH_IOCTL_MAGIC, 5, \ 48571dba52SGreg Farnum struct ceph_ioctl_layout) 498f4e91deSSage Weil 508f4e91deSSage Weil /* 516a8ea470SSage Weil * CEPH_IOC_GET_DATALOC - get location of file data in the cluster 526a8ea470SSage Weil * 538f4e91deSSage Weil * Extract identity, address of the OSD and object storing a given 548f4e91deSSage Weil * file offset. 558f4e91deSSage Weil */ 568f4e91deSSage Weil struct ceph_ioctl_dataloc { 578f4e91deSSage Weil __u64 file_offset; /* in+out: file offset */ 588f4e91deSSage Weil __u64 object_offset; /* out: offset in object */ 598f4e91deSSage Weil __u64 object_no; /* out: object # */ 608f4e91deSSage Weil __u64 object_size; /* out: object size */ 618f4e91deSSage Weil char object_name[64]; /* out: object name */ 628f4e91deSSage Weil __u64 block_offset; /* out: offset in block */ 638f4e91deSSage Weil __u64 block_size; /* out: block length */ 648f4e91deSSage Weil __s64 osd; /* out: osd # */ 658f4e91deSSage Weil struct sockaddr_storage osd_addr; /* out: osd address */ 668f4e91deSSage Weil }; 678f4e91deSSage Weil 688f4e91deSSage Weil #define CEPH_IOC_GET_DATALOC _IOWR(CEPH_IOCTL_MAGIC, 3, \ 698f4e91deSSage Weil struct ceph_ioctl_dataloc) 708f4e91deSSage Weil 716a8ea470SSage Weil /* 726a8ea470SSage Weil * CEPH_IOC_LAZYIO - relax consistency 736a8ea470SSage Weil * 746a8ea470SSage Weil * Normally Ceph switches to synchronous IO when multiple clients have 756a8ea470SSage Weil * the file open (and or more for write). Reads and writes bypass the 766a8ea470SSage Weil * page cache and go directly to the OSD. Setting this flag on a file 776a8ea470SSage Weil * descriptor will allow buffered IO for this file in cases where the 786a8ea470SSage Weil * application knows it won't interfere with other nodes (or doesn't 796a8ea470SSage Weil * care). 806a8ea470SSage Weil */ 818c6e9229SSage Weil #define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4) 826a8ea470SSage Weil 836a8ea470SSage Weil /* 846a8ea470SSage Weil * CEPH_IOC_SYNCIO - force synchronous IO 856a8ea470SSage Weil * 866a8ea470SSage Weil * This ioctl sets a file flag that forces the synchronous IO that 876a8ea470SSage Weil * bypasses the page cache, even if it is not necessary. This is 886a8ea470SSage Weil * essentially the opposite behavior of IOC_LAZYIO. This forces the 896a8ea470SSage Weil * same read/write path as a file opened by multiple clients when one 906a8ea470SSage Weil * or more of those clients is opened for write. 916a8ea470SSage Weil * 926a8ea470SSage Weil * Note that this type of sync IO takes a different path than a file 936a8ea470SSage Weil * opened with O_SYNC/D_SYNC (writes hit the page cache and are 946a8ea470SSage Weil * immediately flushed on page boundaries). It is very similar to 956a8ea470SSage Weil * O_DIRECT (writes bypass the page cache) excep that O_DIRECT writes 966a8ea470SSage Weil * are not copied (user page must remain stable) and O_DIRECT writes 976a8ea470SSage Weil * have alignment restrictions (on the buffer and file offset). 986a8ea470SSage Weil */ 994918b6d1SSage Weil #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5) 1008c6e9229SSage Weil 1018f4e91deSSage Weil #endif 102