From: Benny Halevy <bhalevy@primarydata.com>
To: linux-nfs@vger.kernel.org
Cc: Christoph Hellwig <hch@infradead.org>,
Nadav Shemer <nadav@primarydata.com>
Subject: [PATCH v2 2/4] SQUASHME: pnfsd: nfs4_find_create_layout_stateid
Date: Mon, 07 Oct 2013 18:45:23 +0300 [thread overview]
Message-ID: <5252D713.7000004@primarydata.com> (raw)
In-Reply-To: <1381045468-30670-1-git-send-email-bhalevy@primarydata.com>
Split off nfs4_process_layout_stateid functionality for layout get.
layout commit and return never allocate a new layout stateid.
Signed-off-by: Benny Halevy <bhalevy@primarydata.com>
---
fs/nfsd/nfs4pnfsd.c | 77 ++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 61 insertions(+), 16 deletions(-)
diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c
index 2b421e0..84f0283 100644
--- a/fs/nfsd/nfs4pnfsd.c
+++ b/fs/nfsd/nfs4pnfsd.c
@@ -193,23 +193,20 @@ struct sbid_tracker {
}
/*
- * We have looked up the nfs4_file corresponding to the current_fh, and
- * confirmed the clientid. Pull the few tests from nfs4_preprocess_stateid_op()
- * that make sense with a layout stateid.
- *
* If the layout state was found in cache, grab a reference count on it;
- * otherwise, allocate a new layout state if "do_alloc" is set.
+ * otherwise, allocate a new layout state if the client provided a open/
+ * lock/deleg stateid.
*
* Called with the state_lock held
- * Returns zero and stateid is updated, or error.
+ * Returns zero and the layout state in *lsp, or error.
*/
static __be32
-nfs4_process_layout_stateid(struct nfs4_client *clp, struct nfs4_file *fp,
- stateid_t *stateid, unsigned char typemask,
- struct nfs4_layout_state **lsp)
+nfs4_find_create_layout_stateid(struct nfs4_client *clp, struct nfs4_file *fp,
+ stateid_t *stateid, unsigned char typemask,
+ struct nfs4_layout_state **lsp)
{
struct nfs4_layout_state *ls = NULL;
- __be32 status = 0;
+ __be32 status;
struct nfs4_stid *stid;
dprintk("--> %s clp %p fp %p operation stateid=" STATEID_FMT "\n",
@@ -233,13 +230,61 @@ struct sbid_tracker {
/* BAD STATEID */
if (stateid->si_generation > ls->ls_stid.sc_stateid.si_generation) {
- dprintk("%s bad stateid 1\n", __func__);
status = nfserr_bad_stateid;
goto out;
}
get_layout_state(ls);
}
- status = 0;
+
+ dprintk("%s: layout stateid=" STATEID_FMT " ref=%d\n", __func__,
+ STATEID_VAL(&ls->ls_stid.sc_stateid), atomic_read(&ls->ls_ref.refcount));
+
+ *lsp = ls;
+out:
+ dprintk("<-- %s status %d\n", __func__, htonl(status));
+
+ return status;
+}
+
+/*
+ * If the layout state was found in cache, grab a reference count on it.
+ *
+ * Called with the state_lock held
+ * Returns zero and the layout state in *lsp, or error.
+ */
+static __be32
+nfs4_process_layout_stateid(struct nfs4_client *clp, struct nfs4_file *fp,
+ stateid_t *stateid, unsigned char typemask,
+ struct nfs4_layout_state **lsp)
+{
+ struct nfs4_layout_state *ls = NULL;
+ __be32 status;
+ struct nfs4_stid *stid;
+
+ dprintk("--> %s clp %p fp %p operation stateid=" STATEID_FMT "\n",
+ __func__, clp, fp, STATEID_VAL(stateid));
+
+ nfs4_assert_state_locked();
+ status = nfsd4_lookup_stateid(stateid, typemask, &stid, true,
+ net_generic(clp->net, nfsd_net_id));
+ if (status)
+ goto out;
+
+ /* Is this the first use of this layout ? */
+ if (stid->sc_type != NFS4_LAYOUT_STID) {
+ status = nfserr_bad_stateid;
+ goto out;
+ }
+
+ ls = container_of(stid, struct nfs4_layout_state, ls_stid);
+
+ /* BAD STATEID */
+ if (stateid->si_generation > ls->ls_stid.sc_stateid.si_generation) {
+ dprintk("%s bad stateid 1\n", __func__);
+ status = nfserr_bad_stateid;
+ goto out;
+ }
+ get_layout_state(ls);
*lsp = ls;
dprintk("%s: layout stateid=" STATEID_FMT " ref=%d\n", __func__,
@@ -576,10 +621,10 @@ struct super_block *
}
/* Check decoded layout stateid */
- nfserr = nfs4_process_layout_stateid(clp, fp, &lgp->lg_sid,
- (NFS4_OPEN_STID | NFS4_LOCK_STID |
- NFS4_DELEG_STID | NFS4_LAYOUT_STID),
- &ls);
+ nfserr = nfs4_find_create_layout_stateid(clp, fp, &lgp->lg_sid,
+ (NFS4_OPEN_STID | NFS4_LOCK_STID |
+ NFS4_DELEG_STID | NFS4_LAYOUT_STID),
+ &ls);
if (nfserr)
goto out_unlock;
--
1.8.3.1
next prev parent reply other threads:[~2013-10-07 15:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-06 7:40 [PATCH 0/4] pnfsd: refactor nfs4_process_layout_stateid Benny Halevy
2013-10-06 7:44 ` [PATCH 1/4] SQUASHME: fix lo_destroy_list nested definition Benny Halevy
2013-10-06 7:44 ` [PATCH 2/4] SQUASHME: pnfsd: nfs4_find_create_layout_stateid Benny Halevy
2013-10-06 15:29 ` Christoph Hellwig
2013-10-07 15:03 ` Benny Halevy
2013-10-07 15:45 ` Benny Halevy [this message]
2013-10-06 7:44 ` [PATCH 3/4] SQUASHME: pnfsd: no need for find_file in layout commit/return Benny Halevy
2013-10-06 15:30 ` Christoph Hellwig
2013-10-07 15:50 ` [PATCH v2 " Benny Halevy
2013-10-06 7:44 ` [PATCH 4/4] SQUASHME: pnfsd: fixup error code for layout_commit 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=5252D713.7000004@primarydata.com \
--to=bhalevy@primarydata.com \
--cc=hch@infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=nadav@primarydata.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.