From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 07/20] NFSv4.1: Shrink struct nfs4_sequence_res by moving the session pointer
Date: Wed, 21 Nov 2012 17:43:06 -0500 [thread overview]
Message-ID: <1353537799-60488-8-git-send-email-Trond.Myklebust@netapp.com> (raw)
In-Reply-To: <1353537799-60488-7-git-send-email-Trond.Myklebust@netapp.com>
Move the session pointer into the slot table, then have struct nfs4_slot
point to that slot table.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
fs/nfs/nfs4_fs.h | 3 ++-
fs/nfs/nfs4proc.c | 34 ++++++++++++++++++++++++----------
fs/nfs/nfs4state.c | 2 +-
fs/nfs/nfs4xdr.c | 8 +++++---
include/linux/nfs_fs_sb.h | 1 +
include/linux/nfs_xdr.h | 2 +-
6 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 36880b9..42c5869 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -258,7 +258,8 @@ extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data,
bool sync);
-extern struct nfs4_slot *nfs4_alloc_slots(u32 max_slots, gfp_t gfp_flags);
+extern struct nfs4_slot *nfs4_alloc_slots(struct nfs4_slot_table *table,
+ u32 max_slots, gfp_t gfp_flags);
static inline bool
is_ds_only_client(struct nfs_client *clp)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 14b3974..f8cb60b 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -467,25 +467,29 @@ void nfs4_check_drain_bc_complete(struct nfs4_session *ses)
static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res)
{
+ struct nfs4_session *session;
struct nfs4_slot_table *tbl;
- tbl = &res->sr_session->fc_slot_table;
if (!res->sr_slot) {
/* just wake up the next guy waiting since
* we may have not consumed a slot after all */
dprintk("%s: No slot\n", __func__);
return;
}
+ tbl = res->sr_slot->table;
+ session = tbl->session;
+ tbl = &session->fc_slot_table;
spin_lock(&tbl->slot_tbl_lock);
nfs4_free_slot(tbl, res->sr_slot - tbl->slots);
- nfs4_check_drain_fc_complete(res->sr_session);
+ nfs4_check_drain_fc_complete(session);
spin_unlock(&tbl->slot_tbl_lock);
res->sr_slot = NULL;
}
static int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
{
+ struct nfs4_session *session;
struct nfs4_slot *slot;
unsigned long timestamp;
struct nfs_client *clp;
@@ -504,6 +508,7 @@ static int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *
goto out;
slot = res->sr_slot;
+ session = slot->table->session;
/* Check the SEQUENCE operation status */
switch (res->sr_status) {
@@ -511,7 +516,7 @@ static int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *
/* Update the slot's sequence and clientid lease timer */
++slot->seq_nr;
timestamp = slot->renewal_time;
- clp = res->sr_session->clp;
+ clp = session->clp;
do_renew_lease(clp, timestamp);
/* Check sequence flags */
if (res->sr_status_flags != 0)
@@ -524,7 +529,7 @@ static int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *
*/
dprintk("%s: slot=%td seq=%d: Operation in progress\n",
__func__,
- slot - res->sr_session->fc_slot_table.slots,
+ slot - session->fc_slot_table.slots,
slot->seq_nr);
goto out_retry;
default:
@@ -546,7 +551,7 @@ out_retry:
static int nfs4_sequence_done(struct rpc_task *task,
struct nfs4_sequence_res *res)
{
- if (res->sr_session == NULL)
+ if (res->sr_slot == NULL)
return 1;
return nfs41_sequence_done(task, res);
}
@@ -591,7 +596,6 @@ static void nfs41_init_sequence(struct nfs4_sequence_args *args,
args->sa_cache_this = 0;
if (cache_reply)
args->sa_cache_this = 1;
- res->sr_session = NULL;
res->sr_slot = NULL;
}
@@ -646,7 +650,6 @@ int nfs41_setup_sequence(struct nfs4_session *session,
dprintk("<-- %s slotid=%d seqid=%d\n", __func__, slotid, slot->seq_nr);
- res->sr_session = session;
res->sr_slot = slot;
res->sr_status_flags = 0;
/*
@@ -5659,9 +5662,18 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo)
return status;
}
-struct nfs4_slot *nfs4_alloc_slots(u32 max_slots, gfp_t gfp_flags)
+struct nfs4_slot *nfs4_alloc_slots(struct nfs4_slot_table *table,
+ u32 max_slots, gfp_t gfp_flags)
{
- return kmalloc_array(max_slots, sizeof(struct nfs4_slot), gfp_flags);
+ struct nfs4_slot *tbl;
+ u32 i;
+
+ tbl = kmalloc_array(max_slots, sizeof(*tbl), gfp_flags);
+ if (tbl != NULL) {
+ for (i = 0; i < max_slots; i++)
+ tbl[i].table = table;
+ }
+ return tbl;
}
static void nfs4_add_and_init_slots(struct nfs4_slot_table *tbl,
@@ -5699,7 +5711,7 @@ static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl, u32 max_reqs,
/* Does the newly negotiated max_reqs match the existing slot table? */
if (max_reqs != tbl->max_slots) {
- new = nfs4_alloc_slots(max_reqs, GFP_NOFS);
+ new = nfs4_alloc_slots(tbl, max_reqs, GFP_NOFS);
if (!new)
goto out;
}
@@ -5738,11 +5750,13 @@ static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
dprintk("--> %s\n", __func__);
/* Fore channel */
tbl = &ses->fc_slot_table;
+ tbl->session = ses;
status = nfs4_realloc_slot_table(tbl, ses->fc_attrs.max_reqs, 1);
if (status) /* -ENOMEM */
return status;
/* Back channel */
tbl = &ses->bc_slot_table;
+ tbl->session = ses;
status = nfs4_realloc_slot_table(tbl, ses->bc_attrs.max_reqs, 0);
if (status && tbl->slots == NULL)
/* Fore and back channel share a connection so get
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 96fcbb9..9495789 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -2033,7 +2033,7 @@ static int nfs4_recall_slot(struct nfs_client *clp)
return 0;
nfs4_begin_drain_session(clp);
fc_tbl = &clp->cl_session->fc_slot_table;
- new = nfs4_alloc_slots(fc_tbl->target_max_slots, GFP_NOFS);
+ new = nfs4_alloc_slots(fc_tbl, fc_tbl->target_max_slots, GFP_NOFS);
if (!new)
return -ENOMEM;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 672d9b0..4126f05 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -5507,12 +5507,13 @@ static int decode_sequence(struct xdr_stream *xdr,
struct rpc_rqst *rqstp)
{
#if defined(CONFIG_NFS_V4_1)
+ struct nfs4_session *session;
struct nfs4_sessionid id;
u32 dummy;
int status;
__be32 *p;
- if (!res->sr_session)
+ if (res->sr_slot == NULL)
return 0;
status = decode_op_hdr(xdr, OP_SEQUENCE);
@@ -5526,8 +5527,9 @@ static int decode_sequence(struct xdr_stream *xdr,
* sequence number, the server is looney tunes.
*/
status = -EREMOTEIO;
+ session = res->sr_slot->table->session;
- if (memcmp(id.data, res->sr_session->sess_id.data,
+ if (memcmp(id.data, session->sess_id.data,
NFS4_MAX_SESSIONID_LEN)) {
dprintk("%s Invalid session id\n", __func__);
goto out_err;
@@ -5545,7 +5547,7 @@ static int decode_sequence(struct xdr_stream *xdr,
}
/* slot id */
dummy = be32_to_cpup(p++);
- if (dummy != res->sr_slot - res->sr_session->fc_slot_table.slots) {
+ if (dummy != res->sr_slot - session->fc_slot_table.slots) {
dprintk("%s Invalid slot id\n", __func__);
goto out_err;
}
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 97c8f91..b041287 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -209,6 +209,7 @@ struct nfs_server {
/* Sessions */
#define SLOT_TABLE_SZ DIV_ROUND_UP(NFS4_MAX_SLOT_TABLE, 8*sizeof(long))
struct nfs4_slot_table {
+ struct nfs4_session *session; /* Parent session */
struct nfs4_slot *slots; /* seqid per slot */
unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */
spinlock_t slot_tbl_lock;
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 9cb1c63..0fd88ab 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -187,6 +187,7 @@ struct nfs4_channel_attrs {
/* nfs41 sessions slot seqid */
struct nfs4_slot {
+ struct nfs4_slot_table *table;
unsigned long renewal_time;
u32 seq_nr;
};
@@ -198,7 +199,6 @@ struct nfs4_sequence_args {
};
struct nfs4_sequence_res {
- struct nfs4_session *sr_session;
struct nfs4_slot *sr_slot; /* slot used to send request */
int sr_status; /* sequence operation status */
u32 sr_status_flags;
--
1.7.11.7
next prev parent reply other threads:[~2012-11-22 18:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 22:42 [PATCH 00/20] NFSv4.1: Add support for session dynamic slot management Trond Myklebust
2012-11-21 22:43 ` [PATCH 01/20] NFSv4.1: Don't confuse CREATE_SESSION arguments and results Trond Myklebust
2012-11-21 22:43 ` [PATCH 02/20] NFSv4.1: Adjust CREATE_SESSION arguments when mounting a new filesystem Trond Myklebust
2012-11-21 22:43 ` [PATCH 03/20] NFSv4.1: We must bump the clientid sequence number after CREATE_SESSION Trond Myklebust
2012-11-21 22:43 ` [PATCH 04/20] NFSv4.1: nfs4_alloc_slots doesn't need zeroing Trond Myklebust
2012-11-21 22:43 ` [PATCH 05/20] NFSv4.1: clean up nfs4_recall_slot to use nfs4_alloc_slots Trond Myklebust
2012-11-21 22:43 ` [PATCH 06/20] NFSv4.1: Shrink struct nfs4_sequence_res by moving sr_renewal_time Trond Myklebust
2012-11-21 22:43 ` Trond Myklebust [this message]
2012-11-21 22:43 ` [PATCH 08/20] NFSv4.1: Label each entry in the session slot tables with its slot number Trond Myklebust
2012-11-21 22:43 ` [PATCH 09/20] NFSv4.1: Simplify struct nfs4_sequence_args too Trond Myklebust
2012-11-21 22:43 ` [PATCH 10/20] NFSv4.1: Simplify slot allocation Trond Myklebust
2012-11-21 22:43 ` [PATCH 11/20] NFSv4.1: Clean up nfs4_free_slot Trond Myklebust
2012-11-21 22:43 ` [PATCH 12/20] NFSv4.1: Ensure that the client tracks the server target_highest_slotid Trond Myklebust
2012-11-21 22:43 ` [PATCH 13/20] NFSv4.1: Reset the sequence number for slots that have been deallocated Trond Myklebust
2012-11-21 22:43 ` [PATCH 14/20] NFSv4.1: Fix nfs4_callback_recallslot to work with dynamic slot allocation Trond Myklebust
2012-11-21 22:43 ` [PATCH 15/20] NFSv4.1: Don't confuse target_highest_slotid and max_slots in cb_recall_slot Trond Myklebust
2012-11-21 22:43 ` [PATCH 16/20] NFSv4.1: Allow the server to recall all but one slot Trond Myklebust
2012-11-21 22:43 ` [PATCH 17/20] NFSv4.1: Support dynamic resizing of the session slot table Trond Myklebust
2012-11-21 22:43 ` [PATCH 18/20] NFSv4.1: Allow SEQUENCE to resize the slot table on the fly Trond Myklebust
2012-11-21 22:43 ` [PATCH 19/20] NFSv4.1: Remove the state manager code to resize the slot table Trond Myklebust
2012-11-21 22:43 ` [PATCH 20/20] NFSv4.1: CB_RECALL_SLOT must schedule a sequence op after updating targets Trond Myklebust
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=1353537799-60488-8-git-send-email-Trond.Myklebust@netapp.com \
--to=trond.myklebust@netapp.com \
--cc=linux-nfs@vger.kernel.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).