#include "internal.h"
#include "nfs4_fs.h"
#include "nfs40.h"
+#include "nfs4session.h"
#include "nfs4trace.h"
static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata)
nfs4_sequence_done(task, data->seq_res);
}
+static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res)
+{
+ struct nfs4_slot *slot = res->sr_slot;
+ struct nfs4_slot_table *tbl;
+
+ tbl = slot->table;
+ spin_lock(&tbl->slot_tbl_lock);
+ if (!nfs41_wake_and_assign_slot(tbl, slot))
+ nfs4_free_slot(tbl, slot);
+ spin_unlock(&tbl->slot_tbl_lock);
+
+ res->sr_slot = NULL;
+}
+
+static int nfs40_sequence_done(struct rpc_task *task,
+ struct nfs4_sequence_res *res)
+{
+ if (res->sr_slot != NULL)
+ nfs40_sequence_free_slot(res);
+ return 1;
+}
+
static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
{
if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL)
.rpc_call_done = nfs40_call_sync_done,
};
+static const struct nfs4_sequence_slot_ops nfs40_sequence_slot_ops = {
+ .process = nfs40_sequence_done,
+ .done = nfs40_sequence_done,
+ .free_slot = nfs40_sequence_free_slot,
+};
+
static const struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
.owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT,
.state_flag_bit = NFS_STATE_RECLAIM_REBOOT,
.test_and_free_expired = nfs40_test_and_free_expired_stateid,
.alloc_seqid = nfs_alloc_seqid,
.call_sync_ops = &nfs40_call_sync_ops,
+ .sequence_slot_ops = &nfs40_sequence_slot_ops,
.reboot_recovery_ops = &nfs40_reboot_recovery_ops,
.nograce_recovery_ops = &nfs40_nograce_recovery_ops,
.state_renewal_ops = &nfs40_state_renewal_ops,
void (*session_trunk)(struct rpc_clnt *clnt,
struct rpc_xprt *xprt, void *data);
const struct rpc_call_ops *call_sync_ops;
+ const struct nfs4_sequence_slot_ops *sequence_slot_ops;
const struct nfs4_state_recovery_ops *reboot_recovery_ops;
const struct nfs4_state_recovery_ops *nograce_recovery_ops;
const struct nfs4_state_maintenance_ops *state_renewal_ops;
const struct cred *cred;
};
+struct nfs4_sequence_slot_ops {
+ int (*process)(struct rpc_task *, struct nfs4_sequence_res *);
+ int (*done)(struct rpc_task *, struct nfs4_sequence_res *);
+ void (*free_slot)(struct nfs4_sequence_res *);
+};
+
struct nfs4_state_maintenance_ops {
int (*sched_state_renewal)(struct nfs_client *, const struct cred *, unsigned);
const struct cred * (*get_state_renewal_cred)(struct nfs_client *);
struct nfs4_sequence_res *res);
extern void nfs4_init_sequence(struct nfs_client *clp, struct nfs4_sequence_args *,
struct nfs4_sequence_res *, int, int);
-extern int nfs40_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res);
extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, const struct cred *, struct nfs4_setclientid_res *);
extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, const struct cred *);
extern void renew_lease(const struct nfs_server *server, unsigned long timestamp);
args->sa_privileged = privileged;
res->sr_slot = NULL;
-}
-
-static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res)
-{
- struct nfs4_slot *slot = res->sr_slot;
- struct nfs4_slot_table *tbl;
-
- tbl = slot->table;
- spin_lock(&tbl->slot_tbl_lock);
- if (!nfs41_wake_and_assign_slot(tbl, slot))
- nfs4_free_slot(tbl, slot);
- spin_unlock(&tbl->slot_tbl_lock);
-
- res->sr_slot = NULL;
-}
-
-int nfs40_sequence_done(struct rpc_task *task,
- struct nfs4_sequence_res *res)
-{
- if (res->sr_slot != NULL)
- nfs40_sequence_free_slot(res);
- return 1;
+ res->sr_slot_ops = clp->cl_mvops->sequence_slot_ops;
}
#if defined(CONFIG_NFS_V4_1)
}
EXPORT_SYMBOL_GPL(nfs41_sequence_done);
-static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
-{
- if (res->sr_slot == NULL)
- return 1;
- if (res->sr_slot->table->session != NULL)
- return nfs41_sequence_process(task, res);
- return nfs40_sequence_done(task, res);
-}
-
-static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res)
-{
- if (res->sr_slot != NULL) {
- if (res->sr_slot->table->session != NULL)
- nfs41_sequence_free_slot(res);
- else
- nfs40_sequence_free_slot(res);
- }
-}
-
-int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
-{
- if (res->sr_slot == NULL)
- return 1;
- if (!res->sr_slot->table->session)
- return nfs40_sequence_done(task, res);
- return nfs41_sequence_done(task, res);
-}
-EXPORT_SYMBOL_GPL(nfs4_sequence_done);
-
static void nfs41_call_sync_prepare(struct rpc_task *task, void *calldata)
{
struct nfs4_call_sync_data *data = calldata;
.rpc_call_done = nfs41_call_sync_done,
};
-#else /* !CONFIG_NFS_V4_1 */
-
-static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
-{
- return nfs40_sequence_done(task, res);
-}
-
-static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res)
-{
- if (res->sr_slot != NULL)
- nfs40_sequence_free_slot(res);
-}
-
-int nfs4_sequence_done(struct rpc_task *task,
- struct nfs4_sequence_res *res)
-{
- return nfs40_sequence_done(task, res);
-}
-EXPORT_SYMBOL_GPL(nfs4_sequence_done);
#endif /* !CONFIG_NFS_V4_1 */
res->sr_slot = slot;
}
+static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res)
+{
+ if (res->sr_slot != NULL)
+ res->sr_slot_ops->free_slot(res);
+}
+
+static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
+{
+ if (res->sr_slot == NULL)
+ return 1;
+ return res->sr_slot_ops->process(task, res);
+}
+
+int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
+{
+ if (res->sr_slot == NULL)
+ return 1;
+ return res->sr_slot_ops->done(task, res);
+}
+EXPORT_SYMBOL_GPL(nfs4_sequence_done);
+
+
int nfs4_setup_sequence(struct nfs_client *client,
struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res,
{
struct nfs4_opendata *data = calldata;
- nfs40_sequence_done(task, &data->c_res.seq_res);
+ data->c_res.seq_res.sr_slot_ops->done(task, &data->c_res.seq_res);
data->rpc_status = task->tk_status;
if (data->rpc_status == 0) {
#if defined(CONFIG_NFS_V4_1)
+static const struct nfs4_sequence_slot_ops nfs41_sequence_slot_ops = {
+ .process = nfs41_sequence_process,
+ .done = nfs41_sequence_done,
+ .free_slot = nfs41_sequence_free_slot,
+};
+
static const struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = {
.owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT,
.state_flag_bit = NFS_STATE_RECLAIM_REBOOT,
.alloc_seqid = nfs_alloc_no_seqid,
.session_trunk = nfs4_test_session_trunk,
.call_sync_ops = &nfs41_call_sync_ops,
+ .sequence_slot_ops = &nfs41_sequence_slot_ops,
.reboot_recovery_ops = &nfs41_reboot_recovery_ops,
.nograce_recovery_ops = &nfs41_nograce_recovery_ops,
.state_renewal_ops = &nfs41_state_renewal_ops,
.find_root_sec = nfs41_find_root_sec,
.free_lock_state = nfs41_free_lock_state,
.call_sync_ops = &nfs41_call_sync_ops,
+ .sequence_slot_ops = &nfs41_sequence_slot_ops,
.test_and_free_expired = nfs41_test_and_free_expired_stateid,
.alloc_seqid = nfs_alloc_no_seqid,
.session_trunk = nfs4_test_session_trunk,