From: Fengnan Chang <fengnanchang@gmail.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: Fengnan Chang <changfengnan@vivo.com>,
linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH 2/2] f2fs: fix missing inplace count in overwrite with direct io
Date: Sun, 12 Sep 2021 09:50:58 +0800 [thread overview]
Message-ID: <20210912015058.14063-2-fengnanchang@gmail.com> (raw)
In-Reply-To: <20210912015058.14063-1-fengnanchang@gmail.com>
From: Fengnan Chang <changfengnan@vivo.com>
For now, overwrite file with direct io use inplace policy, but
not counted, fix it.
Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
---
fs/f2fs/data.c | 7 ++++++-
fs/f2fs/f2fs.h | 7 +++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index c1490b9a1345..b5d488c9f9f9 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1491,6 +1491,9 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
if (flag == F2FS_GET_BLOCK_DIO)
f2fs_wait_on_block_writeback_range(inode,
map->m_pblk, map->m_len);
+ if (!f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO &&
+ map->m_may_create)
+ stat_add_inplace_blocks(sbi, map->m_len, true);
goto out;
}
@@ -1553,7 +1556,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 (!create && !f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO &&
+ map->m_may_create)
+ stat_inc_inplace_blocks(sbi, true);
} else {
if (create) {
if (unlikely(f2fs_cp_error(sbi))) {
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 3d4ee444db27..49230115d241 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3792,6 +3792,13 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
else \
(atomic_inc(&(sbi)->inplace_count[1])); \
} while (0)
+#define stat_add_inplace_blocks(sbi, count, direct_io) \
+ do { \
+ if (direct_io) \
+ (atomic_add(count, &(sbi)->inplace_count[0])); \
+ else \
+ (atomic_add(count, &(sbi)->inplace_count[1])); \
+ } while (0)
#define stat_update_max_atomic_write(inode) \
do { \
int cur = F2FS_I_SB(inode)->atomic_files; \
--
2.32.0
_______________________________________________
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-09-12 1:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-12 1:50 [f2fs-dev] [PATCH 1/2] f2fs: separate buffer and direct io in block allocation statistics Fengnan Chang
2021-09-12 1:50 ` Fengnan Chang [this message]
2021-09-16 9:41 ` [f2fs-dev] [PATCH 2/2] f2fs: fix missing inplace count in overwrite with direct io Chao Yu
2021-09-16 9:29 ` [f2fs-dev] [PATCH 1/2] f2fs: separate buffer and direct io in block allocation statistics 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=20210912015058.14063-2-fengnanchang@gmail.com \
--to=fengnanchang@gmail.com \
--cc=changfengnan@vivo.com \
--cc=chao@kernel.org \
--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).