From: Chao Yu <yuchao0@huawei.com>
To: "Ondřej Jirman" <megi@xff.cz>,
jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, chao@kernel.org
Subject: Re: [PATCH v3] f2fs: fix potential .flags overflow on 32bit architecture
Date: Mon, 23 Mar 2020 10:09:48 +0800 [thread overview]
Message-ID: <1d861a2e-0045-af0c-1f5b-c45b774c83f6@huawei.com> (raw)
In-Reply-To: <20200323015036.pniupuucfl3dug4m@core.my.home>
Hello Ondřej,
On 2020/3/23 9:50, Ondřej Jirman wrote:
> Hello Chao Yu,
>
> On Mon, Mar 23, 2020 at 09:25:19AM +0800, Chao Yu wrote:
>> [snip]
>>
>> +static inline void __set_inode_flag(struct inode *inode, int flag)
>> +{
>> + test_and_set_bit(flag % BITS_PER_LONG,
>> + &F2FS_I(inode)->flags[BIT_WORD(flag)]);
>
> This can simply be:
>
> test_and_set_bit(flag, F2FS_I(inode)->flags);
>
> all of these bitmap manipulation functions already will do the
> right thing to access the correct location in the flags array:
>
> https://elixir.bootlin.com/linux/latest/source/include/asm-generic/bitops/atomic.h#L32
>
> see BIT_MASK and BIT_WORD use in that function.
Oops, most f2fs bitmap check uses the same form, I missed this case....
>
>> +}
>> +
>> static inline void set_inode_flag(struct inode *inode, int flag)
>> {
>> - if (!test_bit(flag, &F2FS_I(inode)->flags))
>> - set_bit(flag, &F2FS_I(inode)->flags);
>> + __set_inode_flag(inode, flag);
>> __mark_inode_dirty_flag(inode, flag, true);
>> }
>>
>> static inline int is_inode_flag_set(struct inode *inode, int flag)
>> {
>> - return test_bit(flag, &F2FS_I(inode)->flags);
>> + return test_bit(flag % BITS_PER_LONG,
>> + &F2FS_I(inode)->flags[BIT_WORD(flag)]);
>
> ditto
>
>> }
>>
>> static inline void clear_inode_flag(struct inode *inode, int flag)
>> {
>> - if (test_bit(flag, &F2FS_I(inode)->flags))
>> - clear_bit(flag, &F2FS_I(inode)->flags);
>> + test_and_clear_bit(flag % BITS_PER_LONG,
>> + &F2FS_I(inode)->flags[BIT_WORD(flag)]);
>
> ditto
>
> I'm going to test the patch. It looks like that this was really
> the root cause of all those locking issues I was seeing on my
> 32-bit tablet. It seems to explain why my 64-bit systems were
> not affected, and why reverting compession fixed it too.
> Great job figuring this out.
>
> I'll let you know soon.
Great, hoping this patch can fix the issue this time.
Thanks anyway for supporting on troubleshooting this issue.
Thanks,
>
> thank you and regards,
> o.
>
>> __mark_inode_dirty_flag(inode, flag, false);
>> }
>>
> .
>
next prev parent reply other threads:[~2020-03-23 2:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-23 1:25 Chao Yu
2020-03-23 1:50 ` Ondřej Jirman
2020-03-23 2:09 ` Chao Yu [this message]
2020-03-23 2:00 ` Joe Perches
2020-03-23 2:19 ` Chao Yu
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=1d861a2e-0045-af0c-1f5b-c45b774c83f6@huawei.com \
--to=yuchao0@huawei.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=megi@xff.cz \
/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
all inboxes | Powered by JetHome®