Re: [PATCH] Btrfs: fix deadlock with nested trans handles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 06, 2014 at 07:01:07PM -0500, Josef Bacik wrote:
> Zach found this deadlock that would happen like this
> 
> btrfs_end_transaction <- reduce trans->use_count to 0
>   btrfs_run_delayed_refs
>     btrfs_cow_block
>       find_free_extent
> 	btrfs_start_transaction <- increase trans->use_count to 1
>           allocate chunk
> 	btrfs_end_transaction <- decrease trans->use_count to 0
> 	  btrfs_run_delayed_refs
> 	    lock tree block we are cowing above ^^

Indeed, I stumbled across this while trying to reproduce reported
problems with iozone.  This deadlock would consistently hit during
random 1k reads in a 2gig file.

> We need to only decrease trans->use_count if it is above 1, otherwise leave it
> alone.  This will make nested trans be the only ones who decrease their added
> ref, and will let us get rid of the trans->use_count++ hack if we have to commit
> the transaction.  Thanks,

And this fixes it.  It's run through a few times successfully.

> cc: stable@xxxxxxxxxxxxxxx
> Reported-by: Zach Brown <zab@xxxxxxxxxx>
> Signed-off-by: Josef Bacik <jbacik@xxxxxx>

Tested-by: Zach Brown <zab@xxxxxxxxxx>

- z
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]