From: Chao Yu <chao@kernel.org>
To: fengnan chang <fengnanchang@gmail.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
Fengnan Chang <changfengnan@vivo.com>,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v5 2/2] f2fs: fix missing inplace count in overwrite with direct io
Date: Wed, 27 Oct 2021 11:30:37 +0800 [thread overview]
Message-ID: <6f503a58-0682-143b-b7c2-24390eaaae9f@kernel.org> (raw)
In-Reply-To: <CALWNXx-cHN3TduduXP2cNmVPR0V5J0Ea8RQ5fcw91Q3pmFvUxg@mail.gmail.com>
On 2021/10/16 16:01, fengnan chang wrote:
> Chao Yu <chao@kernel.org> 于2021年10月13日周三 下午11:19写道:
>>
>> On 2021/10/9 19:27, Fengnan Chang wrote:
>>> For now, overwrite file with direct io use inplace policy, but
>>> not counted, fix it. And use stat_add_inplace_blocks(sbi, 1, )
>>> instead of stat_inc_inplace_blocks(sb, ).
>>>
>>> Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
>>> ---
>>> fs/f2fs/data.c | 4 +++-
>>> fs/f2fs/f2fs.h | 8 ++++----
>>> fs/f2fs/segment.c | 2 +-
>>> 3 files changed, 8 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>>> index c1490b9a1345..7798f7236376 100644
>>> --- a/fs/f2fs/data.c
>>> +++ b/fs/f2fs/data.c
>>> @@ -1553,7 +1553,9 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
>>> goto sync_out;
>>> blkaddr = dn.data_blkaddr;
>>> set_inode_flag(inode, FI_APPEND_WRITE);
>>> - }
>>> + } else if (!f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_PRE_DIO &&
>>> + map->m_may_create && create)
>>> + stat_add_inplace_blocks(sbi, 1, true);
>>
>> What about this case?
>>
>> - f2fs_preallocate_blocks
>> - f2fs_map_blocks
>> - stat_add_inplace_blocks
>> map.m_len > 0 && err == -ENOSPC
>> err = 0;
>> - __generic_file_write_iter
>> - generic_file_direct_write
>> - f2fs_direct_IO
>> - get_data_block_dio_write
>> - __allocate_data_block
>> - stat_inc_block_count
>>
>> DIO blocks will be accounted into different type? IIUC.
> Yes, it will be accounted into different type, IPU and LFS, but it
> will not accounted into both in same time for one block.
Not sure this is right, since all writes should be accounted into LFS.
>
> root@kvm-xfstests:/mnt# cat /sys/kernel/debug/f2fs/status |grep SSR -C 2
> buffer direct segments
> IPU: 16 32 N/A
> SSR: 0 0 0
> LFS: 38 48 0
> root@kvm-xfstests:/mnt# dd if=/dev/zero of=./1 bs=32K count=1 oflag=direct
> root@kvm-xfstests:/mnt# cat /sys/kernel/debug/f2fs/status |grep SSR -C 2
> buffer direct segments
> IPU: 16 32 N/A
> SSR: 0 0 0
> LFS: 38 56 0
>
> root@kvm-xfstests:/mnt# dd if=/dev/zero of=./1 bs=32K count=1
> oflag=direct conv=notrunc
> root@kvm-xfstests:/mnt# cat /sys/kernel/debug/f2fs/status |grep SSR -C 2
> buffer direct segments
> IPU: 16 40 N/A
> SSR: 0 0 0
> LFS: 38 56 0
>
> root@kvm-xfstests:/mnt# dd if=/dev/zero of=./1 bs=32K count=2
> oflag=direct conv=notrunc
> root@kvm-xfstests:/mnt# cat /sys/kernel/debug/f2fs/status |grep SSR -C 2
> buffer direct segments
> IPU: 16 48 N/A
> SSR: 0 0 0
> LFS: 41 64 0
>
>
>>
>>> } else {
>>> if (create) {
>>> if (unlikely(f2fs_cp_error(sbi))) {
>>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>>> index bf2e73e46304..a7da836ca64f 100644
>>> --- a/fs/f2fs/f2fs.h
>>> +++ b/fs/f2fs/f2fs.h
>>> @@ -3785,12 +3785,12 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
>>> else \
>>> ((sbi)->block_count[1][(curseg)->alloc_type]++); \
>>> } while (0)
>>> -#define stat_inc_inplace_blocks(sbi, direct_io) \
>>> +#define stat_add_inplace_blocks(sbi, count, direct_io) \
>>> do { \
>>> if (direct_io) \
>>> - (atomic_inc(&(sbi)->inplace_count[0])); \
>>> + (atomic_add(count, &(sbi)->inplace_count[0])); \
>>> else \
>>> - (atomic_inc(&(sbi)->inplace_count[1])); \
>>> + (atomic_add(count, &(sbi)->inplace_count[1])); \
>>
>> If count always be one, we can just keep to use atomic_inc() here?
>>
> I suggest not, we may use this in later patch, not ready for now.
I don't thinks this is the right way, why not including above change in your later patch?
Thanks,
>
>> Thanks,
>>
>>> } while (0)
>>> #define stat_update_max_atomic_write(inode) \
>>> do { \
>>> @@ -3877,7 +3877,7 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi);
>>> #define stat_inc_meta_count(sbi, blkaddr) do { } while (0)
>>> #define stat_inc_seg_type(sbi, curseg) do { } while (0)
>>> #define stat_inc_block_count(sbi, curseg, direct_io) do { } while (0)
>>> -#define stat_inc_inplace_blocks(sbi, direct_io) do { } while (0)
>>> +#define stat_add_inplace_blocks(sbi, count, direct_io) do { } while (0)
>>> #define stat_inc_seg_count(sbi, type, gc_type) do { } while (0)
>>> #define stat_inc_tot_blk_count(si, blks) do { } while (0)
>>> #define stat_inc_data_blk_count(sbi, blks, gc_type) do { } while (0)
>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>>> index ded744e880d0..c542c4b687ca 100644
>>> --- a/fs/f2fs/segment.c
>>> +++ b/fs/f2fs/segment.c
>>> @@ -3611,7 +3611,7 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio)
>>> goto drop_bio;
>>> }
>>>
>>> - stat_inc_inplace_blocks(fio->sbi, false);
>>> + stat_add_inplace_blocks(sbi, 1, false);
>>>
>>> if (fio->bio && !(SM_I(sbi)->ipu_policy & (1 << F2FS_IPU_NOCACHE)))
>>> err = f2fs_merge_page_bio(fio);
>>>
>>
>>
>> _______________________________________________
>> 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
next prev parent reply other threads:[~2021-10-27 3:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-09 11:27 [f2fs-dev] [PATCH v5 1/2] f2fs: separate buffer and direct io in block allocation statistics Fengnan Chang via Linux-f2fs-devel
2021-10-09 11:27 ` [f2fs-dev] [PATCH v5 2/2] f2fs: fix missing inplace count in overwrite with direct io Fengnan Chang via Linux-f2fs-devel
2021-10-13 15:18 ` Chao Yu
2021-10-16 8:01 ` fengnan chang
2021-10-27 3:30 ` Chao Yu [this message]
[not found] ` <AOYAygA-EjrsqgsUALfVQapx.9.1635305442578.Hmail.changfengnan@vivo.com>
2021-10-27 9:24 ` 常凤楠
2021-10-13 14:53 ` [f2fs-dev] [PATCH v5 1/2] f2fs: separate buffer and direct io in block allocation statistics Chao Yu
2021-10-20 0:09 ` Jaegeuk Kim
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=6f503a58-0682-143b-b7c2-24390eaaae9f@kernel.org \
--to=chao@kernel.org \
--cc=changfengnan@vivo.com \
--cc=fengnanchang@gmail.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/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).