From: Yongpeng Yang <yangyongpeng.storage@gmail.com>
To: Chao Yu <chao@kernel.org>,
Yongpeng Yang <yangyongpeng.storage@gmail.com>,
jaegeuk@kernel.org
Cc: Yongpeng Yang <yangyongpeng@xiaomi.com>,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to access i_size w/ i_size_read()
Date: Wed, 29 Oct 2025 19:12:45 +0800 [thread overview]
Message-ID: <130dbea7-01fc-44dd-927e-197badf57450@gmail.com> (raw)
In-Reply-To: <45823945-2ea3-4ec6-9b07-686814f38567@kernel.org>
On 10/29/25 17:41, Chao Yu via Linux-f2fs-devel wrote:
> On 10/29/25 16:09, Yongpeng Yang wrote:
>> On 10/29/25 14:31, Chao Yu via Linux-f2fs-devel wrote:
>>> It recommends to use i_size_{read,write}() to access and update i_size,
>>> otherwise, we may get wrong tearing value due to high 32-bits value
>>> and low 32-bits value of i_size field are not updated atomically in
>>> 32-bits archicture machine.
>>>
>>> Signed-off-by: Chao Yu <chao@kernel.org>
>>> ---
>>> include/trace/events/f2fs.h | 8 ++++----
>>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
>>> index edbbd869078f..e1fae78d64a5 100644
>>> --- a/include/trace/events/f2fs.h
>>> +++ b/include/trace/events/f2fs.h
>>> @@ -204,7 +204,7 @@ DECLARE_EVENT_CLASS(f2fs__inode,
>>> __entry->pino = F2FS_I(inode)->i_pino;
>>> __entry->mode = inode->i_mode;
>>> __entry->nlink = inode->i_nlink;
>>> - __entry->size = inode->i_size;
>>> + __entry->size = i_size_read(inode);
>>> __entry->blocks = inode->i_blocks;
>>> __entry->advise = F2FS_I(inode)->i_advise;
>>> ),
>>> @@ -353,7 +353,7 @@ TRACE_EVENT(f2fs_unlink_enter,
>>> TP_fast_assign(
>>> __entry->dev = dir->i_sb->s_dev;
>>> __entry->ino = dir->i_ino;
>>> - __entry->size = dir->i_size;
>>> + __entry->size = i_size_read(dir);
>>> __entry->blocks = dir->i_blocks;
>>> __assign_str(name);
>>> ),
>>> @@ -433,7 +433,7 @@ DECLARE_EVENT_CLASS(f2fs__truncate_op,
>>> TP_fast_assign(
>>> __entry->dev = inode->i_sb->s_dev;
>>> __entry->ino = inode->i_ino;
>>> - __entry->size = inode->i_size;
>>> + __entry->size = i_size_read(inode);
>>> __entry->blocks = inode->i_blocks;
>>> __entry->from = from;
>>> ),
>>> @@ -1006,7 +1006,7 @@ TRACE_EVENT(f2fs_fallocate,
>>> __entry->mode = mode;
>>> __entry->offset = offset;
>>> __entry->len = len;
>>> - __entry->size = inode->i_size;
>>> + __entry->size = i_size_read(inode);
>>> __entry->blocks = inode->i_blocks;
>>> __entry->ret = ret;
>>> ),
>>
>> inode->i_size usage in fs/f2fs/ also needs to be updated. For example in f2fs_need_verity(), which may not protected by inode_lock.
>
> Accessing i_size directly in f2fs_need_verity() should be fine? Because fsverity
> actived inode should be readonly.
Yes, it's fine.>
> Do you see any other cases which are not covered by inode_lock()?
I checked again, no other cases.:)>
> Thanks,
>
>>
>> Yongpeng,
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
prev parent reply other threads:[~2025-10-29 11:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 6:31 [f2fs-dev] [PATCH] f2fs: fix to access i_size w/ i_size_read() Chao Yu via Linux-f2fs-devel
2025-10-29 8:09 ` Yongpeng Yang
2025-10-29 9:41 ` Chao Yu via Linux-f2fs-devel
2025-10-29 11:12 ` Yongpeng Yang [this message]
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=130dbea7-01fc-44dd-927e-197badf57450@gmail.com \
--to=yangyongpeng.storage@gmail.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yangyongpeng@xiaomi.com \
/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).