]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/cephfs/ceph_ll_client.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / include / cephfs / ceph_ll_client.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * scalable distributed file system
5 *
6 * Copyright (C) Jeff Layton <jlayton@redhat.com>
7 *
7c673cae
FG
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
7c673cae
FG
12 */
13
e306af50
TL
14#ifndef CEPH_CEPH_LL_CLIENT_H
15#define CEPH_CEPH_LL_CLIENT_H
7c673cae
FG
16#include <stdint.h>
17
f67539c2
TL
18#ifdef _WIN32
19#include "include/win32/fs_compat.h"
20#endif
21
7c673cae
FG
22#ifdef __cplusplus
23extern "C" {
e306af50
TL
24
25class Fh;
26
27struct inodeno_t;
28struct vinodeno_t;
29typedef struct vinodeno_t vinodeno;
30
31#else /* __cplusplus */
32
33typedef struct Fh Fh;
34
35typedef struct inodeno_t {
36 uint64_t val;
37} inodeno_t;
38
39typedef struct _snapid_t {
40 uint64_t val;
41} snapid_t;
42
43typedef struct vinodeno_t {
44 inodeno_t ino;
45 snapid_t snapid;
46} vinodeno_t;
47
48#endif /* __cplusplus */
7c673cae
FG
49
50/*
e306af50
TL
51 * Heavily borrowed from David Howells' draft statx patchset.
52 *
7c673cae
FG
53 * Since the xstat patches are still a work in progress, we borrow its data
54 * structures and #defines to implement ceph_getattrx. Once the xstat stuff
55 * has been merged we should drop this and switch over to using that instead.
56 */
57struct ceph_statx {
58 uint32_t stx_mask;
59 uint32_t stx_blksize;
60 uint32_t stx_nlink;
61 uint32_t stx_uid;
62 uint32_t stx_gid;
63 uint16_t stx_mode;
64 uint64_t stx_ino;
65 uint64_t stx_size;
66 uint64_t stx_blocks;
67 dev_t stx_dev;
68 dev_t stx_rdev;
69 struct timespec stx_atime;
70 struct timespec stx_ctime;
71 struct timespec stx_mtime;
72 struct timespec stx_btime;
73 uint64_t stx_version;
74};
75
76#define CEPH_STATX_MODE 0x00000001U /* Want/got stx_mode */
77#define CEPH_STATX_NLINK 0x00000002U /* Want/got stx_nlink */
78#define CEPH_STATX_UID 0x00000004U /* Want/got stx_uid */
79#define CEPH_STATX_GID 0x00000008U /* Want/got stx_gid */
80#define CEPH_STATX_RDEV 0x00000010U /* Want/got stx_rdev */
81#define CEPH_STATX_ATIME 0x00000020U /* Want/got stx_atime */
82#define CEPH_STATX_MTIME 0x00000040U /* Want/got stx_mtime */
83#define CEPH_STATX_CTIME 0x00000080U /* Want/got stx_ctime */
84#define CEPH_STATX_INO 0x00000100U /* Want/got stx_ino */
85#define CEPH_STATX_SIZE 0x00000200U /* Want/got stx_size */
86#define CEPH_STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */
87#define CEPH_STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
88#define CEPH_STATX_BTIME 0x00000800U /* Want/got stx_btime */
89#define CEPH_STATX_VERSION 0x00001000U /* Want/got stx_version */
90#define CEPH_STATX_ALL_STATS 0x00001fffU /* All supported stats */
91
92/*
11fdf7f2 93 * Compatibility macros until these defines make their way into glibc
7c673cae
FG
94 */
95#ifndef AT_NO_ATTR_SYNC
96#define AT_NO_ATTR_SYNC 0x4000 /* Don't sync attributes with the server */
97#endif
98
99/*
100 * The statx interfaces only allow these flags. In order to allow us to add
101 * others in the future, we disallow setting any that aren't recognized.
102 */
103#define CEPH_REQ_FLAG_MASK (AT_SYMLINK_NOFOLLOW|AT_NO_ATTR_SYNC)
104
20effc67
TL
105/* fallocate mode flags */
106#ifndef FALLOC_FL_KEEP_SIZE
107#define FALLOC_FL_KEEP_SIZE 0x01
108#endif
109#ifndef FALLOC_FL_PUNCH_HOLE
110#define FALLOC_FL_PUNCH_HOLE 0x02
111#endif
112
113/** ceph_deleg_cb_t: Delegation recalls
114 *
115 * Called when there is an outstanding Delegation and there is conflicting
116 * access, either locally or via cap activity.
117 * @fh: open filehandle
118 * @priv: private info registered when delegation was acquired
119 */
e306af50
TL
120typedef void (*ceph_deleg_cb_t)(Fh *fh, void *priv);
121
20effc67
TL
122/**
123 * client_ino_callback_t: Inode data/metadata invalidation
124 *
125 * Called when the client wants to invalidate the cached data for a range
126 * in the file.
127 * @handle: client callback handle
128 * @ino: vino of inode to be invalidated
129 * @off: starting offset of content to be invalidated
130 * @len: length of region to invalidate
131 */
e306af50
TL
132typedef void (*client_ino_callback_t)(void *handle, vinodeno_t ino,
133 int64_t off, int64_t len);
134
20effc67
TL
135/**
136 * client_dentry_callback_t: Dentry invalidation
137 *
138 * Called when the client wants to purge a dentry from its cache.
139 * @handle: client callback handle
140 * @dirino: vino of directory that contains dentry to be invalidate
141 * @ino: vino of inode attached to dentry to be invalidated
142 * @name: name of dentry to be invalidated
143 * @len: length of @name
144 */
e306af50
TL
145typedef void (*client_dentry_callback_t)(void *handle, vinodeno_t dirino,
146 vinodeno_t ino, const char *name,
147 size_t len);
148
20effc67
TL
149/**
150 * client_remount_callback_t: Remount entire fs
151 *
152 * Called when the client needs to purge the dentry cache and the application
153 * doesn't have a way to purge an individual dentry. Mostly used for ceph-fuse
154 * on older kernels.
155 * @handle: client callback handle
156 */
157
e306af50
TL
158typedef int (*client_remount_callback_t)(void *handle);
159
20effc67
TL
160/**
161 * client_switch_interrupt_callback_t: Lock request interrupted
162 *
163 * Called before file lock request to set the interrupt handler while waiting
164 * After the wait, called with "data" set to NULL pointer.
165 * @handle: client callback handle
166 * @data: opaque data passed to interrupt before call, NULL pointer after.
167 */
e306af50
TL
168typedef void (*client_switch_interrupt_callback_t)(void *handle, void *data);
169
20effc67
TL
170/**
171 * client_umask_callback_t: Fetch umask of actor
172 *
173 * Called when the client needs the umask of the requestor.
174 * @handle: client callback handle
175 */
e306af50
TL
176typedef mode_t (*client_umask_callback_t)(void *handle);
177
20effc67
TL
178/**
179 * client_ino_release_t: Request that application release Inode references
180 *
181 * Called when the MDS wants to trim caps and Inode records.
182 * @handle: client callback handle
183 * @ino: vino of Inode being released
184 */
e306af50
TL
185typedef void (*client_ino_release_t)(void *handle, vinodeno_t ino);
186
187/*
188 * The handle is an opaque value that gets passed to some callbacks. Any fields
189 * set to NULL will be left alone. There is no way to unregister callbacks.
190 */
191struct ceph_client_callback_args {
192 void *handle;
193 client_ino_callback_t ino_cb;
194 client_dentry_callback_t dentry_cb;
195 client_switch_interrupt_callback_t switch_intr_cb;
196 client_remount_callback_t remount_cb;
197 client_umask_callback_t umask_cb;
198 client_ino_release_t ino_release_cb;
199};
200
7c673cae
FG
201#ifdef __cplusplus
202}
203#endif
204
205#endif /* CEPH_STATX_H */
206