From patchwork Sat Oct 22 07:19:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7833 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1150274wrr; Sat, 22 Oct 2022 03:57:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CjVMGWAQDPpmMeksFoueQG2zLGsb8hbIlQAPM2JYdpobwqrYiJbI3RuE/9IhiF+ncVJuV X-Received: by 2002:a05:6402:c4d:b0:457:99ec:1837 with SMTP id cs13-20020a0564020c4d00b0045799ec1837mr21418826edb.86.1666436247966; Sat, 22 Oct 2022 03:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666436247; cv=none; d=google.com; s=arc-20160816; b=h6Ue3MEfbrILLz1iMOpYVwQaL9aWUjEj9R1vpaMasKUzoPwbEiTPgjFl9ycARNff0b Ss82alp2oTcFjWbhmITDNn44gVdlLvrcZLheJAoqLh5eePZO/vg3OwgogrJHvw9ex4ut WdTilW5frKdUnKqd6aCDpJwKRPW77CREIV6pW9P+y5dn+QnYMhC1f4PmxKdlhRL9f1qJ YflKPHfIa+jttO0BCS6xL4ObxlvW51x6mZE1zLwzF5PoNzlcm/hSsGCOKtb51YfYkED0 ZZWBQfRcHgIqswTUbpbGkpTa4DymCB33WfqLZnul2BAK+c/LAyK5Y55MDvN5CVJA5+42 CumA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/ALK7Sz9ovxgnCUBKau6ehXDCCAg6GA5X/r3UhmtKFQ=; b=OGhNQI1rKWXDRXDbotxF1SRuDsiZHYV3oRmtySPyKRKN2uKLDdBD2Vdgz5lZaYcvBf QNQpiiVIaS2N6to/cz4KIMZuF9KF2ow0v8FfxzwWbaQaCn8dAI+lY1t7vfgp++ZrlPMB KX3BUP+iOOjB642c4j6Kh3emm1Il6L7WMZzrnjkaf8o8Tn8VBB6NZ/SwGntB45raSvtf Yv/nBucUHx2LaWAwJifdrihKjGHgSAZ/3fJYH2HAUqVLCrtbnLPZeUXQN8cFEuZgoF8Q q/gJKEHbgr8p7SQIL666LV2XeyqOTGjYrISOzdx387HkV6zY2UkgRDfqcYxdZVRXgwik Krgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1DLftlsd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a170906b10c00b00787abcb1ce0si20961077ejy.679.2022.10.22.03.57.03; Sat, 22 Oct 2022 03:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1DLftlsd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbiJVKsG (ORCPT + 99 others); Sat, 22 Oct 2022 06:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbiJVKrs (ORCPT ); Sat, 22 Oct 2022 06:47:48 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AE4F2B7326; Sat, 22 Oct 2022 03:05:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 908E1CE2CA9; Sat, 22 Oct 2022 07:39:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C209C433C1; Sat, 22 Oct 2022 07:39:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424364; bh=ShO28mfr568YysBoAVb2B7fppYLdFHUTzMnQl/bF2BE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1DLftlsd54Nl1s+BNpUd3FEbs5D6BUwbZQ+lbH4Dx7FDxW8AcdMrJTPrM/way3LD0 +ksluEFnZANYTBTCasJHQ4mpIQU0AoDrgQDvJ69lJA/fw7D2aH5CxrL0jWBNFzlLMx GLDOWXFyY9RhAEjxH4ys06saTKtnmT40QlIZCNNc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Alexey Lyashkov , "Ritesh Harjani (IBM)" , Theodore Tso Subject: [PATCH 5.19 118/717] jbd2: wake up journal waiters in FIFO order, not LIFO Date: Sat, 22 Oct 2022 09:19:57 +0200 Message-Id: <20221022072436.348390186@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747385054982851605?= X-GMAIL-MSGID: =?utf-8?q?1747385054982851605?= From: Andrew Perepechko commit 34fc8768ec6089565d6d73bad26724083cecf7bd upstream. LIFO wakeup order is unfair and sometimes leads to a journal user not being able to get a journal handle for hundreds of transactions in a row. FIFO wakeup can make things more fair. Cc: stable@kernel.org Signed-off-by: Alexey Lyashkov Reviewed-by: Ritesh Harjani (IBM) Link: https://lore.kernel.org/r/20220907165959.1137482-1-alexey.lyashkov@gmail.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/commit.c | 2 +- fs/jbd2/transaction.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -570,7 +570,7 @@ void jbd2_journal_commit_transaction(jou journal->j_running_transaction = NULL; start_time = ktime_get(); commit_transaction->t_log_start = journal->j_head; - wake_up(&journal->j_wait_transaction_locked); + wake_up_all(&journal->j_wait_transaction_locked); write_unlock(&journal->j_state_lock); jbd_debug(3, "JBD2: commit phase 2a\n"); --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -168,7 +168,7 @@ static void wait_transaction_locked(jour int need_to_start; tid_t tid = journal->j_running_transaction->t_tid; - prepare_to_wait(&journal->j_wait_transaction_locked, &wait, + prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait, TASK_UNINTERRUPTIBLE); need_to_start = !tid_geq(journal->j_commit_request, tid); read_unlock(&journal->j_state_lock); @@ -194,7 +194,7 @@ static void wait_transaction_switching(j read_unlock(&journal->j_state_lock); return; } - prepare_to_wait(&journal->j_wait_transaction_locked, &wait, + prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait, TASK_UNINTERRUPTIBLE); read_unlock(&journal->j_state_lock); /* @@ -920,7 +920,7 @@ void jbd2_journal_unlock_updates (journa write_lock(&journal->j_state_lock); --journal->j_barrier_count; write_unlock(&journal->j_state_lock); - wake_up(&journal->j_wait_transaction_locked); + wake_up_all(&journal->j_wait_transaction_locked); } static void warn_dirty_buffer(struct buffer_head *bh)