From owner-freebsd-fs@FreeBSD.ORG Fri Jun 19 09:43:19 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 61522106564A for ; Fri, 19 Jun 2009 09:43:19 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from gw03.mail.saunalahti.fi (gw03.mail.saunalahti.fi [195.197.172.111]) by mx1.freebsd.org (Postfix) with ESMTP id 233F68FC13 for ; Fri, 19 Jun 2009 09:43:18 +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 gw03.mail.saunalahti.fi (Postfix) with SMTP id 029B02166AA for ; Fri, 19 Jun 2009 12:43:16 +0300 (EEST) Date: Fri, 19 Jun 2009 12:43:16 +0300 From: Jaakko Heinonen To: freebsd-fs@FreeBSD.org Message-ID: <20090619094316.GA805@a91-153-125-115.elisa-laajakaista.fi> References: <20090527150258.GA3666@a91-153-125-115.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090527150258.GA3666@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: Fri, 19 Jun 2009 09:43:19 -0000 On 2009-05-27, Jaakko Heinonen wrote: > I found a few ways to get VOP_WRITE called for a read-only system. > > Ways I found: > > 1) mmap(2) > > 2) ktrace(2) > - start ktracing a process > - remount file-system as read-only While kib@ has a patch for mmap(2) I took a look at ktrace(2). 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. As far as I can tell it does this because the same vnode may be associated with several processes and there is no easy and efficient way to know when it is disassociated from last process. Ideas how to fix it? Some thoughts: - Fiddle with writecount. IMHO it wouldn't fix the real bug (write after vn_close()). - Walk through all processes when disconnecting a vnode from process to find out if it was the last process using the vnode. Inefficient. - Keep track of vnodes which are used for tracing and have reference count for them. -- Jaakko