aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2009-12-05 19:32:11 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-12-05 19:32:11 -0500
commitf26468fb9384e73fb357d2e84d3e9c88c7d1129d (patch)
tree453ab2ea84473a1f52d0400c628d8ad9fd95d8c8 /fs/nfs/nfs4proc.c
parentda6ebfe34a3921cfb47b938fb819abc78c6080e5 (diff)
NFSv41: Fix nfs4_proc_create_session
We should not assume that nfs41_init_clientid() will always want to initialise the session. If it is being called due to a server reboot, then we just want to reset the session after re-establishing the clientid. Fix this by getting rid of the 'reset' parameter in nfs4_proc_create_session(), and instead relying on whether or not the session slot table pointer is non-NULL. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c60
1 files changed, 24 insertions, 36 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 206ce30a595d..be96d28baccf 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4501,7 +4501,6 @@ static int nfs4_reset_slot_table(struct nfs4_slot_table *tbl, int max_slots,
4501 spin_lock(&tbl->slot_tbl_lock); 4501 spin_lock(&tbl->slot_tbl_lock);
4502 for (i = 0; i < max_slots; ++i) 4502 for (i = 0; i < max_slots; ++i)
4503 tbl->slots[i].seq_nr = ivalue; 4503 tbl->slots[i].seq_nr = ivalue;
4504 tbl->highest_used_slotid = -1;
4505 spin_unlock(&tbl->slot_tbl_lock); 4504 spin_unlock(&tbl->slot_tbl_lock);
4506 dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, 4505 dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
4507 tbl, tbl->slots, tbl->max_slots); 4506 tbl, tbl->slots, tbl->max_slots);
@@ -4552,7 +4551,6 @@ static void nfs4_destroy_slot_tables(struct nfs4_session *session)
4552static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, 4551static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
4553 int max_slots, int ivalue) 4552 int max_slots, int ivalue)
4554{ 4553{
4555 int i;
4556 struct nfs4_slot *slot; 4554 struct nfs4_slot *slot;
4557 int ret = -ENOMEM; 4555 int ret = -ENOMEM;
4558 4556
@@ -4563,18 +4561,9 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
4563 slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL); 4561 slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL);
4564 if (!slot) 4562 if (!slot)
4565 goto out; 4563 goto out;
4566 for (i = 0; i < max_slots; ++i)
4567 slot[i].seq_nr = ivalue;
4568 ret = 0; 4564 ret = 0;
4569 4565
4570 spin_lock(&tbl->slot_tbl_lock); 4566 spin_lock(&tbl->slot_tbl_lock);
4571 if (tbl->slots != NULL) {
4572 spin_unlock(&tbl->slot_tbl_lock);
4573 dprintk("%s: slot table already initialized. tbl=%p slots=%p\n",
4574 __func__, tbl, tbl->slots);
4575 WARN_ON(1);
4576 goto out_free;
4577 }
4578 tbl->max_slots = max_slots; 4567 tbl->max_slots = max_slots;
4579 tbl->slots = slot; 4568 tbl->slots = slot;
4580 tbl->highest_used_slotid = -1; /* no slot is currently used */ 4569 tbl->highest_used_slotid = -1; /* no slot is currently used */
@@ -4584,10 +4573,6 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
4584out: 4573out:
4585 dprintk("<-- %s: return %d\n", __func__, ret); 4574 dprintk("<-- %s: return %d\n", __func__, ret);
4586 return ret; 4575 return ret;
4587
4588out_free:
4589 kfree(slot);
4590 goto out;
4591} 4576}
4592 4577
4593/* 4578/*
@@ -4595,17 +4580,24 @@ out_free:
4595 */ 4580 */
4596static int nfs4_init_slot_tables(struct nfs4_session *session) 4581static int nfs4_init_slot_tables(struct nfs4_session *session)
4597{ 4582{
4598 int status; 4583 struct nfs4_slot_table *tbl;
4584 int status = 0;
4599 4585
4600 status = nfs4_init_slot_table(&session->fc_slot_table, 4586 tbl = &session->fc_slot_table;
4601 session->fc_attrs.max_reqs, 1); 4587 if (tbl->slots == NULL) {
4602 if (status) 4588 status = nfs4_init_slot_table(tbl,
4603 return status; 4589 session->fc_attrs.max_reqs, 1);
4590 if (status)
4591 return status;
4592 }
4604 4593
4605 status = nfs4_init_slot_table(&session->bc_slot_table, 4594 tbl = &session->bc_slot_table;
4606 session->bc_attrs.max_reqs, 0); 4595 if (tbl->slots == NULL) {
4607 if (status) 4596 status = nfs4_init_slot_table(tbl,
4608 nfs4_destroy_slot_tables(session); 4597 session->bc_attrs.max_reqs, 0);
4598 if (status)
4599 nfs4_destroy_slot_tables(session);
4600 }
4609 4601
4610 return status; 4602 return status;
4611} 4603}
@@ -4784,7 +4776,7 @@ static int _nfs4_proc_create_session(struct nfs_client *clp)
4784 * It is the responsibility of the caller to verify the session is 4776 * It is the responsibility of the caller to verify the session is
4785 * expired before calling this routine. 4777 * expired before calling this routine.
4786 */ 4778 */
4787int nfs4_proc_create_session(struct nfs_client *clp, int reset) 4779int nfs4_proc_create_session(struct nfs_client *clp)
4788{ 4780{
4789 int status; 4781 int status;
4790 unsigned *ptr; 4782 unsigned *ptr;
@@ -4797,12 +4789,13 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset)
4797 if (status) 4789 if (status)
4798 goto out; 4790 goto out;
4799 4791
4800 /* Init or reset the fore channel */ 4792 /* Init and reset the fore channel */
4801 if (reset) 4793 status = nfs4_init_slot_tables(session);
4802 status = nfs4_reset_slot_tables(session); 4794 dprintk("slot table initialization returned %d\n", status);
4803 else 4795 if (status)
4804 status = nfs4_init_slot_tables(session); 4796 goto out;
4805 dprintk("fore channel slot table initialization returned %d\n", status); 4797 status = nfs4_reset_slot_tables(session);
4798 dprintk("slot table reset returned %d\n", status);
4806 if (status) 4799 if (status)
4807 goto out; 4800 goto out;
4808 4801
@@ -4810,10 +4803,6 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset)
4810 dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__, 4803 dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__,
4811 clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); 4804 clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]);
4812 4805
4813 if (reset)
4814 /* Lease time is aleady set */
4815 goto out;
4816
4817 /* Get the lease time */ 4806 /* Get the lease time */
4818 status = nfs4_proc_get_lease_time(clp, &fsinfo); 4807 status = nfs4_proc_get_lease_time(clp, &fsinfo);
4819 if (status == 0) { 4808 if (status == 0) {
@@ -4821,7 +4810,6 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset)
4821 spin_lock(&clp->cl_lock); 4810 spin_lock(&clp->cl_lock);
4822 clp->cl_lease_time = fsinfo.lease_time * HZ; 4811 clp->cl_lease_time = fsinfo.lease_time * HZ;
4823 clp->cl_last_renewal = jiffies; 4812 clp->cl_last_renewal = jiffies;
4824 clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state);
4825 spin_unlock(&clp->cl_lock); 4813 spin_unlock(&clp->cl_lock);
4826 4814
4827 nfs4_schedule_state_renewal(clp); 4815 nfs4_schedule_state_renewal(clp);