Commit db1d607d3ca5cbb283cbb17d648cd7e8dc67cc7b

Authored by Josef Bacik
1 parent 6e137ed3f3

Btrfs: hold the ordered operations mutex when waiting on ordered extents

We need to hold the ordered_operations mutex while waiting on ordered extents
since we splice and run the ordered extents list.  We need to make sure anybody
else who wants to wait on ordered extents does actually wait for them to be
completed.  This will keep us from bailing out of flushing in case somebody is
already waiting on ordered extents to complete.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>

Showing 1 changed file with 2 additions and 0 deletions Side-by-side Diff

fs/btrfs/ordered-data.c
... ... @@ -557,6 +557,7 @@
557 557 INIT_LIST_HEAD(&splice);
558 558 INIT_LIST_HEAD(&works);
559 559  
  560 + mutex_lock(&root->fs_info->ordered_operations_mutex);
560 561 spin_lock(&root->fs_info->ordered_extent_lock);
561 562 list_splice_init(&root->fs_info->ordered_extents, &splice);
562 563 while (!list_empty(&splice)) {
... ... @@ -600,6 +601,7 @@
600 601  
601 602 cond_resched();
602 603 }
  604 + mutex_unlock(&root->fs_info->ordered_operations_mutex);
603 605 }
604 606  
605 607 /*