btrfs: replace cleaner_delayed_iput_mutex with a waitqueue
The throttle path doesn't take cleaner_delayed_iput_mutex, which means we could think we're done flushing iputs in the data space reservation path when we could have a throttler doing an iput. There's no real reason to serialize the delayed iput flushing, so instead of taking the cleaner_delayed_iput_mutex whenever we flush the delayed iputs just replace it with an atomic counter and a waitqueue. This removes the short (or long depending on how big the inode is) window where we think there are no more pending iputs when there really are some. The waiting is killable as it could be indirectly called from user operations like fallocate or zero-range. Such call sites should handle the error but otherwise it's not necessary. Eg. flush_space just needs to attempt to make space by waiting on iputs. Signed-off-by: Josef Bacik <josef@toxicpanda.com> [ add killable comment and changelog parts ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:

committed by
David Sterba

parent
3ece54e504
commit
034f784d7c
@@ -4279,10 +4279,14 @@ commit_trans:
|
||||
/*
|
||||
* The cleaner kthread might still be doing iput
|
||||
* operations. Wait for it to finish so that
|
||||
* more space is released.
|
||||
* more space is released. We don't need to
|
||||
* explicitly run the delayed iputs here because
|
||||
* the commit_transaction would have woken up
|
||||
* the cleaner.
|
||||
*/
|
||||
mutex_lock(&fs_info->cleaner_delayed_iput_mutex);
|
||||
mutex_unlock(&fs_info->cleaner_delayed_iput_mutex);
|
||||
ret = btrfs_wait_on_delayed_iputs(fs_info);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto again;
|
||||
} else {
|
||||
btrfs_end_transaction(trans);
|
||||
@@ -4967,9 +4971,8 @@ static void flush_space(struct btrfs_fs_info *fs_info,
|
||||
* bunch of pinned space, so make sure we run the iputs before
|
||||
* we do our pinned bytes check below.
|
||||
*/
|
||||
mutex_lock(&fs_info->cleaner_delayed_iput_mutex);
|
||||
btrfs_run_delayed_iputs(fs_info);
|
||||
mutex_unlock(&fs_info->cleaner_delayed_iput_mutex);
|
||||
btrfs_wait_on_delayed_iputs(fs_info);
|
||||
|
||||
ret = may_commit_transaction(fs_info, space_info);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user