Commit ac98141d authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: wake up async_delalloc_pages waiters after submit

We use the async_delalloc_pages mechanism to make sure that we've
completed our async work before trying to continue our delalloc
flushing.  The reason for this is we need to see any ordered extents
that were created by our delalloc flushing.  However we're waking up
before we do the submit work, which is before we create the ordered
extents.  This is a pretty wide race window where we could potentially
think there are no ordered extents and thus exit shrink_delalloc
prematurely.  Fix this by waking us up after we've done the work to
create ordered extents.

CC: stable@vger.kernel.org # 5.4+
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 963e4db8
...@@ -1306,11 +1306,6 @@ static noinline void async_cow_submit(struct btrfs_work *work) ...@@ -1306,11 +1306,6 @@ static noinline void async_cow_submit(struct btrfs_work *work)
nr_pages = (async_chunk->end - async_chunk->start + PAGE_SIZE) >> nr_pages = (async_chunk->end - async_chunk->start + PAGE_SIZE) >>
PAGE_SHIFT; PAGE_SHIFT;
/* atomic_sub_return implies a barrier */
if (atomic_sub_return(nr_pages, &fs_info->async_delalloc_pages) <
5 * SZ_1M)
cond_wake_up_nomb(&fs_info->async_submit_wait);
/* /*
* ->inode could be NULL if async_chunk_start has failed to compress, * ->inode could be NULL if async_chunk_start has failed to compress,
* in which case we don't have anything to submit, yet we need to * in which case we don't have anything to submit, yet we need to
...@@ -1319,6 +1314,11 @@ static noinline void async_cow_submit(struct btrfs_work *work) ...@@ -1319,6 +1314,11 @@ static noinline void async_cow_submit(struct btrfs_work *work)
*/ */
if (async_chunk->inode) if (async_chunk->inode)
submit_compressed_extents(async_chunk); submit_compressed_extents(async_chunk);
/* atomic_sub_return implies a barrier */
if (atomic_sub_return(nr_pages, &fs_info->async_delalloc_pages) <
5 * SZ_1M)
cond_wake_up_nomb(&fs_info->async_submit_wait);
} }
static noinline void async_cow_free(struct btrfs_work *work) static noinline void async_cow_free(struct btrfs_work *work)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment