]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: account for non-CoW'd blocks in btrfs_abort_transaction
authorJeff Mahoney <jeffm@suse.com>
Wed, 8 Jun 2016 04:36:38 +0000 (00:36 -0400)
committerDhaval Giani <dhaval.giani@oracle.com>
Fri, 20 Jan 2017 22:21:56 +0000 (17:21 -0500)
commit0d723081798deacf6a6e71a9a2cc1a6bd740f96b
tree8abcfb2b879e70559fc7f9a860100c88319ec80f
parent65a75af82a941b5a185c3e31703cb8bcdb42ecda
btrfs: account for non-CoW'd blocks in btrfs_abort_transaction

Orabug: 25308019

[ Upstream commit 64c12921e11b3a0c10d088606e328c58e29274d8 ]

The test for !trans->blocks_used in btrfs_abort_transaction is
insufficient to determine whether it's safe to drop the transaction
handle on the floor.  btrfs_cow_block, informed by should_cow_block,
can return blocks that have already been CoW'd in the current
transaction.  trans->blocks_used is only incremented for new block
allocations. If an operation overlaps the blocks in the current
transaction entirely and must abort the transaction, we'll happily
let it clean up the trans handle even though it may have modified
the blocks and will commit an incomplete operation.

In the long-term, I'd like to do closer tracking of when the fs
is actually modified so we can still recover as gracefully as possible,
but that approach will need some discussion.  In the short term,
since this is the only code using trans->blocks_used, let's just
switch it to a bool indicating whether any blocks were used and set
it when should_cow_block returns false.

Cc: stable@vger.kernel.org # 3.4+
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit efe098c364208b0d1fcc1b252290df0fd225d352)
Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
fs/btrfs/ctree.c
fs/btrfs/extent-tree.c
fs/btrfs/super.c
fs/btrfs/transaction.c
fs/btrfs/transaction.h