All of lore.kernel.org
 help / color / mirror / Atom feed
From: <andros@netapp.com>
To: <bfields@fieldses.org>
Cc: <trond.myklebust@primarydata.com>, <anna.schumaker@netapp.com>,
	<linux-nfs@vger.kernel.org>, Andy Adamson <andros@netapp.com>
Subject: [PATCH RFC 09/10] NFSD: add nfs4interssc.c
Date: Tue, 17 Mar 2015 18:31:37 -0400	[thread overview]
Message-ID: <1426631498-14772-10-git-send-email-andros@netapp.com> (raw)
In-Reply-To: <1426631498-14772-1-git-send-email-andros@netapp.com>

From: Andy Adamson <andros@netapp.com>

Signed-off-by: Andy Adamson <andros@netapp.com>
---
 fs/nfsd/Makefile       |   2 +-
 fs/nfsd/nfs4interssc.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 111 insertions(+), 1 deletion(-)
 create mode 100644 fs/nfsd/nfs4interssc.c

diff --git a/fs/nfsd/Makefile b/fs/nfsd/Makefile
index 9a6028e..6355e83 100644
--- a/fs/nfsd/Makefile
+++ b/fs/nfsd/Makefile
@@ -16,5 +16,5 @@ nfsd-$(CONFIG_NFSD_V2_ACL) += nfs2acl.o
 nfsd-$(CONFIG_NFSD_V3)	+= nfs3proc.o nfs3xdr.o
 nfsd-$(CONFIG_NFSD_V3_ACL) += nfs3acl.o
 nfsd-$(CONFIG_NFSD_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4idmap.o \
-			   nfs4acl.o nfs4callback.o nfs4recover.o
+			   nfs4acl.o nfs4callback.o nfs4recover.o nfs4interssc.o
 nfsd-$(CONFIG_NFSD_PNFS) += nfs4layouts.o blocklayout.o blocklayoutxdr.o
diff --git a/fs/nfsd/nfs4interssc.c b/fs/nfsd/nfs4interssc.c
new file mode 100644
index 0000000..bdc73fc
--- /dev/null
+++ b/fs/nfsd/nfs4interssc.c
@@ -0,0 +1,110 @@
+/*
+ * linux/fs/nfsd/nfs4interssc.c
+ *
+ * Copyright (C) 2014 Andy Adamson <andros@netapp.com>
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/nfs_fs.h>
+
+
+/* Inter server side copy module list */
+static DEFINE_SPINLOCK(ssc_spinlock);
+static LIST_HEAD(ssc_modules_tbl);
+
+static struct nfs42_inter_ssc_ops *
+find_ssc_module_locked(int version) {
+	struct nfs42_inter_ssc_ops *local;
+
+	list_for_each_entry(local, &ssc_modules_tbl, ssc_mtable)
+		if (local->ssc_version == version)
+			goto out;
+	local = NULL;
+out:
+	printk("%s: Searching for version %u, found %p\n", __func__, version,
+		local);
+	return local;
+};
+
+static struct nfs42_inter_ssc_ops *
+find_ssc_module(u32 version)
+{
+	struct nfs42_inter_ssc_ops *local;
+
+	spin_lock(&ssc_spinlock);
+	local = find_ssc_module_locked(version);
+	if (local != NULL && !try_module_get(local->ssc_owner)) {
+		printk("%s: Could not grab reference on module\n", __func__);
+		local = NULL;
+	}
+	spin_unlock(&ssc_spinlock);
+	return local;
+}
+
+/**
+ * Ref counting for icopp?
+ */
+void
+set_ssc_module(struct nfs42_inter_ssc_ops **icopp, u32 version) {
+	struct nfs42_inter_ssc_ops *icop;
+
+	icop = find_ssc_module(version);
+	if (icop == NULL) {
+		request_module("nfs42-interserver-copy");
+		icop = find_ssc_module(version);
+		if (icop == NULL) {
+			printk("%s: No Module found for %u.\n",
+				__func__, version);
+			*icopp = NULL;
+			return;
+		}
+	}
+	*icopp = icop;
+	return;
+};
+
+void
+unset_ssc_module(struct nfs42_inter_ssc_ops *icop)
+{
+	printk("--> %s\n", __func__);
+	module_put(icop->ssc_owner);
+}
+
+int
+nfsd4_register_intecopy_driver(struct nfs42_inter_ssc_ops *ico, u32 version)
+{
+	struct nfs42_inter_ssc_ops *tmp;
+	int status = -EINVAL;
+
+	if (version != 42) {
+		printk(KERN_ERR "NFS: %s invalid module version %d\n",
+			__func__, version);
+		return status;
+	}
+
+	spin_lock(&ssc_spinlock);
+	tmp = find_ssc_module_locked(version);
+	if (tmp == NULL) {
+		list_add(&ico->ssc_mtable, &ssc_modules_tbl);
+		status = 0;
+		printk("%s Registering version:%u name:%s\n", __func__,
+			ico->ssc_version, ico->ssc_name);
+	} else {
+		printk(KERN_ERR "NFS: %s Module version %d already loaded!\n",
+			__func__, ico->ssc_version);
+	}
+	spin_unlock(&ssc_spinlock);
+	return status;
+}
+EXPORT_SYMBOL_GPL(nfsd4_register_intecopy_driver);
+
+void
+nfsd4_unregister_intecopy_driver(struct nfs42_inter_ssc_ops *ico)
+{
+	printk("%s Deregistering version:%u\n", __func__, ico->ssc_version);
+	spin_lock(&ssc_spinlock);
+	list_del(&ico->ssc_mtable);
+	spin_unlock(&ssc_spinlock);
+}
+EXPORT_SYMBOL_GPL(nfsd4_unregister_intecopy_driver);
-- 
1.8.3.1


  parent reply	other threads:[~2015-03-17 22:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-17 22:31 [PATCH RFC 00/10] NFSv4.2 Inter server to server copy RFC andros
2015-03-17 22:31 ` [PATCH RFC 01/10] NFS return the root_mnt via the raw data in nfs_fs_mount andros
2015-03-17 22:31 ` [PATCH RFC 02/10] NFS interserver ssc module andros
2015-03-17 22:31 ` [PATCH RFC 03/10] NFS add COPY_NOTIFY operation andros
2015-03-17 22:31 ` [PATCH RFC 04/10] NFSD add ca_source_server<> to COPY andros
2015-03-17 22:31 ` [PATCH RFC 05/10] NFSD add COPY_NOTIFY operation andros
2015-03-17 22:31 ` [PATCH RFC 06/10] NFS add ca_source_server<> to COPY andros
2015-03-17 22:31 ` [PATCH RFC 07/10] NFSD generalize nfsd4_compound_state flag names andros
2015-03-17 22:31 ` [PATCH RFC 08/10] NFSD: allow inter server COPY to have a STALE source server fh andros
2015-03-17 22:31 ` andros [this message]
2015-03-17 22:31 ` [PATCH RFC 10/10] NFSD nfs4 inter ssc copy andros
2015-03-18 18:51 ` [PATCH RFC 00/10] NFSv4.2 Inter server to server copy RFC J. Bruce Fields

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=1426631498-14772-10-git-send-email-andros@netapp.com \
    --to=andros@netapp.com \
    --cc=anna.schumaker@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@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.