From owner-freebsd-fs@FreeBSD.ORG Fri Jul 15 10:38:27 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 10F731065672 for ; Fri, 15 Jul 2011 10:38:27 +0000 (UTC) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.kpi.ua (comsys.kpi.ua [77.47.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 82CFF8FC16 for ; Fri, 15 Jul 2011 10:38:26 +0000 (UTC) Received: from pm513-1.comsys.kpi.ua ([10.18.52.101] helo=pm513-1.comsys.ntu-kpi.kiev.ua) by comsys.kpi.ua with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Qhfmr-0004Ki-Hk for freebsd-fs@freebsd.org; Fri, 15 Jul 2011 13:38:25 +0300 Received: by pm513-1.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1001) id B0B4B1CC21; Fri, 15 Jul 2011 13:38:25 +0300 (EEST) Date: Fri, 15 Jul 2011 13:38:25 +0300 From: Andrey Simonenko To: freebsd-fs@freebsd.org Message-ID: <20110715103825.GA88016@pm513-1.comsys.ntu-kpi.kiev.ua> References: <201107081310.p68DA3Nj019275@freefall.freebsd.org> <20110715101308.GB87688@pm513-1.comsys.ntu-kpi.kiev.ua> <4E2015FC.8020906@aon.at> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="NzB8fVQJ5HfG6fxh" Content-Disposition: inline In-Reply-To: <4E2015FC.8020906@aon.at> User-Agent: Mutt/1.5.21 (2010-09-15) X-Authenticated-User: simon@comsys.ntu-kpi.kiev.ua X-Authenticator: plain X-Sender-Verify: SUCCEEDED (sender exists & accepts mail) X-Exim-Version: 4.63 (build at 10-Dec-2010 16:36:10) X-Date: 2011-07-15 13:38:25 X-Connected-IP: 10.18.52.101:59212 X-Message-Linecount: 140 X-Body-Linecount: 123 X-Message-Size: 5746 X-Body-Size: 5022 Subject: Re: kern/131342: [nfs] mounting/unmounting of disks causes NFS to fail X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2011 10:38:27 -0000 --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Jul 15, 2011 at 12:19:56PM +0200, Martin Birgmeier wrote: > I do not think what you write has to do with the error condition I > describe, for two reasons: first, mountd is only consulted while doing > mounts, and the client is not doing a mount, but rather only a file > access on an already mounted file system; and second, this happens when > I mount a file system on the server which is not exported and thus does > not cause the exports list to be changed. I completely understood the situation you have described. The mountd is responsible for NFSv2/3 MOUNT requests (all procedures MNT, DUMP, UMNT, UNMNTALL, EXPORT), and it is responsible for loading NFS export settings into the kernel part of NFS server. When one mounts any file system on the server, then the mount(8) utility sends SIGHUP to mountd(8), see the src/sbin/mount/mount.c:restart_mountd() function. When mountd(8) re-reads exports(5) file(s), it 1) flushes all current settings and 2) loads all new settings one-by-one. So, mountd(8) reloads all NFS export settings on each file system local mount, even if a file system is being mounted is not NFS exported. If a NFSv2/3/4 client is active on some NFS exported file system, then it will get "access denied" error, NFS export settings on a server side are incomplete. If you do not believe me, then apply attached patch to src/sbin/mount/mount.c and try to reproduce this error. ps: I send CC to freebsd-fs as a separate email, because for some reason my messages could not be delivered to freebsd-fs during last week. > > Regards, > > Martin > > On 07/15/11 12:13, Andrey Simonenko wrote: > > On Fri, Jul 08, 2011 at 01:10:03PM +0000, Martin Birgmeier wrote: > >> The following reply was made to PR kern/131342; it has been noted by GNATS. > >> > >> From: Martin Birgmeier > >> To: bug-followup@FreeBSD.org > >> Cc: > >> Subject: Re: kern/131342: [nfs] mounting/unmounting of disks causes NFS to > >> fail > >> Date: Fri, 08 Jul 2011 15:00:03 +0200 > >> > >> This is a friendly reminder that some kind soul with knowledge of the > >> relevant kernel parts look into this... the error can easily be > >> reproduced. I just had it on a 7.4 system which did heavy reading from > >> an 8.2 server. When I mounted something on the server, the client got a > >> "Permission denied" reply. > >> > >> So, to recap the scenario: > >> > >> 7.4 NFS client > >> 8.2 NFS server > >> client mounts a fs from the server (via IPv4, might be interesting to > >> look at http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/151681, too, but > >> that is unrelated) > >> client does heavy i/o on the mounted fs > >> server does a mount (on its side, in this case it was from an md device) > >> > >> --> error: client gets back some NFS error (in this case "permission > >> denied") > >> > > This is a well-known behaviour of NFS server on FreeBSD when some file > > system is mounted on a server part. This happens because when mount(8) > > mounts something it sends the SIGHUP signal to mountd(8), it then re-reads > > exports(5) file and loads new settings into NFS server. Since mountd(8) > > flushes current settings, loads new settings in a step-by-step style, all > > these changes are happened in nonatomic way. As a result exports settings > > in the NFS server are incomplete in any point of time during configuration > > loading or reloading. > > > > This time window allows "denied" clients to access not allowed parts of > > exported file systems and "allowed" clients can get access denied errors. > > > > If you are interested in this topic, you can look on the kern/136865 > > and my messages related to this topic (information in [3] is outdated > > and in [4] is very outdated): > > > > 1. NFS exports atomic and on-the-fly atomic updates > > http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/136865 > > > > 2. NFSE: new NFS exports support for FreeBSD > > http://nfse.sourceforge.net/ > > > > 3. NFS exports atomic and on-the-fly atomic updates > > http://lists.freebsd.org/pipermail/freebsd-hackers/2009-June/028782.html > > > > 4. Atomic updates of NFS export lists > > http://lists.freebsd.org/pipermail/freebsd-hackers/2006-April/016248.html > > > > 5. CFT: nfse compatible mode with mountd (NFS exports file) > > http://lists.freebsd.org/pipermail/freebsd-fs/2010-May/008421.html > > > > --NzB8fVQJ5HfG6fxh Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mount.c.diff" --- mount.c.orig 2011-07-12 13:20:43.000000000 +0300 +++ mount.c 2011-07-15 13:31:45.000000000 +0300 @@ -233,8 +233,8 @@ restart_mountd(void) return; } /* We have mountd(8) PID in mountdpid varible, let's signal it. */ - if (kill(mountdpid, SIGHUP) == -1) - err(1, "signal mountd"); +/* if (kill(mountdpid, SIGHUP) == -1) + err(1, "signal mountd");*/ } int --NzB8fVQJ5HfG6fxh--