From patchwork Wed Oct 19 08:23:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp206327wrs; Wed, 19 Oct 2022 01:52:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44fXw5De5f+GtwdK0UmRX/qBWbwzvZjrXDa+NjCOtDDYz2fsoQ3L/2r2g/DqQ2IrWonMPq X-Received: by 2002:a17:90b:4a49:b0:20d:5099:f5cc with SMTP id lb9-20020a17090b4a4900b0020d5099f5ccmr8302807pjb.137.1666169518153; Wed, 19 Oct 2022 01:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169518; cv=none; d=google.com; s=arc-20160816; b=VzNfekFtqiJ2oNkiQmvXi28mB4RirLOAKFxsWBsVN1cac/LhVCO7g3aowfTA4Tl7Qd 06+yx8D3Y8QTTKnRLMTuHLdzjL3vC5cCR0Ho9AeY5p13Q//lTGnUJgGwKpfRgEDnXGE8 Z1tkiKRxso/XTIb83Riy9mOsPclfhtR2kDE++r/k/eq2Tz/d6EvB4zVmD02iHgTQMNsj 0co65XV3Vq8HZS1rbQW+GQHCCt++ZLmbghwihQYiKZC2mXd28v3AdpVO8ar4ejZPhOaF JVZDoOpPejkEI//Z+/+vXVm0Jxo7LfXjvOQdJqPNk1gWbzDBOKr5+ioq+3mAqqGtvqgS y2jg== 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=SSCFoykw6FOO9SCXCfgU9pfFvNMe+Z5LomXoHQnUAnM=; b=muGrseIOqi3quCvYh3JE2BL0FwjCHp3kJHzE4ulIoDLWqu7P3ys+PWuSTQWC67eQR7 0ieKFwFTBsGogpMXvMXipYxZHC2B1J41f6NzXORG6+530MAudhxMg02bp7zPzN33h0S/ 0Y3BY64cTl5UE/5UBFeTsnqijWJmofQz9QetL6MWm67+Ff9abwvAHXzOyUGodHebSq9L iIxqLU1R0YHGyskq4hGzNAmbNrFHlg444YAT4BbpJd0zj4w6WdkG0KCQMoYj/g2q8DcM OoZIQjs1Sh1nmOy99Lx0msS1qXnnAr6XUQ2Rf6xYTUHPitRxSB5EdlOG/YQ3QUFhoXu9 ngMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lXd62CKw; 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 f6-20020a056a001ac600b00537b1bc9683si19713238pfv.36.2022.10.19.01.51.45; Wed, 19 Oct 2022 01:51:58 -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=lXd62CKw; 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 S231678AbiJSIvX (ORCPT + 99 others); Wed, 19 Oct 2022 04:51:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231728AbiJSItJ (ORCPT ); Wed, 19 Oct 2022 04:49:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B6DF7F246; Wed, 19 Oct 2022 01:47:16 -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 ams.source.kernel.org (Postfix) with ESMTPS id 47510B822EB; Wed, 19 Oct 2022 08:43:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4BBBC433D6; Wed, 19 Oct 2022 08:43:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169017; bh=GfjJ62WabbxNGfZrN6l/TGRZ5OdTIj100vFWISrqwBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXd62CKwgm5/6od99iaKj32dynNQsZoFkyyBALD9EW73MggUtuyuBwk/ayBNWsj00 CHdtWQam3D847S1/DLVdF/utOUztYdo5bo6wdUJUD9tMxtHPtAAEE/OmT/wCySWoAL lDNtdrlxir9llVVW4qSsKKggaoMNY55+gMwWjCbw= 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 6.0 130/862] jbd2: wake up journal waiters in FIFO order, not LIFO Date: Wed, 19 Oct 2022 10:23:37 +0200 Message-Id: <20221019083255.723410171@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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?1747105369011228197?= X-GMAIL-MSGID: =?utf-8?q?1747105369011228197?= 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); jbd2_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)