From patchwork Tue Mar 17 22:31:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 6035231 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4F765BF910 for ; Tue, 17 Mar 2015 22:41:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A90A2042B for ; Tue, 17 Mar 2015 22:41:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58286204A7 for ; Tue, 17 Mar 2015 22:41:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932425AbbCQWlZ (ORCPT ); Tue, 17 Mar 2015 18:41:25 -0400 Received: from mx144.netapp.com ([216.240.21.25]:7620 "EHLO mx144.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932538AbbCQWlY (ORCPT ); Tue, 17 Mar 2015 18:41:24 -0400 X-IronPort-AV: E=Sophos;i="5.11,418,1422950400"; d="scan'208";a="30293981" Received: from vmwexchts02-prd.hq.netapp.com ([10.122.105.23]) by mx144-out.netapp.com with ESMTP; 17 Mar 2015 15:31:53 -0700 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCHTS02-PRD.hq.netapp.com (10.122.105.23) with Microsoft SMTP Server id 15.0.995.29; Tue, 17 Mar 2015 15:31:53 -0700 Received: from rhel7-1-snap3.androsad.fake (vpn2ntap-637508.vpn.netapp.com [10.55.64.232]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id t2HMViOK020643; Tue, 17 Mar 2015 15:31:52 -0700 (PDT) From: To: CC: , , , Andy Adamson Subject: [PATCH RFC 09/10] NFSD: add nfs4interssc.c Date: Tue, 17 Mar 2015 18:31:37 -0400 Message-ID: <1426631498-14772-10-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1426631498-14772-1-git-send-email-andros@netapp.com> References: <1426631498-14772-1-git-send-email-andros@netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andy Adamson Signed-off-by: Andy Adamson --- 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 + * + */ + +#include +#include + + +/* 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);