From: "J. Bruce Fields" <bfields@fieldses.org>
To: "J. Bruce Fields" <bfields@redhat.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: sessions patches
Date: Sun, 24 Oct 2010 21:06:51 -0400 [thread overview]
Message-ID: <20101025010651.GA11470@fieldses.org> (raw)
In-Reply-To: <1287678018-9266-1-git-send-email-bfields@redhat.com>
On Thu, Oct 21, 2010 at 12:20:07PM -0400, J. Bruce Fields wrote:
> The following patches fix bugs in and do some minor cleanup of the
> server 4.1 sessions code. I'm thinking of submitting them for 2.6.37.
Also, one obvious screwup that I just noticed.
--b.
commit 3f87b9f3ea2517c79aa274fa56df7a17f8e29585
Author: J. Bruce Fields <bfields@redhat.com>
Date: Thu Oct 21 17:17:31 2010 -0400
nfsd4: fix connection allocation in sequence()
We're doing an allocation under a spinlock, and ignoring the
possibility of allocation failure.
A better fix wouldn't require an unnecessary allocation in the common
case, but we'll leave that for later.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index ce0412f..d4aa1b5 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1628,33 +1628,25 @@ out:
return status;
}
-static struct nfsd4_conn *__nfsd4_find_conn(struct svc_rqst *r, struct nfsd4_session *s)
+static struct nfsd4_conn *__nfsd4_find_conn(struct svc_xprt *xpt, struct nfsd4_session *s)
{
struct nfsd4_conn *c;
list_for_each_entry(c, &s->se_conns, cn_persession) {
- if (c->cn_xprt == r->rq_xprt) {
+ if (c->cn_xprt == xpt) {
return c;
}
}
return NULL;
}
-static void nfsd4_sequence_check_conn(struct svc_rqst *rqstp, struct nfsd4_session *ses)
+static void nfsd4_sequence_check_conn(struct nfsd4_conn *new, struct nfsd4_session *ses)
{
struct nfs4_client *clp = ses->se_client;
- struct nfsd4_conn *c, *new = NULL;
-
- spin_lock(&clp->cl_lock);
- c = __nfsd4_find_conn(rqstp, ses);
- spin_unlock(&clp->cl_lock);
- if (c)
- return;
-
- new = alloc_conn(rqstp, NFS4_CDFC4_FORE);
+ struct nfsd4_conn *c;
spin_lock(&clp->cl_lock);
- c = __nfsd4_find_conn(rqstp, ses);
+ c = __nfsd4_find_conn(new->cn_xprt, ses);
if (c) {
spin_unlock(&clp->cl_lock);
free_conn(new);
@@ -1674,11 +1666,20 @@ nfsd4_sequence(struct svc_rqst *rqstp,
struct nfsd4_compoundres *resp = rqstp->rq_resp;
struct nfsd4_session *session;
struct nfsd4_slot *slot;
+ struct nfsd4_conn *conn;
int status;
if (resp->opcnt != 1)
return nfserr_sequence_pos;
+ /*
+ * Will be either used or freed by nfsd4_sequence_check_conn
+ * below.
+ */
+ conn = alloc_conn(rqstp, NFS4_CDFC4_FORE);
+ if (!conn)
+ return nfserr_jukebox;
+
spin_lock(&client_lock);
status = nfserr_badsession;
session = find_in_sessionid_hashtbl(&seq->sessionid);
@@ -1710,7 +1711,8 @@ nfsd4_sequence(struct svc_rqst *rqstp,
if (status)
goto out;
- nfsd4_sequence_check_conn(rqstp, session);
+ nfsd4_sequence_check_conn(conn, session);
+ conn = NULL;
/* Success! bump slot seqid */
slot->sl_inuse = true;
@@ -1726,6 +1728,7 @@ out:
nfsd4_get_session(cstate->session);
atomic_inc(&session->se_client->cl_refcount);
}
+ kfree(conn);
spin_unlock(&client_lock);
dprintk("%s: return %d\n", __func__, ntohl(status));
return status;
prev parent reply other threads:[~2010-10-25 1:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-21 16:20 sessions patches J. Bruce Fields
2010-10-21 16:20 ` [PATCH 01/11] nfsd4: don't cache seq_misordered replies J. Bruce Fields
2010-10-21 16:20 ` [PATCH 02/11] nfsd4: move callback setup into session init code J. Bruce Fields
2010-10-27 17:26 ` Benny Halevy
2010-10-27 17:45 ` Benny Halevy
2010-10-27 17:59 ` J. Bruce Fields
2010-10-27 18:03 ` Benny Halevy
2010-10-21 16:20 ` [PATCH 03/11] nfsd4: use client pointer to backchannel session J. Bruce Fields
2010-10-21 16:20 ` [PATCH 04/11] nfsd4: make backchannel sequence number per-session J. Bruce Fields
2010-10-21 16:20 ` [PATCH 05/11] nfsd4: confirm only on succesful create_session J. Bruce Fields
2010-10-21 16:20 ` [PATCH 06/11] nfsd4: track backchannel connections J. Bruce Fields
2010-10-21 16:20 ` [PATCH 07/11] nfsd4: callback program number is per-session J. Bruce Fields
2010-10-21 16:20 ` [PATCH 08/11] nfsd4: separate callback change and callback probe J. Bruce Fields
2010-10-21 16:20 ` [PATCH 09/11] nfsd4: delay session removal till free_client J. Bruce Fields
2010-10-21 16:20 ` [PATCH 10/11] nfsd4: move minorversion to client J. Bruce Fields
2010-10-21 16:20 ` [PATCH 11/11] nfsd4: only require krb5 principal for NFSv4.0 callbacks J. Bruce Fields
2010-10-25 1:06 ` J. Bruce Fields [this message]
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=20101025010651.GA11470@fieldses.org \
--to=bfields@fieldses.org \
--cc=bfields@redhat.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).