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
..
2013-02-26 23:35:27 +00:00
2013-02-11 23:14:54 +00:00
2013-02-15 20:36:28 +00:00
2012-11-01 04:07:08 +00:00
2013-02-26 07:00:24 +00:00
2013-02-26 01:00:11 +00:00
2013-02-15 07:58:51 +00:00
2013-01-17 19:03:24 +00:00
2013-02-09 04:13:45 +00:00
2013-02-21 12:52:18 +00:00
2013-02-26 23:35:27 +00:00
2013-02-17 11:57:47 +00:00
2013-02-26 01:00:11 +00:00
2013-02-26 23:35:27 +00:00