From patchwork Wed Apr 30 02:43:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weng Meiling X-Patchwork-Id: 4090831 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 463B79F39D for ; Wed, 30 Apr 2014 02:46:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CF3F2022D for ; Wed, 30 Apr 2014 02:46:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6371F2021B for ; Wed, 30 Apr 2014 02:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753450AbaD3Cqu (ORCPT ); Tue, 29 Apr 2014 22:46:50 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:45475 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbaD3Cqr (ORCPT ); Tue, 29 Apr 2014 22:46:47 -0400 Received: from 172.24.2.119 (EHLO szxeml211-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AOB79485; Wed, 30 Apr 2014 10:46:25 +0800 (CST) Received: from SZXEML461-HUB.china.huawei.com (10.82.67.204) by szxeml211-edg.china.huawei.com (172.24.2.182) with Microsoft SMTP Server (TLS) id 14.3.158.1; Wed, 30 Apr 2014 10:46:22 +0800 Received: from localhost (10.177.24.66) by szxeml461-hub.china.huawei.com (10.82.67.204) with Microsoft SMTP Server id 14.3.158.1; Wed, 30 Apr 2014 10:46:12 +0800 From: Weng Meiling To: CC: , , , , , Subject: [PATCH v2 3.4 6/9] nfsd: pass net to __write_ports() and down Date: Wed, 30 Apr 2014 10:43:41 +0800 Message-ID: <1398825824-6360-7-git-send-email-wengmeiling.weng@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 In-Reply-To: <1398825824-6360-1-git-send-email-wengmeiling.weng@huawei.com> References: <1398825824-6360-1-git-send-email-wengmeiling.weng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.24.66] X-CFilter-Loop: Reflected 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.5 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: Stanislav Kinsbursky commit 081603520b25f7b35ef63a363376a17c36ef74ed upstream. Precursor patch. Hard-coded "init_net" will be replaced by proper one in future. Signed-off-by: Stanislav Kinsbursky Signed-off-by: J. Bruce Fields [wengmeiling: backport to 3.4: - adjust context - add net_ns parameter to __write_ports_delxprt()] Signed-off-by: Weng Meiling --- fs/nfsd/nfsctl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index f58e0f9..1d74af2 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -650,11 +650,10 @@ static ssize_t __write_ports_names(char *buf) * a socket of a supported family/protocol, and we use it as an * nfsd listener. */ -static ssize_t __write_ports_addfd(char *buf) +static ssize_t __write_ports_addfd(char *buf, struct net *net) { char *mesg = buf; int fd, err; - struct net *net = &init_net; err = get_int(&mesg, &fd); if (err != 0 || fd < 0) @@ -698,12 +697,11 @@ static ssize_t __write_ports_delfd(char *buf) * A transport listener is added by writing it's transport name and * a port number. */ -static ssize_t __write_ports_addxprt(char *buf) +static ssize_t __write_ports_addxprt(char *buf, struct net *net) { char transport[16]; struct svc_xprt *xprt; int port, err; - struct net *net = &init_net; if (sscanf(buf, "%15s %4u", transport, &port) != 2) return -EINVAL; @@ -743,7 +741,7 @@ out_err: * A transport listener is removed by writing a "-", it's transport * name, and it's port number. */ -static ssize_t __write_ports_delxprt(char *buf) +static ssize_t __write_ports_delxprt(char *buf, struct net *net) { struct svc_xprt *xprt; char transport[16]; @@ -755,7 +753,7 @@ static ssize_t __write_ports_delxprt(char *buf) if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL) return -EINVAL; - xprt = svc_find_xprt(nfsd_serv, transport, &init_net, AF_UNSPEC, port); + xprt = svc_find_xprt(nfsd_serv, transport, net, AF_UNSPEC, port); if (xprt == NULL) return -ENOTCONN; @@ -764,22 +762,23 @@ static ssize_t __write_ports_delxprt(char *buf) return 0; } -static ssize_t __write_ports(struct file *file, char *buf, size_t size) +static ssize_t __write_ports(struct file *file, char *buf, size_t size, + struct net *net) { if (size == 0) return __write_ports_names(buf); if (isdigit(buf[0])) - return __write_ports_addfd(buf); + return __write_ports_addfd(buf, net); if (buf[0] == '-' && isdigit(buf[1])) return __write_ports_delfd(buf); if (isalpha(buf[0])) - return __write_ports_addxprt(buf); + return __write_ports_addxprt(buf, net); if (buf[0] == '-' && isalpha(buf[1])) - return __write_ports_delxprt(buf); + return __write_ports_delxprt(buf, net); return -EINVAL; } @@ -858,9 +857,10 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size) static ssize_t write_ports(struct file *file, char *buf, size_t size) { ssize_t rv; + struct net *net = &init_net; mutex_lock(&nfsd_mutex); - rv = __write_ports(file, buf, size); + rv = __write_ports(file, buf, size, net); mutex_unlock(&nfsd_mutex); return rv; }