linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: properly check for dirty state in ext4_inode_datasync_dirty()
@ 2020-10-24 14:01 Andrea Righi
  2020-10-26 22:28 ` harshad shirwadkar
  0 siblings, 1 reply; 7+ messages in thread
From: Andrea Righi @ 2020-10-24 14:01 UTC (permalink / raw)
  To: Harshad Shirwadkar
  Cc: Theodore Ts'o, Andreas Dilger, linux-ext4, linux-kernel

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 <andrea.righi@canonical.com>
---
 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;
 	}
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-10-29  2:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-24 14:01 [PATCH] ext4: properly check for dirty state in ext4_inode_datasync_dirty() Andrea Righi
2020-10-26 22:28 ` harshad shirwadkar
2020-10-28  3:27   ` Ritesh Harjani
2020-10-28  3:48     ` harshad shirwadkar
2020-10-28  4:33       ` Ritesh Harjani
2020-10-28 15:29     ` Theodore Y. Ts'o
2020-10-28 17:26       ` Ritesh Harjani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).