recovery xdr for free_stateid and test_stateid

This commit is contained in:
Olga Kornievskaia 2011-11-02 11:58:19 -04:00
parent 7efeb31a16
commit ed2ec18d2d
3 changed files with 168 additions and 3 deletions

View file

@ -1851,6 +1851,75 @@ out:
return status; return status;
} }
enum nfsstat4 nfs41_free_stateid(
IN nfs41_session *session,
IN stateid4 *stateid)
{
enum nfsstat4 status;
nfs41_compound compound;
nfs_argop4 argops[2];
nfs_resop4 resops[2];
nfs41_sequence_args sequence_args;
nfs41_sequence_res sequence_res;
nfs41_free_stateid_args freestateid_args;
nfs41_free_stateid_res freestateid_res;
compound_init(&compound, argops, resops, "free_stateid");
compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
status = nfs41_session_sequence(&sequence_args, session, 0);
if (status)
goto out;
compound_add_op(&compound, OP_FREE_STATEID, &freestateid_args, &freestateid_res);
freestateid_args.stateid = stateid;
status = compound_encode_send_decode(session, &compound, FALSE);
if (status)
goto out;
compound_error(status = compound.res.status);
out:
return status;
}
enum nfsstat4 nfs41_test_stateid(
IN nfs41_session *session,
IN stateid_arg *stateid_array,
IN uint32_t count,
OUT uint32_t *status_array)
{
enum nfsstat4 status;
nfs41_compound compound;
nfs_argop4 argops[2];
nfs_resop4 resops[2];
nfs41_sequence_args sequence_args;
nfs41_sequence_res sequence_res;
nfs41_test_stateid_args teststateid_args;
nfs41_test_stateid_res teststateid_res;
compound_init(&compound, argops, resops, "test_stateid");
compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
status = nfs41_session_sequence(&sequence_args, session, 0);
if (status)
goto out;
compound_add_op(&compound, OP_TEST_STATEID, &teststateid_args, &teststateid_res);
teststateid_args.stateids = stateid_array;
teststateid_args.count = count;
teststateid_res.resok.status = status_array;
teststateid_res.resok.count = count;
status = compound_encode_send_decode(session, &compound, FALSE);
if (status)
goto out;
compound_error(status = compound.res.status);
out:
return status;
}
enum nfsstat4 pnfs_rpc_layoutget( enum nfsstat4 pnfs_rpc_layoutget(
IN nfs41_session *session, IN nfs41_session *session,
IN nfs41_path_fh *file, IN nfs41_path_fh *file,

View file

@ -229,7 +229,6 @@ typedef struct __nfs41_destroy_clientid_res {
} nfs41_destroy_clientid_res; } nfs41_destroy_clientid_res;
/* OP_SEQUENCE */ /* OP_SEQUENCE */
typedef struct __nfs41_sequence_args { typedef struct __nfs41_sequence_args {
unsigned char *sa_sessionid; unsigned char *sa_sessionid;
@ -816,6 +815,29 @@ typedef struct __nfs41_want_delegation_res {
/* case NFS4_OK: */ /* case NFS4_OK: */
open_delegation4 *delegation; open_delegation4 *delegation;
} nfs41_want_delegation_res; } nfs41_want_delegation_res;
/* OP_FREE_STATEID */
typedef struct __nfs41_free_stateid_args {
stateid4 *stateid;
} nfs41_free_stateid_args;
typedef struct __nfs41_free_stateid_res {
uint32_t status;
} nfs41_free_stateid_res;
/* OP_TEST_STATEID */
typedef struct __nfs41_test_stateid_args {
uint32_t count;
stateid_arg *stateids; // caller-allocated array
} nfs41_test_stateid_args;
typedef struct __nfs41_test_stateid_res {
uint32_t status;
struct {
uint32_t count;
uint32_t *status; // caller-allocated array
} resok;
} nfs41_test_stateid_res;
/* OP_WRITE */ /* OP_WRITE */
@ -1207,6 +1229,16 @@ int nfs41_secinfo_noname(
IN nfs41_path_fh *file, IN nfs41_path_fh *file,
OUT nfs41_secinfo_info *secinfo); OUT nfs41_secinfo_info *secinfo);
enum nfsstat4 nfs41_free_stateid(
IN nfs41_session *session,
IN stateid4 *stateid);
enum nfsstat4 nfs41_test_stateid(
IN nfs41_session *session,
IN stateid_arg *stateid_array,
IN uint32_t count,
OUT uint32_t *status_array);
enum nfsstat4 pnfs_rpc_layoutget( enum nfsstat4 pnfs_rpc_layoutget(
IN nfs41_session *session, IN nfs41_session *session,
IN nfs41_path_fh *file, IN nfs41_path_fh *file,

View file

@ -2738,6 +2738,70 @@ static bool_t decode_op_want_delegation(
} }
/*
* OP_FREE_STATEID
*/
static bool_t encode_op_free_stateid(
XDR *xdr,
nfs_argop4 *argop)
{
nfs41_free_stateid_args *args = (nfs41_free_stateid_args*)argop->arg;
if (unexpected_op(argop->op, OP_FREE_STATEID))
return FALSE;
return xdr_stateid4(xdr, args->stateid);
}
static bool_t decode_op_free_stateid(
XDR *xdr,
nfs_resop4 *resop)
{
nfs41_free_stateid_res *res = (nfs41_free_stateid_res*)resop->res;
if (unexpected_op(resop->op, OP_FREE_STATEID))
return FALSE;
return xdr_u_int32_t(xdr, &res->status);
}
/*
* OP_TEST_STATEID
*/
static bool_t encode_op_test_stateid(
XDR *xdr,
nfs_argop4 *argop)
{
nfs41_test_stateid_args *args = (nfs41_test_stateid_args*)argop->arg;
if (unexpected_op(argop->op, OP_TEST_STATEID))
return FALSE;
return xdr_array(xdr, (char**)&args->stateids, &args->count,
args->count, sizeof(stateid_arg), (xdrproc_t)xdr_stateid4);
}
static bool_t decode_op_test_stateid(
XDR *xdr,
nfs_resop4 *resop)
{
nfs41_test_stateid_res *res = (nfs41_test_stateid_res*)resop->res;
if (unexpected_op(resop->op, OP_TEST_STATEID))
return FALSE;
if (!xdr_u_int32_t(xdr, &res->status))
return FALSE;
if (res->status == NFS4_OK) {
return xdr_array(xdr, (char**)&res->resok.status, &res->resok.count,
res->resok.count, sizeof(uint32_t), (xdrproc_t)xdr_u_int32_t);
}
return TRUE;
}
/* /*
* OP_WRITE * OP_WRITE
*/ */
@ -3472,7 +3536,7 @@ static const op_table_entry g_op_table[] = {
{ encode_op_exchange_id, decode_op_exchange_id }, /* OP_EXCHANGE_ID = 42 */ { encode_op_exchange_id, decode_op_exchange_id }, /* OP_EXCHANGE_ID = 42 */
{ encode_op_create_session, decode_op_create_session }, /* OP_CREATE_SESSION = 43 */ { encode_op_create_session, decode_op_create_session }, /* OP_CREATE_SESSION = 43 */
{ encode_op_destroy_session, decode_op_destroy_session }, /* OP_DESTROY_SESSION = 44 */ { encode_op_destroy_session, decode_op_destroy_session }, /* OP_DESTROY_SESSION = 44 */
{ NULL, NULL }, /* OP_FREE_STATEID = 45 */ { encode_op_free_stateid, decode_op_free_stateid }, /* OP_FREE_STATEID = 45 */
{ NULL, NULL }, /* OP_GET_DIR_DELEGATION = 46 */ { NULL, NULL }, /* OP_GET_DIR_DELEGATION = 46 */
{ encode_op_getdeviceinfo, decode_op_getdeviceinfo }, /* OP_GETDEVICEINFO = 47 */ { encode_op_getdeviceinfo, decode_op_getdeviceinfo }, /* OP_GETDEVICEINFO = 47 */
{ NULL, NULL }, /* OP_GETDEVICELIST = 48 */ { NULL, NULL }, /* OP_GETDEVICELIST = 48 */
@ -3482,7 +3546,7 @@ static const op_table_entry g_op_table[] = {
{ encode_op_secinfo_noname, decode_op_secinfo_noname }, /* OP_SECINFO_NO_NAME = 52 */ { encode_op_secinfo_noname, decode_op_secinfo_noname }, /* OP_SECINFO_NO_NAME = 52 */
{ encode_op_sequence, decode_op_sequence }, /* OP_SEQUENCE = 53 */ { encode_op_sequence, decode_op_sequence }, /* OP_SEQUENCE = 53 */
{ NULL, NULL }, /* OP_SET_SSV = 54 */ { NULL, NULL }, /* OP_SET_SSV = 54 */
{ NULL, NULL }, /* OP_TEST_STATEID = 55 */ { encode_op_test_stateid, decode_op_test_stateid }, /* OP_TEST_STATEID = 55 */
{ encode_op_want_delegation, decode_op_want_delegation }, /* OP_WANT_DELEGATION = 56 */ { encode_op_want_delegation, decode_op_want_delegation }, /* OP_WANT_DELEGATION = 56 */
{ encode_op_destroy_clientid, decode_op_destroy_clientid }, /* OP_DESTROY_CLIENTID = 57 */ { encode_op_destroy_clientid, decode_op_destroy_clientid }, /* OP_DESTROY_CLIENTID = 57 */
{ encode_op_reclaim_complete, decode_op_reclaim_complete }, /* OP_RECLAIM_COMPLETE = 58 */ { encode_op_reclaim_complete, decode_op_reclaim_complete }, /* OP_RECLAIM_COMPLETE = 58 */