From: Ritesh Harjani <riteshh@linux.ibm.com>
To: harshad shirwadkar <harshadshirwadkar@gmail.com>,
Andrea Righi <andrea.righi@canonical.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Ext4 Developers List <linux-ext4@vger.kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ext4: properly check for dirty state in ext4_inode_datasync_dirty()
Date: Wed, 28 Oct 2020 08:57:03 +0530 [thread overview]
Message-ID: <da6697a0-4a23-ee68-fa2e-121b3d23c972@linux.ibm.com> (raw)
In-Reply-To: <CAD+ocby3hA0GCm5Rf6T3UF+2UWgWoUjrz7=VzbeUMjX6Qx8D5g@mail.gmail.com>
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 <andrea.righi@canonical.com> 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 <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;
> 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).
<condition>
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
>>
next prev parent reply other threads:[~2020-10-28 21:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da6697a0-4a23-ee68-fa2e-121b3d23c972@linux.ibm.com \
--to=riteshh@linux.ibm.com \
--cc=adilger.kernel@dilger.ca \
--cc=andrea.righi@canonical.com \
--cc=harshadshirwadkar@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).