From patchwork Sun Dec 6 15:56:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 11954151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B686CC433FE for ; Sun, 6 Dec 2020 16:00:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77CD12256F for ; Sun, 6 Dec 2020 16:00:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727056AbgLFQAb (ORCPT ); Sun, 6 Dec 2020 11:00:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726602AbgLFQAb (ORCPT ); Sun, 6 Dec 2020 11:00:31 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97658C0613D2 for ; Sun, 6 Dec 2020 07:59:50 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id 3so11350664wmg.4 for ; Sun, 06 Dec 2020 07:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=txZRvtdmWIP24YJQTnRPGboBxmqMtJtzwoE6MfP3IEk=; b=uuFWLKQiCoH1KwHzQ5C7pajA7sNxneLzn73FY2x4+6MEA2PIeSn6QQ4Vs+OqFgOvsF 15sRg0P6EZbBCHrTKk0PqBZIrQrfdsKAE1ltLIwibzgfKSLMw+8QZc3jmU3UC/aZ5Q81 I/oyStZCcPvuliJEb+DGJ5VNvf6R8oDE8gRofV0izk52HDAobVhnpeRbxJojx+z0CbUn tMDj/al3keSt3RfRjIiBxLEpQ/aatKVXTWPRozYVoWutqeDiDox81YiqQ1uJAbjf1dpf LZm6OEcvUeUo70FmK+pe48AHn4oQI8RC2Rm6OkL2SzE9UeIENTJTDw8USOVzck0KClpj NJzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=txZRvtdmWIP24YJQTnRPGboBxmqMtJtzwoE6MfP3IEk=; b=VNv0pfy8oQd6Kt+8KqiBOhwzGOFxqNVyqSEfYWpOOXgWapHQaWyoTiRtP8o0HTAGBC i6b5trUFOO+urIK59HF1Bs3OSpM6u8PfUub5XYZ83wNVx3v4yKkahr3yLtVJmR/L93mh UXCEw2nhqNwyj0HJfWjCHYuqKQWSZhUZpg85/gTzz0Jy6PXM5fLoJ94Pa862jW/O/AnW fkTYkIFOHSypZ00dISWrQ5iWv7Kop5c4do7tr5F2SU9NH++5Xi9fnoIzvKsZ66kEXND/ KErDnCDux3Qccw+O/lIsmOmv2dZLV0qiyRh7rZz4YDC/sUt979DjXNYGOljbo6/qClP9 b8OQ== X-Gm-Message-State: AOAM531+dYPKpVeziRnXaoUq1FtHfhw+eOwVEnxa8rqiegAV8s8X6W/h IYr2CcgrH+/rrm/KWL1f1GALeFVEZyH1Zw== X-Google-Smtp-Source: ABdhPJzG++kOxaIehZIbK/rkJ9fS63RS+Lsz5T1QV7B061qSXo0gnMiXACClMU1DaZ8YhaSWw9nW/g== X-Received: by 2002:a7b:c157:: with SMTP id z23mr14335714wmi.35.1607270389279; Sun, 06 Dec 2020 07:59:49 -0800 (PST) Received: from localhost.localdomain ([185.69.145.92]) by smtp.gmail.com with ESMTPSA id h14sm9933355wrx.37.2020.12.06.07.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 07:59:48 -0800 (PST) From: Pavel Begunkov To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: [PATCH v3 1/3] btrfs: fix async discard stall Date: Sun, 6 Dec 2020 15:56:20 +0000 Message-Id: <5667623ac4bc588fd9d715f105b5d1b38090fa71.1607269878.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Might happen that bg->discard_eligible_time was changed without rescheduling, so btrfs_discard_workfn() wakes up earlier than that new time, peek_discard_list() return null, and all work halts and goes to sleep without further rescheduling even there are block groups to discard. It happens pretty often, but not so visible from the userspace because after some time it usually will be kicked off anyway by someone else calling btrfs_discard_reschedule_work(). Fix it by continue rescheduling if block group discard lists are not empty. Signed-off-by: Pavel Begunkov --- fs/btrfs/discard.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/discard.c b/fs/btrfs/discard.c index 1db966bf85b2..36431d7e1334 100644 --- a/fs/btrfs/discard.c +++ b/fs/btrfs/discard.c @@ -199,16 +199,15 @@ static struct btrfs_block_group *find_next_block_group( static struct btrfs_block_group *peek_discard_list( struct btrfs_discard_ctl *discard_ctl, enum btrfs_discard_state *discard_state, - int *discard_index) + int *discard_index, u64 now) { struct btrfs_block_group *block_group; - const u64 now = ktime_get_ns(); spin_lock(&discard_ctl->lock); again: block_group = find_next_block_group(discard_ctl, now); - if (block_group && now > block_group->discard_eligible_time) { + if (block_group && now >= block_group->discard_eligible_time) { if (block_group->discard_index == BTRFS_DISCARD_INDEX_UNUSED && block_group->used != 0) { if (btrfs_is_block_group_data_only(block_group)) @@ -222,12 +221,11 @@ static struct btrfs_block_group *peek_discard_list( block_group->discard_state = BTRFS_DISCARD_EXTENTS; } discard_ctl->block_group = block_group; + } + if (block_group) { *discard_state = block_group->discard_state; *discard_index = block_group->discard_index; - } else { - block_group = NULL; } - spin_unlock(&discard_ctl->lock); return block_group; @@ -438,13 +436,18 @@ static void btrfs_discard_workfn(struct work_struct *work) int discard_index = 0; u64 trimmed = 0; u64 minlen = 0; + u64 now = ktime_get_ns(); discard_ctl = container_of(work, struct btrfs_discard_ctl, work.work); block_group = peek_discard_list(discard_ctl, &discard_state, - &discard_index); + &discard_index, now); if (!block_group || !btrfs_run_discard_work(discard_ctl)) return; + if (now < block_group->discard_eligible_time) { + btrfs_discard_schedule_work(discard_ctl, false); + return; + } /* Perform discarding */ minlen = discard_minlen[discard_index]; From patchwork Sun Dec 6 15:56:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 11954149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6494C4361B for ; Sun, 6 Dec 2020 16:00:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FD0622D06 for ; Sun, 6 Dec 2020 16:00:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbgLFQAj (ORCPT ); Sun, 6 Dec 2020 11:00:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726602AbgLFQAc (ORCPT ); Sun, 6 Dec 2020 11:00:32 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A01FC0613D3 for ; Sun, 6 Dec 2020 07:59:51 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id f190so11437044wme.1 for ; Sun, 06 Dec 2020 07:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MTZNTj9112GUR4EWB5wrXSfr5LJhNHZqAO0IoO3ucUo=; b=o4GoEIXKzg7vekzOMwGVL357Bq/bcuGoN14zfqaYgUN/m1GBqstfjKqC0tAT31xPqG i4aAhxYVrfvtR1F6vpELJWpDM7ab+ZtEwACi+gco2FS9ZoZ8ps6q9QFNwQzA1aOfFMY2 ELhkphTRqiOiFLpaCB2oZ2N9oHjHR50cJVJ4ejV3yjGpY6Kt2F1Uowkn8q9ijXaW9Xok VyNhdfQ5aXBrRSBG74Q1JEMf3xRPMpOfDJXU58fPDikU/6/othq9de73jJPaVVbHGRvn khgpXp+Hr9/cg8hIoBHJQ7/zU9CzIwnSvtaAhrfehgB1ICibrNP/gUU3Img+VPfQtBKZ XVuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MTZNTj9112GUR4EWB5wrXSfr5LJhNHZqAO0IoO3ucUo=; b=SG1+EJlv+CwTGcCCmMrE4Ugzx/bHDI4EfvCZe3TQ5LEWZ6Qbc7yPrnrNBAd/bukI+9 Y9r0NA1DFKuz3rnqUVatvjql50zvk0wiyiFUL19yE29DOSjTNc9yrpRZoBf4sFRJ+plz MgSV9N797eNeVinDndBkVCx/3KXiiXA4CYhKiwOqCz4UMdt0ttDQUU0kyE6fIs9fuaeR LbLcN9HA6jU4dA79N/woXQt82DNKjf+KbRIh6QAgMaDK+KbZgqHEJY2eehj7jb37Ve3s gp8vnKsEuHESHIqJrg/3SLvroX8BYp6PBUPbZYc2jCDTdvWcXisNW9h4HTS0B4V/Jmj3 O2FQ== X-Gm-Message-State: AOAM531l21pifcsNZBaNkZcvEbjOrhigV6fJxYKu0xyXLtn/7w+NaJqv /zVcrAS3Z+9TEl9BZnWgynY= X-Google-Smtp-Source: ABdhPJxqZCrR30Ujd19DOYKuCfAnIYGe73fUEY/5nhMtWKU/UckDhLY7VoEnuYnqEaHAVX7/lFOueg== X-Received: by 2002:a1c:a9c8:: with SMTP id s191mr14215072wme.89.1607270390434; Sun, 06 Dec 2020 07:59:50 -0800 (PST) Received: from localhost.localdomain ([185.69.145.92]) by smtp.gmail.com with ESMTPSA id h14sm9933355wrx.37.2020.12.06.07.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 07:59:50 -0800 (PST) From: Pavel Begunkov To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: [PATCH v3 2/3] btrfs: fix racy access to discard_ctl data Date: Sun, 6 Dec 2020 15:56:21 +0000 Message-Id: X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Because only one discard worker may be running at any given point, it could have been safe to modify ->prev_discard, etc. without synchronisation, if not for @override flag in btrfs_discard_schedule_work() and delayed_work_pending() returning false while workfn is running. That may lead lead to torn reads of u64 for some architectures, but that's not a big problem as only slightly affects the discard rate. Suggested-by: Josef Bacik Signed-off-by: Pavel Begunkov --- fs/btrfs/discard.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/discard.c b/fs/btrfs/discard.c index 36431d7e1334..d641f451f840 100644 --- a/fs/btrfs/discard.c +++ b/fs/btrfs/discard.c @@ -477,13 +477,6 @@ static void btrfs_discard_workfn(struct work_struct *work) discard_ctl->discard_extent_bytes += trimmed; } - /* - * Updated without locks as this is inside the workfn and nothing else - * is reading the values - */ - discard_ctl->prev_discard = trimmed; - discard_ctl->prev_discard_time = ktime_get_ns(); - /* Determine next steps for a block_group */ if (block_group->discard_cursor >= btrfs_block_group_end(block_group)) { if (discard_state == BTRFS_DISCARD_BITMAPS) { @@ -499,7 +492,10 @@ static void btrfs_discard_workfn(struct work_struct *work) } } + now = ktime_get_ns(); spin_lock(&discard_ctl->lock); + discard_ctl->prev_discard = trimmed; + discard_ctl->prev_discard_time = now; discard_ctl->block_group = NULL; spin_unlock(&discard_ctl->lock); From patchwork Sun Dec 6 15:56:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 11954155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A054C19437 for ; Sun, 6 Dec 2020 16:00:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB3F72256F for ; Sun, 6 Dec 2020 16:00:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727105AbgLFQAj (ORCPT ); Sun, 6 Dec 2020 11:00:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbgLFQAi (ORCPT ); Sun, 6 Dec 2020 11:00:38 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9306DC0613D4 for ; Sun, 6 Dec 2020 07:59:52 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id f190so11437068wme.1 for ; Sun, 06 Dec 2020 07:59:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=l6cHtzUW0lFfnXA96r0AM7XktxyIrNASjnZRsCgM30A=; b=AZBuvM6ExdY2ve2CferpLCBrQytDmwhCAVXi2L2BYA30gHiYOuFOJy6k0PZ+yyub9W JHW8wT1hhDtjdspJhQmbNR/fahK58KN2HktD/mAOCEvrQAUKVNuLSgomSQdX6pfbDLl9 +v3jPBLSgf6zF7+5NpqIGVnrIWNgA8WvSngk8gfVq0C+/PNMaKZbOfR7lDC+dBcGzNPq nfWaeuzLHrWFXb/JIdmBJT6xCQXfc5H50vaV2ZiJRO5nHRdt7YHprblEshaIOQjktkoY EjCLmAV+IrRARw1MmQR1dSoUIaiMJR1+RlbDI4xJ7RP/cK8MLu2yZh7l0GuinqRKEu55 qKJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l6cHtzUW0lFfnXA96r0AM7XktxyIrNASjnZRsCgM30A=; b=kIZi51ZVRM1ABwhS1HlxYj49n7VZyrN7v1g3ooauCxhIADbcwKSa4Wvpnd7pGLQ2El U4K1E9lQOm/nO0F+qoMaUgERGp69riYVV9IXAzkcweTDbS8w41/6c74SqxyzWocaCxZa Y4B9eRmzRHXgLwVNbMspTBMVRxlcYXM5rREGV8arrXS+3pkPtYYvkn/hRKM1pCQfYnpL PvrmUdJFVmwZqyv0Wu8vayCS6D/VkWBbrReCGHj9saHPutxjaqSAZ6sATJ9byE77Hsqo ecTgL7Hi6YogE5tpAyCHna2mqafF0vyVa9KTWsDAouxueGxOgT7ueo8bRhX46GmZs7Go ytCw== X-Gm-Message-State: AOAM530w0LSFfgZHcuxardoa4mjj46zTrK7lATUMREX5u1JxbRmNa+jZ ToX9gBE01JnF7GC1o4+tbEk= X-Google-Smtp-Source: ABdhPJxCeyNRyXcRi3Y9DNpMHeLFVvvjw767SxajSM4DJrk5fvtJOemNWKZ2ZcOFcEUMVHhIFCkoKA== X-Received: by 2002:a1c:5a08:: with SMTP id o8mr14288380wmb.142.1607270391384; Sun, 06 Dec 2020 07:59:51 -0800 (PST) Received: from localhost.localdomain ([185.69.145.92]) by smtp.gmail.com with ESMTPSA id h14sm9933355wrx.37.2020.12.06.07.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 07:59:50 -0800 (PST) From: Pavel Begunkov To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: [PATCH v3 3/3] btrfs: don't overabuse discard lock Date: Sun, 6 Dec 2020 15:56:22 +0000 Message-Id: <9c49efdae18b00adf78ea1c076bbf5e461df96b0.1607269878.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_discard_workfn() drops discard_ctl->lock just to take it again in a moment in btrfs_discard_schedule_work(). Avoid that and also reuse ktime. Signed-off-by: Pavel Begunkov --- fs/btrfs/discard.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/discard.c b/fs/btrfs/discard.c index d641f451f840..9d6ab92391a3 100644 --- a/fs/btrfs/discard.c +++ b/fs/btrfs/discard.c @@ -328,28 +328,15 @@ void btrfs_discard_queue_work(struct btrfs_discard_ctl *discard_ctl, btrfs_discard_schedule_work(discard_ctl, false); } -/** - * btrfs_discard_schedule_work - responsible for scheduling the discard work - * @discard_ctl: discard control - * @override: override the current timer - * - * Discards are issued by a delayed workqueue item. @override is used to - * update the current delay as the baseline delay interval is reevaluated on - * transaction commit. This is also maxed with any other rate limit. - */ -void btrfs_discard_schedule_work(struct btrfs_discard_ctl *discard_ctl, - bool override) +static void __btrfs_discard_schedule_work(struct btrfs_discard_ctl *discard_ctl, + u64 now, bool override) { struct btrfs_block_group *block_group; - const u64 now = ktime_get_ns(); - - spin_lock(&discard_ctl->lock); if (!btrfs_run_discard_work(discard_ctl)) - goto out; - + return; if (!override && delayed_work_pending(&discard_ctl->work)) - goto out; + return; block_group = find_next_block_group(discard_ctl, now); if (block_group) { @@ -391,7 +378,24 @@ void btrfs_discard_schedule_work(struct btrfs_discard_ctl *discard_ctl, mod_delayed_work(discard_ctl->discard_workers, &discard_ctl->work, nsecs_to_jiffies(delay)); } -out: +} + +/** + * btrfs_discard_schedule_work - responsible for scheduling the discard work + * @discard_ctl: discard control + * @override: override the current timer + * + * Discards are issued by a delayed workqueue item. @override is used to + * update the current delay as the baseline delay interval is reevaluated on + * transaction commit. This is also maxed with any other rate limit. + */ +void btrfs_discard_schedule_work(struct btrfs_discard_ctl *discard_ctl, + bool override) +{ + u64 now = ktime_get_ns(); + + spin_lock(&discard_ctl->lock); + __btrfs_discard_schedule_work(discard_ctl, now, override); spin_unlock(&discard_ctl->lock); } @@ -497,9 +501,8 @@ static void btrfs_discard_workfn(struct work_struct *work) discard_ctl->prev_discard = trimmed; discard_ctl->prev_discard_time = now; discard_ctl->block_group = NULL; + __btrfs_discard_schedule_work(discard_ctl, now, false); spin_unlock(&discard_ctl->lock); - - btrfs_discard_schedule_work(discard_ctl, false); } /**