From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 5/5] f2fs: avoid out-of-order execution of atomic writes
Date: Fri, 3 Feb 2017 15:48:16 -0800 [thread overview]
Message-ID: <20170203234816.12723-5-jaegeuk@kernel.org> (raw)
In-Reply-To: <20170203234816.12723-1-jaegeuk@kernel.org>
We need to flush data writes before flushing last node block writes by using
FUA with PREFLUSH. We don't need to guarantee precedent node writes since if
those are not written, we can't reach to the last node block when scanning
node block chain during roll-forward recovery.
Afterwards f2fs_wait_on_page_writeback guarantees all the IO submission to
disk, which builds a valid node block chain.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/file.c | 3 ++-
fs/f2fs/node.c | 10 +++++++---
include/trace/events/f2fs.h | 1 +
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 9c0f469cde13..a3808c49e326 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -278,7 +278,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
flush_out:
remove_ino_entry(sbi, ino, UPDATE_INO);
clear_inode_flag(inode, FI_UPDATE_WRITE);
- ret = f2fs_issue_flush(sbi);
+ if (!atomic)
+ ret = f2fs_issue_flush(sbi);
f2fs_update_time(sbi, REQ_TIME);
out:
trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index f30cf1dec9a8..135a0233a201 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1318,7 +1318,7 @@ static struct page *last_fsync_dnode(struct f2fs_sb_info *sbi, nid_t ino)
return last_page;
}
-static int __write_node_page(struct page *page,
+static int __write_node_page(struct page *page, bool atomic,
struct writeback_control *wbc)
{
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
@@ -1362,6 +1362,9 @@ static int __write_node_page(struct page *page,
return 0;
}
+ if (atomic)
+ fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
+
set_page_writeback(page);
fio.old_blkaddr = ni.blk_addr;
write_node_page(nid, &fio);
@@ -1388,7 +1391,7 @@ static int __write_node_page(struct page *page,
static int f2fs_write_node_page(struct page *page,
struct writeback_control *wbc)
{
- return __write_node_page(page, wbc);
+ return __write_node_page(page, false, wbc);
}
int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
@@ -1470,7 +1473,8 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
if (!clear_page_dirty_for_io(page))
goto continue_unlock;
- ret = __write_node_page(page, wbc);
+ ret = __write_node_page(page, atomic &&
+ page == last_page, wbc);
if (ret) {
unlock_page(page);
f2fs_put_page(last_page, 0);
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 04c527410ecc..82236792b50c 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -81,6 +81,7 @@ TRACE_DEFINE_ENUM(CP_DISCARD);
{ REQ_SYNC | REQ_PRIO, "(SP)" }, \
{ REQ_META, "(M)" }, \
{ REQ_META | REQ_PRIO, "(MP)" }, \
+ { REQ_SYNC | REQ_PREFLUSH , "(SF)" }, \
{ REQ_SYNC | REQ_META | REQ_PRIO, "(SMP)" }, \
{ REQ_PREFLUSH | REQ_META | REQ_PRIO, "(FMP)" }, \
{ 0, " \b" })
--
2.11.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
next prev parent reply other threads:[~2017-02-03 23:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 23:48 [PATCH 1/5] f2fs: show # of APPEND and UPDATE inodes Jaegeuk Kim
2017-02-03 23:48 ` [PATCH 2/5] f2fs: check last page index in cached bio to decide submission Jaegeuk Kim
2017-02-23 6:13 ` Chao Yu
2017-02-03 23:48 ` [PATCH 3/5] f2fs: move flush tracepoint Jaegeuk Kim
2017-02-23 9:22 ` Chao Yu
2017-02-03 23:48 ` [PATCH 4/5] f2fs: move write_node_page above fsync_node_pages Jaegeuk Kim
2017-02-23 9:22 ` Chao Yu
2017-02-03 23:48 ` Jaegeuk Kim [this message]
2017-02-23 9:22 ` [PATCH 5/5] f2fs: avoid out-of-order execution of atomic writes Chao Yu
2017-02-23 3:32 ` [PATCH 1/5] f2fs: show # of APPEND and UPDATE inodes 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=20170203234816.12723-5-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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).