linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: andros@netapp.com
To: iisaman@netapp.com
Cc: linux-nfs@vger.kernel.org, Andy Adamson <andros@netapp.com>
Subject: [[PATCH resend] 6/6] PYNFS implement FREE_STATEID and TEST_STATEID operations
Date: Tue, 29 May 2012 18:11:29 -0400	[thread overview]
Message-ID: <1338329489-29178-7-git-send-email-andros@netapp.com> (raw)
In-Reply-To: <1338329489-29178-1-git-send-email-andros@netapp.com>

From: Andy Adamson <andros@netapp.com>

Signed-off-by: Andy Adamson <andros@netapp.com>
---
 nfs4.1/nfs4server.py |   33 +++++++++++++++++++++++++++++++++
 nfs4.1/nfs4state.py  |   11 ++++++-----
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/nfs4.1/nfs4server.py b/nfs4.1/nfs4server.py
index b279292..8d0f112 100755
--- a/nfs4.1/nfs4server.py
+++ b/nfs4.1/nfs4server.py
@@ -1296,6 +1296,39 @@ class NFS4Server(rpc.Server):
         res = READ4resok(eof, data)
         return encode_status(NFS4_OK, res)
 
+    def op_free_stateid(self, arg, env):
+        check_session(env)
+        status = NFS4_OK
+        with find_state(env, arg.fsa_stateid, no_fh=True) as state:
+            try:
+                log_41.info("free_stateid found state DELETING state")
+                state.delete()
+            except NFS4Error, e:
+                log_41.info("free_stateid %s error: %d") % (arg.fsa_stateid, e.status)
+                status = e.status
+
+	res = FREE_STATEID4res(fsr_status = status)
+        return encode_status(NFS4_OK)
+
+    def op_test_stateid(self, arg, env):
+        check_session(env)
+	out = []
+        for stateid in arg.ts_stateids:
+            status = NFS4_OK
+            with find_state(env, stateid, no_fh=True) as state:
+                try:
+                    log_41.info("test_stateid found state")
+                    self.check_opsconfig(env, "test_stateid")
+                except NFS4Error, e:
+                    if (e.status == NFS4ERR_BAD_STATEID or e.status == NFS4ERR_ADMIN_REVOKED or e.status == NFS4ERR_OPENMODE):
+                        state.delete()
+                    status = e.status
+                finally:
+                    out.append(status)
+
+	res = TEST_STATEID4resok(tsr_status_codes = out)
+        return encode_status(NFS4_OK, res)
+
     def op_open(self, arg, env):
         self.check_opsconfig(env, "open")
         check_session(env)
diff --git a/nfs4.1/nfs4state.py b/nfs4.1/nfs4state.py
index e8445e3..a6b21f4 100644
--- a/nfs4.1/nfs4state.py
+++ b/nfs4.1/nfs4state.py
@@ -23,7 +23,7 @@ NORMAL, CB_INIT, CB_SENT, CB_RECEIVED, INVALID = range(5) # delegation/layout st
 DS_MAGIC = "\xa5" # STUB part of HACK code to ignore DS stateid
 
 @contextmanager
-def find_state(env, stateid, allow_0=True, allow_bypass=False):
+def find_state(env, stateid, allow_0=True, allow_bypass=False, no_fh=False):
     """Find the matching StateTableEntry, and manage its lock."""
     anon = False
     if env.is_ds:
@@ -57,10 +57,11 @@ def find_state(env, stateid, allow_0=True, allow_bypass=False):
         state = env.session.client.state.get(stateid.other, None)
         if state is None:
             raise NFS4Error(NFS4ERR_BAD_STATEID, tag="stateid not known")
-        if state.file != env.cfh:
-            raise NFS4Error(NFS4ERR_BAD_STATEID,
-                            tag="cfh %r does not match stateid %r" % 
-                            (state.file.fh, env.cfh.fh))
+        if no_fh == False:
+            if state.file != env.cfh:
+                raise NFS4Error(NFS4ERR_BAD_STATEID,
+                                tag="cfh %r does not match stateid %r" % 
+                                (state.file.fh, env.cfh.fh))
     state.lock.acquire()
     # It is possible that while waiting to get the lock, the state has been
     # removed.  In that case, the removal sets the invalid flag.
-- 
1.7.7.6


      parent reply	other threads:[~2012-06-01 21:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-29 22:11 [[PATCH resend] 0/6] PYNFS various patches andros
2012-05-29 22:11 ` [[PATCH resend] 1/6] PYNFS rpc drop fix andros
2012-05-29 22:11 ` [[PATCH resend] 2/6] PYNFS fix rpcgen andros
2012-06-01 22:01   ` Adamson, Dros
2012-05-29 22:11 ` [[PATCH resend] 3/6] PYNFS use loopback addresses for MDS<->DS communication andros
2012-05-29 22:11 ` [[PATCH resend] 4/6] PYNFS use requested iomode on layoutget andros
2012-05-29 22:11 ` [[PATCH resend] 5/6] PYNFS: add mdsthreshold to file layout server andros
2012-06-04 15:21   ` Fred Isaman
2012-05-29 22:11 ` andros [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=1338329489-29178-7-git-send-email-andros@netapp.com \
    --to=andros@netapp.com \
    --cc=iisaman@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).