From patchwork Thu Oct 29 18:32:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1390319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CMYvm4NgJz9sTD; Fri, 30 Oct 2020 05:32:35 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1kYCio-0002EM-Vj; Thu, 29 Oct 2020 18:32:26 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kYCil-0002Cy-Mh for kernel-team@lists.ubuntu.com; Thu, 29 Oct 2020 18:32:23 +0000 Received: from mail-wr1-f70.google.com ([209.85.221.70]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kYCil-0005rD-EM for kernel-team@lists.ubuntu.com; Thu, 29 Oct 2020 18:32:23 +0000 Received: by mail-wr1-f70.google.com with SMTP id m20so1621504wrb.21 for ; Thu, 29 Oct 2020 11:32:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=K+IiIlvpFVHm11AJQbsTOoRsUj/qt3d0x8dH7EZwsm8=; b=rX9HrWmfpDLf7lOF5AVm/yWF4+o50ZB5rKCLJ/74p1uw020Z4xVbuhek/1pwcQ7+CB HKfBDhdJYMl0aT4U3vXXgPzuxnhPqGH8Ij2328t18jeOp1a/IOy7VTRk5/BZpQs0kkaz hhtAOBZIZR/edrCDIK6NQKTDWVuEWXkHgZg2wTrmkD9x4mHIDmmFUsMmaibbVSRUenA7 +jetHFPICVncYfRkkoXF36zbLg6pnIjN3pMz+nK8cwmq6xIh2TavM9Q6P9va2KYDQlu0 kySIK/oIAvCV8L6pX6tdOsYZecWoJip2TqmQyZU65J9saLr9t/MttikZWi05RbUibceq G6Pg== X-Gm-Message-State: AOAM532cbR0/4QVRfxZX3V+Uffk4WI6kWns8dduUa8DZ3ClCnBg60DZI Du8NAZusory4ebF22SFG1XprwrAYTDDXG39qaDy2YQvFJJpRFaF3hse/YrqaZubno2dch+Bp2eJ VySXjANDcHjOVdIig9uY5DhIH/BwzSRboet/3NYFtmg== X-Received: by 2002:a1c:234e:: with SMTP id j75mr496502wmj.162.1603996342723; Thu, 29 Oct 2020 11:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDobj5SHSwCSARkxKgdTnZYMN9Z2HYQ7t2FuEQJtFNBIsehPb8l+ChNHLjvikV1zv1o+retw== X-Received: by 2002:a1c:234e:: with SMTP id j75mr496479wmj.162.1603996342474; Thu, 29 Oct 2020 11:32:22 -0700 (PDT) Received: from localhost (host-79-33-123-6.retail.telecomitalia.it. [79.33.123.6]) by smtp.gmail.com with ESMTPSA id r1sm6982226wro.18.2020.10.29.11.32.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 11:32:21 -0700 (PDT) Date: Thu, 29 Oct 2020 19:32:20 +0100 From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [PATCH] [Unstable] ext4: properly check for dirty state in ext4_inode_datasync_dirty() Message-ID: <20201029183220.GA88284@xps-13-7390> MIME-Version: 1.0 Content-Disposition: inline X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" 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 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 Signed-off-by: Harshad Shirwadkar (cherry picked from commit a316082fa331d086dd8dea9d1e10c7fac3cbbad6 https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git) Signed-off-by: Andrea Righi Acked-by: Colin Ian King --- fs/ext4/inode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 03c2253005f0..520a0209451e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3307,10 +3307,12 @@ 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) >= - EXT4_I(inode)->i_fc_committed_subtid; + EXT4_I(inode)->i_datasync_tid)) + return false; + if (test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT)) + return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) < + EXT4_I(inode)->i_fc_committed_subtid; + return true; } /* Any metadata buffers to write? */