Btrfs: fix snapshot vs nocow writting
Btrfs: fix snapshot vs nocow writting

While running fsstress and snapshots concurrently, we will hit something
like followings:

Thread 1			Thread 2

|->fallocate
  |->write pages
    |->join transaction
       |->add ordered extent
    |->end transaction
				|->flushing data
				  |->creating pending snapshots
|->write data into src root's
   fallocated space

After above work flows finished, we will get a state that source and
snapshot root share same space, but source root have written data into
fallocated space, this will make fsck fail to verify checksums for
snapshot root's preallocating file extent data.Nocow writting also
has this same problem.

Fix this problem by syncing snapshots with nocow writting:

 1.for nocow writting,if there are pending snapshots, we will
 fall into COW way.

 2.if there are pending nocow writes, snapshots for this root
 will be blocked until nocow writting finish.

Reported-by: Gui Hecheng <1c5d69841cd43aa5bd620389a9dfe310c76cb958@cn.fujitsu.com>
Signed-off-by: Wang Shilong <a6ffe7a539d70ea74089829fdeeb6c8d6acce33c@cn.fujitsu.com>
Signed-off-by: Chris Mason <e2e8c5702d8ed5f565988a1cf5bb35c9ce199e5e@fb.com>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs