VOP_WRITE & read-only file system

Jaakko Heinonen jh at saunalahti.fi
Tue Jul 14 18:25:25 UTC 2009


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


More information about the freebsd-fs mailing list