From: Benny Halevy <bhalevy@panasas.com>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org, pnfs@linux-nfs.org
Subject: [PATCH 34/46] nfs41: setup_sequence method
Date: Wed, 4 Mar 2009 02:00:02 +0200 [thread overview]
Message-ID: <1236124802-3915-1-git-send-email-bhalevy@panasas.com> (raw)
In-Reply-To: <49ADBD04.2090002@panasas.com>
From: Andy Adamson <andros@netapp.com>
Allocate a slot in the session slot table and set the sequence op arguments.
Called at the rpc prepare stage.
Add a status to nfs41_sequence_res, initialize it to one so that we catch
rpc level failures which do not go through decode_sequence which sets
the new status field.
Note that upon an rpc level failure, we don't know if the server processed the
sequence operation or not. Proceed as if the server did process the sequence
operation.
Signed-off-by: Rahul Iyer <iyer@netapp.com>
[nfs41: sequence args use slotid]
[nfs41: find slot return slotid]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: remove SEQ4_STATUS_USE_TK_STATUS]
As per 11-14-08 review
[move extern declaration from nfs41: sequence setup/done support]
[removed sa_session definition, changed sa_cache_this into a u8 to reduce footprint]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: rpc_sleep_on slot_tbl_waitq must be called under slot_tbl_lock]
Otherwise there's a race (we've hit) with nfs4_free_slot where
nfs41_setup_sequence sees a full slot table, unlocks slot_tbl_lock,
nfs4_free_slots happen concurrently and call rpc_wake_up_next
where there's nobody to wake up yet, context goes back to
nfs41_setup_sequence which goes to sleep when the slot table
is actually empty now and there's no-one to wake it up anymore.
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
---
fs/nfs/nfs4_fs.h | 10 ++++++++++
fs/nfs/nfs4proc.c | 34 ++++++++++++++++++++++++++++++++--
include/linux/nfs_xdr.h | 5 ++++-
3 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 8e2eaa9..a3e57e1 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -203,10 +203,20 @@ extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops;
extern struct nfs4_state_recovery_ops nfs4_nograce_recovery_ops;
#if defined(CONFIG_NFS_V4_1)
+extern int nfs4_setup_sequence(struct nfs_client *clp,
+ struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
+ int cache_reply, struct rpc_task *task);
extern void nfs4_destroy_session(struct nfs4_session *session);
extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
extern int nfs4_proc_create_session(struct nfs4_session *);
extern int nfs4_proc_destroy_session(struct nfs4_session *);
+#else /* CONFIG_NFS_v4_1 */
+static inline int nfs4_setup_sequence(struct nfs_client *clp,
+ struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
+ int cache_reply, struct rpc_task *task)
+{
+ return 0;
+}
#endif /* CONFIG_NFS_V4_1 */
extern const u32 nfs4_fattr_bitmap[2];
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 14d77f7..898d83b 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -324,6 +324,8 @@ nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid)
* If found, we mark the slot as used, update the highest_used_slotid,
* and respectively set up the sequence operation args.
* The slot number is returned if found, or NFS4_MAX_SLOT_TABLE otherwise.
+ *
+ * Note: must be called with under the slot_tbl_lock.
*/
static u8
nfs4_find_slot(struct nfs4_slot_table *tbl, struct rpc_task *task)
@@ -332,7 +334,6 @@ nfs4_find_slot(struct nfs4_slot_table *tbl, struct rpc_task *task)
u8 ret_id = NFS4_MAX_SLOT_TABLE;
BUILD_BUG_ON((u8)NFS4_MAX_SLOT_TABLE != (int)NFS4_MAX_SLOT_TABLE);
- spin_lock(&tbl->slot_tbl_lock);
dprintk("--> %s used_slots=%04lx highest_used=%d max_slots=%d\n",
__func__, tbl->used_slots[0], tbl->highest_used_slotid,
tbl->max_slots);
@@ -346,7 +347,6 @@ nfs4_find_slot(struct nfs4_slot_table *tbl, struct rpc_task *task)
out:
dprintk("<-- %s used_slots=%04lx highest_used=%d slotid=%d \n",
__func__, tbl->used_slots[0], tbl->highest_used_slotid, ret_id);
- spin_unlock(&tbl->slot_tbl_lock);
return ret_id;
}
@@ -356,12 +356,42 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
int cache_reply,
struct rpc_task *task)
{
+ struct nfs4_slot *slot;
+ struct nfs4_slot_table *tbl;
+ u8 slotid;
+
+ dprintk("--> %s\n", __func__);
/* slot already allocated? */
if (res->sr_slotid != NFS4_MAX_SLOT_TABLE)
return 0;
memset(res, 0, sizeof(*res));
res->sr_slotid = NFS4_MAX_SLOT_TABLE;
+ tbl = &session->fc_slot_table;
+
+ spin_lock(&tbl->slot_tbl_lock);
+ slotid = nfs4_find_slot(tbl, task);
+ if (slotid == NFS4_MAX_SLOT_TABLE) {
+ rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
+ spin_unlock(&tbl->slot_tbl_lock);
+ dprintk("<-- %s: no free slots\n", __func__);
+ return -EAGAIN;
+ }
+ spin_unlock(&tbl->slot_tbl_lock);
+
+ slot = tbl->slots + slotid;
+ args->sa_slotid = slotid;
+ args->sa_cache_this = cache_reply;
+
+ dprintk("<-- %s slotid=%d seqid=%d\n", __func__, slotid, slot->seq_nr);
+
+ res->sr_slotid = slotid;
+ res->sr_renewal_time = jiffies;
+ /*
+ * sr_status is only set in decode_sequence, and so will remain
+ * set to 1 if an rpc level failure occurs.
+ */
+ res->sr_status = 1;
return 0;
}
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 8dcf841..9f7885f 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -130,11 +130,14 @@ struct nfs4_slot {
};
struct nfs4_sequence_args {
- /* stub */
+ u8 sa_slotid;
+ u8 sa_cache_this;
};
struct nfs4_sequence_res {
u8 sr_slotid; /* slot used to send request */
+ unsigned long sr_renewal_time;
+ int sr_status; /* sequence operation status */
};
struct nfs4_get_lease_time_args {
--
1.6.1.3
next prev parent reply other threads:[~2009-03-04 0:00 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-03 23:28 [PATCH 0/46] nfs41 sessions infrastructure Benny Halevy
2009-03-03 23:51 ` [PATCH 02/46] nfs41: Add Kconfig symbols for NFSv4.1 Benny Halevy
2009-03-03 23:52 ` [PATCH 03/46] nfs41: define NFS4_MAX_MINOR_VERSION based on CONFIG_NFS_V4_1 Benny Halevy
2009-03-03 23:52 ` [PATCH 04/46] nfs41: nfs_client.cl_minorversion Benny Halevy
2009-03-29 16:02 ` Trond Myklebust
[not found] ` <1238342562.10999.0.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-29 16:57 ` Benny Halevy
2009-03-03 23:52 ` [PATCH 05/46] nfs41: add mount command option minorversion Benny Halevy
2009-03-29 16:18 ` Trond Myklebust
[not found] ` <1238343501.10999.6.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-30 8:01 ` Benny Halevy
2009-03-03 23:52 ` [PATCH 06/46] nfs41: Use mount minorversion option Benny Halevy
2009-03-29 16:16 ` Trond Myklebust
2009-03-03 23:52 ` [PATCH 07/46] nfs41: translate NFS4ERR_MINOR_VERS_MISMATCH to EPROTONOSUPPORT Benny Halevy
2009-03-03 23:53 ` [PATCH 08/46] nfs41: client xdr definitions Benny Halevy
2009-03-03 23:53 ` [PATCH 09/46] nfs41: sessions client infrastructure Benny Halevy
2009-03-29 16:31 ` Trond Myklebust
[not found] ` <1238344265.10999.14.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-30 8:30 ` Benny Halevy
2009-03-03 23:53 ` [PATCH 10/46] nfs41: find slot Benny Halevy
2009-03-03 23:53 ` [PATCH 11/46] nfs41: free slot Benny Halevy
2009-03-03 23:53 ` [PATCH 12/46] nfs41: use nfs4_server_caps_arg Benny Halevy
2009-03-03 23:54 ` [PATCH 13/46] nfs41: use nfs4_readlink_res Benny Halevy
2009-03-03 23:54 ` [PATCH 14/46] nfs41: use nfs4_statfs_res Benny Halevy
2009-03-03 23:54 ` [PATCH 15/46] nfs41: use nfs4_fsinfo_res Benny Halevy
2009-03-03 23:54 ` [PATCH 16/46] nfs41: use nfs4_pathconf_res Benny Halevy
2009-03-03 23:54 ` [PATCH 17/46] nfs41: use nfs4_getaclres Benny Halevy
2009-03-29 17:28 ` Trond Myklebust
[not found] ` <1238347692.10999.16.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-30 8:47 ` Benny Halevy
2009-03-03 23:55 ` [PATCH 18/46] NFS: get rid of unused xdr decode_setattr(, res) argument Benny Halevy
2009-03-03 23:55 ` [PATCH 19/46] nfs41: use nfs4_setaclres Benny Halevy
2009-03-29 17:30 ` Trond Myklebust
[not found] ` <1238347823.10999.17.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-29 17:48 ` Benny Halevy
2009-03-03 23:55 ` [PATCH 20/46] nfs41: use nfs4_fs_locations_res Benny Halevy
2009-03-03 23:55 ` [PATCH 21/46] sunrpc: add cl_private field to struct rpc_clnt Benny Halevy
2009-03-03 23:55 ` [PATCH 22/46] nfs41: sunrpc: use private void pointer in rpc_clnt Benny Halevy
2009-03-03 23:57 ` [PATCH 23/46] nfs41: encode minorversion in compound header Benny Halevy
2009-03-03 23:57 ` [PATCH 24/46] NFS: fix decode_fs_locations_maxsz Benny Halevy
2009-03-29 17:40 ` Trond Myklebust
[not found] ` <1238348417.23986.1.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-30 11:32 ` Benny Halevy
2009-03-03 23:58 ` [PATCH 25/46] NFS: use decode_change_info_maxsz for xdr maxsz calculations Benny Halevy
2009-03-03 23:58 ` [PATCH 26/46] NFS: define and initialize compound_hdr.replen Benny Halevy
2009-03-03 23:58 ` [PATCH 27/46] NFS: update hdr->replen for every encode op Benny Halevy
2009-03-29 17:46 ` Trond Myklebust
[not found] ` <1238348809.23986.4.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-03-29 19:25 ` Benny Halevy
2009-03-03 23:58 ` [PATCH 28/46] NFS: use dynamically computed compound_hdr.replen for xdr_inline_pages offset Benny Halevy
2009-03-29 19:30 ` [pnfs] " Benny Halevy
2009-03-30 12:40 ` Benny Halevy
2009-03-03 23:58 ` [PATCH 29/46] nfs41: xdr {encode,decode}_sequence Benny Halevy
2009-03-03 23:59 ` [PATCH 30/46] nfs41: stubs for nfs41 procedures Benny Halevy
2009-03-03 23:59 ` [PATCH 31/46] nfs41: introduce nfs4_call_sync Benny Halevy
2009-03-03 23:59 ` [PATCH 32/46] nfs41: set up seq_res.sr_slotid Benny Halevy
2009-03-03 23:59 ` [PATCH 33/46] nfs41: nfs4_setup_sequence Benny Halevy
2009-03-04 0:00 ` Benny Halevy [this message]
2009-03-04 0:00 ` [PATCH 35/46] nfs41: nfs41_sequence_free_slot Benny Halevy
2009-03-04 0:00 ` [PATCH 36/46] nfs41: nfs41_sequence_done Benny Halevy
2009-03-04 0:00 ` [PATCH 37/46] nfs41: nfs41_call_sync_done Benny Halevy
2009-03-04 0:00 ` [PATCH 38/46] nfs41: close sequence setup/done support Benny Halevy
2009-03-04 0:01 ` [PATCH 39/46] nfs41: open " Benny Halevy
2009-03-04 0:01 ` [PATCH 40/46] nfs41: lock " Benny Halevy
2009-03-04 0:01 ` [PATCH 41/46] nfs41: locku " Benny Halevy
2009-03-04 0:01 ` [PATCH 42/46] nfs41: unlink " Benny Halevy
2009-03-04 0:01 ` [PATCH 43/46] nfs41: read " Benny Halevy
2009-03-04 0:01 ` [PATCH 44/46] nfs41 write sequence setup done support Benny Halevy
2009-03-04 0:02 ` [PATCH 45/46] nfs41 commit " Benny Halevy
2009-03-04 0:02 ` [PATCH 46/46] nfs41 delegreturn " Benny Halevy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1236124802-3915-1-git-send-email-bhalevy@panasas.com \
--to=bhalevy@panasas.com \
--cc=Trond.Myklebust@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=pnfs@linux-nfs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).