* [PATCH 1/2] f2fs: unlock cp_rwsem early for IPU writes
@ 2017-04-18 11:23 Chao Yu
2017-04-18 11:23 ` [PATCH 2/2] f2fs: add undiscard blocks stat Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2017-04-18 11:23 UTC (permalink / raw)
To: jaegeuk; +Cc: chao, linux-kernel, linux-f2fs-devel
For IPU writes, there won't be any udpates in dnode page since we
will reuse old block address instead of allocating new one, so we
don't need to lock cp_rwsem during IPU IO submitting.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/data.c | 6 +++++-
fs/f2fs/f2fs.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index e984a42eabf4..32d5a3b38a3f 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1357,6 +1357,8 @@ int do_write_data_page(struct f2fs_io_info *fio)
!is_cold_data(page) &&
!IS_ATOMIC_WRITTEN_PAGE(page) &&
need_inplace_update(inode))) {
+ f2fs_unlock_op(F2FS_I_SB(inode));
+ fio->cp_rwsem_locked = false;
err = rewrite_data_page(fio);
set_inode_flag(inode, FI_UPDATE_WRITE);
trace_f2fs_do_write_data_page(page, IPU);
@@ -1392,6 +1394,7 @@ static int __write_data_page(struct page *page, bool *submitted,
.page = page,
.encrypted_page = NULL,
.submitted = false,
+ .cp_rwsem_locked = true,
};
trace_f2fs_writepage(page, DATA);
@@ -1449,7 +1452,8 @@ static int __write_data_page(struct page *page, bool *submitted,
err = do_write_data_page(&fio);
if (F2FS_I(inode)->last_disk_size < psize)
F2FS_I(inode)->last_disk_size = psize;
- f2fs_unlock_op(sbi);
+ if (fio.cp_rwsem_locked)
+ f2fs_unlock_op(sbi);
done:
if (err && err != -ENOENT)
goto redirty_out;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a39749412803..5c3e60551df5 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -795,6 +795,7 @@ struct f2fs_io_info {
struct page *page; /* page to be written */
struct page *encrypted_page; /* encrypted page */
bool submitted; /* indicate IO submission */
+ bool cp_rwsem_locked; /* indicate cp_rwsem is held */
};
#define is_read_io(rw) ((rw) == READ)
--
2.12.2.510.ge1104a5ee539
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] f2fs: add undiscard blocks stat
2017-04-18 11:23 [PATCH 1/2] f2fs: unlock cp_rwsem early for IPU writes Chao Yu
@ 2017-04-18 11:23 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2017-04-18 11:23 UTC (permalink / raw)
To: jaegeuk; +Cc: chao, linux-kernel, linux-f2fs-devel
This patch adds to account undiscard blocks.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/debug.c | 5 +++--
fs/f2fs/f2fs.h | 2 ++
fs/f2fs/segment.c | 9 +++++++++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index 692beff66bf8..6102737473d4 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -69,6 +69,7 @@ static void update_general_status(struct f2fs_sb_info *sbi)
atomic_read(&SM_I(sbi)->dcc_info->issing_discard);
si->nr_discard_cmd =
atomic_read(&SM_I(sbi)->dcc_info->discard_cmd_cnt);
+ si->undiscard_blks = SM_I(sbi)->dcc_info->undiscard_blks;
}
si->total_count = (int)sbi->user_block_count / sbi->blocks_per_seg;
si->rsvd_segs = reserved_segments(sbi);
@@ -348,11 +349,11 @@ static int stat_show(struct seq_file *s, void *v)
si->ext_tree, si->zombie_tree, si->ext_node);
seq_puts(s, "\nBalancing F2FS Async:\n");
seq_printf(s, " - IO (CP: %4d, Data: %4d, Flush: (%4d %4d), "
- "Discard: (%4d %4d)) cmd: %4d\n",
+ "Discard: (%4d %4d)) cmd: %4d undiscard:%4u\n",
si->nr_wb_cp_data, si->nr_wb_data,
si->nr_flushing, si->nr_flushed,
si->nr_discarding, si->nr_discarded,
- si->nr_discard_cmd);
+ si->nr_discard_cmd, si->undiscard_blks);
seq_printf(s, " - inmem: %4d, atomic IO: %4d (Max. %4d), "
"volatile IO: %4d (Max. %4d)\n",
si->inmem_pages, si->aw_cnt, si->max_aw_cnt,
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 5c3e60551df5..b866504e8ec3 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -233,6 +233,7 @@ struct discard_cmd_control {
struct mutex cmd_lock;
int nr_discards; /* # of discards in the list */
int max_discards; /* max. discards to be issued */
+ unsigned int undiscard_blks; /* # of undiscard blocks */
atomic_t issued_discard; /* # of issued discard */
atomic_t issing_discard; /* # of issing discard */
atomic_t discard_cmd_cnt; /* # of cached cmd count */
@@ -2393,6 +2394,7 @@ struct f2fs_stat_info {
int bg_gc, nr_wb_cp_data, nr_wb_data;
int nr_flushing, nr_flushed, nr_discarding, nr_discarded;
int nr_discard_cmd;
+ unsigned int undiscard_blks;
int inline_xattr, inline_inode, inline_dir, append, update, orphans;
int aw_cnt, max_aw_cnt, vw_cnt, max_vw_cnt;
unsigned int valid_count, valid_node_count, valid_inode_count, discard_blks;
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index eea70621a50f..9b7587db73ab 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -695,6 +695,7 @@ static struct discard_cmd *__create_discard_cmd(struct f2fs_sb_info *sbi,
init_completion(&dc->wait);
list_add_tail(&dc->list, pend_list);
atomic_inc(&dcc->discard_cmd_cnt);
+ dcc->undiscard_blks += len;
return dc;
}
@@ -723,6 +724,7 @@ static void __detach_discard_cmd(struct discard_cmd_control *dcc,
list_del(&dc->list);
rb_erase(&dc->rb_node, &dcc->root);
+ dcc->undiscard_blks -= dc->len;
kmem_cache_free(discard_cmd_slab, dc);
@@ -831,8 +833,11 @@ static void __punch_discard_cmd(struct f2fs_sb_info *sbi,
return;
}
+ dcc->undiscard_blks -= di.len;
+
if (blkaddr > di.lstart) {
dc->len = blkaddr - dc->lstart;
+ dcc->undiscard_blks += dc->len;
__relocate_discard_cmd(dcc, dc);
f2fs_bug_on(sbi, !__check_rb_tree_consistence(sbi, &dcc->root));
modified = true;
@@ -850,6 +855,7 @@ static void __punch_discard_cmd(struct f2fs_sb_info *sbi,
dc->lstart++;
dc->len--;
dc->start++;
+ dcc->undiscard_blks += dc->len;
__relocate_discard_cmd(dcc, dc);
f2fs_bug_on(sbi,
!__check_rb_tree_consistence(sbi, &dcc->root));
@@ -911,6 +917,7 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi,
prev_dc->bdev == bdev &&
__is_discard_back_mergeable(&di, &prev_dc->di)) {
prev_dc->di.len += di.len;
+ dcc->undiscard_blks += di.len;
__relocate_discard_cmd(dcc, prev_dc);
f2fs_bug_on(sbi,
!__check_rb_tree_consistence(sbi, &dcc->root));
@@ -925,6 +932,7 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi,
next_dc->di.lstart = di.lstart;
next_dc->di.len += di.len;
next_dc->di.start = di.start;
+ dcc->undiscard_blks += di.len;
__relocate_discard_cmd(dcc, next_dc);
if (tdc)
__remove_discard_cmd(sbi, tdc);
@@ -1358,6 +1366,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
atomic_set(&dcc->discard_cmd_cnt, 0);
dcc->nr_discards = 0;
dcc->max_discards = DEFAULT_SMALL_DISCARD_NUMBER;
+ dcc->undiscard_blks = 0;
dcc->root = RB_ROOT;
init_waitqueue_head(&dcc->discard_wait_queue);
--
2.12.2.510.ge1104a5ee539
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-18 11:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-18 11:23 [PATCH 1/2] f2fs: unlock cp_rwsem early for IPU writes Chao Yu
2017-04-18 11:23 ` [PATCH 2/2] f2fs: add undiscard blocks stat Chao Yu
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).