]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: catch transaction abortion after waiting for it
authorLiu Bo <bo.li.liu@oracle.com>
Fri, 6 Mar 2015 12:23:44 +0000 (20:23 +0800)
committerChris Mason <clm@fb.com>
Fri, 13 Mar 2015 20:38:23 +0000 (13:38 -0700)
commit55080407b5d5fc6f05077bf586b61c337428e8b5
tree6cae8c50aa9733e369e7eddb3f96317b4810ddd1
parent2409025707adf25944cba2c85e439dd8d32413e9
Btrfs: catch transaction abortion after waiting for it

This problem is uncovered by a test case: http://patchwork.ozlabs.org/patch/244297.

Fsync() can report success when it actually doesn't.  When we
have several threads running fsync() at the same tiem and in one fsync() we
get a transaction abortion due to some problems(in the test case it's disk
failures), and other fsync()s may return successfully which makes userspace
programs think that data is now safely flushed into disk.

It's because that after fsyncs() fail btrfs_sync_log() due to disk failures,
they get to try btrfs_commit_transaction() where it finds that there is
already a transaction being committed, and they'll just call wait_for_commit()
and return.  Note that we actually check "trans->aborted" in btrfs_end_transaction,
but it's likely that the error message is still not yet throwed out and only after
wait_for_commit() we're sure whether the transaction is committed successfully.

This add the necessary check and it now passes the test.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/transaction.c