From owner-freebsd-fs@FreeBSD.ORG Tue Jul 14 18:25:25 2009 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 50809106566B for ; Tue, 14 Jul 2009 18:25:25 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from gw02.mail.saunalahti.fi (gw02.mail.saunalahti.fi [195.197.172.116]) by mx1.freebsd.org (Postfix) with ESMTP id 1116F8FC1F for ; Tue, 14 Jul 2009 18:25:24 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from a91-153-125-115.elisa-laajakaista.fi (a91-153-125-115.elisa-laajakaista.fi [91.153.125.115]) by gw02.mail.saunalahti.fi (Postfix) with SMTP id DF8C21396CD for ; Tue, 14 Jul 2009 21:25:22 +0300 (EEST) Date: Tue, 14 Jul 2009 21:25:22 +0300 From: Jaakko Heinonen To: freebsd-fs@FreeBSD.org Message-ID: <20090714182522.GA40040@a91-153-125-115.elisa-laajakaista.fi> References: <20090527150258.GA3666@a91-153-125-115.elisa-laajakaista.fi> <20090619094316.GA805@a91-153-125-115.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090619094316.GA805@a91-153-125-115.elisa-laajakaista.fi> User-Agent: Mutt/1.5.19 (2009-01-05) Cc: Subject: Re: VOP_WRITE & read-only file system 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: Tue, 14 Jul 2009 18:25:25 -0000 On 2009-06-19, Jaakko Heinonen wrote: > > I found a few ways to get VOP_WRITE called for a read-only system. > > > > 2) ktrace(2) - start ktracing a process - remount file-system as > > read-only > > ktrace too has a problem with writecount. ktrace uses vn_open() to > open the trace file but immediately after that it calls vn_close() > which decreases the writecount. I wrote a couple of patches for ktrace(2). > - Fiddle with writecount. IMHO it wouldn't fix the real bug (write > after vn_close()). http://www.saunalahti.fi/~jh3/patches/ktrace-writecount.diff The patch just increases v_writecount for trace file vnodes. It's quite straightforward and fixes the problem at hand but writes will still happen after vn_close()/VOP_CLOSE(). > - Keep track of vnodes which are used for tracing and have reference > count for them. http://www.saunalahti.fi/~jh3/patches/ktrace-vn_close.diff The patch uses a list to keep track of trace files. A file is closed when reference count hits zero. I am slightly concerned about scalability of the list approach but otherwise this should be more complete fix. -- Jaakko