ReactOS  0.4.12-dev-75-g00dd17e
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 */
50 struct __nfs41_client;
51 struct __nfs41_session;
52 struct __nfs41_open_state;
53 struct __nfs41_root;
54 struct __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 
104 };
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 */
115 typedef struct __pnfs_device {
116  unsigned char deviceid[PNFS_DEVICEID_SIZE];
119  uint32_t layout_count; /* layouts using this device */
121 } pnfs_device;
122 
123 typedef struct __pnfs_stripe_indices {
127 
128 typedef struct __pnfs_data_server {
131  SRWLOCK lock;
133 
134 typedef struct __pnfs_data_server_list {
138 
139 typedef 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 */
149 typedef 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 
164 typedef struct __pnfs_layout {
168  enum pnfs_iomode iomode;
170 } pnfs_layout;
171 
176 
177 typedef struct __pnfs_file_layout {
180  unsigned char deviceid[PNFS_DEVICEID_SIZE];
186 
187 
188 /* pnfs_layout.c */
189 struct pnfs_layout_list;
190 struct cb_layoutrecall_args;
191 
193  OUT struct pnfs_layout_list **layouts_out);
194 
196  IN struct pnfs_layout_list *layouts);
197 
199  IN struct __nfs41_open_state *state,
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,
210  IN uint64_t length);
211 
213  IN struct __nfs41_session *session,
214  IN struct __nfs41_open_state *state,
215  IN bool_t remove);
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 */
223  IN const pnfs_layout_state *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 */
239 struct pnfs_file_device_list;
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 
259 struct 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,
275  IN struct __nfs41_open_state *state,
276  IN struct __stateid_arg *stateid,
280  OUT unsigned char *buffer_out,
281  OUT ULONG *len_out);
282 
284  IN struct __nfs41_root *root,
285  IN struct __nfs41_open_state *state,
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
301  IN const pnfs_file_layout *layout)
302 {
303  return (layout->util & NFL4_UFLG_DENSE) != 0;
304 }
305 #ifndef __REACTOS__
306 __inline int should_commit_to_mds(
307 #else
309 #endif
310  IN const pnfs_file_layout *layout)
311 {
312  return (layout->util & NFL4_UFLG_COMMIT_THRU_MDS) != 0;
313 }
314 #ifndef __REACTOS__
316 #else
318 #endif
319  IN const pnfs_file_layout *layout)
320 {
321  return layout->util & NFL4_UFLG_STRIPE_UNIT_SIZE_MASK;
322 }
323 #ifndef __REACTOS__
325 #else
327 #endif
328  IN const pnfs_file_layout *layout,
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
340  IN const pnfs_file_layout *layout,
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
351  IN const pnfs_file_layout *layout,
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
362  IN const pnfs_file_device *device,
363  IN uint32_t stripeid)
364 {
365  return device->stripes.arr[stripeid];
366 }
367 
368 #endif /* !__PNFS_H__ */
pnfs_status
Definition: pnfs.h:58
struct __pnfs_file_layout_handles pnfs_file_layout_handles
struct cb_recall recall
CONDITION_VARIABLE cond
Definition: pnfs.h:161
#define IN
Definition: typedefs.h:38
struct __pnfs_stripe_indices pnfs_stripe_indices
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define NFL4_UFLG_COMMIT_THRU_MDS
Definition: pnfs.h:108
pnfs_device_status
Definition: pnfs.h:93
uint32_t layout_count
Definition: pnfs.h:119
__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
int32_t bool_t
Definition: types.h:101
void pnfs_layout_state_close(IN struct __nfs41_session *session, IN struct __nfs41_open_state *state, IN bool_t remove)
uint64_t offset
Definition: pnfs.h:166
enum pnfs_status pnfs_file_device_list_create(OUT struct pnfs_file_device_list **devices_out)
Definition: pnfs_device.c:124
__inline uint32_t stripe_index(IN const pnfs_file_layout *layout, IN uint64_t sui, IN uint32_t stripe_count)
Definition: pnfs.h:347
const char * devices
Definition: diskspace.c:793
uint8_t entry
Definition: isohybrid.c:63
nfs41_path_fh * arr
Definition: pnfs.h:174
__inline uint32_t layout_unit_size(IN const pnfs_file_layout *layout)
Definition: pnfs.h:315
pnfs_file_layout_handles filehandles
Definition: pnfs.h:179
GLintptr offset
Definition: glext.h:5920
struct __nfs41_client * client
Definition: pnfs.h:129
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)
unsigned char deviceid[PNFS_DEVICEID_SIZE]
Definition: pnfs.h:116
struct __pnfs_data_server pnfs_data_server
#define PNFS_DEVICEID_SIZE
Definition: pnfs.h:111
pnfs_file_device * device
Definition: pnfs.h:181
GLuint buffer
Definition: glext.h:5915
uint32_t first_index
Definition: pnfs.h:183
CRITICAL_SECTION lock
Definition: pnfs.h:120
uint32_t count
Definition: pnfs.h:124
void pnfs_file_device_list_invalidate(IN struct pnfs_file_device_list *devices)
Definition: pnfs_device.c:159
struct __pnfs_file_device pnfs_file_device
__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
pnfs_stripe_indices stripes
Definition: pnfs.h:141
#define NFL4_UFLG_DENSE
Definition: pnfs.h:107
long LONG
Definition: pedump.c:60
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)
Definition: devices.h:39
enum pnfs_status pnfs_layout_state_open(IN struct __nfs41_open_state *state, OUT pnfs_layout_state **layout_out)
uint32_t io_count
Definition: pnfs.h:158
pnfs_data_server_list servers
Definition: pnfs.h:142
void pnfs_layout_io_finished(IN pnfs_layout_state *state)
Definition: pnfs_layout.c:1267
#define FORCEINLINE
Definition: ntbasedef.h:221
#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK
Definition: pnfs.h:109
uint64_t pattern_offset
Definition: pnfs.h:182
pnfs_data_server * arr
Definition: pnfs.h:136
multi_addr4 addrs
Definition: pnfs.h:130
struct __pnfs_data_server_list pnfs_data_server_list
pnfs_device device
Definition: pnfs.h:140
__inline int should_commit_to_mds(IN const pnfs_file_layout *layout)
Definition: pnfs.h:306
bool_t return_on_close
Definition: pnfs.h:156
notify_deviceid_type4
uint64_t length
Definition: pnfs.h:167
pnfs_return_type
Definition: pnfs.h:100
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
void pnfs_file_device_list_free(IN struct pnfs_file_device_list *devices)
Definition: pnfs_device.c:144
pnfs_layout_type
Definition: pnfs.h:74
static FILE * client
Definition: client.c:41
bool_t pending
Definition: pnfs.h:159
void pnfs_layout_io_start(IN pnfs_layout_state *state)
Definition: pnfs_layout.c:1257
uint32_t * arr
Definition: pnfs.h:125
uint32_t util
Definition: pnfs.h:184
SRWLOCK lock
Definition: pnfs.h:131
enum pnfs_layout_type type
Definition: pnfs.h:117
enum pnfs_status pnfs_layout_list_create(OUT struct pnfs_layout_list **layouts_out)
Definition: pnfs_layout.c:121
void pnfs_layout_recall_fenced(IN pnfs_layout_state *state, IN const pnfs_layout *layout)
Definition: pnfs_layout.c:1233
static int state
Definition: maze.c:121
static DWORD layout
Definition: bitmap.c:46
void pnfs_layout_list_free(IN struct pnfs_layout_list *layouts)
Definition: pnfs_layout.c:139
struct __pnfs_layout pnfs_layout
nfs41_fh meta_fh
Definition: pnfs.h:150
stateid4 stateid
Definition: pnfs.h:151
enum pnfs_iomode iomode
UINT64 uint64_t
Definition: types.h:77
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)
Definition: list.h:27
UINT32 uint32_t
Definition: types.h:75
pnfs_layout layout
Definition: pnfs.h:178
enum pnfs_device_status status
Definition: pnfs.h:118
#define OUT
Definition: typedefs.h:39
SRWLOCK lock
Definition: pnfs.h:160
unsigned int ULONG
Definition: retypes.h:1
struct __pnfs_layout_state pnfs_layout_state
struct __pnfs_device pnfs_device
pnfs_iomode
Definition: pnfs.h:80
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)
enum pnfs_status pnfs_file_layout_recall(IN struct __nfs41_client *client, IN const struct cb_layoutrecall_args *recall)
pnfs_layout_status
Definition: pnfs.h:86
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
struct pnfs_file_device_list * devices
Definition: pnfs.h:143
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)
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_file_layout pnfs_file_layout
__inline int is_dense(IN const pnfs_file_layout *layout)
Definition: pnfs.h:297
__inline uint32_t data_server_index(IN const pnfs_file_device *device, IN uint32_t stripeid)
Definition: pnfs.h:358
void pnfs_file_device_put(IN pnfs_file_device *device)
Definition: pnfs_device.c:245