From patchwork Mon Oct 24 11:27:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp534524wru; Mon, 24 Oct 2022 09:11:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4NffbxWq4coikhSaGvqTSNM62t31x/9z0EXqzSwE+wAHYPYZYopP+Fzhl40TMsaJyKmi5E X-Received: by 2002:a05:6a00:4192:b0:563:5e95:1db3 with SMTP id ca18-20020a056a00419200b005635e951db3mr34472703pfb.14.1666627874640; Mon, 24 Oct 2022 09:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666627874; cv=none; d=google.com; s=arc-20160816; b=u1F/IuQSvcL4+k4JgzSm910Qw/VsqxbrqBdwZgFGFo7ZYayTNf+saEYgiA41VtXYRe 1reP9cIzcrck3WILOnpkOno0XgDpf0ZrmT5FwlwcfPVHleSXy1J5bkJ2Pt5Q7Rkjl9qz /RO9Fk5od6c7JVAoApxPlfti0NrG2/IO0mucqXYN+cvRdO/HWjpY9XXr6aE/hLnkIp4G 1CKSfOJeo1jcUPaJeXj9i3cGJzYG0jWf1jDANJQU3s/U/P+H7+Lp4bKl207Fi+FSyQil 9tJy32CAcbWFraE/z1YVUVh1d0/L9/eQUGzurRyzIUUqpFqLN1dg6j60ixDPkrhZcAAn ZtZw== 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=/U/yr4JfCGI3+QaE1tPgeaVdqO/m81flMyydc/I35hA=; b=0KqFq4LyfJIp3X5EwwJwSg1ks2wkDCvmC2EQ7p1MjeALePvy//lj4CI7+U+TB3QsO4 D8B3nXgYeg8a7znYE0AOQKyaO7/mPHNBYEyO+wG1ccaiaZqDk2QAEOw+FmJBolPtKlm9 FvFQg6/LDaodnErloKxFammz+sx4zhzSZHUFFe2uS/xa7VdJW/XSyQgTnamBRKW1Nvoa 8R7L6bbJPv9AbVHff7SURqOoeKUCO7/7IEVaEjK+HWAlGsQlPgPe/tPe8wWJdK802nGT IxNgvTiZ5aY10/U0rKhwU0FjhEyscwZaAdy+m0hvceUameia3MsZIgo8fd2OIpfgAmw+ tyoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C1JbzQIq; 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 v24-20020a63d558000000b0046ed15af9d1si9563016pgi.213.2022.10.24.09.11.01; Mon, 24 Oct 2022 09:11:14 -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=C1JbzQIq; 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 S233857AbiJXQJP (ORCPT + 99 others); Mon, 24 Oct 2022 12:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233671AbiJXQEx (ORCPT ); Mon, 24 Oct 2022 12:04:53 -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 C260B14D29; Mon, 24 Oct 2022 07:57:35 -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 BFBC7B81647; Mon, 24 Oct 2022 12:19:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17D14C433D6; Mon, 24 Oct 2022 12:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613979; bh=/tfY/D6Dr1Tjzeph7TEUSjiYk1e6n24XThlyzr692f8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C1JbzQIqs9X31ZZym3fxxSidBX5imMGybIjJcmsJF+QeRHU8o+OqvwsuP3J2r8536 3egcb6p/bmVd67WP6ISpC3rasRL2zOJG/QN6Bh5NpYlQukTT88XSmOWjdVgvk6ptwX SczUgQRWa+SfKepht8lYxjxOemjbFJWgKm2ICH4Y= 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.10 056/390] jbd2: wake up journal waiters in FIFO order, not LIFO Date: Mon, 24 Oct 2022 13:27:33 +0200 Message-Id: <20221024113025.016206957@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747585990423859433?= X-GMAIL-MSGID: =?utf-8?q?1747585990423859433?= 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 @@ -581,7 +581,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 @@ -173,7 +173,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); @@ -199,7 +199,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); /* @@ -894,7 +894,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)