f2fs: clean up bio cache trace
Subsystems (2)
Chao Yu
maintainerPATCH 1/2 f2fs: clean up bio cache trace
From: Chao Yu <[email protected]>
Trace info related to bio cache operation is out of format, clean up it.
Before:
<...>-28308 [002] .... 4781.052703: f2fs_submit_write_bio: dev = (251,1), WRITEWRITE_SYNC ^H, DATA, sector = 271424, size = 126976
<...>-28308 [002] .... 4781.052820: f2fs_submit_page_mbio: dev = (251,1), ino = 103, page_index = 0x1f, oldaddr = 0xffffffff, newaddr = 0x84a7 rw = WRITEWRITE_SYNCi ^H, type = DATA
kworker/u8:2-29988 [001] .... 5549.293877: f2fs_submit_page_mbio: dev = (251,1), ino = 91, page_index = 0xd, oldaddr = 0xffffffff, newaddr = 0x782f rw = WRITE0x0i ^H type = DATAAfter:
kworker/u8:2-8678 [000] .... 7945.124459: f2fs_submit_write_bio: dev = (251,1), rw = WRITE_SYNC, DATA, sector = 74080, size = 53248 kworker/u8:2-8678 [000] .... 7945.124551: f2fs_submit_page_mbio: dev = (251,1), ino = 11, page_index = 0xec, oldaddr = 0xffffffff, newaddr = 0x243a, rw = WRITE, type = DATA
--- include/trace/events/f2fs.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
include/trace/events/f2fs.h +7 -11
@@ -58,16 +58,12 @@ TRACE_DEFINE_ENUM(CP_DISCARD);#define F2FS_BIO_FLAG_MASK (t) (t & (REQ_RAHEAD | WRITE_FLUSH_FUA))#define F2FS_BIO_EXTRA_MASK (t) (t & (REQ_META | REQ_PRIO)) -#define show_bio_type (op, op_flags) show_bio_op(op), \ - show_bio_op_flags(op_flags), show_bio_extra(op_flags) - -#define show_bio_op (op) \ - __print_symbolic(op, \ - { READ, "READ" }, \ - { WRITE, "WRITE" }) +#define show_bio_type (op_flags) show_bio_op_flags(op_flags), \ + show_bio_extra(op_flags)#define show_bio_op_flags (flags) \ __print_symbolic(F2FS_BIO_FLAG_MASK(flags), \ + { 0, "WRITE" }, \ { REQ_RAHEAD, "READAHEAD" }, \ { READ_SYNC, "READ_SYNC" }, \ { WRITE_SYNC, "WRITE_SYNC" }, \
@@ -754,12 +750,12 @@ DECLARE_EVENT_CLASS(f2fs__submit_page_bio, ),TP_printk ("dev = (%d,%d), ino = %lu, page_index = 0x%lx, " -"oldaddr = 0x%llx, newaddr = 0x%llx rw = %s%si%s, type = %s" , +"oldaddr = 0x%llx, newaddr = 0x%llx, rw = %s%s, type = %s" ,show_dev_ino (__entry), (unsigned long )__entry->index, (unsigned long long )__entry->old_blkaddr, (unsigned long long )__entry->new_blkaddr, -show_bio_type (__entry->op, __entry->op_flags), +show_bio_type (__entry->op_flags),show_block_type (__entry->type)) );
@@ -806,9 +802,9 @@ DECLARE_EVENT_CLASS(f2fs__submit_bio, __entry->size = bio->bi_iter.bi_size; ), -TP_printk ("dev = (%d,%d), %s%s%s, %s, sector = %lld, size = %u" , +TP_printk ("dev = (%d,%d), rw = %s%s, %s, sector = %lld, size = %u" ,show_dev (__entry), -show_bio_type (__entry->op, __entry->op_flags), +show_bio_type (__entry->op_flags),show_block_type (__entry->type), (unsigned long long )__entry->sector, __entry->size)
Signature · 4 lines
2.7.2 ------------------------------------------------------------------------------
Chao Yu
maintainerPATCH 2/2 Revert "f2fs: move i_size_write in f2fs_write_end"
From: Chao Yu <[email protected]>
This reverts commit a2ee0a300344a6da76186129b078113354fe13d2.
When testing with generic/032 of xfstest suit, failure message will be reported as below:
generic/032 8s ... [failed, exit status 1] - output mismatch (see results/generic/032.out.bad)
--- tests/generic/032.out 2015-01-11 16:52:27.643681072 +0800
+++ results/generic/032.out.bad 2016-08-06 13:44:43.861330500 +0800
@@ -1,5 +1,5 @@
QA output created by 032
-100 iterations
-0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd
-*
-0100000
+1: [768..775]: unwritten
+Unwritten extents found!
...
(Run 'diff -u tests/generic/032.out results/generic/032.out.bad' to see the entire diff)Ran: generic/032
Failures: generic/032
Failed 1 of 1 tests
In write_end(), we should update i_size of inode before unlock page, otherwise, we will lose newly updated data in following race condition.
Thread A Thread B
- write_end
- unlock page
- writepages
- lock_page
- writepage
if page is out-of-range of file size, we will skip writting the page.
- update i_size
--- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
@@ -1700,11 +1700,11 @@ static int f2fs_write_end(struct file *file,trace_f2fs_write_end (inode, pos, len, copied);set_page_dirty (page); -f2fs_put_page (page,1 );if (pos + copied >i_size_read (inode))f2fs_i_size_write (inode, pos + copied); +f2fs_put_page (page,1 );f2fs_update_time (F2FS_I_SB (inode),REQ_TIME );return copied; }
Signature · 4 lines
2.7.2 ------------------------------------------------------------------------------