ReactOS 0.4.16-dev-340-g0540c21
pnfs.h
Go to the documentation of this file.
1/* NFSv4.1 client for Windows
2 * Copyright © 2012 The Regents of the University of Michigan
3 *
4 * Olga Kornievskaia <aglo@umich.edu>
5 * Casey Bodley <cbodley@umich.edu>
6 *
7 * This library is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or (at
10 * your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * without any warranty; without even the implied warranty of merchantability
14 * or fitness for a particular purpose. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 */
21
22#ifndef __PNFS_H__
23#define __PNFS_H__
24
25#include "nfs41_types.h"
26#include "list.h"
27
28
29/* preprocessor options */
30#ifndef PNFS_DISABLE
31
32# ifndef PNFS_DISABLE_READ
33# define PNFS_ENABLE_READ
34# endif
35# ifndef PNFS_DISABLE_WRITE
36# define PNFS_ENABLE_WRITE
37# endif
38
39# define PNFS_THREADING
40
41/* XXX: the thread-by-server model breaks down when using dense layouts,
42 * because multiple stripes could be mapped to a single data server, and
43 * the per-data-server thread would have to send a COMMIT for each stripe */
44//# define PNFS_THREAD_BY_SERVER
45
46#endif
47
48
49/* forward declarations from nfs41.h */
50struct __nfs41_client;
51struct __nfs41_session;
53struct __nfs41_root;
54struct __stateid_arg;
55
56
57/* pnfs error values, in order of increasing severity */
72};
73
78};
79
84};
85
87 /* a LAYOUTGET error indicated that this layout will never be granted */
89 /* LAYOUTGET returned BADIOMODE, so a RW layout will never be granted */
91};
92
94 /* GETDEVICEINFO was successful */
96 /* a bulk recall or lease expiration led to device invalidation */
98};
99
105
106#define NFL4_UFLG_MASK 0x0000003F
107#define NFL4_UFLG_DENSE 0x00000001
108#define NFL4_UFLG_COMMIT_THRU_MDS 0x00000002
109#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0
110
111#define PNFS_DEVICEID_SIZE 16
112
113
114/* device */
115typedef struct __pnfs_device {
119 uint32_t layout_count; /* layouts using this device */
122
123typedef struct __pnfs_stripe_indices {
127
128typedef struct __pnfs_data_server {
131 SRWLOCK lock;
133
138
139typedef struct __pnfs_file_device {
143 struct pnfs_file_device_list *devices; /* -> nfs41_client.devices */
144 struct list_entry entry; /* position in devices */
146
147
148/* layout */
149typedef struct __pnfs_layout_state {
152 struct list_entry entry; /* position in nfs41_client.layouts */
153 struct list_entry layouts; /* list of pnfs_file_layouts */
154 struct list_entry recalls; /* list of pnfs_layouts */
157 LONG open_count; /* for return on last close */
158 uint32_t io_count; /* number of pending io operations */
159 bool_t pending; /* pending LAYOUTGET/LAYOUTRETURN */
160 SRWLOCK lock;
161 CONDITION_VARIABLE cond;
163
164typedef struct __pnfs_layout {
171
176
177typedef struct __pnfs_file_layout {
186
187
188/* pnfs_layout.c */
189struct pnfs_layout_list;
191
193 OUT struct pnfs_layout_list **layouts_out);
194
196 IN struct pnfs_layout_list *layouts);
197
200 OUT pnfs_layout_state **layout_out);
201
202/* expects caller to hold an exclusive lock on pnfs_layout_state */
205 IN struct __nfs41_session *session,
206 IN nfs41_path_fh *meta_file,
207 IN struct __stateid_arg *stateid,
208 IN enum pnfs_iomode iomode,
211
213 IN struct __nfs41_session *session,
216
218 IN struct __nfs41_client *client,
219 IN const struct cb_layoutrecall_args *recall);
220
221/* expects caller to hold a shared lock on pnfs_layout_state */
224 IN const pnfs_layout *layout);
225
228 IN const pnfs_layout *layout);
229
230/* expects caller to hold an exclusive lock on pnfs_layout_state */
233
236
237
238/* pnfs_device.c */
240
242 OUT struct pnfs_file_device_list **devices_out);
243
246
249
251 IN struct __nfs41_session *session,
253 IN unsigned char *deviceid,
254 OUT pnfs_file_device **device_out);
255
258
259struct notify_deviceid4; /* from nfs41_callback.h */
263 IN const struct notify_deviceid4 *change);
264
266 IN struct __nfs41_root *root,
268 IN uint32_t default_lease,
269 OUT struct __nfs41_client **client_out);
270
271
272/* pnfs_io.c */
274 IN struct __nfs41_root *root,
276 IN struct __stateid_arg *stateid,
280 OUT unsigned char *buffer_out,
281 OUT ULONG *len_out);
282
284 IN struct __nfs41_root *root,
286 IN struct __stateid_arg *stateid,
290 IN unsigned char *buffer,
291 OUT ULONG *len_out,
292 OUT nfs41_file_info *cinfo);
293
294
295/* helper functions */
296#ifndef __REACTOS__
297__inline int is_dense(
298#else
300#endif
302{
303 return (layout->util & NFL4_UFLG_DENSE) != 0;
304}
305#ifndef __REACTOS__
307#else
309#endif
311{
312 return (layout->util & NFL4_UFLG_COMMIT_THRU_MDS) != 0;
313}
314#ifndef __REACTOS__
316#else
318#endif
320{
322}
323#ifndef __REACTOS__
325#else
327#endif
330 IN uint32_t unit_size)
331{
332 const uint64_t relative_offset = offset - layout->pattern_offset;
333 return relative_offset / unit_size;
334}
335#ifndef __REACTOS__
337#else
339#endif
341 IN uint64_t sui,
342 IN uint32_t unit_size)
343{
344 return layout->pattern_offset + unit_size * sui;
345}
346#ifndef __REACTOS__
348#else
350#endif
352 IN uint64_t sui,
353 IN uint32_t stripe_count)
354{
355 return (uint32_t)((sui + layout->first_index) % stripe_count);
356}
357#ifndef __REACTOS__
359#else
361#endif
363 IN uint32_t stripeid)
364{
365 return device->stripes.arr[stripeid];
366}
367
368#endif /* !__PNFS_H__ */
static int state
Definition: maze.c:121
int32_t bool_t
Definition: types.h:101
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
static struct all_devices * devices
Definition: dsm_ctrl.c:48
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLintptr offset
Definition: glext.h:5920
static DWORD layout
Definition: bitmap.c:46
int remove
Definition: msacm.c:1366
notify_deviceid_type4
long LONG
Definition: pedump.c:60
__inline uint32_t stripe_index(IN const pnfs_file_layout *layout, IN uint64_t sui, IN uint32_t stripe_count)
Definition: pnfs.h:347
void pnfs_layout_io_finished(IN pnfs_layout_state *state)
Definition: pnfs_layout.c:1267
__inline uint32_t layout_unit_size(IN const pnfs_file_layout *layout)
Definition: pnfs.h:315
struct __pnfs_file_device pnfs_file_device
__inline uint32_t data_server_index(IN const pnfs_file_device *device, IN uint32_t stripeid)
Definition: pnfs.h:358
#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK
Definition: pnfs.h:109
enum pnfs_status pnfs_file_device_notify(IN struct pnfs_file_device_list *devices, IN const struct notify_deviceid4 *change)
Definition: pnfs_device.c:328
void pnfs_layout_io_start(IN pnfs_layout_state *state)
Definition: pnfs_layout.c:1257
enum pnfs_status pnfs_file_device_list_create(OUT struct pnfs_file_device_list **devices_out)
Definition: pnfs_device.c:124
enum pnfs_status pnfs_file_device_get(IN struct __nfs41_session *session, IN struct pnfs_file_device_list *devices, IN unsigned char *deviceid, OUT pnfs_file_device **device_out)
__inline int is_dense(IN const pnfs_file_layout *layout)
Definition: pnfs.h:297
__inline uint64_t stripe_unit_offset(IN const pnfs_file_layout *layout, IN uint64_t sui, IN uint32_t unit_size)
Definition: pnfs.h:336
void pnfs_layout_state_close(IN struct __nfs41_session *session, IN struct __nfs41_open_state *state, IN bool_t remove)
enum pnfs_status pnfs_layout_list_create(OUT struct pnfs_layout_list **layouts_out)
Definition: pnfs_layout.c:121
struct __pnfs_file_layout pnfs_file_layout
enum pnfs_status pnfs_file_layout_recall(IN struct __nfs41_client *client, IN const struct cb_layoutrecall_args *recall)
void pnfs_layout_recall_fenced(IN pnfs_layout_state *state, IN const pnfs_layout *layout)
Definition: pnfs_layout.c:1233
enum pnfs_status pnfs_write(IN struct __nfs41_root *root, IN struct __nfs41_open_state *state, IN struct __stateid_arg *stateid, IN pnfs_layout_state *layout, IN uint64_t offset, IN uint64_t length, IN unsigned char *buffer, OUT ULONG *len_out, OUT nfs41_file_info *cinfo)
__inline uint64_t stripe_unit_number(IN const pnfs_file_layout *layout, IN uint64_t offset, IN uint32_t unit_size)
Definition: pnfs.h:324
#define PNFS_DEVICEID_SIZE
Definition: pnfs.h:111
pnfs_status
Definition: pnfs.h:58
@ PNFSERR_NOT_SUPPORTED
Definition: pnfs.h:62
@ PNFSERR_IO
Definition: pnfs.h:64
@ PNFS_PENDING
Definition: pnfs.h:60
@ PNFSERR_NOT_CONNECTED
Definition: pnfs.h:63
@ PNFSERR_LAYOUT_CHANGED
Definition: pnfs.h:71
@ PNFSERR_NO_LAYOUT
Definition: pnfs.h:66
@ PNFSERR_INVALID_FH_LIST
Definition: pnfs.h:67
@ PNFSERR_RESOURCES
Definition: pnfs.h:69
@ PNFS_READ_EOF
Definition: pnfs.h:61
@ PNFSERR_NO_DEVICE
Definition: pnfs.h:65
@ PNFSERR_INVALID_DS_INDEX
Definition: pnfs.h:68
@ PNFSERR_LAYOUT_RECALLED
Definition: pnfs.h:70
@ PNFS_SUCCESS
Definition: pnfs.h:59
__inline int should_commit_to_mds(IN const pnfs_file_layout *layout)
Definition: pnfs.h:306
pnfs_device_status
Definition: pnfs.h:93
@ PNFS_DEVICE_REVOKED
Definition: pnfs.h:97
@ PNFS_DEVICE_GRANTED
Definition: pnfs.h:95
void pnfs_layout_list_free(IN struct pnfs_layout_list *layouts)
Definition: pnfs_layout.c:139
enum pnfs_status pnfs_data_server_client(IN struct __nfs41_root *root, IN pnfs_data_server *server, IN uint32_t default_lease, OUT struct __nfs41_client **client_out)
pnfs_iomode
Definition: pnfs.h:80
@ PNFS_IOMODE_ANY
Definition: pnfs.h:83
@ PNFS_IOMODE_READ
Definition: pnfs.h:81
@ PNFS_IOMODE_RW
Definition: pnfs.h:82
#define NFL4_UFLG_DENSE
Definition: pnfs.h:107
struct __pnfs_data_server pnfs_data_server
#define NFL4_UFLG_COMMIT_THRU_MDS
Definition: pnfs.h:108
pnfs_layout_type
Definition: pnfs.h:74
@ PNFS_LAYOUTTYPE_OBJECT
Definition: pnfs.h:76
@ PNFS_LAYOUTTYPE_FILE
Definition: pnfs.h:75
@ PNFS_LAYOUTTYPE_BLOCK
Definition: pnfs.h:77
enum pnfs_status pnfs_layout_state_prepare(IN pnfs_layout_state *state, IN struct __nfs41_session *session, IN nfs41_path_fh *meta_file, IN struct __stateid_arg *stateid, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length)
struct __pnfs_data_server_list pnfs_data_server_list
pnfs_return_type
Definition: pnfs.h:100
@ PNFS_RETURN_FSID
Definition: pnfs.h:102
@ PNFS_RETURN_ALL
Definition: pnfs.h:103
@ PNFS_RETURN_FILE
Definition: pnfs.h:101
void pnfs_file_device_put(IN pnfs_file_device *device)
Definition: pnfs_device.c:245
struct __pnfs_layout pnfs_layout
pnfs_layout_status
Definition: pnfs.h:86
@ PNFS_LAYOUT_NOT_RW
Definition: pnfs.h:90
@ PNFS_LAYOUT_UNAVAILABLE
Definition: pnfs.h:88
struct __pnfs_file_layout_handles pnfs_file_layout_handles
enum pnfs_status pnfs_layout_recall_status(IN const pnfs_layout_state *state, IN const pnfs_layout *layout)
Definition: pnfs_layout.c:1211
struct __pnfs_stripe_indices pnfs_stripe_indices
enum pnfs_status pnfs_layout_state_open(IN struct __nfs41_open_state *state, OUT pnfs_layout_state **layout_out)
struct __pnfs_device pnfs_device
enum pnfs_status pnfs_read(IN struct __nfs41_root *root, IN struct __nfs41_open_state *state, IN struct __stateid_arg *stateid, IN pnfs_layout_state *layout, IN uint64_t offset, IN uint64_t length, OUT unsigned char *buffer_out, OUT ULONG *len_out)
void pnfs_file_device_list_invalidate(IN struct pnfs_file_device_list *devices)
Definition: pnfs_device.c:159
void pnfs_file_device_list_free(IN struct pnfs_file_device_list *devices)
Definition: pnfs_device.c:144
struct __pnfs_layout_state pnfs_layout_state
static FILE * client
Definition: client.c:41
pnfs_data_server * arr
Definition: pnfs.h:136
SRWLOCK lock
Definition: pnfs.h:131
multi_addr4 addrs
Definition: pnfs.h:130
struct __nfs41_client * client
Definition: pnfs.h:129
CRITICAL_SECTION lock
Definition: pnfs.h:120
uint32_t layout_count
Definition: pnfs.h:119
enum pnfs_layout_type type
Definition: pnfs.h:117
enum pnfs_device_status status
Definition: pnfs.h:118
unsigned char deviceid[PNFS_DEVICEID_SIZE]
Definition: pnfs.h:116
struct pnfs_file_device_list * devices
Definition: pnfs.h:143
pnfs_stripe_indices stripes
Definition: pnfs.h:141
pnfs_device device
Definition: pnfs.h:140
pnfs_data_server_list servers
Definition: pnfs.h:142
struct list_entry entry
Definition: pnfs.h:144
nfs41_path_fh * arr
Definition: pnfs.h:174
uint32_t first_index
Definition: pnfs.h:183
pnfs_file_device * device
Definition: pnfs.h:181
pnfs_layout layout
Definition: pnfs.h:178
uint32_t util
Definition: pnfs.h:184
uint64_t pattern_offset
Definition: pnfs.h:182
unsigned char deviceid[PNFS_DEVICEID_SIZE]
Definition: pnfs.h:180
pnfs_file_layout_handles filehandles
Definition: pnfs.h:179
bool_t pending
Definition: pnfs.h:159
stateid4 stateid
Definition: pnfs.h:151
SRWLOCK lock
Definition: pnfs.h:160
enum pnfs_layout_status status
Definition: pnfs.h:155
struct list_entry entry
Definition: pnfs.h:152
bool_t return_on_close
Definition: pnfs.h:156
nfs41_fh meta_fh
Definition: pnfs.h:150
struct list_entry recalls
Definition: pnfs.h:154
CONDITION_VARIABLE cond
Definition: pnfs.h:161
struct list_entry layouts
Definition: pnfs.h:153
uint32_t io_count
Definition: pnfs.h:158
uint64_t offset
Definition: pnfs.h:166
enum pnfs_layout_type type
Definition: pnfs.h:169
enum pnfs_iomode iomode
Definition: pnfs.h:168
uint64_t length
Definition: pnfs.h:167
struct list_entry entry
Definition: pnfs.h:165
uint32_t count
Definition: pnfs.h:124
uint32_t * arr
Definition: pnfs.h:125
struct cb_recall recall
enum pnfs_iomode iomode
Definition: devices.h:37
Definition: list.h:27
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define FORCEINLINE
Definition: wdftypes.h:67