Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2186936rbb; Tue, 27 Feb 2024 13:34:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxI3OPhREyea5U8NhlRg9g7o8+W6ohlPJN5cBVLqqjcXfjMJIk2bOKELOTHw9uHbmJvKgS8znwpEjnLnxUgUXwnp0LxD+k0Y/H/K17Gw== X-Google-Smtp-Source: AGHT+IFf+u/uTgpQx5VZcGqT6OOMcEvIiZdBiZhpUBQdi9rQuTGVGNzZuHHyPKQqs6NojGCm9hTe X-Received: by 2002:a17:906:f353:b0:a42:f02e:a7fa with SMTP id hg19-20020a170906f35300b00a42f02ea7famr5871268ejb.3.1709069657651; Tue, 27 Feb 2024 13:34:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709069657; cv=pass; d=google.com; s=arc-20160816; b=ty1uUmoyfjekMRT/YuSgtrUy9uPgBd4GwwjfyLeTH6J7HDXN/e+9VAbRuMEBd86jiu jOP4F/C01LzybYOheZZpYTyLebAS2kr0hvv+R7qnQKfZectci3reNAzeNJ6/O3uJT+eH uvIcG2xt0vHKu/V9QexIA1GoQbnrUFRSzlE4yvDMqNFY8FCzdDJEczhBMm0vwdjSYJzn fE2jACDjiAXO+jOYcTLILkyMmkl3/CyNdwo363CYahTjL83IPlY9/lenB4kALtXO2hNe V0mbYizKyIop6qaYz1R4Ql4KvtcH4womu9AULt80bLO7lpIwskZSAPGXWN4XHDSfp06i KRlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=sLxorEXO+UWl8ElTE+BkQxN9zHMh9Hb7JOYF/O3mhow=; fh=qJDq/zsQ/WSSFew0aHNoOgSvNQcYTd3ML5z1vc3a4Jg=; b=gvx3aVyua1EZdMyBBeomgX6+ETDMYuiQTUSJgdVmcrPJJyA9UlF9Ghk+5eGNC1+L+b pmNEESXC/EAC6zx0j/0QviM3nGvAipqzoModl6CG/axJinZCZVlsZsGD4U6/NECsDck6 6g4ppzyVg7QGcKrvVi8CQu7GHpVxJWEWEhL07oy7q9palBZRtD23tWkEyIdFPr+xqjQF sbXYGWLy0kAsP+BAkVz81baHMWgdgb+fhWIiUoEPhfVOarF/79EQN2l3+lEkRt72ZDJ6 yWZqXYvYM8kY5lQKEC7+K6OXjC5oV5sdCxECyZGMro4PXPSgbygG0zzTQOfLahlL7HwB 4BEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=thesusis.net); spf=pass (google.com: domain of linux-ext4+bounces-1408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1408-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id by6-20020a170906a2c600b00a3e52e39d96si1012241ejb.256.2024.02.27.13.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 13:34:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=thesusis.net); spf=pass (google.com: domain of linux-ext4+bounces-1408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1408-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 86E941F2E758 for ; Tue, 27 Feb 2024 21:33:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA99314EFE1; Tue, 27 Feb 2024 21:33:29 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from vps.thesusis.net (vps.thesusis.net [34.202.238.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C988A4DA0C for ; Tue, 27 Feb 2024 21:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=34.202.238.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709069609; cv=none; b=YeR5KboDeBspgtPGQMp+swcU/L3Y7kXu3i/OrpRno9gQ/cqaAYExuK6oe3ZveZfw7bkcJjiyTmmCybyb9yad5EL7oYkOiQeOsLF4Nfdb6zQr2qNyrtmwS2fMFAwR/X7BjMM7W76T9ISBh/nUCyiGUWciko7LqvKUMVa66hpcLZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709069609; c=relaxed/simple; bh=Ng5fq7bFGKGorX8ineXVl98VlG7mcrnX9ER8uqksi1c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=LyiWKbwuHvTtHemQ0csEK8EHs4QTosI04Ey/E9yeakwnumjyIH5t0KNJXlk1T0Ms8edAeTIk5fJEJ/kOd4RSj8exuG0AvdW4ucyK1lpLLdi6HVlw7rR1sx1RwT+Im8/qWlDR3y+a5rPJik/VkTzcfpnOGZdzU8EZM3Vr6yjpnkA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thesusis.net; spf=pass smtp.mailfrom=thesusis.net; arc=none smtp.client-ip=34.202.238.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thesusis.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=thesusis.net Received: by vps.thesusis.net (Postfix, from userid 1000) id 1CDB627452; Tue, 27 Feb 2024 16:26:38 -0500 (EST) From: Phillip Susi To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org, Phillip Susi Subject: [PATCH] [RFC] Fix jbd2 to stop waking up sleeping disks on sync Date: Tue, 27 Feb 2024 16:25:46 -0500 Message-Id: <20240227212546.110340-1-phill@thesusis.net> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit I noticed that every time I sync ( which happens automatically when you suspend to ram ), ext4 issues a flush to the block device, even though there have been no writes to flush. This appears to be because jbd2_trans_will_send_data_barrier() returns a 0 when no transaction has been started. The intent appears to be that a transaction that has completed should return 0, and that when there is NO transaction, it should return a 1, but the tests were in the wrong order, leading to the 0 to be returned before checking for the absense of a transaction at all. Reversing the order allows my disk to remain in runtime_pm when syncing. I *think* this is correct, but I'm not very familliar with jbd2, so it may have unintended consequences. What do you think? --- fs/jbd2/journal.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index b6c114c11b97..be13dae767be 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -632,14 +632,16 @@ int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid) if (!(journal->j_flags & JBD2_BARRIER)) return 0; read_lock(&journal->j_state_lock); - /* Transaction already committed? */ - if (tid_geq(journal->j_commit_sequence, tid)) - goto out; commit_trans = journal->j_committing_transaction; if (!commit_trans || commit_trans->t_tid != tid) { ret = 1; goto out; } + /* Transaction already committed? */ + if (tid_geq(journal->j_commit_sequence, tid)) + { + goto out; + } /* * Transaction is being committed and we already proceeded to * submitting a flush to fs partition? -- 2.43.0