linux/include/linux/ceph/ceph_fs.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * ceph_fs.h - Ceph constants and data types to share between kernel and
 * user space.
 *
 * Most types in this file are defined as little-endian, and are
 * primarily intended to describe data structures that pass over the
 * wire or that are stored on disk.
 *
 * LGPL2
 */

#ifndef CEPH_FS_H
#define CEPH_FS_H

#include <linux/ceph/msgr.h>
#include <linux/ceph/rados.h>

/*
 * subprotocol versions.  when specific messages types or high-level
 * protocols change, bump the affected components.  we keep rev
 * internal cluster protocols separately from the public,
 * client-facing protocol.
 */
#define CEPH_OSDC_PROTOCOL
#define CEPH_MDSC_PROTOCOL
#define CEPH_MONC_PROTOCOL


#define CEPH_INO_ROOT
#define CEPH_INO_CEPH
#define CEPH_INO_GLOBAL_SNAPREALM

/* arbitrary limit on max # of monitors (cluster of 3 is typical) */
#define CEPH_MAX_MON

/*
 * legacy ceph_file_layoute
 */
struct ceph_file_layout_legacy {} __attribute__ ((packed));

struct ceph_string;
/*
 * ceph_file_layout - describe data layout for a file/inode
 */
struct ceph_file_layout {};

extern int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
extern void ceph_file_layout_from_legacy(struct ceph_file_layout *fl,
				struct ceph_file_layout_legacy *legacy);
extern void ceph_file_layout_to_legacy(struct ceph_file_layout *fl,
				struct ceph_file_layout_legacy *legacy);

#define CEPH_MIN_STRIPE_UNIT

struct ceph_dir_layout {} __attribute__ ((packed));

/* crypto algorithms */
#define CEPH_CRYPTO_NONE
#define CEPH_CRYPTO_AES

#define CEPH_AES_IV

/* security/authentication protocols */
#define CEPH_AUTH_UNKNOWN
#define CEPH_AUTH_NONE
#define CEPH_AUTH_CEPHX

#define CEPH_AUTH_MODE_NONE
#define CEPH_AUTH_MODE_AUTHORIZER
#define CEPH_AUTH_MODE_MON

/* msgr2 protocol modes */
#define CEPH_CON_MODE_UNKNOWN
#define CEPH_CON_MODE_CRC
#define CEPH_CON_MODE_SECURE

#define CEPH_AUTH_UID_DEFAULT

const char *ceph_auth_proto_name(int proto);
const char *ceph_con_mode_name(int mode);

/*********************************************
 * message layer
 */

/*
 * message types
 */

/* misc */
#define CEPH_MSG_SHUTDOWN
#define CEPH_MSG_PING

/* client <-> monitor */
#define CEPH_MSG_MON_MAP
#define CEPH_MSG_MON_GET_MAP
#define CEPH_MSG_STATFS
#define CEPH_MSG_STATFS_REPLY
#define CEPH_MSG_MON_SUBSCRIBE
#define CEPH_MSG_MON_SUBSCRIBE_ACK
#define CEPH_MSG_AUTH
#define CEPH_MSG_AUTH_REPLY
#define CEPH_MSG_MON_GET_VERSION
#define CEPH_MSG_MON_GET_VERSION_REPLY

/* client <-> mds */
#define CEPH_MSG_MDS_MAP
#define CEPH_MSG_FS_MAP_USER

#define CEPH_MSG_CLIENT_SESSION
#define CEPH_MSG_CLIENT_RECONNECT

#define CEPH_MSG_CLIENT_REQUEST
#define CEPH_MSG_CLIENT_REQUEST_FORWARD
#define CEPH_MSG_CLIENT_REPLY
#define CEPH_MSG_CLIENT_METRICS
#define CEPH_MSG_CLIENT_CAPS
#define CEPH_MSG_CLIENT_LEASE
#define CEPH_MSG_CLIENT_SNAP
#define CEPH_MSG_CLIENT_CAPRELEASE
#define CEPH_MSG_CLIENT_QUOTA

/* pool ops */
#define CEPH_MSG_POOLOP_REPLY
#define CEPH_MSG_POOLOP

/* mon commands */
#define CEPH_MSG_MON_COMMAND
#define CEPH_MSG_MON_COMMAND_ACK

/* osd */
#define CEPH_MSG_OSD_MAP
#define CEPH_MSG_OSD_OP
#define CEPH_MSG_OSD_OPREPLY
#define CEPH_MSG_WATCH_NOTIFY
#define CEPH_MSG_OSD_BACKOFF


/* watch-notify operations */
enum {};


struct ceph_mon_request_header {} __attribute__ ((packed));

struct ceph_mon_statfs {} __attribute__ ((packed));

struct ceph_statfs {} __attribute__ ((packed));

struct ceph_mon_statfs_reply {} __attribute__ ((packed));

struct ceph_mon_command {} __attribute__ ((packed));

struct ceph_osd_getmap {} __attribute__ ((packed));

struct ceph_mds_getmap {} __attribute__ ((packed));

struct ceph_client_mount {} __attribute__ ((packed));

#define CEPH_SUBSCRIBE_ONETIME

struct ceph_mon_subscribe_item {} __attribute__ ((packed));

struct ceph_mon_subscribe_ack {} __attribute__ ((packed));

#define CEPH_FS_CLUSTER_ID_NONE

/*
 * mdsmap flags
 */
#define CEPH_MDSMAP_DOWN

/*
 * mds states
 *   > 0 -> in
 *  <= 0 -> out
 */
#define CEPH_MDS_STATE_DNE
#define CEPH_MDS_STATE_STOPPED
#define CEPH_MDS_STATE_BOOT
#define CEPH_MDS_STATE_STANDBY
#define CEPH_MDS_STATE_CREATING
#define CEPH_MDS_STATE_STARTING
#define CEPH_MDS_STATE_STANDBY_REPLAY
#define CEPH_MDS_STATE_REPLAYONCE

#define CEPH_MDS_STATE_REPLAY
#define CEPH_MDS_STATE_RESOLVE
#define CEPH_MDS_STATE_RECONNECT
#define CEPH_MDS_STATE_REJOIN
#define CEPH_MDS_STATE_CLIENTREPLAY
#define CEPH_MDS_STATE_ACTIVE
#define CEPH_MDS_STATE_STOPPING

extern const char *ceph_mds_state_name(int s);


/*
 * metadata lock types.
 *  - these are bitmasks.. we can compose them
 *  - they also define the lock ordering by the MDS
 *  - a few of these are internal to the mds
 */
#define CEPH_LOCK_DVERSION
#define CEPH_LOCK_DN
#define CEPH_LOCK_ISNAP
#define CEPH_LOCK_IVERSION
#define CEPH_LOCK_IFILE
#define CEPH_LOCK_IAUTH
#define CEPH_LOCK_ILINK
#define CEPH_LOCK_IDFT
#define CEPH_LOCK_INEST
#define CEPH_LOCK_IXATTR
#define CEPH_LOCK_IFLOCK
#define CEPH_LOCK_INO
#define CEPH_LOCK_IPOLICY

/* client_session ops */
enum {};

#define CEPH_SESSION_BLOCKLISTED

extern const char *ceph_session_op_name(int op);

struct ceph_mds_session_head {} __attribute__ ((packed));

/* client_request */
/*
 * metadata ops.
 *  & 0x001000 -> write op
 *  & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
 &  & 0x100000 -> use weird ino/path trace
 */
#define CEPH_MDS_OP_WRITE
enum {};

#define IS_CEPH_MDS_OP_NEWINODE(op)

extern const char *ceph_mds_op_name(int op);

#define CEPH_SETATTR_MODE
#define CEPH_SETATTR_UID
#define CEPH_SETATTR_GID
#define CEPH_SETATTR_MTIME
#define CEPH_SETATTR_ATIME
#define CEPH_SETATTR_SIZE
#define CEPH_SETATTR_CTIME
#define CEPH_SETATTR_MTIME_NOW
#define CEPH_SETATTR_ATIME_NOW
#define CEPH_SETATTR_BTIME
#define CEPH_SETATTR_KILL_SGUID
#define CEPH_SETATTR_FSCRYPT_AUTH
#define CEPH_SETATTR_FSCRYPT_FILE

/*
 * Ceph setxattr request flags.
 */
#define CEPH_XATTR_CREATE
#define CEPH_XATTR_REPLACE
#define CEPH_XATTR_REMOVE

/*
 * readdir request flags;
 */
#define CEPH_READDIR_REPLY_BITFLAGS

/*
 * readdir reply flags.
 */
#define CEPH_READDIR_FRAG_END
#define CEPH_READDIR_FRAG_COMPLETE
#define CEPH_READDIR_HASH_ORDER
#define CEPH_READDIR_OFFSET_HASH

/*
 * open request flags
 */
#define CEPH_O_RDONLY
#define CEPH_O_WRONLY
#define CEPH_O_RDWR
#define CEPH_O_CREAT
#define CEPH_O_EXCL
#define CEPH_O_TRUNC
#define CEPH_O_DIRECTORY
#define CEPH_O_NOFOLLOW

ceph_mds_request_args __attribute__ ((packed));

ceph_mds_request_args_ext;

#define CEPH_MDS_FLAG_REPLAY
#define CEPH_MDS_FLAG_WANT_DENTRY
#define CEPH_MDS_FLAG_ASYNC

struct ceph_mds_request_head_legacy {} __attribute__ ((packed));

#define CEPH_MDS_REQUEST_HEAD_VERSION

struct ceph_mds_request_head_old {} __attribute__ ((packed));

struct ceph_mds_request_head {} __attribute__ ((packed));

/* cap/lease release record */
struct ceph_mds_request_release {} __attribute__ ((packed));

/* client reply */
struct ceph_mds_reply_head {} __attribute__ ((packed));

/* one for each node split */
struct ceph_frag_tree_split {} __attribute__ ((packed));

struct ceph_frag_tree_head {} __attribute__ ((packed));

/* capability issue, for bundling with mds reply */
struct ceph_mds_reply_cap {} __attribute__ ((packed));

#define CEPH_CAP_FLAG_AUTH
#define CEPH_CAP_FLAG_RELEASE

/* inode record, for bundling with mds reply */
struct ceph_mds_reply_inode {} __attribute__ ((packed));
/* followed by frag array, symlink string, dir layout, xattr blob */

/* reply_lease follows dname, and reply_inode */
struct ceph_mds_reply_lease {} __attribute__ ((packed));

#define CEPH_LEASE_VALID
#define CEPH_LEASE_PRIMARY_LINK

struct ceph_mds_reply_dirfrag {} __attribute__ ((packed));

#define CEPH_LOCK_FCNTL
#define CEPH_LOCK_FLOCK
#define CEPH_LOCK_FCNTL_INTR
#define CEPH_LOCK_FLOCK_INTR


#define CEPH_LOCK_SHARED
#define CEPH_LOCK_EXCL
#define CEPH_LOCK_UNLOCK

struct ceph_filelock {} __attribute__ ((packed));


/* file access modes */
#define CEPH_FILE_MODE_PIN
#define CEPH_FILE_MODE_RD
#define CEPH_FILE_MODE_WR
#define CEPH_FILE_MODE_RDWR
#define CEPH_FILE_MODE_LAZY
#define CEPH_FILE_MODE_BITS
#define CEPH_FILE_MODE_MASK

int ceph_flags_to_mode(int flags);

#define CEPH_INLINE_NONE

/* capability bits */
#define CEPH_CAP_PIN

/* generic cap bits */
#define CEPH_CAP_GSHARED
#define CEPH_CAP_GEXCL
#define CEPH_CAP_GCACHE
#define CEPH_CAP_GRD
#define CEPH_CAP_GWR
#define CEPH_CAP_GBUFFER
#define CEPH_CAP_GWREXTEND
#define CEPH_CAP_GLAZYIO

#define CEPH_CAP_SIMPLE_BITS
#define CEPH_CAP_FILE_BITS

/* per-lock shift */
#define CEPH_CAP_SAUTH
#define CEPH_CAP_SLINK
#define CEPH_CAP_SXATTR
#define CEPH_CAP_SFILE
#define CEPH_CAP_SFLOCK

#define CEPH_CAP_BITS

/* composed values */
#define CEPH_CAP_AUTH_SHARED
#define CEPH_CAP_AUTH_EXCL
#define CEPH_CAP_LINK_SHARED
#define CEPH_CAP_LINK_EXCL
#define CEPH_CAP_XATTR_SHARED
#define CEPH_CAP_XATTR_EXCL
#define CEPH_CAP_FILE(x)
#define CEPH_CAP_FILE_SHARED
#define CEPH_CAP_FILE_EXCL
#define CEPH_CAP_FILE_CACHE
#define CEPH_CAP_FILE_RD
#define CEPH_CAP_FILE_WR
#define CEPH_CAP_FILE_BUFFER
#define CEPH_CAP_FILE_WREXTEND
#define CEPH_CAP_FILE_LAZYIO
#define CEPH_CAP_FLOCK_SHARED
#define CEPH_CAP_FLOCK_EXCL


/* cap masks (for getattr) */
#define CEPH_STAT_CAP_INODE
#define CEPH_STAT_CAP_TYPE
#define CEPH_STAT_CAP_SYMLINK
#define CEPH_STAT_CAP_UID
#define CEPH_STAT_CAP_GID
#define CEPH_STAT_CAP_MODE
#define CEPH_STAT_CAP_NLINK
#define CEPH_STAT_CAP_LAYOUT
#define CEPH_STAT_CAP_MTIME
#define CEPH_STAT_CAP_SIZE
#define CEPH_STAT_CAP_ATIME
#define CEPH_STAT_CAP_XATTR
#define CEPH_STAT_CAP_INODE_ALL
#define CEPH_STAT_CAP_INLINE_DATA
#define CEPH_STAT_RSTAT

#define CEPH_CAP_ANY_SHARED
#define CEPH_CAP_ANY_RD

#define CEPH_CAP_ANY_EXCL
#define CEPH_CAP_ANY_FILE_RD
#define CEPH_CAP_ANY_FILE_WR
#define CEPH_CAP_ANY_WR
#define CEPH_CAP_ANY
#define CEPH_CAP_ALL_FILE

#define CEPH_CAP_LOCKS

/* cap masks async dir operations */
#define CEPH_CAP_DIR_CREATE
#define CEPH_CAP_DIR_UNLINK
#define CEPH_CAP_ANY_DIR_OPS

int ceph_caps_for_mode(int mode);

enum {};

extern const char *ceph_cap_op_name(int op);

/* flags field in client cap messages (version >= 10) */
#define CEPH_CLIENT_CAPS_SYNC
#define CEPH_CLIENT_CAPS_NO_CAPSNAP
#define CEPH_CLIENT_CAPS_PENDING_CAPSNAP

/*
 * caps message, used for capability callbacks, acks, requests, etc.
 */
struct ceph_mds_caps {} __attribute__ ((packed));

struct ceph_mds_cap_peer {} __attribute__ ((packed));

/* cap release msg head */
struct ceph_mds_cap_release {} __attribute__ ((packed));

struct ceph_mds_cap_item {} __attribute__ ((packed));

#define CEPH_MDS_LEASE_REVOKE
#define CEPH_MDS_LEASE_RELEASE
#define CEPH_MDS_LEASE_RENEW
#define CEPH_MDS_LEASE_REVOKE_ACK

extern const char *ceph_lease_op_name(int o);

/* lease msg header */
struct ceph_mds_lease {} __attribute__ ((packed));
/* followed by a __le32+string for dname */

/* client reconnect */
struct ceph_mds_cap_reconnect {} __attribute__ ((packed));
/* followed by flock blob */

struct ceph_mds_cap_reconnect_v1 {} __attribute__ ((packed));

struct ceph_mds_snaprealm_reconnect {} __attribute__ ((packed));

/*
 * snaps
 */
enum {};

extern const char *ceph_snap_op_name(int o);

/* snap msg header */
struct ceph_mds_snap_head {} __attribute__ ((packed));
/* followed by split ino list, then split realms, then the trace blob */

/*
 * encode info about a snaprealm, as viewed by a client
 */
struct ceph_mds_snap_realm {} __attribute__ ((packed));
/* followed by my snap list, then prior parent snap list */

/*
 * quotas
 */
struct ceph_mds_quota {} __attribute__ ((packed));

#endif