ReactOS  0.4.12-dev-36-g472787f
nfs41.h File Reference
#include "util.h"
#include "list.h"
Include dependency graph for nfs41.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  __nfs41_superblock
 
struct  __nfs41_superblock_list
 
struct  server_addrs
 
struct  __nfs41_server
 
struct  __nfs41_delegation_state
 
struct  __nfs41_lock_state
 
struct  __nfs41_open_state
 
struct  __nfs41_rpc_clnt
 
struct  client_state
 
struct  __nfs41_client
 
struct  __nfs41_slot_table
 
struct  __nfs41_channel_attrs
 
struct  replay_cache
 
struct  __nfs41_cb_session
 
struct  __nfs41_session
 
struct  __nfs41_root
 

Macros

#define NFS41_MAX_NUM_SLOTS   NFS41_MAX_RPC_REQS
 

Typedefs

typedef struct __nfs41_superblock nfs41_superblock
 
typedef struct __nfs41_superblock_list nfs41_superblock_list
 
typedef struct __nfs41_server nfs41_server
 
typedef struct __nfs41_delegation_state nfs41_delegation_state
 
typedef struct __nfs41_lock_state nfs41_lock_state
 
typedef struct __nfs41_open_state nfs41_open_state
 
typedef struct __nfs41_rpc_clnt nfs41_rpc_clnt
 
typedef struct __nfs41_client nfs41_client
 
typedef struct __nfs41_slot_table nfs41_slot_table
 
typedef struct __nfs41_channel_attrs nfs41_channel_attrs
 
typedef struct __nfs41_cb_session nfs41_cb_session
 
typedef struct __nfs41_session nfs41_session
 
typedef struct __nfs41_root nfs41_root
 

Enumerations

enum  delegation_status { DELEGATION_GRANTED, DELEGATION_RETURNING, DELEGATION_RETURNED }
 

Functions

int nfs41_root_create (IN const char *name, IN uint32_t sec_flavor, IN uint32_t wsize, IN uint32_t rsize, OUT nfs41_root **root_out)
 
void nfs41_root_ref (IN nfs41_root *root)
 
void nfs41_root_deref (IN nfs41_root *root)
 
int nfs41_root_mount_addrs (IN nfs41_root *root, IN const multi_addr4 *addrs, IN bool_t is_data, IN OPTIONAL uint32_t lease_time, OUT nfs41_client **client_out)
 
int nfs41_root_mount_server (IN nfs41_root *root, IN nfs41_server *server, IN bool_t is_data, IN OPTIONAL uint32_t lease_time, OUT nfs41_client **client_out)
 
int nfs41_root_mount_referral (IN nfs41_root *root, IN const fs_locations4 *locations, OUT const fs_location4 **loc_out, OUT nfs41_client **client_out)
 
static __inline nfs41_sessionnfs41_root_session (IN nfs41_root *root)
 
int nfs41_session_create (IN nfs41_client *client, IN nfs41_session **session_out)
 
int nfs41_session_renew (IN nfs41_session *session)
 
int nfs41_session_set_lease (IN nfs41_session *session, IN uint32_t lease_time)
 
void nfs41_session_free (IN nfs41_session *session)
 
void nfs41_session_bump_seq (IN nfs41_session *session, IN uint32_t slotid, IN uint32_t target_highest_slotid)
 
void nfs41_session_free_slot (IN nfs41_session *session, IN uint32_t slotid)
 
void nfs41_session_get_slot (IN nfs41_session *session, OUT uint32_t *slot, OUT uint32_t *seq, OUT uint32_t *highest)
 
int nfs41_session_recall_slot (IN nfs41_session *session, IN OUT uint32_t target_highest_slotid)
 
void nfs41_session_sequence (struct __nfs41_sequence_args *args, nfs41_session *session, bool_t cachethis)
 
int nfs41_session_bad_slot (IN nfs41_session *session, IN OUT struct __nfs41_sequence_args *args)
 
void nfs41_server_list_init ()
 
int nfs41_server_resolve (IN const char *hostname, IN unsigned short port, OUT multi_addr4 *addrs)
 
int nfs41_server_find_or_create (IN const char *server_owner_major_id, IN const char *server_scope, IN const netaddr4 *addr, OUT nfs41_server **server_out)
 
void nfs41_server_ref (IN nfs41_server *server)
 
void nfs41_server_deref (IN nfs41_server *server)
 
void nfs41_server_addrs (IN nfs41_server *server, OUT multi_addr4 *addrs)
 
int nfs41_client_owner (IN const char *name, IN uint32_t sec_flavor, OUT client_owner4 *owner)
 
uint32_t nfs41_exchange_id_flags (IN bool_t is_data)
 
int nfs41_client_create (IN nfs41_rpc_clnt *rpc, IN const client_owner4 *owner, IN bool_t is_data, IN const struct __nfs41_exchange_id_res *exchangeid, OUT nfs41_client **client_out)
 
int nfs41_client_renew (IN nfs41_client *client)
 
void nfs41_client_free (IN nfs41_client *client)
 
static __inline nfs41_serverclient_server (IN nfs41_client *client)
 
int nfs41_superblock_for_fh (IN nfs41_session *session, IN const nfs41_fsid *fsid, IN const nfs41_fh *parent OPTIONAL, OUT nfs41_path_fh *file)
 
static __inline void nfs41_superblock_getattr_mask (IN const nfs41_superblock *superblock, OUT bitmap4 *attrs)
 
static __inline void nfs41_superblock_supported_attrs (IN const nfs41_superblock *superblock, IN OUT bitmap4 *attrs)
 
static __inline void nfs41_superblock_supported_attrs_exclcreat (IN const nfs41_superblock *superblock, IN OUT bitmap4 *attrs)
 
void nfs41_superblock_fs_attributes (IN const nfs41_superblock *superblock, OUT struct _FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs)
 
void nfs41_superblock_space_changed (IN nfs41_superblock *superblock)
 
void nfs41_superblock_list_init (IN nfs41_superblock_list *superblocks)
 
void nfs41_superblock_list_free (IN nfs41_superblock_list *superblocks)
 
int nfs41_rpc_clnt_create (IN const multi_addr4 *addrs, IN uint32_t wsize, IN uint32_t rsize, IN uint32_t uid, IN uint32_t gid, IN uint32_t sec_flavor, OUT nfs41_rpc_clnt **rpc_out)
 
void nfs41_rpc_clnt_free (IN nfs41_rpc_clnt *rpc)
 
int nfs41_send_compound (IN nfs41_rpc_clnt *rpc, IN char *inbuf, OUT char *outbuf)
 
static __inline netaddr4nfs41_rpc_netaddr (IN nfs41_rpc_clnt *rpc)
 
void nfs41_open_state_ref (IN nfs41_open_state *state)
 
void nfs41_open_state_deref (IN nfs41_open_state *state)
 
void nfs41_open_stateid_arg (IN nfs41_open_state *state, OUT struct __stateid_arg *arg)
 
int nfs41_ea_set (IN nfs41_open_state *state, IN struct _FILE_FULL_EA_INFORMATION *ea)
 

Macro Definition Documentation

◆ NFS41_MAX_NUM_SLOTS

#define NFS41_MAX_NUM_SLOTS   NFS41_MAX_RPC_REQS

Definition at line 218 of file nfs41.h.

Referenced by init_slot_table(), nfs41_session_bump_seq(), and resize_slot_table().

Typedef Documentation

◆ nfs41_cb_session

◆ nfs41_channel_attrs

◆ nfs41_client

◆ nfs41_delegation_state

◆ nfs41_lock_state

◆ nfs41_open_state

◆ nfs41_root

◆ nfs41_rpc_clnt

◆ nfs41_server

◆ nfs41_session

◆ nfs41_slot_table

◆ nfs41_superblock

◆ nfs41_superblock_list

Enumeration Type Documentation

◆ delegation_status

Enumerator
DELEGATION_GRANTED 
DELEGATION_RETURNING 
DELEGATION_RETURNED 

Definition at line 89 of file nfs41.h.

Function Documentation

◆ client_server()

static __inline nfs41_server* client_server ( IN nfs41_client client)
static

Definition at line 428 of file nfs41.h.

Referenced by client_name_cache(), and nfs41_superblock_for_fh().

430 {
431  /* the client's server could change during nfs41_client_renew(),
432  * so access to client->server must be protected */
434  AcquireSRWLockShared(&client->exid_lock);
435  server = client->server;
436  ReleaseSRWLockShared(&client->exid_lock);
437  return server;
438 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
static FILE * client
Definition: client.c:41
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_client_create()

int nfs41_client_create ( IN nfs41_rpc_clnt rpc,
IN const client_owner4 owner,
IN bool_t  is_data,
IN const struct __nfs41_exchange_id_res exchangeid,
OUT nfs41_client **  client_out 
)

◆ nfs41_client_free()

void nfs41_client_free ( IN nfs41_client client)

Definition at line 206 of file nfs41_client.c.

Referenced by nfs41_client_create(), nfs41_root_mount_addrs(), nfs41_root_session(), root_client_create(), and root_free().

208 {
209  dprintf(2, "nfs41_client_free(%llu)\n", client->clnt_id);
211  if (client->session) nfs41_session_free(client->session);
212  nfs41_destroy_clientid(client->rpc, client->clnt_id);
213  if (client->server) nfs41_server_deref(client->server);
215  if (client->layouts) pnfs_layout_list_free(client->layouts);
216  if (client->devices) pnfs_file_device_list_free(client->devices);
217  DeleteCriticalSection(&client->state.lock);
218  DeleteCriticalSection(&client->recovery.lock);
219  free(client);
220 }
int nfs41_destroy_clientid(IN nfs41_rpc_clnt *rpc, IN uint64_t clientid)
Definition: nfs41_ops.c:242
#define free
Definition: debug_ros.c:5
void nfs41_client_delegation_free(IN nfs41_client *client)
Definition: delegation.c:828
void nfs41_rpc_clnt_free(IN nfs41_rpc_clnt *rpc)
Definition: nfs41_rpc.c:243
#define dprintf
Definition: regdump.c:33
void nfs41_session_free(IN nfs41_session *session)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
void pnfs_file_device_list_free(IN struct pnfs_file_device_list *devices)
Definition: pnfs_device.c:144
static FILE * client
Definition: client.c:41
void pnfs_layout_list_free(IN struct pnfs_layout_list *layouts)
Definition: pnfs_layout.c:139
void nfs41_server_deref(IN nfs41_server *server)
Definition: nfs41_server.c:155

◆ nfs41_client_owner()

int nfs41_client_owner ( IN const char name,
IN uint32_t  sec_flavor,
OUT client_owner4 owner 
)

Definition at line 358 of file nfs41_client.c.

Referenced by nfs41_root_create(), and nfs41_root_session().

362 {
365  PBYTE buffer;
366  DWORD length;
367  const ULONGLONG time_created = GetTickCount64();
368  int status;
369  char username[UNLEN + 1];
370  DWORD len = UNLEN + 1;
371 
372  if (!GetUserNameA(username, &len)) {
373  status = GetLastError();
374  eprintf("GetUserName() failed with %d\n", status);
375  goto out;
376  }
377 
378  /* owner.verifier = "time created" */
379  memcpy(owner->co_verifier, &time_created, sizeof(time_created));
380 
381  /* set up the md5 hash generator */
382  if (!CryptAcquireContext(&context, NULL, NULL,
384  status = GetLastError();
385  eprintf("CryptAcquireContext() failed with %d\n", status);
386  goto out;
387  }
388  if (!CryptCreateHash(context, CALG_MD5, 0, 0, &hash)) {
389  status = GetLastError();
390  eprintf("CryptCreateHash() failed with %d\n", status);
391  goto out_context;
392  }
393 
394  if (!CryptHashData(hash, (const BYTE*)&sec_flavor, (DWORD)sizeof(sec_flavor), 0)) {
395  status = GetLastError();
396  eprintf("CryptHashData() failed with %d\n", status);
397  goto out_hash;
398  }
399 
400  if (!CryptHashData(hash, (const BYTE*)username, (DWORD)strlen(username), 0)) {
401  status = GetLastError();
402  eprintf("CryptHashData() failed with %d\n", status);
403  goto out_hash;
404  }
405 
406  if (!CryptHashData(hash, (const BYTE*)name, (DWORD)strlen(name), 0)) {
407  status = GetLastError();
408  eprintf("CryptHashData() failed with %d\n", status);
409  goto out_hash;
410  }
411 
412  /* add the mac address from each applicable adapter to the hash */
413  status = hash_mac_addrs(hash);
414  if (status) {
415  eprintf("hash_mac_addrs() failed with %d\n", status);
416  goto out_hash;
417  }
418 
419  /* extract the hash size (should always be 16 for md5) */
420  buffer = (PBYTE)&owner->co_ownerid_len;
421  length = (DWORD)sizeof(DWORD);
422  if (!CryptGetHashParam(hash, HP_HASHSIZE, buffer, &length, 0)) {
423  status = GetLastError();
424  eprintf("CryptGetHashParam(size) failed with %d\n", status);
425  goto out_hash;
426  }
427  /* extract the hash buffer */
428  buffer = owner->co_ownerid;
429  length = owner->co_ownerid_len;
430  if (!CryptGetHashParam(hash, HP_HASHVAL, buffer, &length, 0)) {
431  status = GetLastError();
432  eprintf("CryptGetHashParam(val) failed with %d\n", status);
433  goto out_hash;
434  }
435 
436 out_hash:
437  CryptDestroyHash(hash);
438 out_context:
439  CryptReleaseContext(context, 0);
440 out:
441  return status;
442 }
static DWORD hash_mac_addrs(IN HCRYPTHASH hash)
Definition: nfs41_client.c:296
Definition: http.c:6587
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define DWORD
Definition: msvc.h:34
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
GLuint buffer
Definition: glext.h:5915
#define CryptAcquireContext
Definition: wincrypt.h:4162
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
#define HP_HASHSIZE
Definition: wincrypt.h:2184
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1615
int hash
Definition: main.c:58
smooth NULL
Definition: ftsmooth.c:416
static WCHAR username[]
Definition: url.c:32
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
uint64_t ULONGLONG
Definition: typedefs.h:65
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:895
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
BOOL WINAPI GetUserNameA(LPSTR lpszName, LPDWORD lpSize)
Definition: misc.c:246
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:745
#define CALG_MD5
Definition: wincrypt.h:1805
unsigned char BYTE
Definition: ntddk_ex.h:96
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2069
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:50
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
#define UNLEN
Definition: sspi.c:28
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1776
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, ULONG_PTR dwFlags)
Definition: crypt.c:651
Definition: name.c:36
sec_flavor
Definition: nfs41_ops.h:861
#define HP_HASHVAL
Definition: wincrypt.h:2183
static SERVICE_STATUS status
Definition: service.c:31
BYTE * PBYTE
Definition: pedump.c:66
#define PROV_RSA_FULL
Definition: wincrypt.h:2039

◆ nfs41_client_renew()

int nfs41_client_renew ( IN nfs41_client client)

Definition at line 168 of file nfs41_client.c.

Referenced by compound_encode_send_decode(), nfs41_recover_session(), and nfs41_root_session().

170 {
171  nfs41_exchange_id_res exchangeid = { 0 };
172  int status;
173 
174  status = nfs41_exchange_id(client->rpc, &client->owner,
175  nfs41_exchange_id_flags(client->is_data), &exchangeid);
176  if (status) {
177  eprintf("nfs41_exchange_id() failed with %d\n", status);
178  status = ERROR_BAD_NET_RESP;
179  goto out;
180  }
181 
182  if (client->is_data) { /* require USE_PNFS_DS */
183  if ((exchangeid.flags & EXCHGID4_FLAG_USE_PNFS_DS) == 0) {
184  eprintf("client expected USE_PNFS_DS\n");
185  status = ERROR_BAD_NET_RESP;
186  goto out;
187  }
188  } else { /* require USE_NON_PNFS or USE_PNFS_MDS */
189  if ((exchangeid.flags & EXCHGID4_FLAG_USE_NON_PNFS) == 0 &&
190  (exchangeid.flags & EXCHGID4_FLAG_USE_PNFS_MDS) == 0) {
191  eprintf("client expected USE_NON_PNFS OR USE_PNFS_MDS\n");
192  status = ERROR_BAD_NET_RESP;
193  goto out;
194  }
195  }
196 
197  dprint_roles(2, exchangeid.flags);
198 
199  AcquireSRWLockExclusive(&client->exid_lock);
200  status = update_exchangeid_res(client, &exchangeid);
201  ReleaseSRWLockExclusive(&client->exid_lock);
202 out:
203  return status;
204 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
uint32_t nfs41_exchange_id_flags(IN bool_t is_data)
Definition: nfs41_client.c:36
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define ERROR_BAD_NET_RESP
Definition: winerror.h:150
static FILE * client
Definition: client.c:41
static FILE * out
Definition: regtests2xml.c:44
int nfs41_exchange_id(IN nfs41_rpc_clnt *rpc, IN client_owner4 *owner, IN uint32_t flags_in, OUT nfs41_exchange_id_res *res_out)
Definition: nfs41_ops.c:36
static void dprint_roles(IN int level, IN uint32_t roles)
Definition: nfs41_client.c:158
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
static SERVICE_STATUS status
Definition: service.c:31
static int update_exchangeid_res(IN nfs41_client *client, IN const nfs41_exchange_id_res *exchangeid)
Definition: nfs41_client.c:97

◆ nfs41_ea_set()

int nfs41_ea_set ( IN nfs41_open_state state,
IN struct _FILE_FULL_EA_INFORMATION ea 
)

Referenced by nfs41_rpc_netaddr().

◆ nfs41_exchange_id_flags()

◆ nfs41_open_state_deref()

void nfs41_open_state_deref ( IN nfs41_open_state state)

Definition at line 104 of file open.c.

Referenced by cancel_open(), cleanup_close(), delegation_return(), handle_open(), nfs41_rpc_netaddr(), and upcall_cleanup().

106 {
107  const LONG count = InterlockedDecrement(&state->ref_count);
108 
109  dprintf(2, "nfs41_open_state_deref(%s) count %d\n", state->path.path, count);
110  if (count == 0)
112 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
static void open_state_free(IN nfs41_open_state *state)
Definition: open.c:79
long LONG
Definition: pedump.c:60
#define dprintf
Definition: regdump.c:33
#define InterlockedDecrement
Definition: armddk.h:52
static int state
Definition: maze.c:121

◆ nfs41_open_state_ref()

void nfs41_open_state_ref ( IN nfs41_open_state state)

Definition at line 96 of file open.c.

Referenced by deleg_open_find(), handle_open(), nfs41_rpc_netaddr(), and upcall_parse().

98 {
99  const LONG count = InterlockedIncrement(&state->ref_count);
100 
101  dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
102 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
long LONG
Definition: pedump.c:60
#define dprintf
Definition: regdump.c:33
static int state
Definition: maze.c:121
#define InterlockedIncrement
Definition: armddk.h:53

◆ nfs41_open_stateid_arg()

◆ nfs41_root_create()

int nfs41_root_create ( IN const char name,
IN uint32_t  sec_flavor,
IN uint32_t  wsize,
IN uint32_t  rsize,
OUT nfs41_root **  root_out 
)

Definition at line 37 of file namespace.c.

Referenced by handle_mount().

43 {
44  int status = NO_ERROR;
46 
47  dprintf(NSLVL, "--> nfs41_root_create()\n");
48 
49  root = calloc(1, sizeof(nfs41_root));
50  if (root == NULL) {
51  status = GetLastError();
52  goto out;
53  }
54 
55  list_init(&root->clients);
56  root->wsize = wsize;
57  root->rsize = rsize;
59  root->ref_count = 1;
60  root->sec_flavor = sec_flavor;
61 
62  /* generate a unique client_owner */
64  if (status) {
65  eprintf("nfs41_client_owner() failed with %d\n", status);
66  free(root);
67  goto out;
68  }
69 
70  *root_out = root;
71 out:
72  dprintf(NSLVL, "<-- nfs41_root_create() returning %d\n", status);
73  return status;
74 }
uint32_t wsize
Definition: nfs41.h:278
#define free
Definition: debug_ros.c:5
struct _root root
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define NO_ERROR
Definition: dderror.h:5
client_owner4 client_owner
Definition: nfs41.h:275
#define dprintf
Definition: regdump.c:33
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int nfs41_client_owner(IN const char *name, IN uint32_t sec_flavor, OUT client_owner4 *owner)
Definition: nfs41_client.c:358
Definition: name.c:36
#define calloc
Definition: rosglue.h:14
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
DWORD sec_flavor
Definition: nfs41.h:283
sec_flavor
Definition: nfs41_ops.h:861
LONG ref_count
Definition: nfs41.h:280
struct list_entry clients
Definition: nfs41.h:277
CRITICAL_SECTION lock
Definition: nfs41.h:276
static SERVICE_STATUS status
Definition: service.c:31
uint32_t rsize
Definition: nfs41.h:279
#define NSLVL
Definition: namespace.c:30
Definition: ps.c:97

◆ nfs41_root_deref()

void nfs41_root_deref ( IN nfs41_root root)

Definition at line 100 of file namespace.c.

Referenced by cancel_mount(), delegation_recall_thread(), handle_mount(), handle_unmount(), nfs41_delegation_recall(), and upcall_cleanup().

102 {
103  const LONG count = InterlockedDecrement(&root->ref_count);
104 
105  dprintf(NSLVL, "nfs41_root_deref() count %d\n", count);
106  if (count == 0)
107  root_free(root);
108 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
static void root_free(IN nfs41_root *root)
Definition: namespace.c:76
long LONG
Definition: pedump.c:60
#define dprintf
Definition: regdump.c:33
#define InterlockedDecrement
Definition: armddk.h:52
#define NSLVL
Definition: namespace.c:30

◆ nfs41_root_mount_addrs()

int nfs41_root_mount_addrs ( IN nfs41_root root,
IN const multi_addr4 addrs,
IN bool_t  is_data,
IN OPTIONAL uint32_t  lease_time,
OUT nfs41_client **  client_out 
)

Definition at line 335 of file namespace.c.

Referenced by handle_mount(), pnfs_data_server_client(), and referral_mount_location().

341 {
342  nfs41_exchange_id_res exchangeid = { 0 };
343  nfs41_rpc_clnt *rpc;
344  nfs41_client *client, *existing;
345  int status;
346 
347  dprintf(NSLVL, "--> nfs41_root_mount_addrs()\n");
348 
349  /* look for an existing client that matches the address and role */
350  EnterCriticalSection(&root->lock);
351  status = root_client_find_addrs(root, addrs, is_data, &client);
352  LeaveCriticalSection(&root->lock);
353 
354  if (status == NO_ERROR)
355  goto out;
356 
357  /* create an rpc client */
358  status = nfs41_rpc_clnt_create(addrs, root->wsize, root->rsize,
359  root->uid, root->gid, root->sec_flavor, &rpc);
360  if (status) {
361  eprintf("nfs41_rpc_clnt_create() failed %d\n", status);
362  goto out;
363  }
364 
365  /* get a clientid with exchangeid */
366  status = nfs41_exchange_id(rpc, &root->client_owner,
367  nfs41_exchange_id_flags(is_data), &exchangeid);
368  if (status) {
369  eprintf("nfs41_exchange_id() failed %s\n", nfs_error_string(status));
370  status = ERROR_BAD_NET_RESP;
371  goto out_free_rpc;
372  }
373 
374  /* attempt to match existing clients by the exchangeid response */
375  EnterCriticalSection(&root->lock);
376  status = root_client_find(root, &exchangeid, is_data, &client);
377  LeaveCriticalSection(&root->lock);
378 
379  if (status == NO_ERROR)
380  goto out_free_rpc;
381 
382  /* create a client for this clientid */
383  status = root_client_create(root, rpc, is_data,
384  lease_time, &exchangeid, &client);
385  if (status) {
386  eprintf("nfs41_client_create() failed %d\n", status);
387  /* root_client_create takes care of cleaning up
388  * thus don't go to out_free_rpc */
389  goto out;
390  }
391 
392  /* because we don't hold the root's lock over session creation,
393  * we could end up creating multiple clients with the same
394  * server and roles */
395  EnterCriticalSection(&root->lock);
396  status = root_client_find(root, &exchangeid, is_data, &existing);
397 
398  if (status) {
399  dprintf(NSLVL, "caching new client 0x%p\n", client);
400 
401  /* the client is not a duplicate, so add it to the list */
402  list_add_tail(&root->clients, &client->root_entry);
403  status = NO_ERROR;
404  } else {
405  dprintf(NSLVL, "created a duplicate client 0x%p! using "
406  "existing client 0x%p instead\n", client, existing);
407 
408  /* a matching client has been created in parallel, so free
409  * the one we created and use the existing client instead */
410  nfs41_client_free(client);
411  client = existing;
412  }
413  LeaveCriticalSection(&root->lock);
414 
415 out:
416  if (status == NO_ERROR)
417  *client_out = client;
418  dprintf(NSLVL, "<-- nfs41_root_mount_addrs() returning %d\n", status);
419  return status;
420 
421 out_free_rpc:
422  nfs41_rpc_clnt_free(rpc);
423  goto out;
424 }
void nfs41_client_free(IN nfs41_client *client)
Definition: nfs41_client.c:206
int nfs41_rpc_clnt_create(IN const multi_addr4 *addrs, IN uint32_t wsize, IN uint32_t rsize, IN uint32_t uid, IN uint32_t gid, IN uint32_t sec_flavor, OUT nfs41_rpc_clnt **rpc_out)
Definition: nfs41_rpc.c:145
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
void nfs41_rpc_clnt_free(IN nfs41_rpc_clnt *rpc)
Definition: nfs41_rpc.c:243
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define NO_ERROR
Definition: dderror.h:5
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define ERROR_BAD_NET_RESP
Definition: winerror.h:150
#define dprintf
Definition: regdump.c:33
static int root_client_create(IN nfs41_root *root, IN nfs41_rpc_clnt *rpc, IN bool_t is_data, IN OPTIONAL uint32_t lease_time, IN const nfs41_exchange_id_res *exchangeid, OUT nfs41_client **client_out)
Definition: namespace.c:281
uint32_t nfs41_exchange_id_flags(IN bool_t is_data)
Definition: nfs41_client.c:36
struct list_entry root_entry
Definition: nfs41.h:205
static int root_client_find(IN nfs41_root *root, IN const nfs41_exchange_id_res *exchangeid, IN bool_t is_data, OUT nfs41_client **client_out)
Definition: namespace.c:207
static FILE * client
Definition: client.c:41
static FILE * out
Definition: regtests2xml.c:44
const char * nfs_error_string(int status)
Definition: daemon_debug.c:370
int nfs41_exchange_id(IN nfs41_rpc_clnt *rpc, IN client_owner4 *owner, IN uint32_t flags_in, OUT nfs41_exchange_id_res *res_out)
Definition: nfs41_ops.c:36
static int root_client_find_addrs(IN nfs41_root *root, IN const multi_addr4 *addrs, IN bool_t is_data, OUT nfs41_client **client_out)
Definition: namespace.c:141
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static SERVICE_STATUS status
Definition: service.c:31
#define NSLVL
Definition: namespace.c:30

◆ nfs41_root_mount_referral()

int nfs41_root_mount_referral ( IN nfs41_root root,
IN const fs_locations4 locations,
OUT const fs_location4 **  loc_out,
OUT nfs41_client **  client_out 
)

Definition at line 459 of file namespace.c.

Referenced by referral_resolve().

464 {
466  uint32_t i;
467 
468  /* establish a mount to the first available location */
469  for (i = 0; i < locations->location_count; i++) {
470  status = referral_mount_location(root,
471  &locations->locations[i], client_out);
472  if (status == NO_ERROR) {
473  *loc_out = &locations->locations[i];
474  break;
475  }
476  }
477  return status;
478 }
#define ERROR_BAD_NET_NAME
Definition: winerror.h:159
#define NO_ERROR
Definition: dderror.h:5
GLenum GLclampf GLint i
Definition: glfuncs.h:14
static int referral_mount_location(IN nfs41_root *root, IN const fs_location4 *loc, OUT nfs41_client **client_out)
Definition: namespace.c:437
GLsizei const GLint * locations
Definition: glext.h:10542
UINT32 uint32_t
Definition: types.h:75
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ nfs41_root_mount_server()

int nfs41_root_mount_server ( IN nfs41_root root,
IN nfs41_server server,
IN bool_t  is_data,
IN OPTIONAL uint32_t  lease_time,
OUT nfs41_client **  client_out 
)

◆ nfs41_root_ref()

void nfs41_root_ref ( IN nfs41_root root)

Definition at line 92 of file namespace.c.

Referenced by handle_mount(), nfs41_delegation_recall(), and upcall_parse().

94 {
95  const LONG count = InterlockedIncrement(&root->ref_count);
96 
97  dprintf(NSLVL, "nfs41_root_ref() count %d\n", count);
98 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
long LONG
Definition: pedump.c:60
#define dprintf
Definition: regdump.c:33
#define InterlockedIncrement
Definition: armddk.h:53
#define NSLVL
Definition: namespace.c:30

◆ nfs41_root_session()

static __inline nfs41_session* nfs41_root_session ( IN nfs41_root root)
static

Definition at line 321 of file nfs41.h.

Referenced by handle_open().

323 {
325  /* return a session for the server at the root of the namespace.
326  * because we created it on mount, it's the first one in the list */
327  EnterCriticalSection(&root->lock);
328  client = list_container(root->clients.next, nfs41_client, root_entry);
329  LeaveCriticalSection(&root->lock);
330  return client->session;
331 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define list_container(entry, type, field)
Definition: list.h:33
static FILE * client
Definition: client.c:41
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
struct __nfs41_session * session
Definition: nfs41.h:199

◆ nfs41_rpc_clnt_create()

int nfs41_rpc_clnt_create ( IN const multi_addr4 addrs,
IN uint32_t  wsize,
IN uint32_t  rsize,
IN uint32_t  uid,
IN uint32_t  gid,
IN uint32_t  sec_flavor,
OUT nfs41_rpc_clnt **  rpc_out 
)

Definition at line 145 of file nfs41_rpc.c.

Referenced by nfs41_root_mount_addrs(), and nfs41_superblock_supported_attrs_exclcreat().

153 {
154  CLIENT *client;
155  nfs41_rpc_clnt *rpc;
156  uint32_t addr_index;
157  int status;
158  char machname[MAXHOSTNAMELEN + 1];
159  gid_t gids[1];
160  bool_t needcb = 1;
161 
162  rpc = calloc(1, sizeof(nfs41_rpc_clnt));
163  if (rpc == NULL) {
164  status = GetLastError();
165  goto out;
166  }
167 #ifdef NO_CB_4_KRB5P
169  needcb = 0;
170 #endif
171  rpc->needcb = needcb;
172  rpc->cond = CreateEvent(NULL, TRUE, FALSE, NULL);
173  if (rpc->cond == NULL) {
174  status = GetLastError();
175  eprintf("CreateEvent failed %d\n", status);
176  goto out_free_rpc_clnt;
177  }
178  status = get_client_for_multi_addr(addrs, wsize, rsize, needcb?rpc:NULL,
179  rpc->server_name, &client, &addr_index);
180  if (status) {
181  clnt_pcreateerror("connecting failed");
182  goto out_free_rpc_cond;
183  }
184  if (send_null(client) != RPC_SUCCESS) {
185  // XXX Do what here?
186  eprintf("nfs41_rpc_clnt_create: send_null failed\n");
187  status = ERROR_NETWORK_UNREACHABLE;
188  goto out_err_client;
189  }
190 
191  rpc->sec_flavor = sec_flavor;
192  if (sec_flavor == RPCSEC_AUTH_SYS) {
193  if (gethostname(machname, sizeof(machname)) == -1) {
194  eprintf("nfs41_rpc_clnt_create: gethostname failed\n");
195  goto out_err_client;
196  }
197  machname[sizeof(machname) - 1] = '\0';
198  client->cl_auth = authsys_create(machname, uid, gid, 0, gids);
199  if (client->cl_auth == NULL) {
200  eprintf("nfs41_rpc_clnt_create: failed to create rpc authsys\n");
201  status = ERROR_NETWORK_UNREACHABLE;
202  goto out_err_client;
203  }
204  } else {
205  status = create_rpcsec_auth_client(sec_flavor, rpc->server_name, client);
206  if (status) {
207  eprintf("nfs41_rpc_clnt_create: failed to establish security "
208  "context with %s\n", rpc->server_name);
209  status = ERROR_NETWORK_UNREACHABLE;
210  goto out_err_client;
211  } else
212  dprintf(1, "nfs41_rpc_clnt_create: successfully created %s\n",
214  }
215  rpc->rpc = client;
216 
217  /* keep a copy of the address and buffer sizes for reconnect */
218  memcpy(&rpc->addrs, addrs, sizeof(multi_addr4));
219  /* save the index of the address we connected to */
220  rpc->addr_index = addr_index;
221  rpc->wsize = wsize;
222  rpc->rsize = rsize;
223  rpc->is_valid_session = TRUE;
224  rpc->uid = uid;
225  rpc->gid = gid;
226 
227  //initialize rpc client lock
228  InitializeSRWLock(&rpc->lock);
229 
230  *rpc_out = rpc;
231 out:
232  return status;
233 out_err_client:
234  clnt_destroy(client);
235 out_free_rpc_cond:
236  CloseHandle(rpc->cond);
237 out_free_rpc_clnt:
238  free(rpc);
239  goto out;
240 }
#define CreateEvent
Definition: winbase.h:3562
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
static enum clnt_stat send_null(CLIENT *client)
Definition: nfs41_rpc.c:33
int32_t bool_t
Definition: types.h:101
#define free
Definition: debug_ros.c:5
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
bool_t is_valid_session
Definition: nfs41.h:181
uint32_t rsize
Definition: nfs41.h:175
bool_t needcb
Definition: nfs41.h:183
UINT gid_t
Definition: types.h:89
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
Definition: getxbyxx.c:397
#define dprintf
Definition: regdump.c:33
smooth NULL
Definition: ftsmooth.c:416
static int get_client_for_multi_addr(IN const multi_addr4 *addrs, IN uint32_t wsize, IN uint32_t rsize, IN nfs41_rpc_clnt *rpc, OUT OPTIONAL char *server_name, OUT CLIENT **client_out, OUT uint32_t *addr_index)
Definition: nfs41_rpc.c:83
char server_name[NI_MAXHOST]
Definition: nfs41.h:180
AUTH * cl_auth
Definition: clnt.h:122
uint32_t wsize
Definition: nfs41.h:174
multi_addr4 addrs
Definition: nfs41.h:172
int create_rpcsec_auth_client(IN uint32_t sec_flavor, IN char *server_name, CLIENT *client)
Definition: nfs41_rpc.c:105
static FILE * client
Definition: client.c:41
static FILE * out
Definition: regtests2xml.c:44
HANDLE cond
Definition: nfs41.h:170
uint32_t sec_flavor
Definition: nfs41.h:177
SRWLOCK lock
Definition: nfs41.h:169
void clnt_pcreateerror(char *s) const
Definition: clnt_perror.c:307
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
Definition: sync.c:75
uint32_t addr_index
Definition: nfs41.h:173
const char * secflavorop2name(DWORD sec_flavor)
Definition: daemon_debug.c:558
struct __rpc_client * rpc
Definition: nfs41.h:168
#define MAXHOSTNAMELEN
Definition: ftp.c:31
#define ERROR_NETWORK_UNREACHABLE
Definition: winerror.h:734
uint32_t uid
Definition: nfs41.h:178
UINT32 uint32_t
Definition: types.h:75
#define calloc
Definition: rosglue.h:14
#define authsys_create(c, i1, i2, i3, ip)
Definition: auth.h:323
sec_flavor
Definition: nfs41_ops.h:861
uint32_t gid
Definition: nfs41.h:179
static SERVICE_STATUS status
Definition: service.c:31
#define clnt_destroy(rh)
Definition: clnt.h:276

◆ nfs41_rpc_clnt_free()

void nfs41_rpc_clnt_free ( IN nfs41_rpc_clnt rpc)

Definition at line 243 of file nfs41_rpc.c.

Referenced by nfs41_client_create(), nfs41_client_free(), nfs41_root_mount_addrs(), and nfs41_superblock_supported_attrs_exclcreat().

245 {
246  auth_destroy(rpc->rpc->cl_auth);
247  clnt_destroy(rpc->rpc);
248  CloseHandle(rpc->cond);
249  free(rpc);
250 }
#define CloseHandle
Definition: compat.h:398
#define free
Definition: debug_ros.c:5
#define clnt_destroy(rh)
Definition: clnt.h:276
#define auth_destroy(auth)
Definition: auth.h:259

◆ nfs41_rpc_netaddr()

static __inline netaddr4* nfs41_rpc_netaddr ( IN nfs41_rpc_clnt rpc)
static

Definition at line 500 of file nfs41.h.

Referenced by update_server().

502 {
503  uint32_t id;
504  AcquireSRWLockShared(&rpc->lock);
505  /* only addr_index needs to be protected, as rpc->addrs is write-once */
506  id = rpc->addr_index;
507  ReleaseSRWLockShared(&rpc->lock);
508 
509  /* return the netaddr used to create the rpc client */
510  return &rpc->addrs.arr[id];
511 }
UINT32 uint32_t
Definition: types.h:75
GLenum GLuint id
Definition: glext.h:5579
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_send_compound()

int nfs41_send_compound ( IN nfs41_rpc_clnt rpc,
IN char inbuf,
OUT char outbuf 
)

Definition at line 337 of file nfs41_rpc.c.

Referenced by compound_encode_send_decode(), nfs41_bind_conn_to_session(), nfs41_destroy_clientid(), nfs41_exchange_id(), and nfs41_superblock_supported_attrs_exclcreat().

341 {
342  struct timeval timeout = {90, 100};
343  enum clnt_stat rpc_status;
344  int status, count = 0, one = 1, zero = 0;
346 
347  try_again:
348  AcquireSRWLockShared(&rpc->lock);
349  version = rpc->version;
350  rpc_status = clnt_call(rpc->rpc, 1,
353  timeout);
354  ReleaseSRWLockShared(&rpc->lock);
355 
356  if (rpc_status != RPC_SUCCESS) {
357  eprintf("clnt_call returned rpc_status = %s\n",
358  rpc_error_string(rpc_status));
359  switch(rpc_status) {
360  case RPC_CANTRECV:
361  case RPC_CANTSEND:
362  case RPC_TIMEDOUT:
363  case RPC_AUTHERROR:
364  if (++count > 3 || !rpc->is_valid_session) {
365  status = ERROR_NETWORK_UNREACHABLE;
366  break;
367  }
368  if (rpc_should_retry(rpc, version))
369  goto try_again;
370  while (rpc_renew_in_progress(rpc, NULL)) {
371  status = WaitForSingleObject(rpc->cond, INFINITE);
372  if (status != WAIT_OBJECT_0) {
373  dprintf(1, "rpc_renew_in_progress: WaitForSingleObject failed\n");
374  print_condwait_status(1, status);
375  status = ERROR_LOCK_VIOLATION;
376  goto out;
377  }
379  goto try_again;
380  }
381  rpc_renew_in_progress(rpc, &one);
382  if (rpc_status == RPC_AUTHERROR && rpc->sec_flavor != RPCSEC_AUTH_SYS) {
383  AcquireSRWLockExclusive(&rpc->lock);
384  auth_destroy(rpc->rpc->cl_auth);
385  status = create_rpcsec_auth_client(rpc->sec_flavor,
386  rpc->server_name, rpc->rpc);
387  ReleaseSRWLockExclusive(&rpc->lock);
388  if (status) {
389  eprintf("Failed to reestablish security context\n");
390  status = ERROR_NETWORK_UNREACHABLE;
391  goto out;
392  }
393  } else
394  if (rpc_reconnect(rpc))
395  eprintf("rpc_reconnect: Failed to reconnect!\n");
397  goto try_again;
398  default:
399  eprintf("UNHANDLED RPC_ERROR: %d\n", rpc_status);
400  status = ERROR_NETWORK_UNREACHABLE;
401  goto out;
402  }
403  goto out;
404  }
405 
406  status = 0;
407 out:
408  return status;
409 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
GLuint GLuint GLsizei count
Definition: gl.h:1545
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
Definition: dhcpd.h:245
static double one
Definition: j0_y0.c:80
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144
#define dprintf
Definition: regdump.c:33
const char * rpc_error_string(int status)
Definition: daemon_debug.c:482
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:64
#define WAIT_OBJECT_0
Definition: winbase.h:387
static bool_t rpc_renew_in_progress(nfs41_rpc_clnt *rpc, int *value)
Definition: nfs41_rpc.c:252
bool_t nfs_decode_compound(XDR *xdr, caddr_t *pres)
Definition: nfs41_xdr.c:3625
int create_rpcsec_auth_client(IN uint32_t sec_flavor, IN char *server_name, CLIENT *client)
Definition: nfs41_rpc.c:105
static FILE * out
Definition: regtests2xml.c:44
uchar inbuf[M_BLOCK]
Definition: unzcrash.c:40
static double zero
Definition: j0_y0.c:96
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
static int rpc_reconnect(IN nfs41_rpc_clnt *rpc)
Definition: nfs41_rpc.c:279
#define ERROR_NETWORK_UNREACHABLE
Definition: winerror.h:734
#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs)
Definition: clnt.h:202
UINT32 uint32_t
Definition: types.h:75
#define ERROR_LOCK_VIOLATION
Definition: winerror.h:136
bool_t nfs_encode_compound(XDR *xdr, caddr_t *pargs)
Definition: nfs41_xdr.c:3591
static bool_t rpc_should_retry(nfs41_rpc_clnt *rpc, uint32_t version)
Definition: nfs41_rpc.c:269
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
void print_condwait_status(int level, int status)
Definition: daemon_debug.c:513
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
#define auth_destroy(auth)
Definition: auth.h:259
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89
clnt_stat
Definition: clnt_stat.h:21
uchar outbuf[M_BLOCK_OUT]
Definition: unzcrash.c:41

◆ nfs41_server_addrs()

void nfs41_server_addrs ( IN nfs41_server server,
OUT multi_addr4 addrs 
)

Definition at line 203 of file nfs41_server.c.

Referenced by nfs41_root_session().

206 {
207  struct server_addrs *saddrs = &server->addrs;
208  uint32_t i, j;
209 
210  /* make a copy of the server's addrs, with most recent first */
211  AcquireSRWLockShared(&saddrs->lock);
212  j = saddrs->next_index;
213  for (i = 0; i < saddrs->addrs.count; i++) {
214  /* decrement/wrap j */
216  memcpy(&addrs->arr[i], &saddrs->addrs.arr[j], sizeof(netaddr4));
217  }
218  ReleaseSRWLockShared(&saddrs->lock);
219 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
static rfbScreenInfoPtr server
Definition: vnc.c:74
multi_addr4 addrs
Definition: nfs41.h:74
GLenum GLclampf GLint i
Definition: glfuncs.h:14
SRWLOCK lock
Definition: nfs41.h:76
#define NFS41_ADDRS_PER_SERVER
Definition: nfs41_const.h:49
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
uint32_t count
Definition: nfs41_types.h:92
UINT32 uint32_t
Definition: types.h:75
uint32_t next_index
Definition: nfs41.h:75
netaddr4 arr[NFS41_ADDRS_PER_SERVER]
Definition: nfs41_types.h:91
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_server_deref()

void nfs41_server_deref ( IN nfs41_server server)

Definition at line 155 of file nfs41_server.c.

Referenced by nfs41_client_free(), nfs41_root_session(), and update_server().

157 {
159 
160  server->ref_count--;
161  dprintf(SRVLVL, "nfs41_server_deref(%s) count %d\n",
162  server->owner, server->ref_count);
163  if (server->ref_count == 0) {
164  list_remove(&server->entry);
166  }
167 
169 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static struct server_list g_server_list
Definition: nfs41_server.c:43
#define dprintf
Definition: regdump.c:33
static void server_free(IN nfs41_server *server)
Definition: nfs41_server.c:128
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define SRVLVL
Definition: nfs41_server.c:35
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ nfs41_server_find_or_create()

int nfs41_server_find_or_create ( IN const char server_owner_major_id,
IN const char server_scope,
IN const netaddr4 addr,
OUT nfs41_server **  server_out 
)

Definition at line 221 of file nfs41_server.c.

Referenced by nfs41_root_session(), and update_server().

226 {
227  struct server_info info;
228  struct list_entry *entry;
230  int status;
231 
232  info.owner = server_owner_major_id;
233  info.scope = server_scope;
234 
235  dprintf(SRVLVL, "--> nfs41_server_find_or_create(%s)\n", info.owner);
236 
238 
239  /* search for an existing server */
240  entry = list_search(&g_server_list.head, &info, server_compare);
241  if (entry == NULL) {
242  /* create a new server */
243  status = server_create(&info, &server);
244  if (status == NO_ERROR) {
245  /* add it to the list */
246  list_add_tail(&g_server_list.head, &server->entry);
247  *server_out = server;
248 
249  dprintf(SRVLVL, "<-- nfs41_server_find_or_create() "
250  "returning new server %p\n", server);
251  } else {
252  dprintf(SRVLVL, "<-- nfs41_server_find_or_create() "
253  "returning %d\n", status);
254  }
255  } else {
256  server = server_entry(entry);
257  status = NO_ERROR;
258 
259  dprintf(SRVLVL, "<-- nfs41_server_find_or_create() "
260  "returning existing server %p\n", server);
261  }
262 
263  if (server) {
264  /* register the address used to connect */
265  server_addrs_add(&server->addrs, addr);
266 
267  server_ref_locked(server);
268  }
269 
270  *server_out = server;
272  return status;
273 }
static int server_create(IN const struct server_info *info, OUT nfs41_server **server_out)
Definition: nfs41_server.c:94
static rfbScreenInfoPtr server
Definition: vnc.c:74
static void server_addrs_add(IN OUT struct server_addrs *addrs, IN const netaddr4 *addr)
Definition: nfs41_server.c:171
uint8_t entry
Definition: isohybrid.c:63
static __inline void server_ref_locked(IN nfs41_server *server)
Definition: nfs41_server.c:137
struct server_addrs addrs
Definition: nfs41.h:82
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define NO_ERROR
Definition: dderror.h:5
static struct server_list g_server_list
Definition: nfs41_server.c:43
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
struct list_entry entry
Definition: nfs41.h:85
#define dprintf
Definition: regdump.c:33
smooth NULL
Definition: ftsmooth.c:416
GLenum const GLvoid * addr
Definition: glext.h:9621
static struct list_entry * list_search(const struct list_entry *head, const void *value, list_compare_fn compare)
Definition: list.h:102
Definition: list.h:27
#define SRVLVL
Definition: nfs41_server.c:35
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static SERVICE_STATUS status
Definition: service.c:31
static int server_compare(const struct list_entry *entry, const void *value)
Definition: nfs41_server.c:75
#define server_entry(pos)
Definition: nfs41_server.c:45

◆ nfs41_server_list_init()

void nfs41_server_list_init ( )

Definition at line 48 of file nfs41_server.c.

Referenced by nfs41_root_session(), and ServiceStart().

49 {
50  list_init(&g_server_list.head);
52 }
static struct server_list g_server_list
Definition: nfs41_server.c:43
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149

◆ nfs41_server_ref()

void nfs41_server_ref ( IN nfs41_server server)

Definition at line 145 of file nfs41_server.c.

Referenced by nfs41_root_session().

147 {
149 
151 
153 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
static __inline void server_ref_locked(IN nfs41_server *server)
Definition: nfs41_server.c:137
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static struct server_list g_server_list
Definition: nfs41_server.c:43
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ nfs41_server_resolve()

int nfs41_server_resolve ( IN const char hostname,
IN unsigned short  port,
OUT multi_addr4 addrs 
)

Definition at line 275 of file nfs41_server.c.

Referenced by handle_mount(), nfs41_root_session(), and referral_mount_location().

279 {
281  char service[16];
282  struct addrinfo hints = { 0 }, *res, *info;
283  struct netconfig *nconf;
284  struct netbuf addr;
285  char *netid, *uaddr;
286 
287  dprintf(SRVLVL, "--> nfs41_server_resolve(%s:%u)\n",
288  hostname, port);
289 
290  addrs->count = 0;
291 
292  StringCchPrintfA(service, 16, "%u", port);
293 
294  /* request a list of tcp addrs for the given hostname,port */
295  hints.ai_family = AF_UNSPEC;
296  hints.ai_socktype = SOCK_STREAM;
297  hints.ai_protocol = IPPROTO_TCP;
298 
299  if (getaddrinfo(hostname, service, &hints, &res) != 0)
300  goto out;
301 
302  for (info = res; info != NULL; info = info->ai_next) {
303  /* find the appropriate entry in /etc/netconfig */
304  switch (info->ai_family) {
305  case AF_INET: netid = "tcp"; break;
306  case AF_INET6: netid = "tcp6"; break;
307  default: continue;
308  }
309 
310  nconf = getnetconfigent(netid);
311  if (nconf == NULL)
312  continue;
313 
314  /* convert to a transport-independent universal address */
315  addr.buf = info->ai_addr;
316  addr.maxlen = addr.len = (unsigned int)info->ai_addrlen;
317 
318  uaddr = taddr2uaddr(nconf, &addr);
319  freenetconfigent(nconf);
320 
321  if (uaddr == NULL)
322  continue;
323 
324  StringCchCopyA(addrs->arr[addrs->count].netid,
325  NFS41_NETWORK_ID_LEN+1, netid);
326  StringCchCopyA(addrs->arr[addrs->count].uaddr,
327  NFS41_UNIVERSAL_ADDR_LEN+1, uaddr);
328  freeuaddr(uaddr);
329 
330  status = NO_ERROR;
331  if (++addrs->count >= NFS41_ADDRS_PER_SERVER)
332  break;
333  }
334  freeaddrinfo(res);
335 out:
336  if (status)
337  dprintf(SRVLVL, "<-- nfs41_server_resolve(%s:%u) returning "
338  "error %d\n", hostname, port, status);
339  else
340  dprintf(SRVLVL, "<-- nfs41_server_resolve(%s:%u) returning "
341  "%s\n", hostname, port, addrs->arr[0].uaddr);
342  return status;
343 }
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
#define freeaddrinfo
Definition: wspiapi.h:46
#define ERROR_BAD_NET_NAME
Definition: winerror.h:159
#define NO_ERROR
Definition: dderror.h:5
struct _test_info info[]
Definition: SetCursorPos.c:19
char * hostname
Definition: ftp.c:88
void freeuaddr(char *uaddr)
Definition: rpc_generic.c:628
#define dprintf
Definition: regdump.c:33
void freenetconfigent(struct netconfig *netconfigp)
Definition: getnetconfig.c:530
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:520
smooth NULL
Definition: ftsmooth.c:416
struct netconfig * getnetconfigent(char *netid) const
Definition: getnetconfig.c:432
#define AF_INET6
Definition: winsock.h:369
#define AF_UNSPEC
Definition: winsock.h:344
#define NFS41_ADDRS_PER_SERVER
Definition: nfs41_const.h:49
static FILE * out
Definition: regtests2xml.c:44
#define NFS41_UNIVERSAL_ADDR_LEN
Definition: nfs41_const.h:53
GLenum const GLvoid * addr
Definition: glext.h:9621
int ai_protocol
Definition: ws2def.h:668
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
int ai_socktype
Definition: ws2def.h:667
Definition: types.h:144
#define NFS41_NETWORK_ID_LEN
Definition: nfs41_const.h:56
GLuint res
Definition: glext.h:9613
#define AF_INET
Definition: tcpip.h:117
#define SRVLVL
Definition: nfs41_server.c:35
char * taddr2uaddr(const struct netconfig *nconf, const struct netbuf *nbuf)
Definition: rpc_generic.c:609
#define SOCK_STREAM
Definition: tcpip.h:118
USHORT port
Definition: uri.c:227
static SERVICE_STATUS status
Definition: service.c:31
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
#define getaddrinfo
Definition: wspiapi.h:44
Definition: ps.c:97
int ai_family
Definition: ws2def.h:666

◆ nfs41_session_bad_slot()

int nfs41_session_bad_slot ( IN nfs41_session session,
IN OUT struct __nfs41_sequence_args args 
)

◆ nfs41_session_bump_seq()

void nfs41_session_bump_seq ( IN nfs41_session session,
IN uint32_t  slotid,
IN uint32_t  target_highest_slotid 
)

Definition at line 80 of file nfs41_session.c.

Referenced by compound_encode_send_decode(), and nfs41_root_session().

84 {
85  nfs41_slot_table *table = &session->table;
86 
87  AcquireSRWLockShared(&session->client->session_lock);
88  EnterCriticalSection(&table->lock);
89 
90  if (slotid < NFS41_MAX_NUM_SLOTS)
91  table->seq_nums[slotid]++;
92 
93  /* adjust max_slots in response to changes in target_highest_slotid,
94  * but not immediately after a CB_RECALL_SLOT or NFS4ERR_BADSLOT error */
95  if (table->target_delay <= GetTickCount64())
96  resize_slot_table(table, target_highest_slotid);
97 
98  LeaveCriticalSection(&table->lock);
99  ReleaseSRWLockShared(&session->client->session_lock);
100 }
#define NFS41_MAX_NUM_SLOTS
Definition: nfs41.h:218
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
uint32_t seq_nums[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:220
ULONGLONG target_delay
Definition: nfs41.h:225
static void resize_slot_table(IN nfs41_slot_table *table, IN uint32_t target_highest_slotid)
Definition: nfs41_session.c:63
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_create()

int nfs41_session_create ( IN nfs41_client client,
IN nfs41_session **  session_out 
)

Definition at line 278 of file nfs41_session.c.

Referenced by nfs41_root_session(), and root_client_create().

281 {
282  nfs41_session *session;
283  int status;
284 
285  status = session_alloc(client, &session);
286  if (status) {
287  eprintf("session_alloc() failed with %d\n", status);
288  goto out;
289  }
290 
291  AcquireSRWLockShared(&client->exid_lock);
292  if (client->rpc->needcb)
295  ReleaseSRWLockShared(&client->exid_lock);
296 
297  status = nfs41_create_session(client, session, TRUE);
298  if (status) {
299  eprintf("nfs41_create_session failed %d\n", status);
300  status = ERROR_BAD_NET_RESP;
301  goto out_err;
302  }
303 
305  client->session = session;
306  session->isValidState = TRUE;
308  *session_out = session;
309 out:
310  return status;
311 
312 out_err:
313  nfs41_session_free(session);
314  goto out;
315 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
#define TRUE
Definition: types.h:120
uint32_t flags
Definition: nfs41.h:265
SRWLOCK session_lock
Definition: nfs41.h:200
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define ERROR_BAD_NET_RESP
Definition: winerror.h:150
nfs41_client * client
Definition: nfs41.h:256
bool_t isValidState
Definition: nfs41.h:264
#define CREATE_SESSION4_FLAG_PERSIST
Definition: nfs41_const.h:307
static FILE * client
Definition: client.c:41
static FILE * out
Definition: regtests2xml.c:44
static int session_alloc(IN nfs41_client *client, OUT nfs41_session **session_out)
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
#define CREATE_SESSION4_FLAG_CONN_BACK_CHAN
Definition: nfs41_const.h:308
int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_recovery)
Definition: nfs41_ops.c:101
void nfs41_session_free(IN nfs41_session *session)
static SERVICE_STATUS status
Definition: service.c:31
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_free()

void nfs41_session_free ( IN nfs41_session session)

Definition at line 363 of file nfs41_session.c.

Referenced by nfs41_client_free(), nfs41_root_session(), and nfs41_session_create().

365 {
366  AcquireSRWLockExclusive(&session->client->session_lock);
367  if (valid_handle(session->renew_thread)) {
368  dprintf(1, "nfs41_session_free: terminating session renewal thread\n");
369  if (!TerminateThread(session->renew_thread, NO_ERROR))
370  eprintf("failed to terminate renewal thread %p\n",
371  session->renew_thread);
372  }
373 
374  if (session->isValidState) {
375  session->client->rpc->is_valid_session = FALSE;
376  nfs41_destroy_session(session);
377  }
378  DeleteCriticalSection(&session->table.lock);
379  ReleaseSRWLockExclusive(&session->client->session_lock);
380  free(session);
381 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:549
#define free
Definition: debug_ros.c:5
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define NO_ERROR
Definition: dderror.h:5
__inline int valid_handle(HANDLE handle)
Definition: util.h:281
#define dprintf
Definition: regdump.c:33
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
int nfs41_destroy_session(IN nfs41_session *session)
Definition: nfs41_ops.c:214

◆ nfs41_session_free_slot()

void nfs41_session_free_slot ( IN nfs41_session session,
IN uint32_t  slotid 
)

Definition at line 102 of file nfs41_session.c.

Referenced by compound_encode_send_decode(), nfs41_root_session(), and nfs41_session_bad_slot().

105 {
106  nfs41_slot_table *table = &session->table;
107 
108  AcquireSRWLockShared(&session->client->session_lock);
109  EnterCriticalSection(&table->lock);
110 
111  /* flag the slot as unused */
112  if (slotid < NFS41_MAX_NUM_SLOTS && table->used_slots[slotid]) {
113  table->used_slots[slotid] = 0;
114  table->num_used--;
115  }
116  /* update highest_used if necessary */
117  if (slotid == table->highest_used) {
118  while (table->highest_used && !table->used_slots[table->highest_used])
119  table->highest_used--;
120  }
121  dprintf(3, "freeing slot#=%d used=%d highest=%d\n",
122  slotid, table->num_used, table->highest_used);
123 
124  /* wake any threads waiting on a slot */
125  if (slot_table_avail(table))
127 
128  LeaveCriticalSection(&table->lock);
129  ReleaseSRWLockShared(&session->client->session_lock);
130 }
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t highest_used
Definition: nfs41.h:223
static int slot_table_avail(IN const nfs41_slot_table *table)
Definition: nfs41_session.c:38
VOID WINAPI WakeAllConditionVariable(PCONDITION_VARIABLE ConditionVariable)
Definition: sync.c:137
#define dprintf
Definition: regdump.c:33
uint32_t num_used
Definition: nfs41.h:224
uint32_t used_slots[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:221
CONDITION_VARIABLE cond
Definition: nfs41.h:227
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_get_slot()

void nfs41_session_get_slot ( IN nfs41_session session,
OUT uint32_t slot,
OUT uint32_t seq,
OUT uint32_t highest 
)

Definition at line 132 of file nfs41_session.c.

Referenced by compound_encode_send_decode(), nfs41_root_session(), nfs41_session_bad_slot(), and nfs41_session_sequence().

137 {
138  nfs41_slot_table *table = &session->table;
139  uint32_t i;
140 
141  AcquireSRWLockShared(&session->client->session_lock);
142  EnterCriticalSection(&table->lock);
143 
144  /* wait for an available slot */
145  while (!slot_table_avail(table))
146  SleepConditionVariableCS(&table->cond, &table->lock, INFINITE);
147 
148  for (i = 0; i < table->max_slots; i++) {
149  if (table->used_slots[i])
150  continue;
151 
152  table->used_slots[i] = 1;
153  table->num_used++;
154  if (i > table->highest_used)
155  table->highest_used = i;
156 
157  *slot = i;
158  *seqid = table->seq_nums[i];
159  *highest = table->highest_used;
160  break;
161  }
162  LeaveCriticalSection(&table->lock);
163  ReleaseSRWLockShared(&session->client->session_lock);
164 
165  dprintf(2, "session %p: using slot#=%d with seq#=%d highest=%d\n",
166  session, *slot, *seqid, *highest);
167 }
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t seq_nums[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:220
uint32_t highest_used
Definition: nfs41.h:223
GLenum GLclampf GLint i
Definition: glfuncs.h:14
static int slot_table_avail(IN const nfs41_slot_table *table)
Definition: nfs41_session.c:38
#define dprintf
Definition: regdump.c:33
uint32_t num_used
Definition: nfs41.h:224
uint32_t used_slots[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:221
Definition: vfat.h:189
uint32_t max_slots
Definition: nfs41.h:222
BOOL WINAPI SleepConditionVariableCS(PCONDITION_VARIABLE ConditionVariable, PCRITICAL_SECTION CriticalSection, DWORD Timeout)
Definition: sync.c:105
UINT32 uint32_t
Definition: types.h:75
CONDITION_VARIABLE cond
Definition: nfs41.h:227
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INFINITE
Definition: serial.h:102
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_recall_slot()

int nfs41_session_recall_slot ( IN nfs41_session session,
IN OUT uint32_t  target_highest_slotid 
)

Definition at line 169 of file nfs41_session.c.

Referenced by handle_cb_recall_slot(), and nfs41_root_session().

172 {
173  nfs41_slot_table *table = &session->table;
174 
175  AcquireSRWLockShared(&session->client->session_lock);
176  EnterCriticalSection(&table->lock);
177  resize_slot_table(table, target_highest_slotid);
179  LeaveCriticalSection(&table->lock);
180  ReleaseSRWLockShared(&session->client->session_lock);
181 
182  return NFS4_OK;
183 }
#define MAX_SLOTS_DELAY
Definition: nfs41_session.c:34
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
ULONGLONG target_delay
Definition: nfs41.h:225
static void resize_slot_table(IN nfs41_slot_table *table, IN uint32_t target_highest_slotid)
Definition: nfs41_session.c:63
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_renew()

int nfs41_session_renew ( IN nfs41_session session)

Definition at line 318 of file nfs41_session.c.

Referenced by nfs41_recover_session(), and nfs41_root_session().

320 {
321  int status;
322 
323  AcquireSRWLockExclusive(&session->client->session_lock);
324  session->cb_session.cb_seqnum = 0;
325  init_slot_table(&session->table);
326 
327  status = nfs41_create_session(session->client, session, FALSE);
328  ReleaseSRWLockExclusive(&session->client->session_lock);
329  return status;
330 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
static void init_slot_table(nfs41_slot_table *table)
Definition: nfs41_session.c:45
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_recovery)
Definition: nfs41_ops.c:101
static SERVICE_STATUS status
Definition: service.c:31

◆ nfs41_session_sequence()

void nfs41_session_sequence ( struct __nfs41_sequence_args args,
nfs41_session session,
bool_t  cachethis 
)

Definition at line 214 of file nfs41_session.c.

Referenced by lookup_rpc(), nfs41_access(), nfs41_close(), nfs41_commit(), nfs41_create(), nfs41_delegpurge(), nfs41_delegreturn(), nfs41_free_stateid(), nfs41_fs_locations(), nfs41_getattr(), nfs41_link(), nfs41_lock(), nfs41_open(), nfs41_read(), nfs41_readdir(), nfs41_readlink(), nfs41_reclaim_complete(), nfs41_remove(), nfs41_rename(), nfs41_root_session(), nfs41_rpc_openattr(), nfs41_secinfo(), nfs41_secinfo_noname(), nfs41_send_sequence(), nfs41_setattr(), nfs41_superblock_getattr(), nfs41_test_stateid(), nfs41_unlock(), nfs41_want_delegation(), nfs41_write(), pnfs_rpc_getdeviceinfo(), pnfs_rpc_layoutcommit(), pnfs_rpc_layoutget(), pnfs_rpc_layoutreturn(), and rpc_array_putfh().

218 {
219  nfs41_session_get_slot(session, &args->sa_slotid,
220  &args->sa_sequenceid, &args->sa_highest_slotid);
221  args->sa_sessionid = session->session_id;
222  args->sa_cachethis = cachethis;
223 }
uint32_t sa_highest_slotid
Definition: nfs41_ops.h:232
unsigned char session_id[NFS4_SESSIONID_SIZE]
Definition: nfs41.h:257
uint32_t sa_sequenceid
Definition: nfs41_ops.h:230
unsigned char * sa_sessionid
Definition: nfs41_ops.h:229
void nfs41_session_get_slot(IN nfs41_session *session, OUT uint32_t *slot, OUT uint32_t *seqid, OUT uint32_t *highest)

◆ nfs41_session_set_lease()

int nfs41_session_set_lease ( IN nfs41_session session,
IN uint32_t  lease_time 
)

Definition at line 332 of file nfs41_session.c.

Referenced by nfs41_root_session(), and session_get_lease().

335 {
336  int status = NO_ERROR;
338 
339  if (valid_handle(session->renew_thread)) {
340  eprintf("nfs41_session_set_lease(): session "
341  "renewal thread already started!\n");
342  goto out;
343  }
344 
345  if (lease_time == 0) {
346  eprintf("nfs41_session_set_lease(): invalid lease_time=0\n");
347  status = ERROR_INVALID_PARAMETER;
348  goto out;
349  }
350 
351  session->lease_time = lease_time;
352  session->renew_thread = (HANDLE)_beginthreadex(NULL,
353  0, renew_session, session, 0, &thread_id);
354  if (!valid_handle(session->renew_thread)) {
355  status = GetLastError();
356  eprintf("_beginthreadex failed %d\n", status);
357  goto out;
358  }
359 out:
360  return status;
361 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
#define NO_ERROR
Definition: dderror.h:5
__inline int valid_handle(HANDLE handle)
Definition: util.h:281
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
PVOID HANDLE
Definition: typedefs.h:71
static DWORD thread_id
Definition: protocol.c:158
UINT32 uint32_t
Definition: types.h:75
static unsigned int WINAPI renew_session(void *args)
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ nfs41_superblock_for_fh()

int nfs41_superblock_for_fh ( IN nfs41_session session,
IN const nfs41_fsid fsid,
IN const nfs41_fh *parent  OPTIONAL,
OUT nfs41_path_fh file 
)

Definition at line 233 of file nfs41_superblock.c.

Referenced by client_server(), nfs41_link(), nfs41_open(), and server_lookup().

238 {
239  int status = NFS4_OK;
240  nfs41_server *server = client_server(session->client);
241  nfs41_superblock_list *superblocks = &server->superblocks;
243 
244  dprintf(SBLVL, "--> nfs41_superblock_for_fh(fsid(%llu,%llu))\n",
245  fsid->major, fsid->minor);
246 
247  /* compare with the parent's fsid, and use that if it matches */
248  if (parent && parent->superblock &&
249  compare_fsid(fsid, &parent->superblock->fsid) == 0) {
250  file->fh.superblock = parent->superblock;
251  dprintf(SBLVL, "using superblock from parent\n");
252  goto out;
253  }
254 
255  /* using a shared lock, search for an existing superblock */
256  AcquireSRWLockShared(&superblocks->lock);
257  superblock = find_superblock(superblocks, fsid);
258  ReleaseSRWLockShared(&superblocks->lock);
259 
260  if (superblock) {
261  dprintf(SBLVL, "found existing superblock in server list "
262  "[shared lock]\n");
263  } else {
264  AcquireSRWLockExclusive(&superblocks->lock);
265  /* must search again under an exclusive lock, in case another thread
266  * created it after our first search */
267  superblock = find_superblock(superblocks, fsid);
268  if (superblock) {
269  dprintf(SBLVL, "found newly created superblock in server list "
270  "[exclusive lock]\n");
271  } else {
272  /* create the superblock */
273  status = superblock_create(fsid, &superblock);
274  if (status == NO_ERROR) /* add it to the list */
275  list_add_tail(&superblocks->head, &superblock->entry);
276  }
277  ReleaseSRWLockExclusive(&superblocks->lock);
278  }
279 
280  if (status == NO_ERROR && superblock->supported_attrs.count == 0) {
281  /* exclusive lock on the superblock while fetching attributes */
282  AcquireSRWLockExclusive(&superblock->lock);
283  if (superblock->supported_attrs.count == 0)
284  status = get_superblock_attrs(session, superblock, file);
285  ReleaseSRWLockExclusive(&superblock->lock);
286  }
287 
288  file->fh.superblock = superblock;
289 out:
290  dprintf(SBLVL, "<-- nfs41_superblock_for_fh() returning %p, status %d\n",
291  file->fh.superblock, status);
292  return status;
293 }
#define SBLVL
static int get_superblock_attrs(IN nfs41_session *session, IN nfs41_superblock *superblock, IN nfs41_path_fh *file)
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
SRWLOCK lock
Definition: nfs41.h:65
static rfbScreenInfoPtr server
Definition: vnc.c:74
static int superblock_create(IN const nfs41_fsid *fsid, OUT nfs41_superblock **superblock_out)
struct list_entry entry
Definition: nfs41.h:39
#define NO_ERROR
Definition: dderror.h:5
static __inline int compare_fsid(IN const nfs41_fsid *lhs, IN const nfs41_fsid *rhs)
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define dprintf
Definition: regdump.c:33
uint32_t count
Definition: nfs41_types.h:96
static __inline nfs41_server * client_server(IN nfs41_client *client)
Definition: nfs41.h:428
r parent
Definition: btrfs.c:2644
static nfs41_superblock * find_superblock(IN nfs41_superblock_list *superblocks, IN const nfs41_fsid *fsid)
struct list_entry head
Definition: nfs41.h:69
static FILE * out
Definition: regtests2xml.c:44
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
nfs41_superblock_list superblocks
Definition: nfs41.h:83
static SERVICE_STATUS status
Definition: service.c:31
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
bitmap4 supported_attrs
Definition: nfs41.h:41
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89
Definition: fci.c:126
Definition: ps.c:97

◆ nfs41_superblock_fs_attributes()

void nfs41_superblock_fs_attributes ( IN const nfs41_superblock superblock,
OUT struct _FILE_FS_ATTRIBUTE_INFORMATION FsAttrs 
)

◆ nfs41_superblock_getattr_mask()

static __inline void nfs41_superblock_getattr_mask ( IN const nfs41_superblock superblock,
OUT bitmap4 attrs 
)
static

◆ nfs41_superblock_list_free()

void nfs41_superblock_list_free ( IN nfs41_superblock_list superblocks)

Definition at line 221 of file nfs41_superblock.c.

Referenced by nfs41_superblock_supported_attrs_exclcreat(), and server_free().

223 {
224  struct list_entry *entry, *tmp;
225 
226  dprintf(SBLVL, "nfs41_superblock_list_free()\n");
227 
228  list_for_each_tmp(entry, tmp, &superblocks->head)
229  free(superblock_entry(entry));
230 }
#define SBLVL
#define free
Definition: debug_ros.c:5
uint8_t entry
Definition: isohybrid.c:63
#define dprintf
Definition: regdump.c:33
Definition: list.h:27
#define list_for_each_tmp(entry, tmp, head)
Definition: list.h:39
#define superblock_entry(pos)

◆ nfs41_superblock_list_init()

void nfs41_superblock_list_init ( IN nfs41_superblock_list superblocks)

Definition at line 214 of file nfs41_superblock.c.

Referenced by nfs41_superblock_supported_attrs_exclcreat(), and server_create().

216 {
217  list_init(&superblocks->head);
218  InitializeSRWLock(&superblocks->lock);
219 }
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
Definition: sync.c:75
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149

◆ nfs41_superblock_space_changed()

void nfs41_superblock_space_changed ( IN nfs41_superblock superblock)

Definition at line 295 of file nfs41_superblock.c.

Referenced by nfs41_commit(), nfs41_create(), nfs41_link(), nfs41_open(), nfs41_remove(), nfs41_setattr(), nfs41_superblock_supported_attrs_exclcreat(), and nfs41_write().

297 {
298  /* invalidate cached volume size attributes */
300  superblock->cache_expiration = 0;
302 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82

◆ nfs41_superblock_supported_attrs()

static __inline void nfs41_superblock_supported_attrs ( IN const nfs41_superblock superblock,
IN OUT bitmap4 attrs 
)
static

Definition at line 454 of file nfs41.h.

Referenced by delegation_truncate(), get_superblock_attrs(), nfs41_create(), and nfs41_open().

457 {
458  bitmap_intersect(attrs, &superblock->supported_attrs);
459 }
static __inline void bitmap_intersect(IN bitmap4 *dst, IN const bitmap4 *src)
Definition: util.h:85

◆ nfs41_superblock_supported_attrs_exclcreat()

static __inline void nfs41_superblock_supported_attrs_exclcreat ( IN const nfs41_superblock superblock,
IN OUT bitmap4 attrs 
)
static

Definition at line 460 of file nfs41.h.

Referenced by nfs41_open().

463 {
464  bitmap_intersect(attrs, &superblock->suppattr_exclcreat);
465 }
static __inline void bitmap_intersect(IN bitmap4 *dst, IN const bitmap4 *src)
Definition: util.h:85