linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandros Batsakis <batsakis@netapp.com>
To: bhalevy@panasas.com
Cc: linux-nfs@vger.kernel.org, Alexandros Batsakis <batsakis@netapp.com>
Subject: [PATCH 8/8] pnfs-submit: support for cb_recall_any (layouts)
Date: Mon, 17 May 2010 10:56:44 -0700	[thread overview]
Message-ID: <1274119004-30213-9-git-send-email-batsakis@netapp.com> (raw)
In-Reply-To: <1274119004-30213-8-git-send-email-batsakis@netapp.com>

CB_RECALL_ANY serves as a hint to the client to return some server state.
We reply immediately and we clean the layouts asycnhronously.

FIXME: currently we return _all_ layouts
FIXME: eventually we should treat layouts as delegations, marked them expired
and fire the state manager to clean them.

Signed-off-by: Alexandros Batsakis <batsakis@netapp.com>
---
 fs/nfs/callback.h      |    7 ++++++
 fs/nfs/callback_proc.c |   52 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index 73f21bc..b39ac86 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -115,6 +115,13 @@ extern int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation,
 
 #define RCA4_TYPE_MASK_RDATA_DLG	0
 #define RCA4_TYPE_MASK_WDATA_DLG	1
+#define RCA4_TYPE_MASK_DIR_DLG         2
+#define RCA4_TYPE_MASK_FILE_LAYOUT     3
+#define RCA4_TYPE_MASK_BLK_LAYOUT      4
+#define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN  8
+#define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX  9
+#define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12
+#define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15
 
 struct cb_recallanyargs {
 	struct sockaddr	*craa_addr;
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 419fee7..d09fb07 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -337,6 +337,26 @@ out_put_no_client:
 	return status;
 }
 
+static int pnfs_recall_all_layouts(struct nfs_client *clp)
+{
+	struct cb_pnfs_layoutrecallargs rl;
+	struct inode *inode;
+	int status = 0;
+
+	rl.cbl_recall_type = RETURN_ALL;
+	rl.cbl_seg.offset = 0;
+	rl.cbl_seg.length = NFS4_MAX_UINT64;
+	rl.cbl_seg.iomode = IOMODE_ANY;
+	/* we need the inode to get the nfs_server struct */
+	inode = nfs_layoutrecall_find_inode(clp, &rl);
+	if (!inode)
+		return status;
+	status = pnfs_async_return_layout(clp, inode, &rl);
+	iput(inode);
+
+	return status;
+}
+
 __be32 pnfs_cb_layoutrecall(struct cb_pnfs_layoutrecallargs *args,
 			    void *dummy)
 {
@@ -651,6 +671,27 @@ out:
 	return status;
 }
 
+static inline int
+validate_bitmap_values(const unsigned long* mask)
+{
+	int i;
+	if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, mask) ||
+	    test_bit(RCA4_TYPE_MASK_WDATA_DLG, mask) ||
+	    test_bit(RCA4_TYPE_MASK_DIR_DLG, mask) ||
+	    test_bit(RCA4_TYPE_MASK_FILE_LAYOUT, mask) ||
+	    test_bit(RCA4_TYPE_MASK_BLK_LAYOUT, mask))
+		return 1;
+	for (i = RCA4_TYPE_MASK_OBJ_LAYOUT_MIN;
+             i <= RCA4_TYPE_MASK_OBJ_LAYOUT_MAX; i++)
+		if (test_bit(i, mask))
+			return 1;
+	for (i = RCA4_TYPE_MASK_OTHER_LAYOUT_MIN;
+	     i <= RCA4_TYPE_MASK_OTHER_LAYOUT_MAX; i++)
+		if (test_bit(i, mask))
+			return 1;
+	return 0;
+}
+
 __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy)
 {
 	struct nfs_client *clp;
@@ -665,16 +706,25 @@ __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy)
 	dprintk("NFS: RECALL_ANY callback request from %s\n",
 		rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
 
+	status = htonl(NFS4ERR_INVAL);
+	if (!validate_bitmap_values((const unsigned long *)
+				    &args->craa_type_mask))
+		return status;
+
 	if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *)
 		     &args->craa_type_mask))
 		flags = FMODE_READ;
 	if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *)
 		     &args->craa_type_mask))
 		flags |= FMODE_WRITE;
+	if (test_bit(RCA4_TYPE_MASK_FILE_LAYOUT, (const unsigned long *)
+		     &args->craa_type_mask))
+		status = pnfs_recall_all_layouts(clp);
 
 	if (flags)
 		nfs_expire_all_delegation_types(clp, flags);
-	status = htonl(NFS4_OK);
+	if (status != htonl(NFS4ERR_DELAY))
+		status = htonl(NFS4_OK);
 out:
 	dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
 	return status;
-- 
1.6.2.5


  reply	other threads:[~2010-05-17 17:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-17 17:56 [PATCH 0/8] pnfs-submit: Forgetful cleint and some layout cleanups Alexandros Batsakis
2010-05-17 17:56 ` [PATCH 1/8] pnfs-submit: clean struct nfs_inode Alexandros Batsakis
2010-05-17 17:56   ` [PATCH 2/8] pnfs-submit: clean locking infrastructure Alexandros Batsakis
2010-05-17 17:56     ` [PATCH 3/8] pnfs-submit: remove lgetcount, lretcount (outstanding LAYOUTGETs/LAYOUTRETUNs) Alexandros Batsakis
2010-05-17 17:56       ` [PATCH 4/8] pnfs-submit: change stateid to be a union Alexandros Batsakis
2010-05-17 17:56         ` [PATCH 5/8] pnfs-submit: request whole file layouts only Alexandros Batsakis
2010-05-17 17:56           ` [PATCH 6/8] pnfs-submit: change layouts list to be similar to the other state list management Alexandros Batsakis
2010-05-17 17:56             ` [PATCH 7/8] pnfs-submit: forgetful client model Alexandros Batsakis
2010-05-17 17:56               ` Alexandros Batsakis [this message]
2010-05-26 10:48                 ` [PATCH 8/8] pnfs-submit: support for cb_recall_any (layouts) Benny Halevy
2010-05-17 20:38               ` [PATCH 7/8] pnfs-submit: forgetful client model J. Bruce Fields
2010-05-18  0:06                 ` Alexandros Batsakis
2010-05-18 14:16                   ` J. Bruce Fields
2010-05-18 17:33                     ` Alexandros Batsakis
2010-05-18 18:22                       ` J. Bruce Fields
2010-05-26  9:20               ` Benny Halevy
2010-05-27 18:38                 ` Batsakis, Alexandros
2010-05-26  8:49             ` [PATCH 6/8] pnfs-submit: change layouts list to be similar to the other state list management Benny Halevy
2010-05-26  8:42           ` [PATCH 5/8] pnfs-submit: request whole file layouts only Benny Halevy
2010-05-26  8:26         ` [PATCH 4/8] pnfs-submit: change stateid to be a union Benny Halevy
2010-05-26  8:28     ` [PATCH 2/8] pnfs-submit: clean locking infrastructure Benny Halevy
2010-05-28 17:27     ` Fred Isaman
     [not found]       ` <AANLkTinsHI0fHYdpUlq-MsMX0BmsLGvdAbrKx7M5ydjw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-05-28 18:27         ` Alexandros Batsakis
  -- strict thread matches above, loose matches on Subject: below --
2010-06-07 21:11 [PATCH 0/8] forgetful client v2 Alexandros Batsakis
2010-06-07 21:11 ` [PATCH 1/8] pnfs-submit: clean struct nfs_inode Alexandros Batsakis
2010-06-07 21:11   ` [PATCH 2/8] pnfs-submit: clean locking infrastructure Alexandros Batsakis
2010-06-07 21:11     ` [PATCH 3/8] pnfs-submit: remove lgetcount, lretcount Alexandros Batsakis
2010-06-07 21:11       ` [PATCH 4/8] pnfs-submit: change stateid to be a union Alexandros Batsakis
2010-06-07 21:11         ` [PATCH 5/8] pnfs-submit: request whole-file layouts only Alexandros Batsakis
2010-06-07 21:11           ` [PATCH 6/8] pnfs-submit: change layout list to be similar to other state lists Alexandros Batsakis
2010-06-07 21:11             ` [PATCH 7/8] pnfs-submit: forgetful client (layouts) Alexandros Batsakis
2010-06-07 21:11               ` [PATCH 8/8] pnfs-submit: support for CB_RECALL_ANY (layouts) Alexandros Batsakis
2010-05-05 17:00 [PATCH 0/8] pnfs-submit: forgetful client v2 Alexandros Batsakis
2010-05-05 17:00 ` [PATCH 1/8] pnfs-submit: clean struct nfs_inode Alexandros Batsakis
2010-05-05 17:00   ` [PATCH 2/8] pnfs-submit: clean locking infrastructure Alexandros Batsakis
2010-05-05 17:00     ` [PATCH 3/8] pnfs-submit: remove lgetcount, lretcount (outstanding LAYOUTGETs/LAYOUTRETUNs) Alexandros Batsakis
2010-05-05 17:00       ` [PATCH 4/8] pnfs-submit: change stateid to be a union Alexandros Batsakis
2010-05-05 17:00         ` [PATCH 5/8] pnfs-submit: request whole file layouts only Alexandros Batsakis
2010-05-05 17:00           ` [PATCH 6/8] pnfs-submit: change layouts list to be similar to the other state list management Alexandros Batsakis
2010-05-05 17:00             ` [PATCH 7/8] pnfs-submit: forgetful client model Alexandros Batsakis
2010-05-05 17:00               ` [PATCH 8/8] pnfs-submit: support for cb_recall_any (layouts) Alexandros Batsakis

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=1274119004-30213-9-git-send-email-batsakis@netapp.com \
    --to=batsakis@netapp.com \
    --cc=bhalevy@panasas.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).