Commit 050047ce authored by Ricardo Labiaga's avatar Ricardo Labiaga Committed by Benny Halevy

nfs41: Backchannel: Refactor nfs4_init_slot_table()

Generalize nfs4_init_slot_table() so it can be used to initialize the
backchannel slot table in addition to the forechannel slot table.
Signed-off-by: default avatarRicardo Labiaga <Ricardo.Labiaga@netapp.com>
Signed-off-by: default avatarBenny Halevy <bhalevy@panasas.com>
parent b73dafa7
...@@ -4420,23 +4420,22 @@ static int nfs4_reset_slot_tables(struct nfs4_session *session) ...@@ -4420,23 +4420,22 @@ static int nfs4_reset_slot_tables(struct nfs4_session *session)
/* /*
* Initialize slot table * Initialize slot table
*/ */
static int nfs4_init_slot_table(struct nfs4_session *session) static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
int max_slots, int ivalue)
{ {
struct nfs4_slot_table *tbl = &session->fc_slot_table; int i;
int i, max_slots = session->fc_attrs.max_reqs;
struct nfs4_slot *slot; struct nfs4_slot *slot;
int ret = -ENOMEM; int ret = -ENOMEM;
BUG_ON(max_slots > NFS4_MAX_SLOT_TABLE); BUG_ON(max_slots > NFS4_MAX_SLOT_TABLE);
dprintk("--> %s: max_reqs=%u\n", __func__, dprintk("--> %s: max_reqs=%u\n", __func__, max_slots);
session->fc_attrs.max_reqs);
slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL); slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL);
if (!slot) if (!slot)
goto out; goto out;
for (i = 0; i < max_slots; ++i) for (i = 0; i < max_slots; ++i)
slot[i].seq_nr = 1; slot[i].seq_nr = ivalue;
ret = 0; ret = 0;
spin_lock(&tbl->slot_tbl_lock); spin_lock(&tbl->slot_tbl_lock);
...@@ -4456,11 +4455,24 @@ static int nfs4_init_slot_table(struct nfs4_session *session) ...@@ -4456,11 +4455,24 @@ static int nfs4_init_slot_table(struct nfs4_session *session)
out: out:
dprintk("<-- %s: return %d\n", __func__, ret); dprintk("<-- %s: return %d\n", __func__, ret);
return ret; return ret;
out_free: out_free:
kfree(slot); kfree(slot);
goto out; goto out;
} }
/*
* Initialize the forechannel and backchannel tables
*/
static int nfs4_init_slot_tables(struct nfs4_session *session)
{
int status;
status = nfs4_init_slot_table(&session->fc_slot_table,
session->fc_attrs.max_reqs, 1);
return status;
}
/* Destroy the slot table */ /* Destroy the slot table */
static void nfs4_destroy_slot_table(struct nfs4_session *session) static void nfs4_destroy_slot_table(struct nfs4_session *session)
{ {
...@@ -4657,7 +4669,7 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset) ...@@ -4657,7 +4669,7 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset)
if (reset) if (reset)
status = nfs4_reset_slot_tables(session); status = nfs4_reset_slot_tables(session);
else else
status = nfs4_init_slot_table(session); status = nfs4_init_slot_tables(session);
dprintk("fore channel slot table initialization returned %d\n", status); dprintk("fore channel slot table initialization returned %d\n", status);
if (status) if (status)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment