Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2491554pxj; Mon, 10 May 2021 04:23:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLU67Lhy7huK4jl/MeytVnahv4H13puRDx/P5PfdBvoEqd68z6+JbHYSv+1/HRhyWORiXa X-Received: by 2002:a17:906:2510:: with SMTP id i16mr25123185ejb.488.1620645708797; Mon, 10 May 2021 04:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645708; cv=none; d=google.com; s=arc-20160816; b=1FpZ5WRsdecjR4MXvm+E8qPYszZujQ4qJfQYn/NRoeqLA9fXaom4rB5Lfju98pf9lZ qFReGUFZuMjB+bksExpoEGrE8NePClUyGEwsIy8jDPUtCTdpDR5OAqywRzKe4t66JwFe D/tLTt3URqdL3zTppBPRn672yMHuSdaWgb5ULFov5+B6Qoy7AoXHZfMQF7CWaIAgMAhV vXD0+BhL2EvvVn+MnhaKKJiboczGJL+aeSGXeBwnrqrVSW5Qs1wFASJEofA79TCifxIf +DAbF1Szgt1ZDrkUSa8/oVWPIWBVPZNDN8npRu33vCNzgqbwggAabWPDQzkY3TyMuIIC HnpQ== 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=pNrGkzv2YzSQywCUPJfzNqy1Rj7QFK4W6wey0oMZXgo=; b=cj0tIMfum5OmaW31WUpmH8AXqO/6AkIBubd6PPk1GQKat7MYXdxrdMt1HxjvU29ZG5 k/MAvi1anOpDewM59q2Mq9D3Qn2rErMBaunjYlrYr5WC/+ZI2WRnRgx2qsiKTzoEIaaq qDejLZ4cjFbYUkRdkm4bmdVaHJ0/uMS2F6IAqugE8mSazfmnXccCHtQR7jom1bdzn6oi gnOe84ZZA2LRFn8CgWnNZxl8o0ybz3cu5CWtOMT5GnULa/OpCNIeTWGcOBVgWpHmw3Sc uS8IspFgad3NiBgQRMYXpdM1xlW18DEtaFD6Ich8cJ5vVMkEvalmWRdknGO7F1lFPv17 99jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="s3D/2ej/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x16si14417254edd.495.2021.05.10.04.21.25; Mon, 10 May 2021 04:21:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="s3D/2ej/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S238509AbhEJLRw (ORCPT + 99 others); Mon, 10 May 2021 07:17:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:41732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233086AbhEJKyZ (ORCPT ); Mon, 10 May 2021 06:54:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 700476101E; Mon, 10 May 2021 10:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643317; bh=b+X48dCloFuRbRgUeHgCfH6mM1EbHUpVAf6wPUprbmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s3D/2ej/kbpC47UvC++IzBRmUzHL3vW3rDo93hN3AZwtZf2h+hZoEcrGHEHahppJE Ryb6jVRHSQijkgwaNhUKspJ/LwlXQfqDVrznNwgAOqag/SeJ3wLUHmmDjx2cQv1cWj zzXNBc9VFy0YLBB42+deTov6jQdAKnn5b4vSQ6Fs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Hao Sun , Jan Kara , Theodore Tso Subject: [PATCH 5.10 265/299] ext4: annotate data race in jbd2_journal_dirty_metadata() Date: Mon, 10 May 2021 12:21:02 +0200 Message-Id: <20210510102013.696784393@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara commit 83fe6b18b8d04c6c849379005e1679bac9752466 upstream. Assertion checks in jbd2_journal_dirty_metadata() are known to be racy but we don't want to be grabbing locks just for them. We thus recheck them under b_state_lock only if it looks like they would fail. Annotate the checks with data_race(). Cc: stable@kernel.org Reported-by: Hao Sun Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20210406161804.20150-2-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/transaction.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -1479,8 +1479,8 @@ int jbd2_journal_dirty_metadata(handle_t * crucial to catch bugs so let's do a reliable check until the * lockless handling is fully proven. */ - if (jh->b_transaction != transaction && - jh->b_next_transaction != transaction) { + if (data_race(jh->b_transaction != transaction && + jh->b_next_transaction != transaction)) { spin_lock(&jh->b_state_lock); J_ASSERT_JH(jh, jh->b_transaction == transaction || jh->b_next_transaction == transaction); @@ -1488,8 +1488,8 @@ int jbd2_journal_dirty_metadata(handle_t } if (jh->b_modified == 1) { /* If it's in our transaction it must be in BJ_Metadata list. */ - if (jh->b_transaction == transaction && - jh->b_jlist != BJ_Metadata) { + if (data_race(jh->b_transaction == transaction && + jh->b_jlist != BJ_Metadata)) { spin_lock(&jh->b_state_lock); if (jh->b_transaction == transaction && jh->b_jlist != BJ_Metadata)