freebsd-nq/sys/ufs/ffs
Konstantin Belousov 94f4ac214c An inode block must not be blockingly read while cg block is owned.
The order is inode buffer lock -> snaplk -> cg buffer lock, reversing
the order causes deadlocks.

Inode block must not be written while cg block buffer is owned. The
FFS copy on write needs to allocate a block to copy the content of the
inode block, and the cylinder group selected for the allocation might
be the same as the owned cg block.  The reserved block detection code
in the ffs_copyonwrite() and ffs_bp_snapblk() is unable to detect the
situation, because the locked cg buffer is not exposed to it.

In order to maintain the dependency between initialized inode block
and the cg_initediblk pointer, look up the inode buffer in
non-blocking mode. If succeeded, brelse cg block, initialize the inode
block and write it.  After the write is finished, reread cg block and
update the cg_initediblk.

If inode block is already locked by another thread, let the another
thread initialize it.  If another thread raced with us after we
started writing inode block, the situation is detected by an update of
cg_initediblk.  Note that double-initialization of the inode block is
harmless, the block cannot be used until cg_initediblk is incremented.

Sponsored by:	The FreeBSD Foundation
In collaboration with:	pho
Reviewed by:	mckusick
MFC after:	1 month
X-MFC-note:	after r246877
2013-02-27 07:31:23 +00:00
..
ffs_alloc.c An inode block must not be blockingly read while cg block is owned. 2013-02-27 07:31:23 +00:00
ffs_balloc.c When a file is first being written, the dynamic block reallocation 2012-11-03 18:55:55 +00:00
ffs_extern.h Add UFS writesuspension mechanism, designed to allow userland processes 2012-11-18 18:57:19 +00:00
ffs_inode.c For UFS2 i_blocks is unsigned. The current "sanity" check that it 2013-02-03 17:16:32 +00:00
ffs_rawread.c Add a third flags argument to ffs_syncvnode to avoid a possible conflict 2012-03-25 00:02:37 +00:00
ffs_snapshot.c Add flags argument to vfs_write_resume() and remove 2013-01-11 06:08:32 +00:00
ffs_softdep.c Add flags argument to vfs_write_resume() and remove 2013-01-11 06:08:32 +00:00
ffs_subr.c
ffs_suspend.c Add flags argument to vfs_write_resume() and remove 2013-01-11 06:08:32 +00:00
ffs_tables.c
ffs_vfsops.c Add flags argument to vfs_write_resume() and remove 2013-01-11 06:08:32 +00:00
ffs_vnops.c After the PHYS_TO_VM_PAGE() function was de-inlined, the main reason 2012-08-05 14:11:42 +00:00
fs.h Fix build of kdump(1). 2012-11-18 22:03:31 +00:00
softdep.h - Speed up pendingblock processing again. Having too much delay between 2011-07-04 22:08:04 +00:00