ReactOS 0.4.15-dev-8058-ga7cbb60
recovery.h File Reference
#include "nfs41.h"
Include dependency graph for recovery.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool_t nfs41_recovery_start_or_wait (IN nfs41_client *client)
 
void nfs41_recovery_finish (IN nfs41_client *client)
 
int nfs41_recover_session (IN nfs41_session *session, IN bool_t client_state_lost)
 
void nfs41_recover_sequence_flags (IN nfs41_session *session, IN uint32_t flags)
 
int nfs41_recover_client_state (IN nfs41_session *session, IN nfs41_client *client)
 
void nfs41_client_state_revoked (IN nfs41_session *session, IN nfs41_client *client, IN uint32_t revoked)
 
bool_t nfs41_recover_stateid (IN nfs41_session *session, IN struct __nfs_argop4 *argop)
 

Function Documentation

◆ nfs41_client_state_revoked()

void nfs41_client_state_revoked ( IN nfs41_session session,
IN nfs41_client client,
IN uint32_t  revoked 
)

Definition at line 633 of file recovery.c.

637{
640 struct list_entry empty, *opens;
641 struct client_state *clientstate = &session->client->state;
642 stateid_arg *stateids = NULL;
643 uint32_t *statuses = NULL;
645 bool_t grace = TRUE;
646 bool_t want_supported = TRUE;
647
648 EnterCriticalSection(&clientstate->lock);
649
651 /* only delegations were revoked. use an empty list for opens */
653 opens = ∅
654 } else {
655 opens = &clientstate->opens;
656 }
657
658 /* get an array of the client's stateids */
659 count = stateid_array(&clientstate->delegations,
660 opens, &stateids, &statuses);
661 if (count == 0)
662 goto out;
663
664 /* determine which stateids were revoked with TEST_STATEID */
665 if ((revoked & SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED) == 0)
666 nfs41_test_stateid(session, stateids, count, statuses);
667
668 /* free all revoked stateids with FREE_STATEID */
669 for (i = 0; i < count; i++)
670 if (statuses[i])
671 nfs41_free_stateid(session, &stateids[i].stateid);
672
673 /* revoke all of the client's layouts */
675
676 /* recover the revoked stateids */
677 for (i = 0; i < count; i++) {
678 if (statuses[i]) {
679 if (stateids[i].type == STATEID_DELEG_FILE)
680 stateids[i].delegation->revoked = TRUE;
681 else if (stateids[i].type == STATEID_OPEN)
682 recover_open(session, stateids[i].open, &grace);
683 else if (stateids[i].type == STATEID_LOCK)
684 recover_locks(session, stateids[i].open, &grace);
685 }
686 }
687 for (i = 0; i < count; i++) {
688 /* delegations that weren't recovered by recover_open() */
689 if (statuses[i] && stateids[i].type == STATEID_DELEG_FILE
690 && stateids[i].delegation->revoked)
691 recover_delegation(session, stateids[i].delegation,
692 &grace, &want_supported);
693 }
694
696out:
697 LeaveCriticalSection(&clientstate->lock);
698 free(stateids);
699 free(statuses);
700}
#define open
Definition: acwin.h:95
static void list_init(struct list_entry *head)
Definition: list.h:51
static uint32_t stateid_array(IN struct list_entry *delegations, IN struct list_entry *opens, OUT stateid_arg **stateids_out, OUT uint32_t **statuses_out)
Definition: recovery.c:547
static int recover_delegation(IN nfs41_session *session, IN nfs41_delegation_state *deleg, IN OUT bool_t *grace, IN OUT bool_t *want_supported)
Definition: recovery.c:460
static int recover_locks(IN nfs41_session *session, IN nfs41_open_state *open, IN OUT bool_t *grace)
Definition: recovery.c:281
static int recover_open(IN nfs41_session *session, IN nfs41_open_state *open, IN OUT bool_t *grace)
Definition: recovery.c:202
#define free
Definition: debug_ros.c:5
int nfs41_client_delegation_recovery(IN nfs41_client *client)
Definition: delegation.c:861
#define NULL
Definition: types.h:112
int32_t bool_t
Definition: types.h:101
#define TRUE
Definition: types.h:120
UINT32 uint32_t
Definition: types.h:75
static const WCHAR empty[]
Definition: main.c:47
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
enum nfsstat4 nfs41_free_stateid(IN nfs41_session *session, IN stateid4 *stateid)
Definition: nfs41_ops.c:1870
enum nfsstat4 nfs41_test_stateid(IN nfs41_session *session, IN stateid_arg *stateid_array, IN uint32_t count, OUT uint32_t *status_array)
Definition: nfs41_ops.c:1900
@ STATEID_LOCK
Definition: nfs41_ops.h:277
@ STATEID_DELEG_FILE
Definition: nfs41_ops.h:278
@ STATEID_OPEN
Definition: nfs41_ops.h:276
@ SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED
Definition: nfs41_ops.h:240
@ SEQ4_STATUS_RECALLABLE_STATE_REVOKED
Definition: nfs41_ops.h:243
enum pnfs_status pnfs_file_layout_recall(IN struct __nfs41_client *client, IN const struct cb_layoutrecall_args *recall)
@ PNFS_IOMODE_ANY
Definition: pnfs.h:83
@ PNFS_LAYOUTTYPE_FILE
Definition: pnfs.h:75
@ PNFS_RETURN_ALL
Definition: pnfs.h:103
static FILE * out
Definition: regtests2xml.c:44
static FILE * client
Definition: client.c:41
nfs41_delegation_state * delegation
Definition: nfs41_ops.h:287
struct cb_recall recall
CRITICAL_SECTION lock
Definition: nfs41.h:189
struct list_entry opens
Definition: nfs41.h:187
struct list_entry delegations
Definition: nfs41.h:188
Definition: list.h:27
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by nfs41_recover_sequence_flags().

◆ nfs41_recover_client_state()

int nfs41_recover_client_state ( IN nfs41_session session,
IN nfs41_client client 
)

Definition at line 487 of file recovery.c.

490{
493 struct client_state *state = &session->client->state;
494 struct list_entry *entry;
497 bool_t grace = TRUE;
498 bool_t want_supported = TRUE;
499 int status = NFS4_OK;
500
502
503 /* flag all delegations as revoked until successful recovery;
504 * recover_open() and recover_delegation_open() will only ask
505 * for delegations when revoked = TRUE */
506 list_for_each(entry, &state->delegations) {
508 deleg->revoked = TRUE;
509 }
510
511 /* recover each of the client's opens and associated delegations */
512 list_for_each(entry, &state->opens) {
514 status = recover_open(session, open, &grace);
515 if (status == NFS4_OK)
516 status = recover_locks(session, open, &grace);
518 goto unlock;
519 }
520
521 /* recover delegations that weren't associated with any opens */
522 list_for_each(entry, &state->delegations) {
524 if (deleg->revoked) {
526 deleg, &grace, &want_supported);
528 goto unlock;
529 }
530 }
531
532 /* return any delegations that were reclaimed as 'recalled' */
534unlock:
536
537 /* revoke all of the client's layouts */
539
540 if (grace && status != NFS4ERR_BADSESSION) {
541 /* send reclaim_complete, but don't fail on errors */
543 }
544 return status;
545}
static int state
Definition: maze.c:121
#define list_container(entry, type, field)
Definition: list.h:33
#define list_for_each(entry, head)
Definition: list.h:36
uint32_t entry
Definition: isohybrid.c:63
#define client_entry(pos)
Definition: namespace.c:33
@ NFS4ERR_BADSESSION
Definition: nfs41_const.h:161
@ NFS4_OK
Definition: nfs41_const.h:87
enum nfsstat4 nfs41_reclaim_complete(IN nfs41_session *session)
Definition: nfs41_ops.c:268
Definition: ps.c:97

Referenced by nfs41_recover_sequence_flags(), and nfs41_recover_session().

◆ nfs41_recover_sequence_flags()

void nfs41_recover_sequence_flags ( IN nfs41_session session,
IN uint32_t  flags 
)

Definition at line 98 of file recovery.c.

101{
102 const uint32_t revoked = flags &
107 const uint32_t restarted = flags &
109
110 /* no state recovery needed */
111 if (revoked == 0 && restarted == 0)
112 return;
113
115 return;
116
117 if (revoked) {
118 /* free stateids and attempt to recover them */
119 nfs41_client_state_revoked(session, session->client, revoked);
120
121 /* if RESTART_RECLAIM_NEEDED is also set, just do RECLAIM_COMPLETE */
122 if (restarted) nfs41_reclaim_complete(session);
123
124 } else if (restarted) {
125 /* do server reboot state recovery */
127 if (status == NFS4ERR_BADSESSION) {
128 /* recover the session and finish state recovery */
130 }
131 }
132
134}
void nfs41_client_state_revoked(IN nfs41_session *session, IN nfs41_client *client, IN uint32_t revoked)
Definition: recovery.c:633
int nfs41_recover_client_state(IN nfs41_session *session, IN nfs41_client *client)
Definition: recovery.c:487
void nfs41_recovery_finish(IN nfs41_client *client)
Definition: recovery.c:57
int nfs41_recover_session(IN nfs41_session *session, IN bool_t client_state_lost)
Definition: recovery.c:69
bool_t nfs41_recovery_start_or_wait(IN nfs41_client *client)
Definition: recovery.c:34
GLbitfield flags
Definition: glext.h:7161
@ SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED
Definition: nfs41_ops.h:241
@ SEQ4_STATUS_RESTART_RECLAIM_NEEDED
Definition: nfs41_ops.h:245
@ SEQ4_STATUS_ADMIN_STATE_REVOKED
Definition: nfs41_ops.h:242

Referenced by compound_encode_send_decode().

◆ nfs41_recover_session()

int nfs41_recover_session ( IN nfs41_session session,
IN bool_t  client_state_lost 
)

Definition at line 69 of file recovery.c.

72{
73 enum nfsstat4 status = NFS4_OK;
74
75restart_recovery:
76 /* recover the session */
78
80 /* recover the client */
81 client_state_lost = TRUE;
83 if (status == NFS4_OK)
84 goto restart_recovery; /* resume session recovery */
85
86 eprintf("nfs41_client_renew() failed with %d\n", status);
87 } else if (status) {
88 eprintf("nfs41_session_renew() failed with %d\n", status);
89 } else if (client_state_lost) {
90 /* recover the client's state */
93 goto restart_recovery;
94 }
95 return status;
96}
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
int nfs41_session_renew(IN nfs41_session *session)
int nfs41_client_renew(IN nfs41_client *client)
Definition: nfs41_client.c:168
nfsstat4
Definition: nfs41_const.h:86
@ NFS4ERR_STALE_CLIENTID
Definition: nfs41_const.h:129

Referenced by compound_encode_send_decode(), and nfs41_recover_sequence_flags().

◆ nfs41_recover_stateid()

bool_t nfs41_recover_stateid ( IN nfs41_session session,
IN struct __nfs_argop4 argop 
)

◆ nfs41_recovery_finish()

void nfs41_recovery_finish ( IN nfs41_client client)

Definition at line 57 of file recovery.c.

59{
60 EnterCriticalSection(&client->recovery.lock);
61 dprintf(1, "Finished recovery for client %llu\n", client->clnt_id);
62 client->recovery.in_recovery = FALSE;
63 WakeAllConditionVariable(&client->recovery.cond);
64 LeaveCriticalSection(&client->recovery.lock);
65}
#define FALSE
Definition: types.h:117
VOID WINAPI WakeAllConditionVariable(PCONDITION_VARIABLE ConditionVariable)
Definition: sync.c:137
#define dprintf
Definition: regdump.c:33

Referenced by compound_encode_send_decode(), and nfs41_recover_sequence_flags().

◆ nfs41_recovery_start_or_wait()

bool_t nfs41_recovery_start_or_wait ( IN nfs41_client client)

Definition at line 34 of file recovery.c.

36{
38
39 EnterCriticalSection(&client->recovery.lock);
40
41 if (!client->recovery.in_recovery) {
42 dprintf(1, "Entering recovery mode for client %llu\n", client->clnt_id);
43 client->recovery.in_recovery = TRUE;
44 } else {
45 status = FALSE;
46 dprintf(1, "Waiting for recovery of client %llu\n", client->clnt_id);
47 while (client->recovery.in_recovery)
48 SleepConditionVariableCS(&client->recovery.cond,
49 &client->recovery.lock, INFINITE);
50 dprintf(1, "Woke up after recovery of client %llu\n", client->clnt_id);
51 }
52
53 LeaveCriticalSection(&client->recovery.lock);
54 return status;
55}
BOOL WINAPI SleepConditionVariableCS(PCONDITION_VARIABLE ConditionVariable, PCRITICAL_SECTION CriticalSection, DWORD Timeout)
Definition: sync.c:105
#define INFINITE
Definition: serial.h:102

Referenced by compound_encode_send_decode(), and nfs41_recover_sequence_flags().