From patchwork Tue Mar 22 03:14:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Landley X-Patchwork-Id: 651701 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2M3EXvw003966 for ; Tue, 22 Mar 2011 03:14:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751677Ab1CVDOc (ORCPT ); Mon, 21 Mar 2011 23:14:32 -0400 Received: from mx2.parallels.com ([64.131.90.16]:58750 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532Ab1CVDOc (ORCPT ); Mon, 21 Mar 2011 23:14:32 -0400 Received: from [96.31.168.206] (helo=mail.parallels.com) by mx2.parallels.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.74) (envelope-from ) id 1Q1s3D-00035x-Cy; Mon, 21 Mar 2011 23:14:31 -0400 Received: from [192.168.2.108] (24.27.19.110) by mail.parallels.com (10.255.249.32) with Microsoft SMTP Server (TLS) id 14.1.218.12; Mon, 21 Mar 2011 20:14:29 -0700 Message-ID: <4D881413.9050807@parallels.com> Date: Mon, 21 Mar 2011 22:14:27 -0500 From: Rob Landley User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: Trond Myklebust , "linux-nfs@vger.kernel.org" , Tim Spriggs Subject: [PATCH] Minimal fix to mount NFS in containers with non-default network context. X-Originating-IP: [24.27.19.110] Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 22 Mar 2011 03:14:34 +0000 (UTC) different code path, and if you remount from a different network context I'm not sure what _should_ happen, anyway. Keep the old one, I guess?) (I'm working on a patch adds a network context to nfs_client and then drills that down to the various places that could use it, which is more than just these 3, but it's a lot more intrusive and can be done on top of this. Also, the rpc code is already doing the get_net() and put_net() reference counting for lifetimes this way. When I add it to nfs_client I'll have to get that right myself.) Signed-off-by: Rob Landley --- fs/nfs/client.c | 3 ++- fs/nfs/mount_clnt.c | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 192f2f8..4fb94e9 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -619,7 +620,7 @@ static int nfs_create_rpc_client(struct nfs_client *clp, { struct rpc_clnt *clnt = NULL; struct rpc_create_args args = { - .net = &init_net, + .net = current->nsproxy->net_ns, .protocol = clp->cl_proto, .address = (struct sockaddr *)&clp->cl_addr, .addrsize = clp->cl_addrlen, diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c index d4c2d6b..5564f64 100644 --- a/fs/nfs/mount_clnt.c +++ b/fs/nfs/mount_clnt.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "internal.h" #ifdef RPC_DEBUG @@ -153,7 +156,7 @@ int nfs_mount(struct nfs_mount_request *info) .rpc_resp = &result, }; struct rpc_create_args args = { - .net = &init_net, + .net = current->nsproxy->net_ns, .protocol = info->protocol, .address = info->sap, .addrsize = info->salen, @@ -225,7 +228,7 @@ void nfs_umount(const struct nfs_mount_request *info) .to_retries = 2, }; struct rpc_create_args args = { - .net = &init_net, + .net = current->nsproxy->net_ns, .protocol = IPPROTO_UDP, .address = info->sap, .addrsize = info->salen,