/* SPDX-License-Identifier: GPL-2.0 */1#ifndef FS_CEPH_IOCTL_H2#define FS_CEPH_IOCTL_H34#include <linux/ioctl.h>5#include <linux/types.h>67#define CEPH_IOCTL_MAGIC 0x9789/*10* CEPH_IOC_GET_LAYOUT - get file layout or dir layout policy11* CEPH_IOC_SET_LAYOUT - set file layout12* CEPH_IOC_SET_LAYOUT_POLICY - set dir layout policy13*14* The file layout specifies how file data is striped over objects in15* the distributed object store, which object pool they belong to (if16* it differs from the default), and an optional 'preferred osd' to17* store them on.18*19* Files get a new layout based on the policy set on the containing20* directory or one of its ancestors. The GET_LAYOUT ioctl will let21* you examine the layout for a file or the policy on a directory.22*23* SET_LAYOUT will let you set a layout on a newly created file. This24* only works immediately after the file is created and before any25* data is written to it.26*27* SET_LAYOUT_POLICY will let you set a layout policy (default layout)28* on a directory that will apply to any new files created in that29* directory (or any child directory that doesn't specify a layout of30* its own).31*/3233/* use u64 to align sanely on all archs */34struct ceph_ioctl_layout {35__u64 stripe_unit, stripe_count, object_size;36__u64 data_pool;3738/* obsolete. new values ignored, always return -1 */39__s64 preferred_osd;40};4142#define CEPH_IOC_GET_LAYOUT _IOR(CEPH_IOCTL_MAGIC, 1, \43struct ceph_ioctl_layout)44#define CEPH_IOC_SET_LAYOUT _IOW(CEPH_IOCTL_MAGIC, 2, \45struct ceph_ioctl_layout)46#define CEPH_IOC_SET_LAYOUT_POLICY _IOW(CEPH_IOCTL_MAGIC, 5, \47struct ceph_ioctl_layout)4849/*50* CEPH_IOC_GET_DATALOC - get location of file data in the cluster51*52* Extract identity, address of the OSD and object storing a given53* file offset.54*/55struct ceph_ioctl_dataloc {56__u64 file_offset; /* in+out: file offset */57__u64 object_offset; /* out: offset in object */58__u64 object_no; /* out: object # */59__u64 object_size; /* out: object size */60char object_name[64]; /* out: object name */61__u64 block_offset; /* out: offset in block */62__u64 block_size; /* out: block length */63__s64 osd; /* out: osd # */64struct sockaddr_storage osd_addr; /* out: osd address */65};6667#define CEPH_IOC_GET_DATALOC _IOWR(CEPH_IOCTL_MAGIC, 3, \68struct ceph_ioctl_dataloc)6970/*71* CEPH_IOC_LAZYIO - relax consistency72*73* Normally Ceph switches to synchronous IO when multiple clients have74* the file open (and or more for write). Reads and writes bypass the75* page cache and go directly to the OSD. Setting this flag on a file76* descriptor will allow buffered IO for this file in cases where the77* application knows it won't interfere with other nodes (or doesn't78* care).79*/80#define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4)8182/*83* CEPH_IOC_SYNCIO - force synchronous IO84*85* This ioctl sets a file flag that forces the synchronous IO that86* bypasses the page cache, even if it is not necessary. This is87* essentially the opposite behavior of IOC_LAZYIO. This forces the88* same read/write path as a file opened by multiple clients when one89* or more of those clients is opened for write.90*91* Note that this type of sync IO takes a different path than a file92* opened with O_SYNC/D_SYNC (writes hit the page cache and are93* immediately flushed on page boundaries). It is very similar to94* O_DIRECT (writes bypass the page cache) excep that O_DIRECT writes95* are not copied (user page must remain stable) and O_DIRECT writes96* have alignment restrictions (on the buffer and file offset).97*/98#define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5)99100#endif101102103