From patchwork Thu Jun 3 15:20:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12297435 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B6215C47096 for ; Thu, 3 Jun 2021 15:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DA16613F4 for ; Thu, 3 Jun 2021 15:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232008AbhFCPYs (ORCPT ); Thu, 3 Jun 2021 11:24:48 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:46758 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbhFCPYs (ORCPT ); Thu, 3 Jun 2021 11:24:48 -0400 Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id AF0F821A01; Thu, 3 Jun 2021 15:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622733782; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ChSmtv2sbtzKIbixBJEYI0hyiOk1rXtHFUyiwV/GFik=; b=EdYX0kvosiKWeRGMQIpT+XCCXxV0KlqY8Sz4lc0QohWaq87B1Tk5vKvlaB098Kft/xemym ZcuzqNE8aMUlLIJgvMwMlhF7WwZ7kpAXiq3cPq9VzDx4mdNSbRH003YzTb6gsMsT4z46uJ TvQqGJrXhJ/ivg7V+eAyeRfzRFJvAJI= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id A9123A3BBB; Thu, 3 Jun 2021 15:23:02 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id C8122DA734; Thu, 3 Jun 2021 17:20:21 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 1/4] btrfs: sink wait_for_unblock parameter to async commit Date: Thu, 3 Jun 2021 17:20:21 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org There's only one caller left btrfs_ioctl_start_sync that passes 0, so we can remove the switch in btrfs_commit_transaction_async. A cleanup 9babda9f33fd ("btrfs: Remove async_transid from btrfs_mksubvol/create_subvol/create_snapshot") removed calls that passed 1, so this is a followup. As this removes last call of wait_current_trans_commit_start_and_unblock, remove the function as well. Signed-off-by: David Sterba Reviewed-by: Anand Jain --- fs/btrfs/ioctl.c | 2 +- fs/btrfs/transaction.c | 24 ++---------------------- fs/btrfs/transaction.h | 3 +-- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 2bdaf2018197..f83eb4a225cc 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3643,7 +3643,7 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root, goto out; } transid = trans->transid; - ret = btrfs_commit_transaction_async(trans, 0); + ret = btrfs_commit_transaction_async(trans); if (ret) { btrfs_end_transaction(trans); return ret; diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 22951621363f..30347e660027 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1882,19 +1882,6 @@ static void wait_current_trans_commit_start(struct btrfs_fs_info *fs_info, TRANS_ABORTED(trans)); } -/* - * wait for the current transaction to start and then become unblocked. - * caller holds ref. - */ -static void wait_current_trans_commit_start_and_unblock( - struct btrfs_fs_info *fs_info, - struct btrfs_transaction *trans) -{ - wait_event(fs_info->transaction_wait, - trans->state >= TRANS_STATE_UNBLOCKED || - TRANS_ABORTED(trans)); -} - /* * commit transactions asynchronously. once btrfs_commit_transaction_async * returns, any subsequent transaction will not be allowed to join. @@ -1922,8 +1909,7 @@ static void do_async_commit(struct work_struct *work) kfree(ac); } -int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, - int wait_for_unblock) +int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans) { struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_async_commit *ac; @@ -1955,13 +1941,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, __sb_writers_release(fs_info->sb, SB_FREEZE_FS); schedule_work(&ac->work); - - /* wait for transaction to start and unblock */ - if (wait_for_unblock) - wait_current_trans_commit_start_and_unblock(fs_info, cur_trans); - else - wait_current_trans_commit_start(fs_info, cur_trans); - + wait_current_trans_commit_start(fs_info, cur_trans); if (current->journal_info == trans) current->journal_info = NULL; diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index c49e2266b28b..0702e8d9b30e 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -226,8 +226,7 @@ void btrfs_add_dead_root(struct btrfs_root *root); int btrfs_defrag_root(struct btrfs_root *root); int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); int btrfs_commit_transaction(struct btrfs_trans_handle *trans); -int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, - int wait_for_unblock); +int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans); int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans); bool btrfs_should_end_transaction(struct btrfs_trans_handle *trans); void btrfs_throttle(struct btrfs_fs_info *fs_info); From patchwork Thu Jun 3 15:20:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12297437 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 E9EC9C47096 for ; Thu, 3 Jun 2021 15:23:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D799161208 for ; Thu, 3 Jun 2021 15:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232116AbhFCPYu (ORCPT ); Thu, 3 Jun 2021 11:24:50 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:46778 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbhFCPYu (ORCPT ); Thu, 3 Jun 2021 11:24:50 -0400 Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 02EAA21A04; Thu, 3 Jun 2021 15:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622733785; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z8t1pQ5q334oB5+59VWbTGd6Y+RfMp4CI9UYJ85kbHs=; b=Mfo3a57EW6vxgG9yRdSn9THgue808wMbePcTsR69rMX+6TpE/R8zaW4BHvMwOXaQErIuHg N2Tqi+7Mm6qxzQExe9u/YCt3h8An8F/2rg5qMB0bcvsSLIT6T7dNpN1scE2KiRPKWcrBgA 1lqA3BCbNp6ccJH8M7qdDQd4F3NfIj0= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id F1F5CA3B93; Thu, 3 Jun 2021 15:23:04 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 12CE2DA734; Thu, 3 Jun 2021 17:20:24 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 2/4] btrfs: inline wait_current_trans_commit_start in its caller Date: Thu, 3 Jun 2021 17:20:24 +0200 Message-Id: <21a09105f7c7cc9bed5c565b32d3b37964806b82.1622733245.git.dsterba@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Function wait_current_trans_commit_start is now fairly trivial so it can be inlined in its only caller. Signed-off-by: David Sterba Reviewed-by: Anand Jain --- fs/btrfs/transaction.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 30347e660027..73df8b81496e 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1870,18 +1870,6 @@ int btrfs_transaction_blocked(struct btrfs_fs_info *info) return ret; } -/* - * wait for the current transaction commit to start and block subsequent - * transaction joins - */ -static void wait_current_trans_commit_start(struct btrfs_fs_info *fs_info, - struct btrfs_transaction *trans) -{ - wait_event(fs_info->transaction_blocked_wait, - trans->state >= TRANS_STATE_COMMIT_START || - TRANS_ABORTED(trans)); -} - /* * commit transactions asynchronously. once btrfs_commit_transaction_async * returns, any subsequent transaction will not be allowed to join. @@ -1941,7 +1929,13 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans) __sb_writers_release(fs_info->sb, SB_FREEZE_FS); schedule_work(&ac->work); - wait_current_trans_commit_start(fs_info, cur_trans); + /* + * Wait for the current transaction commit to start and block + * subsequent transaction joins + */ + wait_event(fs_info->transaction_blocked_wait, + cur_trans->state >= TRANS_STATE_COMMIT_START || + TRANS_ABORTED(cur_trans)); if (current->journal_info == trans) current->journal_info = NULL; From patchwork Thu Jun 3 15:20:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12297439 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 A9B64C47082 for ; Thu, 3 Jun 2021 15:23:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 950B5613E3 for ; Thu, 3 Jun 2021 15:23:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbhFCPYx (ORCPT ); Thu, 3 Jun 2021 11:24:53 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:40040 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbhFCPYw (ORCPT ); Thu, 3 Jun 2021 11:24:52 -0400 Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 479FB1FD4E; Thu, 3 Jun 2021 15:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622733787; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TWsx6NeqnVVyC63q2+X5wkUlyBfwivB4pgyaqYqGT3U=; b=lxd65Z8bPRIzvZ0Qnzk3PIeSd9pK3PL1Kaw/kdqAt1DJMVAYnR4ceUdRdW31KqQpYKRH4N X5Lq9tAih05POCbkkKmYaJe4DNVqh6Ky3Vn87U2qmEbi0Nhh7fBTSouOCUuPbl7xgE5++S men/xSO1tPcM642tpWd8VHJ/8rDEkks= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 41B88A3B92; Thu, 3 Jun 2021 15:23:07 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 55A16DA734; Thu, 3 Jun 2021 17:20:26 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 3/4] btrfs: replace async commit by pending actions Date: Thu, 3 Jun 2021 17:20:26 +0200 Message-Id: <808c557f1ae3034fdfa2d2361e864aac90ba5a94.1622733245.git.dsterba@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Note: this is a semantic change of what the async transaction ioctl does. This used to be utilized by ceph, together with the now removed user transaction ioctls. Last external code that can be found using this ioctl is a test in ceph testsuite. As btrfs and ceph have taken independent routes, we don't need to keep the code around. The btrfs-progs use the start and wait transaction ioctls in a simpler way, that does not require to block new transaction on the start. The new semantics is to eventually get transaction id of the running transaction if there is anything pending for a commit. The wait for transaction ioctl will block until it's finished. If there's nothing to be done since start, wait will return immediately. This effectively implements "wait for current transaction, if any". Any action started before the start, like deleting a subvolume, may take long time to finish. In case it's fast enough to finish before the start, the following wait will also finish immediately. A long running operation will catch the transaction and block at wait call until it's done. Both cases are expected and shall be the new semantics. This is implemented by the pending action infrastructure, that allows to asynchronously and safely request a commit by just setting a bit and waking the transaction kthread. This is different, because originally start would block, but now it returns immediately. However, the new behaviour still corresponds with the documentation of libbtrfsutil so this should not cause any surprises. This also simplifies a few transaction commit things: - another quirky freezing protection removed - fs_info::transaction_blocked_wait is now never populated, so it's a no-op and can be simplified as well - one less current->journal_info usage, that's been problematic in some cases Signed-off-by: David Sterba --- fs/btrfs/ioctl.c | 12 +++---- fs/btrfs/transaction.c | 74 ------------------------------------------ fs/btrfs/transaction.h | 1 - 3 files changed, 5 insertions(+), 82 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index f83eb4a225cc..445bb19d8a57 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3629,9 +3629,9 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info, static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root, void __user *argp) { + struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_trans_handle *trans; u64 transid; - int ret; trans = btrfs_attach_transaction_barrier(root); if (IS_ERR(trans)) { @@ -3639,15 +3639,13 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root, return PTR_ERR(trans); /* No running transaction, don't bother */ - transid = root->fs_info->last_trans_committed; + transid = fs_info->last_trans_committed; goto out; } transid = trans->transid; - ret = btrfs_commit_transaction_async(trans); - if (ret) { - btrfs_end_transaction(trans); - return ret; - } + /* Trigger commit via the pending action */ + btrfs_set_pending(fs_info, COMMIT); + wake_up_process(fs_info->transaction_kthread); out: if (argp) if (copy_to_user(argp, &transid, sizeof(transid))) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 73df8b81496e..5f3c95c876c8 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1870,80 +1870,6 @@ int btrfs_transaction_blocked(struct btrfs_fs_info *info) return ret; } -/* - * commit transactions asynchronously. once btrfs_commit_transaction_async - * returns, any subsequent transaction will not be allowed to join. - */ -struct btrfs_async_commit { - struct btrfs_trans_handle *newtrans; - struct work_struct work; -}; - -static void do_async_commit(struct work_struct *work) -{ - struct btrfs_async_commit *ac = - container_of(work, struct btrfs_async_commit, work); - - /* - * We've got freeze protection passed with the transaction. - * Tell lockdep about it. - */ - if (ac->newtrans->type & __TRANS_FREEZABLE) - __sb_writers_acquired(ac->newtrans->fs_info->sb, SB_FREEZE_FS); - - current->journal_info = ac->newtrans; - - btrfs_commit_transaction(ac->newtrans); - kfree(ac); -} - -int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans) -{ - struct btrfs_fs_info *fs_info = trans->fs_info; - struct btrfs_async_commit *ac; - struct btrfs_transaction *cur_trans; - - ac = kmalloc(sizeof(*ac), GFP_NOFS); - if (!ac) - return -ENOMEM; - - INIT_WORK(&ac->work, do_async_commit); - ac->newtrans = btrfs_join_transaction(trans->root); - if (IS_ERR(ac->newtrans)) { - int err = PTR_ERR(ac->newtrans); - kfree(ac); - return err; - } - - /* take transaction reference */ - cur_trans = trans->transaction; - refcount_inc(&cur_trans->use_count); - - btrfs_end_transaction(trans); - - /* - * Tell lockdep we've released the freeze rwsem, since the - * async commit thread will be the one to unlock it. - */ - if (ac->newtrans->type & __TRANS_FREEZABLE) - __sb_writers_release(fs_info->sb, SB_FREEZE_FS); - - schedule_work(&ac->work); - /* - * Wait for the current transaction commit to start and block - * subsequent transaction joins - */ - wait_event(fs_info->transaction_blocked_wait, - cur_trans->state >= TRANS_STATE_COMMIT_START || - TRANS_ABORTED(cur_trans)); - if (current->journal_info == trans) - current->journal_info = NULL; - - btrfs_put_transaction(cur_trans); - return 0; -} - - static void cleanup_transaction(struct btrfs_trans_handle *trans, int err) { struct btrfs_fs_info *fs_info = trans->fs_info; diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 0702e8d9b30e..0bdb804fddcb 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -226,7 +226,6 @@ void btrfs_add_dead_root(struct btrfs_root *root); int btrfs_defrag_root(struct btrfs_root *root); int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); int btrfs_commit_transaction(struct btrfs_trans_handle *trans); -int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans); int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans); bool btrfs_should_end_transaction(struct btrfs_trans_handle *trans); void btrfs_throttle(struct btrfs_fs_info *fs_info); From patchwork Thu Jun 3 15:20:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 12297441 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 BA263C47097 for ; Thu, 3 Jun 2021 15:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7C64613EE for ; Thu, 3 Jun 2021 15:23:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232134AbhFCPYz (ORCPT ); Thu, 3 Jun 2021 11:24:55 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:46786 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbhFCPYz (ORCPT ); Thu, 3 Jun 2021 11:24:55 -0400 Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9124221A01; Thu, 3 Jun 2021 15:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622733789; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I/uGzbvHi07RSQCm2ksenXVfLi37DX4LI6jdkL0poEA=; b=NFiCN8hFKJQtQvi0L9WD5mIA0xnS7CD52YLleVXhqFrzE2NC3y30ZjSFGimXklOE3DTgPH 6hPv5+UPTVKH2ywXLZ6vcr6Ke33nEDgjmJQArixJmEINevAdGx9z+XyH2cEgmxQHgk6ACU CHAe8xNU+HosMS6CG9r+53BmwhuE2uc= Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 8A338A3B96; Thu, 3 Jun 2021 15:23:09 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id A090DDA734; Thu, 3 Jun 2021 17:20:28 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 4/4] btrfs: remove fs_info::transaction_blocked_wait Date: Thu, 3 Jun 2021 17:20:28 +0200 Message-Id: <2451f25c6c27f0e3e51774b95efc709bc9abf572.1622733245.git.dsterba@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Previous commit removed last use of transaction_blocked_wait. There were still the waking call sites, that are now without use as there's nothing populating the wait list. As wake_up has a memory barrier semantics, it's directly replaced by smp_mb. The transaction state TRANS_STATE_COMMIT_START is now perhaps trivial, but there's more code relying on that, it's left in place to keep the behaviour as close as possible to the original code. Signed-off-by: David Sterba --- fs/btrfs/ctree.h | 1 - fs/btrfs/disk-io.c | 5 ++--- fs/btrfs/super.c | 1 - fs/btrfs/transaction.c | 3 ++- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index c601f6733576..384c00c982ab 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -683,7 +683,6 @@ struct btrfs_fs_info { struct btrfs_transaction *running_transaction; wait_queue_head_t transaction_throttle; wait_queue_head_t transaction_wait; - wait_queue_head_t transaction_blocked_wait; wait_queue_head_t async_submit_wait; /* diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index d1d5091a8385..bad7df788458 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2986,7 +2986,6 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info) init_waitqueue_head(&fs_info->transaction_throttle); init_waitqueue_head(&fs_info->transaction_wait); - init_waitqueue_head(&fs_info->transaction_blocked_wait); init_waitqueue_head(&fs_info->async_submit_wait); init_waitqueue_head(&fs_info->delayed_iputs_wait); @@ -4918,8 +4917,8 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans, btrfs_destroy_delayed_refs(cur_trans, fs_info); cur_trans->state = TRANS_STATE_COMMIT_START; - wake_up(&fs_info->transaction_blocked_wait); - + /* Serialize state change, but there are no waiters */ + smp_mb(); cur_trans->state = TRANS_STATE_UNBLOCKED; wake_up(&fs_info->transaction_wait); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index bc613218c8c5..8d87da2b2377 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -302,7 +302,6 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, WRITE_ONCE(trans->transaction->aborted, errno); /* Wake up anybody who may be waiting on this transaction */ wake_up(&fs_info->transaction_wait); - wake_up(&fs_info->transaction_blocked_wait); __btrfs_handle_fs_error(fs_info, function, line, errno, NULL); } /* diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 5f3c95c876c8..1fd04170b0bf 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2057,7 +2057,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) } cur_trans->state = TRANS_STATE_COMMIT_START; - wake_up(&fs_info->transaction_blocked_wait); + /* Serialize state change, but there are no waiters */ + smp_mb(); if (cur_trans->list.prev != &fs_info->trans_list) { enum btrfs_trans_state want_state = TRANS_STATE_COMPLETED;