From patchwork Wed Apr 27 15:36:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 8959451 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DA2C69F372 for ; Wed, 27 Apr 2016 15:42:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBC2920263 for ; Wed, 27 Apr 2016 15:42:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA1AA2015A for ; Wed, 27 Apr 2016 15:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752542AbcD0Pgi (ORCPT ); Wed, 27 Apr 2016 11:36:38 -0400 Received: from mx141.netapp.com ([216.240.21.12]:34604 "EHLO mx141.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752431AbcD0Pgg (ORCPT ); Wed, 27 Apr 2016 11:36:36 -0400 X-IronPort-AV: E=Sophos;i="5.24,542,1455004800"; d="scan'208";a="115249454" Received: from vmwexchts03-prd.hq.netapp.com ([10.122.105.31]) by mx141-out.netapp.com with ESMTP; 27 Apr 2016 08:36:35 -0700 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCHTS03-PRD.hq.netapp.com (10.122.105.31) with Microsoft SMTP Server id 15.0.1156.6; Wed, 27 Apr 2016 08:36:31 -0700 Received: from localhost.localdomain (andros-new.vpn.netapp.com [10.55.74.31]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id u3RFaXwS014459; Wed, 27 Apr 2016 08:36:34 -0700 (PDT) From: To: CC: , , Andy Adamson Subject: [PATCH Version 3 1/9] NFS parse multiple hostnames Date: Wed, 27 Apr 2016 11:36:02 -0400 Message-ID: <1461771370-16375-2-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1461771370-16375-1-git-send-email-andros@netapp.com> References: <1461771370-16375-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=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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/nfs/internal.h | 17 +++++++++++++++++ fs/nfs/nfs4_fs.h | 4 ++++ fs/nfs/super.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index f1d1d2c..606b153 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -75,6 +75,20 @@ struct nfs_client_initdata { struct net *net; }; +/** + * NFS_MAXHOSTNAME of 255 limits the number of multiple hostnames on the + * mount stanza. 16 is a reasonable maximum number + */ +#define NFS_MAX_MULTIADDR 16 + + +/* hold multiple hostname info */ +struct multi_addr { + struct sockaddr_storage addr; + size_t addrlen; + char *hostname; +}; + /* * In-kernel mount arguments */ @@ -113,6 +127,9 @@ struct nfs_parsed_mount_data { unsigned short protocol; } nfs_server; + unsigned int num_multi; + struct multi_addr *multiaddrs; + struct security_mnt_opts lsm_opts; struct net *net; }; diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 4afdee4..4c21022 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -214,6 +214,10 @@ struct nfs4_mig_recovery_ops { int (*fsid_present)(struct inode *, struct rpc_cred *); }; +struct nfs4_add_xprt_data { + struct nfs_client *clp; + struct rpc_cred *cred; +}; extern const struct dentry_operations nfs4_dentry_operations; /* dir.c */ diff --git a/fs/nfs/super.c b/fs/nfs/super.c index f126828..70a4fda 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -107,6 +107,7 @@ enum { Opt_nfsvers, Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, Opt_addr, Opt_mountaddr, Opt_clientaddr, + Opt_multiaddr, Opt_lookupcache, Opt_fscache_uniq, Opt_local_lock, @@ -178,6 +179,7 @@ static const match_table_t nfs_mount_option_tokens = { { Opt_clientaddr, "clientaddr=%s" }, { Opt_mounthost, "mounthost=%s" }, { Opt_mountaddr, "mountaddr=%s" }, + { Opt_multiaddr, "multiaddr=%s" }, { Opt_lookupcache, "lookupcache=%s" }, { Opt_fscache_uniq, "fsc=%s" }, @@ -921,6 +923,12 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void) data = kzalloc(sizeof(*data), GFP_KERNEL); if (data) { + data->multiaddrs = kzalloc(sizeof(*data->multiaddrs) * + NFS_MAX_MULTIADDR, GFP_KERNEL); + if (!data->multiaddrs) { + kfree(data); + return NULL; + } data->acregmin = NFS_DEF_ACREGMIN; data->acregmax = NFS_DEF_ACREGMAX; data->acdirmin = NFS_DEF_ACDIRMIN; @@ -939,12 +947,20 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void) static void nfs_free_parsed_mount_data(struct nfs_parsed_mount_data *data) { + struct multi_addr *multip = data->multiaddrs; + int i; + if (data) { kfree(data->client_address); kfree(data->mount_server.hostname); kfree(data->nfs_server.export_path); kfree(data->nfs_server.hostname); kfree(data->fscache_uniq); + for (i = 0; i < data->num_multi; i++) { + kfree(multip->hostname); + multip++; + } + kfree(data->multiaddrs); security_free_mnt_opts(&data->lsm_opts); kfree(data); } @@ -1200,6 +1216,7 @@ static int nfs_parse_mount_options(char *raw, int rc, sloppy = 0, invalid_option = 0; unsigned short protofamily = AF_UNSPEC; unsigned short mountfamily = AF_UNSPEC; + struct multi_addr *multip = mnt->multiaddrs; if (!raw) { dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); @@ -1589,6 +1606,25 @@ static int nfs_parse_mount_options(char *raw, return 0; }; break; + case Opt_multiaddr: + if (mnt->num_multi == NFS_MAX_MULTIADDR) + goto out_too_many_multiaddrs; + + if (nfs_get_option_str(args, &multip->hostname)) + goto out_nomem; + + multip->addrlen = rpc_pton(mnt->net, multip->hostname, + strlen(multip->hostname), + (struct sockaddr *) + &multip->addr, + sizeof(multip->addr)); + + dfprintk(MOUNT, "NFS: Added multiaddr %s\n", + multip->hostname); + mnt->num_multi++; + multip++; + + break; /* * Special options @@ -1640,6 +1676,10 @@ static int nfs_parse_mount_options(char *raw, return 1; +out_too_many_multiaddrs: + printk(KERN_INFO "NFS: %d is too many multiple hostnames.\n", + mnt->num_multi); + return 0; out_mountproto_mismatch: printk(KERN_INFO "NFS: mount server address does not match mountproto= " "option\n");