Skip to content

Commit bb28b66

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: trace elapsed time for node_write lock
Use f2fs_{down,up}_read_trace for node_write to trace lock elapsed time. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent f9f9360 commit bb28b66

6 files changed

Lines changed: 16 additions & 11 deletions

File tree

fs/f2fs/compress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
13091309
* checkpoint. This can only happen to quota writes which can cause
13101310
* the below discard race condition.
13111311
*/
1312-
f2fs_down_read(&sbi->node_write);
1312+
f2fs_down_read_trace(&sbi->node_write, &lc);
13131313
} else if (!f2fs_trylock_op(sbi, &lc)) {
13141314
goto out_free;
13151315
}
@@ -1434,7 +1434,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
14341434

14351435
f2fs_put_dnode(&dn);
14361436
if (quota_inode)
1437-
f2fs_up_read(&sbi->node_write);
1437+
f2fs_up_read_trace(&sbi->node_write, &lc);
14381438
else
14391439
f2fs_unlock_op(sbi, &lc);
14401440

@@ -1463,7 +1463,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
14631463
f2fs_put_dnode(&dn);
14641464
out_unlock_op:
14651465
if (quota_inode)
1466-
f2fs_up_read(&sbi->node_write);
1466+
f2fs_up_read_trace(&sbi->node_write, &lc);
14671467
else
14681468
f2fs_unlock_op(sbi, &lc);
14691469
out_free:

fs/f2fs/data.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,19 +3064,21 @@ int f2fs_write_single_data_page(struct folio *folio, int *submitted,
30643064
write:
30653065
/* Dentry/quota blocks are controlled by checkpoint */
30663066
if (S_ISDIR(inode->i_mode) || quota_inode) {
3067+
struct f2fs_lock_context lc;
3068+
30673069
/*
30683070
* We need to wait for node_write to avoid block allocation during
30693071
* checkpoint. This can only happen to quota writes which can cause
30703072
* the below discard race condition.
30713073
*/
30723074
if (quota_inode)
3073-
f2fs_down_read(&sbi->node_write);
3075+
f2fs_down_read_trace(&sbi->node_write, &lc);
30743076

30753077
fio.need_lock = LOCK_DONE;
30763078
err = f2fs_do_write_data_page(&fio);
30773079

30783080
if (quota_inode)
3079-
f2fs_up_read(&sbi->node_write);
3081+
f2fs_up_read_trace(&sbi->node_write, &lc);
30803082

30813083
goto done;
30823084
}

fs/f2fs/f2fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ enum f2fs_lock_name {
177177
LOCK_NAME_NONE,
178178
LOCK_NAME_CP_RWSEM,
179179
LOCK_NAME_NODE_CHANGE,
180+
LOCK_NAME_NODE_WRITE,
180181
};
181182

182183
/*

fs/f2fs/node.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,7 @@ static bool __write_node_folio(struct folio *folio, bool atomic, bool *submitted
17381738
.io_type = io_type,
17391739
.io_wbc = wbc,
17401740
};
1741+
struct f2fs_lock_context lc;
17411742
unsigned int seq;
17421743

17431744
trace_f2fs_writepage(folio, NODE);
@@ -1767,21 +1768,21 @@ static bool __write_node_folio(struct folio *folio, bool atomic, bool *submitted
17671768
if (f2fs_get_node_info(sbi, nid, &ni, !do_balance))
17681769
goto redirty_out;
17691770

1770-
f2fs_down_read(&sbi->node_write);
1771+
f2fs_down_read_trace(&sbi->node_write, &lc);
17711772

17721773
/* This page is already truncated */
17731774
if (unlikely(ni.blk_addr == NULL_ADDR)) {
17741775
folio_clear_uptodate(folio);
17751776
dec_page_count(sbi, F2FS_DIRTY_NODES);
1776-
f2fs_up_read(&sbi->node_write);
1777+
f2fs_up_read_trace(&sbi->node_write, &lc);
17771778
folio_unlock(folio);
17781779
return true;
17791780
}
17801781

17811782
if (__is_valid_data_blkaddr(ni.blk_addr) &&
17821783
!f2fs_is_valid_blkaddr(sbi, ni.blk_addr,
17831784
DATA_GENERIC_ENHANCE)) {
1784-
f2fs_up_read(&sbi->node_write);
1785+
f2fs_up_read_trace(&sbi->node_write, &lc);
17851786
goto redirty_out;
17861787
}
17871788

@@ -1801,7 +1802,7 @@ static bool __write_node_folio(struct folio *folio, bool atomic, bool *submitted
18011802
f2fs_do_write_node_page(nid, &fio);
18021803
set_node_addr(sbi, &ni, fio.new_blkaddr, is_fsync_dnode(folio));
18031804
dec_page_count(sbi, F2FS_DIRTY_NODES);
1804-
f2fs_up_read(&sbi->node_write);
1805+
f2fs_up_read_trace(&sbi->node_write, &lc);
18051806

18061807
folio_unlock(folio);
18071808

fs/f2fs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4896,7 +4896,7 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)
48964896
init_f2fs_rwsem(&sbi->gc_lock);
48974897
mutex_init(&sbi->writepages);
48984898
init_f2fs_rwsem(&sbi->cp_global_sem);
4899-
init_f2fs_rwsem(&sbi->node_write);
4899+
init_f2fs_rwsem_trace(&sbi->node_write, sbi, LOCK_NAME_NODE_WRITE);
49004900
init_f2fs_rwsem_trace(&sbi->node_change, sbi, LOCK_NAME_NODE_CHANGE);
49014901
spin_lock_init(&sbi->stat_lock);
49024902
init_f2fs_rwsem_trace(&sbi->cp_rwsem, sbi, LOCK_NAME_CP_RWSEM);

include/trace/events/f2fs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ TRACE_DEFINE_ENUM(CP_PHASE_FINISH_CHECKPOINT);
187187
#define show_lock_name(lock) \
188188
__print_symbolic(lock, \
189189
{ LOCK_NAME_CP_RWSEM, "cp_rwsem" }, \
190-
{ LOCK_NAME_NODE_CHANGE, "node_change" })
190+
{ LOCK_NAME_NODE_CHANGE, "node_change" }, \
191+
{ LOCK_NAME_NODE_WRITE, "node_write" })
191192

192193
struct f2fs_sb_info;
193194
struct f2fs_io_info;

0 commit comments

Comments
 (0)