Commit 1372a313 authored by Trond Myklebust's avatar Trond Myklebust

Merge branch 'bugfixes'

* bugfixes:
  NFS: Ensure we set NFS_CONTEXT_RESEND_WRITES when requeuing writes
  pNFS: Fix a memory leak when attempted pnfs fails
  NFS: Ensure that we update the sequence id under the slot table lock
  nfs: Initialize cb_sequenceres information before validate_seqid()
  nfs: Only update callback sequnce id when CB_SEQUENCE success
  NFSv4: nfs4_handle_delegation_recall_error should ignore EAGAIN
parents 775f06ab c7070113
...@@ -327,10 +327,8 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args) ...@@ -327,10 +327,8 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args)
dprintk("%s slot table seqid: %u\n", __func__, slot->seq_nr); dprintk("%s slot table seqid: %u\n", __func__, slot->seq_nr);
/* Normal */ /* Normal */
if (likely(args->csa_sequenceid == slot->seq_nr + 1)) { if (likely(args->csa_sequenceid == slot->seq_nr + 1))
slot->seq_nr++;
goto out_ok; goto out_ok;
}
/* Replay */ /* Replay */
if (args->csa_sequenceid == slot->seq_nr) { if (args->csa_sequenceid == slot->seq_nr) {
...@@ -418,6 +416,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, ...@@ -418,6 +416,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
struct cb_process_state *cps) struct cb_process_state *cps)
{ {
struct nfs4_slot_table *tbl; struct nfs4_slot_table *tbl;
struct nfs4_slot *slot;
struct nfs_client *clp; struct nfs_client *clp;
int i; int i;
__be32 status = htonl(NFS4ERR_BADSESSION); __be32 status = htonl(NFS4ERR_BADSESSION);
...@@ -429,25 +428,32 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, ...@@ -429,25 +428,32 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
if (!(clp->cl_session->flags & SESSION4_BACK_CHAN)) if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
goto out; goto out;
tbl = &clp->cl_session->bc_slot_table; tbl = &clp->cl_session->bc_slot_table;
slot = tbl->slots + args->csa_slotid;
spin_lock(&tbl->slot_tbl_lock); spin_lock(&tbl->slot_tbl_lock);
/* state manager is resetting the session */ /* state manager is resetting the session */
if (test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state)) { if (test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state)) {
spin_unlock(&tbl->slot_tbl_lock);
status = htonl(NFS4ERR_DELAY); status = htonl(NFS4ERR_DELAY);
/* Return NFS4ERR_BADSESSION if we're draining the session /* Return NFS4ERR_BADSESSION if we're draining the session
* in order to reset it. * in order to reset it.
*/ */
if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state)) if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
status = htonl(NFS4ERR_BADSESSION); status = htonl(NFS4ERR_BADSESSION);
goto out; goto out_unlock;
} }
status = validate_seqid(&clp->cl_session->bc_slot_table, args); memcpy(&res->csr_sessionid, &args->csa_sessionid,
spin_unlock(&tbl->slot_tbl_lock); sizeof(res->csr_sessionid));
res->csr_sequenceid = args->csa_sequenceid;
res->csr_slotid = args->csa_slotid;
res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
status = validate_seqid(tbl, args);
if (status) if (status)
goto out; goto out_unlock;
cps->slotid = args->csa_slotid; cps->slotid = args->csa_slotid;
...@@ -458,15 +464,17 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, ...@@ -458,15 +464,17 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
*/ */
if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) { if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) {
status = htonl(NFS4ERR_DELAY); status = htonl(NFS4ERR_DELAY);
goto out; goto out_unlock;
} }
memcpy(&res->csr_sessionid, &args->csa_sessionid, /*
sizeof(res->csr_sessionid)); * RFC5661 20.9.3
res->csr_sequenceid = args->csa_sequenceid; * If CB_SEQUENCE returns an error, then the state of the slot
res->csr_slotid = args->csa_slotid; * (sequence ID, cached reply) MUST NOT change.
res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; */
res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1; slot->seq_nr++;
out_unlock:
spin_unlock(&tbl->slot_tbl_lock);
out: out:
cps->clp = clp; /* put in nfs4_callback_compound */ cps->clp = clp; /* put in nfs4_callback_compound */
......
...@@ -1678,6 +1678,7 @@ static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct ...@@ -1678,6 +1678,7 @@ static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct
"%d.\n", __func__, err); "%d.\n", __func__, err);
case 0: case 0:
case -ENOENT: case -ENOENT:
case -EAGAIN:
case -ESTALE: case -ESTALE:
break; break;
case -NFS4ERR_BADSESSION: case -NFS4ERR_BADSESSION:
......
...@@ -1821,6 +1821,7 @@ int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *hdr) ...@@ -1821,6 +1821,7 @@ int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *hdr)
/* Resend all requests through the MDS */ /* Resend all requests through the MDS */
nfs_pageio_init_write(&pgio, hdr->inode, FLUSH_STABLE, true, nfs_pageio_init_write(&pgio, hdr->inode, FLUSH_STABLE, true,
hdr->completion_ops); hdr->completion_ops);
set_bit(NFS_CONTEXT_RESEND_WRITES, &hdr->args.context->flags);
return nfs_pageio_resend(&pgio, hdr); return nfs_pageio_resend(&pgio, hdr);
} }
EXPORT_SYMBOL_GPL(pnfs_write_done_resend_to_mds); EXPORT_SYMBOL_GPL(pnfs_write_done_resend_to_mds);
...@@ -1865,6 +1866,7 @@ pnfs_write_through_mds(struct nfs_pageio_descriptor *desc, ...@@ -1865,6 +1866,7 @@ pnfs_write_through_mds(struct nfs_pageio_descriptor *desc,
mirror->pg_recoalesce = 1; mirror->pg_recoalesce = 1;
} }
nfs_pgio_data_destroy(hdr); nfs_pgio_data_destroy(hdr);
hdr->release(hdr);
} }
static enum pnfs_try_status static enum pnfs_try_status
...@@ -1979,6 +1981,7 @@ pnfs_read_through_mds(struct nfs_pageio_descriptor *desc, ...@@ -1979,6 +1981,7 @@ pnfs_read_through_mds(struct nfs_pageio_descriptor *desc,
mirror->pg_recoalesce = 1; mirror->pg_recoalesce = 1;
} }
nfs_pgio_data_destroy(hdr); nfs_pgio_data_destroy(hdr);
hdr->release(hdr);
} }
/* /*
......
...@@ -1289,6 +1289,7 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr, ...@@ -1289,6 +1289,7 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr,
static void nfs_redirty_request(struct nfs_page *req) static void nfs_redirty_request(struct nfs_page *req)
{ {
nfs_mark_request_dirty(req); nfs_mark_request_dirty(req);
set_bit(NFS_CONTEXT_RESEND_WRITES, &req->wb_context->flags);
nfs_unlock_request(req); nfs_unlock_request(req);
nfs_end_page_writeback(req); nfs_end_page_writeback(req);
nfs_release_request(req); nfs_release_request(req);
......
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