Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp717920pxx; Wed, 28 Oct 2020 15:25:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5cyl0n9+kZFrFfYEGTb2gnIA0Aw2LcUzKjVxDMaHGEpulf5SmCfl168rMEJuQo2tK9/1x X-Received: by 2002:a50:8245:: with SMTP id 63mr1110436edf.133.1603923926491; Wed, 28 Oct 2020 15:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603923926; cv=none; d=google.com; s=arc-20160816; b=GNKGJC0qMW5u4s3Yv3GMgOiExZBR8KtwFio6dgBeMHVN/hFeTF1vAbX81JSJJDklXb Q9rcZR15rCH4qV9DQ2OS06fZ5Zz4jbtHLbPOeOe1p/poKsxMpgcoQB8ib5MHDZIfRn6G eT9gyIaCwoOqODrlhl1KvKwOBNaWzq7q0u8rTWqqKTqxGqo8ToP1Q+lHowCXW7/1Mm1q 9nZpWCnltetm4jIS2YJvJPRsrXnt8CdvYjvqyHEGgLQekfa/wra2CkpDRewqMXDMKqCw aVgDp0GiSVr/dlWilN0PkLRxtWqAg99doOx29BOjNbL8zp3afuxiXnYa1apqgoI6Qgn6 abwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TsmTh3EY4PlXa0ncerE94aAQcFnKZIBIojGnStqQXyU=; b=VEtWHIdoQMWPLed/4tzUqt8zpp/8ovRIN+9l5gubOXH3H/k8h6zsKeJpORlyBQP/+9 iLDeG+efynwb+4QvdcrWmLdeKcju+oMsP2TDAd5AGhpi1Bl6IS1qVH2btstL8UxrySSD oYQnk0J4IUFtjuxAgU337cssgD/oaailWpRaIg94tbMSIwWIx2DzRME/9danRu7YH6Pt K/lMEl1oGkTeHq7IkGUNjjCI6oPe7gbsgYdYute9/oF95hjgKkxgbKAnRY9rCHXCBA6t Q42T2JtJLkxF2K2+HpkLjDbl3gLHGsMbTcFekG+HNIhLbdVp218pqU3ZdGi3SUGOBbPz 1nWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QHjnktl8; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si641837edy.531.2020.10.28.15.25.00; Wed, 28 Oct 2020 15:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@gmail.com header.s=20161025 header.b=QHjnktl8; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732912AbgJ1WYU (ORCPT + 99 others); Wed, 28 Oct 2020 18:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732909AbgJ1WYT (ORCPT ); Wed, 28 Oct 2020 18:24:19 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0876C0613CF; Wed, 28 Oct 2020 15:24:18 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id x1so1169995eds.1; Wed, 28 Oct 2020 15:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TsmTh3EY4PlXa0ncerE94aAQcFnKZIBIojGnStqQXyU=; b=QHjnktl8YmRQstpwq4nVhZJ5MIynb9jtS0Lt70XNKDx041dxoG+Zp8hcZ8q1iUi9Kl LvSTjuci6R+A8eyB6u6RgiFlV7TNsdtXskzJHg+Zw+3YI3cRBvyehWFPrpTmlhARWa17 mtcF3We28lh3Oe7zVeTlOMO6K9oljAR3JSDCh75C3eN9u7tluabznRsKUGppkci5GmgT QkPt+VELV3DiNm0fs6O4wZmqFuRrY1IOTERz+y619MagoZFqTGdgnSkiD6saSkM9Szn7 2L7BhV5vVu7v12na9QzkWO9byC1vpAx4+USDzZa2WBrvbkTdVykblB+1Xv134VfvGZaj Gjcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TsmTh3EY4PlXa0ncerE94aAQcFnKZIBIojGnStqQXyU=; b=bxZpsuX8SXpd1uV1APiRVJGXDtFufjFMSAE9OIwD9K9BpPGXoQZPZ7Pr9a8cwIbhqF /6NLeFxrk0r57kjCLwzjoljERvogalhNmozsd35/r1PV9uffOc6tbk/a/yi7dmgJwkLq L4BPWgOTbS9D8vicceLe/O3l8/5B9EWcTEiDRDq9S7qzc6PiF+we8ATQfUnckDrVK5rs G6R+KvE9Fkc12D1QV2WBJnbQG5GyxvRJ7X9gjwqQz8U27/2G5wj8JYblbzlXOC/PZsjy R8l0jecpSlgU5GDrjzfPhcZ8cZo59NQFfQJ5hu0haxcfVWVq9SweMIpBzkwVohGTaH1T DGzA== X-Gm-Message-State: AOAM531IAoOtAfwLpYFcMSgTZ3/8H+HFvgjgZkLfS8dYh3CuotqYq0Ws lk4Zt1814pkQCT61OET6uyeuiUODFqDZa9ksV3VNd9+gxSz3yg== X-Received: by 2002:a50:9ec6:: with SMTP id a64mr5478708edf.382.1603856918746; Tue, 27 Oct 2020 20:48:38 -0700 (PDT) MIME-Version: 1.0 References: <20201024140115.GA35973@xps-13-7390> In-Reply-To: From: harshad shirwadkar Date: Tue, 27 Oct 2020 20:48:27 -0700 Message-ID: Subject: Re: [PATCH] ext4: properly check for dirty state in ext4_inode_datasync_dirty() To: Ritesh Harjani Cc: Andrea Righi , "Theodore Ts'o" , Andreas Dilger , Ext4 Developers List , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Actually the simpler fix for this in case of fast commits is to check if the inode is on the fast commit list or not. Since we clear the fast commit list after every fast and / or full commit, it's always true that if the inode is not on the list, that means it isn't dirty. This will simplify the logic here and then we can probably get rid of i_fc_committed_subtid field altogether. I'll test this and send out a patch. Thanks, Harshad On Tue, Oct 27, 2020 at 8:27 PM Ritesh Harjani wrote: > > > > On 10/27/20 3:58 AM, harshad shirwadkar wrote: > > Thanks Andrea for catching and sending out a fix for this. > > > > On Sat, Oct 24, 2020 at 7:01 AM Andrea Righi wrote: > >> > >> ext4_inode_datasync_dirty() needs to return 'true' if the inode is > >> dirty, 'false' otherwise, but the logic seems to be incorrectly changed > >> by commit aa75f4d3daae ("ext4: main fast-commit commit path"). > >> > >> This introduces a problem with swap files that are always failing to be > >> activated, showing this error in dmesg: > >> > >> [ 34.406479] swapon: file is not committed > >> > > Well, I too noticed this yesterday while I was testing xfstests -g swap. > Those tests were returning _notrun, hence that could be the reason why > it didn't get notice in XFSTESTing from Ted. > > - I did notice that this code was introduced in v10 only. > This wasn't there in v9 though. > > > >> Simple test case to reproduce the problem: > >> > >> # fallocate -l 8G swapfile > >> # chmod 0600 swapfile > >> # mkswap swapfile > >> # swapon swapfile > >> > >> Fix the logic to return the proper state of the inode. > >> > >> Link: https://lore.kernel.org/lkml/20201024131333.GA32124@xps-13-7390 > >> Fixes: aa75f4d3daae ("ext4: main fast-commit commit path") > >> Signed-off-by: Andrea Righi > >> --- > >> fs/ext4/inode.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > >> index 03c2253005f0..a890a17ab7e1 100644 > >> --- a/fs/ext4/inode.c > >> +++ b/fs/ext4/inode.c > >> @@ -3308,8 +3308,8 @@ static bool ext4_inode_datasync_dirty(struct inode *inode) > >> if (journal) { > >> if (jbd2_transaction_committed(journal, > >> EXT4_I(inode)->i_datasync_tid)) > >> - return true; > >> - return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) >= > >> + return false; > >> + return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) < > >> EXT4_I(inode)->i_fc_committed_subtid; > > In addition, the above condition should only be checked if fast > > commits are enabled. So, in effect this overall condition will look > > like this: > > > > if (journal) { > > if (jbd2_transaction_committed(journal, EXT4_I(inode)->i_datasync_tid)) > > return false; > > if (test_opt2(sb, JOURNAL_FAST_COMMIT)) > > return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) < > > EXT4_I(inode)->i_fc_committed_subtid; > > return true; > > } > > Yup - I too had made a similar patch. But then I also noticed that below > condition will always remain false. Since we never update > "i_fc_committed_subtid" other than at these 2 places > (one during init where we set it to 0 and other during ext4_fc_commit() > where we set it to sbi->s_fc_subtid). > > > atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid < > EXT4_I(inode)->i_fc_committed_subtid > > > Maybe I need more reading around this. > > -ritesh > > > > > > > > > Thanks, > > Harshad > > > >> } > >> > >> -- > >> 2.27.0 > >>