From owner-cvs-all@FreeBSD.ORG Wed Mar 5 12:20:33 2008 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6351106566C for ; Wed, 5 Mar 2008 12:20:33 +0000 (UTC) (envelope-from yar.tikhiy@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by mx1.freebsd.org (Postfix) with ESMTP id 54E888FC1B for ; Wed, 5 Mar 2008 12:20:32 +0000 (UTC) (envelope-from yar.tikhiy@gmail.com) Received: by nf-out-0910.google.com with SMTP id b2so1082388nfb.33 for ; Wed, 05 Mar 2008 04:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:sender; bh=Im15V2VZ6jha8UzzcpJnrxWnGDoSD4YB0H2ttiFkWyQ=; b=J0ypva1LMO/QnZ+dBboeibm4gNpxA5CSNQzpmga467H0iLvtO6RK2h4rndxwzbvz0620WNjaO1RKfvzg11t1c5Vpkmhps5o7JGduA5onMRSGJTFQNzA8qOed+uq8dNCWSxI8W2C8wRbB4WewEwzNmfC6HjOiFlGU/Enz9d1Fxrk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:sender; b=JS64hxQ4p6AyrzBHaxICXF8EkmDrHP2Kf/8cdBhbO+217rWvVka0UXh1ke614DMTyvu0/DDIu90rOsSyE0TVdwTDfV/lAa9TnK4ZPrEwYOAO/o5hoez4LZrGetWGIK1s6eKdVzEn6uAwDrla6lDQ1G9GnYCkNXnynFRtF8T4nt0= Received: by 10.82.187.2 with SMTP id k2mr7108327buf.26.1204719631527; Wed, 05 Mar 2008 04:20:31 -0800 (PST) Received: from dg.local ( [83.237.57.198]) by mx.google.com with ESMTPS id d13sm1195250fka.7.2008.03.05.04.20.27 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Mar 2008 04:20:29 -0800 (PST) Date: Wed, 5 Mar 2008 15:20:29 +0300 From: Yar Tikhiy To: Craig Rodrigues Message-ID: <20080305122029.GA7027@dg.local> References: <200803050825.m258Ppv2016738@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200803050825.m258Ppv2016738@repoman.freebsd.org> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: Yar Tikhiy Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sbin/fsck_ffs main.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Mar 2008 12:20:33 -0000 On Wed, Mar 05, 2008 at 08:25:49AM +0000, Craig Rodrigues wrote: > rodrigc 2008-03-05 08:25:49 UTC > > FreeBSD src repository > > Modified files: > sbin/fsck_ffs main.c > Log: > For a mounted file system which is read-only, when > doing the MNT_RELOAD, pass in "ro" and "update" > string mount options to nmount() instead of MNT_RDONLY and MNT_UPDATE flags. > > Due to the complexity of the mount parsing code especially > with respect to the root file system, passing in MNT_RDONLY and MNT_UPDATE > flags would do weird things and would cause fsck to convert the root > file system from a read-only mount to read-write. Your analysis of the problem sounds not quite correct to me. In fact, the weird things happen because the "ro" string option isn't set on the root mount from the outset. After your patch, fsck just adds the missing "ro" to the root mount options `when it becomes safe to do so' -- the "ro" string option is dangerous to set on the root FS from the outset due to a bunch of bugs in the kernel code, as my experience with this issue showed to the public. The bugs are all the same: one piece of code passes bit flags and old-style mount() arguments while its counterpart wants string options or vice versa. Our current position in the middle of the way appears totally unacceptable as it leads to problems like this one. Either we should arrive at using string options exlusively, or abandon them at all. Also note that, were the string options implemented in full, there would be no need for fsck to pass "ro" along with "update" to preserve read-only status: existing string options go away from the mount point only if explicitly turned off through a "no" prefix, as in "noro". This is an evident design point of string options, and it's implemented already (modulo bugs in vfs_mergeopts().) Finally, it can be argued that "update" actually belongs to nmount() flags, not to string options, because essentially it is not a persistent mount option, it's a modifier for the current operation requested by this nmount() call. But this is a topic for a separate discussion on the desired nmount(2) semantics. I won't restart our back-out war, but please clearly mark your change as a temporary workaround so that it doesn't mislead people, including us when we revisit the code. Adding "ro" to the root mount options lately is an obvious hack, and it isn't a job for fsck at all. It'll be safe to set the "ro" string option on the root mount from the beginning as soon as all the root-capable filesystems and their mount_foo tools are converted to using string options properly. A crucial part of the task is your work on nfs_mount(), which I fully support. Thanks! > To test: > - boot into single user mode > - show mounted file systems with: mount > - root file system should be mounted read-only > - fsck / > - show mounted file systems with: mount > - root file system should still be mounted read-only > > PR: 120319 > MFC after: 1 month > Reported by: yar > > Revision Changes Path > 1.49 +3 -1 src/sbin/fsck_ffs/main.c -- Yar