Commit d0520df7 authored by Andrea Righi's avatar Andrea Righi Committed by Theodore Ts'o

ext4: properly check for dirty state in ext4_inode_datasync_dirty()

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 aa75f4d3 ("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: 8016e29f ("ext4: fast commit recovery path")
Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
Signed-off-by: default avatarHarshad Shirwadkar <harshadshirwadkar@gmail.com>
Link: https://lore.kernel.org/r/20201027044915.2553163-1-harshadshirwadkar@gmail.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 5112e9a5
...@@ -3307,10 +3307,12 @@ static bool ext4_inode_datasync_dirty(struct inode *inode) ...@@ -3307,10 +3307,12 @@ static bool ext4_inode_datasync_dirty(struct inode *inode)
if (journal) { if (journal) {
if (jbd2_transaction_committed(journal, if (jbd2_transaction_committed(journal,
EXT4_I(inode)->i_datasync_tid)) EXT4_I(inode)->i_datasync_tid))
return true; return false;
return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) >= if (test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT))
EXT4_I(inode)->i_fc_committed_subtid; 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? */ /* Any metadata buffers to write? */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment