提交 8b70484c 编写于 作者: T Tigran Mkrtchyan 提交者: J. Bruce Fields

nfsd41: handle current stateid in open and close

Signed-off-by: NTigran Mkrtchyan <kofemann@gmail.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 19ff0f28
#ifndef _NFSD4_CURRENT_STATE_H
#define _NFSD4_CURRENT_STATE_H
#include "state.h"
#include "xdr4.h"
extern void nfsd4_set_openstateid(struct nfsd4_compound_state *, struct nfsd4_open *);
extern void nfsd4_get_closestateid(struct nfsd4_compound_state *, struct nfsd4_close *);
extern void nfsd4_set_closestateid(struct nfsd4_compound_state *, struct nfsd4_close *);
#endif /* _NFSD4_CURRENT_STATE_H */
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "cache.h" #include "cache.h"
#include "xdr4.h" #include "xdr4.h"
#include "vfs.h" #include "vfs.h"
#include "current_stateid.h"
#define NFSDDBG_FACILITY NFSDDBG_PROC #define NFSDDBG_FACILITY NFSDDBG_PROC
...@@ -1000,6 +1001,8 @@ static inline void nfsd4_increment_op_stats(u32 opnum) ...@@ -1000,6 +1001,8 @@ static inline void nfsd4_increment_op_stats(u32 opnum)
typedef __be32(*nfsd4op_func)(struct svc_rqst *, struct nfsd4_compound_state *, typedef __be32(*nfsd4op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
void *); void *);
typedef u32(*nfsd4op_rsize)(struct svc_rqst *, struct nfsd4_op *op); typedef u32(*nfsd4op_rsize)(struct svc_rqst *, struct nfsd4_op *op);
typedef void(*stateid_setter)(struct nfsd4_compound_state *, void *);
typedef void(*stateid_getter)(struct nfsd4_compound_state *, void *);
enum nfsd4_op_flags { enum nfsd4_op_flags {
ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */ ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */
...@@ -1025,6 +1028,10 @@ enum nfsd4_op_flags { ...@@ -1025,6 +1028,10 @@ enum nfsd4_op_flags {
* the v4.0 case). * the v4.0 case).
*/ */
OP_CACHEME = 1 << 6, OP_CACHEME = 1 << 6,
/*
* These are ops which clear current state id.
*/
OP_CLEAR_STATEID = 1 << 7,
}; };
struct nfsd4_operation { struct nfsd4_operation {
...@@ -1033,6 +1040,8 @@ struct nfsd4_operation { ...@@ -1033,6 +1040,8 @@ struct nfsd4_operation {
char *op_name; char *op_name;
/* Try to get response size before operation */ /* Try to get response size before operation */
nfsd4op_rsize op_rsize_bop; nfsd4op_rsize op_rsize_bop;
stateid_setter op_get_currentstateid;
stateid_getter op_set_currentstateid;
}; };
static struct nfsd4_operation nfsd4_ops[]; static struct nfsd4_operation nfsd4_ops[];
...@@ -1215,13 +1224,23 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, ...@@ -1215,13 +1224,23 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
if (op->status) if (op->status)
goto encode_op; goto encode_op;
if (opdesc->op_func) if (opdesc->op_func) {
if (opdesc->op_get_currentstateid)
opdesc->op_get_currentstateid(cstate, &op->u);
op->status = opdesc->op_func(rqstp, cstate, &op->u); op->status = opdesc->op_func(rqstp, cstate, &op->u);
else } else
BUG_ON(op->status == nfs_ok); BUG_ON(op->status == nfs_ok);
if (!op->status && need_wrongsec_check(rqstp)) if (!op->status) {
op->status = check_nfsd_access(cstate->current_fh.fh_export, rqstp); if (opdesc->op_set_currentstateid)
opdesc->op_set_currentstateid(cstate, &op->u);
if (opdesc->op_flags & OP_CLEAR_STATEID)
cstate->current_stateid = NULL;
if (need_wrongsec_check(rqstp))
op->status = check_nfsd_access(cstate->current_fh.fh_export, rqstp);
}
encode_op: encode_op:
/* Only from SEQUENCE */ /* Only from SEQUENCE */
...@@ -1413,6 +1432,8 @@ static struct nfsd4_operation nfsd4_ops[] = { ...@@ -1413,6 +1432,8 @@ static struct nfsd4_operation nfsd4_ops[] = {
.op_flags = OP_MODIFIES_SOMETHING, .op_flags = OP_MODIFIES_SOMETHING,
.op_name = "OP_CLOSE", .op_name = "OP_CLOSE",
.op_rsize_bop = (nfsd4op_rsize)nfsd4_status_stateid_rsize, .op_rsize_bop = (nfsd4op_rsize)nfsd4_status_stateid_rsize,
.op_get_currentstateid = (stateid_getter)nfsd4_get_closestateid,
.op_set_currentstateid = (stateid_setter)nfsd4_set_closestateid,
}, },
[OP_COMMIT] = { [OP_COMMIT] = {
.op_func = (nfsd4op_func)nfsd4_commit, .op_func = (nfsd4op_func)nfsd4_commit,
...@@ -1483,6 +1504,7 @@ static struct nfsd4_operation nfsd4_ops[] = { ...@@ -1483,6 +1504,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
.op_flags = OP_HANDLES_WRONGSEC | OP_MODIFIES_SOMETHING, .op_flags = OP_HANDLES_WRONGSEC | OP_MODIFIES_SOMETHING,
.op_name = "OP_OPEN", .op_name = "OP_OPEN",
.op_rsize_bop = (nfsd4op_rsize)nfsd4_open_rsize, .op_rsize_bop = (nfsd4op_rsize)nfsd4_open_rsize,
.op_set_currentstateid = (stateid_setter)nfsd4_set_openstateid,
}, },
[OP_OPEN_CONFIRM] = { [OP_OPEN_CONFIRM] = {
.op_func = (nfsd4op_func)nfsd4_open_confirm, .op_func = (nfsd4op_func)nfsd4_open_confirm,
......
...@@ -4695,3 +4695,35 @@ nfs4_state_shutdown(void) ...@@ -4695,3 +4695,35 @@ nfs4_state_shutdown(void)
nfs4_unlock_state(); nfs4_unlock_state();
nfsd4_destroy_callback_queue(); nfsd4_destroy_callback_queue();
} }
static void
get_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid)
{
if (cstate->current_stateid && CURRENT_STATEID(stateid))
memcpy(stateid, cstate->current_stateid, sizeof(stateid_t));
}
static void
put_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid)
{
if (cstate->minorversion)
cstate->current_stateid = stateid;
}
void
nfsd4_set_openstateid(struct nfsd4_compound_state *cstate, struct nfsd4_open *open)
{
put_stateid(cstate, &open->op_stateid);
}
void
nfsd4_get_closestateid(struct nfsd4_compound_state *cstate, struct nfsd4_close *close)
{
get_stateid(cstate, &close->cl_stateid);
}
void
nfsd4_set_closestateid(struct nfsd4_compound_state *cstate, struct nfsd4_close *close)
{
get_stateid(cstate, &close->cl_stateid);
}
...@@ -54,6 +54,7 @@ struct nfsd4_compound_state { ...@@ -54,6 +54,7 @@ struct nfsd4_compound_state {
size_t iovlen; size_t iovlen;
u32 minorversion; u32 minorversion;
u32 status; u32 status;
const stateid_t *current_stateid;
}; };
static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs) static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册