]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix race in WAIT_SYNC ioctl
authorSage Weil <sage@redhat.com>
Fri, 26 Sep 2014 15:30:06 +0000 (08:30 -0700)
committerChris Mason <clm@fb.com>
Fri, 3 Oct 2014 23:14:59 +0000 (16:14 -0700)
commit6743853c867dcafb39c673949610f1cc76e5b9e8
tree08e2411cd332c3c56323ac9ffc27164079e29daf
parent8f2202f50801d1849b65c54088d620d3367dd673
Btrfs: fix race in WAIT_SYNC ioctl

We check whether transid is already committed via last_trans_committed and
then search through trans_list for pending transactions.  If
last_trans_committed is updated by btrfs_commit_transaction after we check
it (there is no locking), we will fail to find the committed transaction
and return EINVAL to the caller.  This has been observed occasionally by
ceph-osd (which uses this ioctl heavily).

Fix by rechecking whether the provided transid <= last_trans_committed
after the search fails, and if so return 0.

Signed-off-by: Sage Weil <sage@redhat.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/transaction.c