Skip to content

Commit

Permalink
Btrfs: make sure the delalloc workers actually flush compressed writes
Browse files Browse the repository at this point in the history
When using delalloc workers in a non-waiting way (like for enospc handling) we
can end up not actually waiting for the dirty pages to be started if we have
compression.  We need to add an extra filemap flush to make sure any async
extents that have started are actually moved along before returning.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
  • Loading branch information
Josef Bacik authored and Chris Mason committed Nov 12, 2013
1 parent 9385876 commit 9f23e28
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -8163,18 +8163,24 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
static void btrfs_run_delalloc_work(struct btrfs_work *work)
{
struct btrfs_delalloc_work *delalloc_work;
struct inode *inode;

delalloc_work = container_of(work, struct btrfs_delalloc_work,
work);
if (delalloc_work->wait)
btrfs_wait_ordered_range(delalloc_work->inode, 0, (u64)-1);
else
filemap_flush(delalloc_work->inode->i_mapping);
inode = delalloc_work->inode;
if (delalloc_work->wait) {
btrfs_wait_ordered_range(inode, 0, (u64)-1);
} else {
filemap_flush(inode->i_mapping);
if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
&BTRFS_I(inode)->runtime_flags))
filemap_flush(inode->i_mapping);
}

if (delalloc_work->delay_iput)
btrfs_add_delayed_iput(delalloc_work->inode);
btrfs_add_delayed_iput(inode);
else
iput(delalloc_work->inode);
iput(inode);
complete(&delalloc_work->completion);
}

Expand Down

0 comments on commit 9f23e28

Please sign in to comment.