Commit 69d206b5 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4.1: If slot allocation fails due to OOM, retry more quickly

If the NFSv4.1 session slot allocation fails due to an ENOMEM condition,
then set the task->tk_timeout to 1/4 second to ensure that we do retry
the slot allocation more quickly.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent ac074835
...@@ -662,7 +662,7 @@ static struct nfs4_slot *nfs4_find_or_create_slot(struct nfs4_slot_table *tbl, ...@@ -662,7 +662,7 @@ static struct nfs4_slot *nfs4_find_or_create_slot(struct nfs4_slot_table *tbl,
return slot; return slot;
p = &slot->next; p = &slot->next;
} }
return NULL; return ERR_PTR(-ENOMEM);
} }
/* /*
...@@ -676,7 +676,7 @@ static struct nfs4_slot *nfs4_find_or_create_slot(struct nfs4_slot_table *tbl, ...@@ -676,7 +676,7 @@ static struct nfs4_slot *nfs4_find_or_create_slot(struct nfs4_slot_table *tbl,
*/ */
static struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl) static struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl)
{ {
struct nfs4_slot *ret = NULL; struct nfs4_slot *ret = ERR_PTR(-EBUSY);
u32 slotid; u32 slotid;
dprintk("--> %s used_slots=%04lx highest_used=%u max_slots=%u\n", dprintk("--> %s used_slots=%04lx highest_used=%u max_slots=%u\n",
...@@ -686,7 +686,7 @@ static struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl) ...@@ -686,7 +686,7 @@ static struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl)
if (slotid > tbl->max_slotid) if (slotid > tbl->max_slotid)
goto out; goto out;
ret = nfs4_find_or_create_slot(tbl, slotid, 1, GFP_NOWAIT); ret = nfs4_find_or_create_slot(tbl, slotid, 1, GFP_NOWAIT);
if (ret == NULL) if (IS_ERR(ret))
goto out; goto out;
__set_bit(slotid, tbl->used_slots); __set_bit(slotid, tbl->used_slots);
if (slotid > tbl->highest_used_slotid || if (slotid > tbl->highest_used_slotid ||
...@@ -698,7 +698,7 @@ static struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl) ...@@ -698,7 +698,7 @@ static struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl)
out: out:
dprintk("<-- %s used_slots=%04lx highest_used=%d slotid=%d \n", dprintk("<-- %s used_slots=%04lx highest_used=%d slotid=%d \n",
__func__, tbl->used_slots[0], tbl->highest_used_slotid, __func__, tbl->used_slots[0], tbl->highest_used_slotid,
ret ? ret->slot_nr : -1); !IS_ERR(ret) ? ret->slot_nr : -1);
return ret; return ret;
} }
...@@ -727,6 +727,8 @@ int nfs41_setup_sequence(struct nfs4_session *session, ...@@ -727,6 +727,8 @@ int nfs41_setup_sequence(struct nfs4_session *session,
tbl = &session->fc_slot_table; tbl = &session->fc_slot_table;
task->tk_timeout = 0;
spin_lock(&tbl->slot_tbl_lock); spin_lock(&tbl->slot_tbl_lock);
if (test_bit(NFS4_SESSION_DRAINING, &session->session_state) && if (test_bit(NFS4_SESSION_DRAINING, &session->session_state) &&
!rpc_task_has_priority(task, RPC_PRIORITY_PRIVILEGED)) { !rpc_task_has_priority(task, RPC_PRIORITY_PRIVILEGED)) {
...@@ -746,7 +748,10 @@ int nfs41_setup_sequence(struct nfs4_session *session, ...@@ -746,7 +748,10 @@ int nfs41_setup_sequence(struct nfs4_session *session,
} }
slot = nfs4_alloc_slot(tbl); slot = nfs4_alloc_slot(tbl);
if (slot == NULL) { if (IS_ERR(slot)) {
/* If out of memory, try again in 1/4 second */
if (slot == ERR_PTR(-ENOMEM))
task->tk_timeout = HZ >> 2;
rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
spin_unlock(&tbl->slot_tbl_lock); spin_unlock(&tbl->slot_tbl_lock);
dprintk("<-- %s: no free slots\n", __func__); dprintk("<-- %s: no free slots\n", __func__);
...@@ -5778,7 +5783,7 @@ static int nfs4_grow_slot_table(struct nfs4_slot_table *tbl, ...@@ -5778,7 +5783,7 @@ static int nfs4_grow_slot_table(struct nfs4_slot_table *tbl,
{ {
if (max_reqs <= tbl->max_slots) if (max_reqs <= tbl->max_slots)
return 0; return 0;
if (nfs4_find_or_create_slot(tbl, max_reqs - 1, ivalue, GFP_NOFS)) if (!IS_ERR(nfs4_find_or_create_slot(tbl, max_reqs - 1, ivalue, GFP_NOFS)))
return 0; return 0;
return -ENOMEM; return -ENOMEM;
} }
......
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