From owner-freebsd-hackers@FreeBSD.ORG Sun Jan 23 10:16:33 2011 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9E4721065675; Sun, 23 Jan 2011 10:16:33 +0000 (UTC) (envelope-from aurelien@aurel32.net) Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:470:1f15:c4f::1]) by mx1.freebsd.org (Postfix) with ESMTP id 0E50F8FC17; Sun, 23 Jan 2011 10:16:33 +0000 (UTC) Received: from static-qvn-qvu-163095.business.bouyguestelecom.com ([89.81.163.95] helo=ohm.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1Pgwzn-0006Hx-3t; Sun, 23 Jan 2011 11:16:32 +0100 Received: from aurel32 by ohm.aurel32.net with local (Exim 4.72) (envelope-from ) id 1PgwVe-0008NJ-QM; Sun, 23 Jan 2011 10:45:22 +0100 Date: Sun, 23 Jan 2011 10:45:22 +0100 From: Aurelien Jarno To: Jaakko Heinonen Message-ID: <20110123094522.GA32156@ohm.aurel32.net> References: <20110114122454.GA4805@jh> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20110114122454.GA4805@jh> X-Mailer: Mutt 1.5.20 (2009-06-14) User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Sun, 23 Jan 2011 12:25:51 +0000 Cc: rodrigc@FreeBSD.org, freebsd-hackers@FreeBSD.org Subject: Re: [patch] nmount ro, rw and negated option handling X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jan 2011 10:16:33 -0000 On Fri, Jan 14, 2011 at 02:24:54PM +0200, Jaakko Heinonen wrote: > > Hi, Hi, > Currently nmount(2) allows a mount point to have "ro", "rw", and "noro" > string options concurrently active. This can cause erratic behavior > demonstrated by this example: > > 1. Have mountd(8) running. > 2. # mdconfig -a -t vnode -f ufsimg > 3. # mount -o ro,rw /dev/md0 /mnt > > After these steps the mount point has string options "ro", "rw" and > "noro" active but the MNT_RDONLY flag is not set. Eventually this will > lead to "ffs_sync: rofs mod" (or similar) panic because the ffs code > marks the file system read-only due to the "ro" string option. > (MNT_RDONLY flag is used in most places for read-only check.) > > I wrote a patch to do following changes: > > - vfs_equalopts() now recognizes "ro" and "rw" as equal options > - vfs_mergeopts() uses vfs_sanitizeopts() to merge options. This ensures > that if the same option shows up several times (negated or not), only > the last one is taken in account. There is still a problem when for > example option "foo" and "nofoo" are merged: the "nofoo" option will > become an active option. This is not a regression however and > currently I don't know an easy way to solve this because the list of > valid options is not available in vfs_mergeopts(). > - vfs_donmount() always converts "norw"/"rdonly" to "ro" and "noro" to > "rw". Thus the mount point will always have either "rw" or "ro" > option. I haven't seen any in-tree file system to test for "noro" but > at least ZFS tests for "rw". That's why I chose "rw" instead or > "noro". > > The patch is available here: > > http://people.freebsd.org/~jh/patches/nmount-ro-rw.diff > > Reviews and testing would be appreciated. > Thanks for the patch, I confirm it fixes the issue I reported in kern/150206. Aurelien -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net