]> www.infradead.org Git - users/willy/xarray.git/commitdiff
btrfs: check worker before need_preemptive_reclaim
authorJosef Bacik <josef@toxicpanda.com>
Wed, 28 Apr 2021 17:38:42 +0000 (13:38 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jun 2021 13:19:04 +0000 (15:19 +0200)
need_preemptive_reclaim() does some calculations, which aren't heavy,
but if we're already running preemptive reclaim there's no reason to do
them at all, so re-order the checks so that we don't do the calculation
if we're already doing reclaim.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/space-info.c

index 2dc674b7c3b14fd6ba306f7d16699c0659753b9f..c9a5e003bcfa377fa997ba1577925ab500e1d2da 100644 (file)
@@ -1588,8 +1588,8 @@ static int __reserve_bytes(struct btrfs_fs_info *fs_info,
                 * the async reclaim as we will panic.
                 */
                if (!test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags) &&
-                   need_preemptive_reclaim(fs_info, space_info) &&
-                   !work_busy(&fs_info->preempt_reclaim_work)) {
+                   !work_busy(&fs_info->preempt_reclaim_work) &&
+                   need_preemptive_reclaim(fs_info, space_info)) {
                        trace_btrfs_trigger_flush(fs_info, space_info->flags,
                                                  orig_bytes, flush, "preempt");
                        queue_work(system_unbound_wq,