Skip to content

Commit c45d600

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: show f2fs instance in printk_ratelimited
As Eric mentioned, bare printk{,_ratelimited} won't show which filesystem instance these message is coming from, this patch tries to show fs instance with sb->s_id field in all places we missed before. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 1f0d5c9 commit c45d600

File tree

9 files changed

+32
-27
lines changed

9 files changed

+32
-27
lines changed

fs/f2fs/checkpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ int f2fs_acquire_orphan_inode(struct f2fs_sb_info *sbi)
581581

582582
if (time_to_inject(sbi, FAULT_ORPHAN)) {
583583
spin_unlock(&im->ino_lock);
584-
f2fs_show_injection_info(FAULT_ORPHAN);
584+
f2fs_show_injection_info(sbi, FAULT_ORPHAN);
585585
return -ENOSPC;
586586
}
587587

fs/f2fs/data.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,10 @@ static bool f2fs_bio_post_read_required(struct bio *bio)
168168

169169
static void f2fs_read_end_io(struct bio *bio)
170170
{
171-
if (time_to_inject(F2FS_P_SB(bio_first_page_all(bio)),
172-
FAULT_READ_IO)) {
173-
f2fs_show_injection_info(FAULT_READ_IO);
171+
struct f2fs_sb_info *sbi = F2FS_P_SB(bio_first_page_all(bio));
172+
173+
if (time_to_inject(sbi, FAULT_READ_IO)) {
174+
f2fs_show_injection_info(sbi, FAULT_READ_IO);
174175
bio->bi_status = BLK_STS_IOERR;
175176
}
176177

@@ -192,7 +193,7 @@ static void f2fs_write_end_io(struct bio *bio)
192193
struct bvec_iter_all iter_all;
193194

194195
if (time_to_inject(sbi, FAULT_WRITE_IO)) {
195-
f2fs_show_injection_info(FAULT_WRITE_IO);
196+
f2fs_show_injection_info(sbi, FAULT_WRITE_IO);
196197
bio->bi_status = BLK_STS_IOERR;
197198
}
198199

fs/f2fs/dir.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
628628

629629
start:
630630
if (time_to_inject(F2FS_I_SB(dir), FAULT_DIR_DEPTH)) {
631-
f2fs_show_injection_info(FAULT_DIR_DEPTH);
631+
f2fs_show_injection_info(F2FS_I_SB(dir), FAULT_DIR_DEPTH);
632632
return -ENOSPC;
633633
}
634634

@@ -919,8 +919,9 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
919919
bit_pos++;
920920
ctx->pos = start_pos + bit_pos;
921921
printk_ratelimited(
922-
"%s, invalid namelen(0), ino:%u, run fsck to fix.",
923-
KERN_WARNING, le32_to_cpu(de->ino));
922+
"%sF2FS-fs (%s): invalid namelen(0), ino:%u, run fsck to fix.",
923+
KERN_WARNING, sbi->sb->s_id,
924+
le32_to_cpu(de->ino));
924925
set_sbi_flag(sbi, SBI_NEED_FSCK);
925926
continue;
926927
}

fs/f2fs/f2fs.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,9 +1374,10 @@ struct f2fs_private_dio {
13741374
};
13751375

13761376
#ifdef CONFIG_F2FS_FAULT_INJECTION
1377-
#define f2fs_show_injection_info(type) \
1378-
printk_ratelimited("%sF2FS-fs : inject %s in %s of %pS\n", \
1379-
KERN_INFO, f2fs_fault_name[type], \
1377+
#define f2fs_show_injection_info(sbi, type) \
1378+
printk_ratelimited("%sF2FS-fs (%s) : inject %s in %s of %pS\n", \
1379+
KERN_INFO, sbi->sb->s_id, \
1380+
f2fs_fault_name[type], \
13801381
__func__, __builtin_return_address(0))
13811382
static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
13821383
{
@@ -1396,7 +1397,7 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
13961397
return false;
13971398
}
13981399
#else
1399-
#define f2fs_show_injection_info(type) do { } while (0)
1400+
#define f2fs_show_injection_info(sbi, type) do { } while (0)
14001401
static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
14011402
{
14021403
return false;
@@ -1781,7 +1782,7 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
17811782
return ret;
17821783

17831784
if (time_to_inject(sbi, FAULT_BLOCK)) {
1784-
f2fs_show_injection_info(FAULT_BLOCK);
1785+
f2fs_show_injection_info(sbi, FAULT_BLOCK);
17851786
release = *count;
17861787
goto release_quota;
17871788
}
@@ -2033,7 +2034,7 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,
20332034
}
20342035

20352036
if (time_to_inject(sbi, FAULT_BLOCK)) {
2036-
f2fs_show_injection_info(FAULT_BLOCK);
2037+
f2fs_show_injection_info(sbi, FAULT_BLOCK);
20372038
goto enospc;
20382039
}
20392040

@@ -2148,7 +2149,8 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
21482149
return page;
21492150

21502151
if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC)) {
2151-
f2fs_show_injection_info(FAULT_PAGE_ALLOC);
2152+
f2fs_show_injection_info(F2FS_M_SB(mapping),
2153+
FAULT_PAGE_ALLOC);
21522154
return NULL;
21532155
}
21542156
}
@@ -2163,7 +2165,7 @@ static inline struct page *f2fs_pagecache_get_page(
21632165
int fgp_flags, gfp_t gfp_mask)
21642166
{
21652167
if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_GET)) {
2166-
f2fs_show_injection_info(FAULT_PAGE_GET);
2168+
f2fs_show_injection_info(F2FS_M_SB(mapping), FAULT_PAGE_GET);
21672169
return NULL;
21682170
}
21692171

@@ -2232,7 +2234,7 @@ static inline struct bio *f2fs_bio_alloc(struct f2fs_sb_info *sbi,
22322234
return bio;
22332235
}
22342236
if (time_to_inject(sbi, FAULT_ALLOC_BIO)) {
2235-
f2fs_show_injection_info(FAULT_ALLOC_BIO);
2237+
f2fs_show_injection_info(sbi, FAULT_ALLOC_BIO);
22362238
return NULL;
22372239
}
22382240

@@ -2799,7 +2801,7 @@ static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
27992801
void *ret;
28002802

28012803
if (time_to_inject(sbi, FAULT_KMALLOC)) {
2802-
f2fs_show_injection_info(FAULT_KMALLOC);
2804+
f2fs_show_injection_info(sbi, FAULT_KMALLOC);
28032805
return NULL;
28042806
}
28052807

@@ -2820,7 +2822,7 @@ static inline void *f2fs_kvmalloc(struct f2fs_sb_info *sbi,
28202822
size_t size, gfp_t flags)
28212823
{
28222824
if (time_to_inject(sbi, FAULT_KVMALLOC)) {
2823-
f2fs_show_injection_info(FAULT_KVMALLOC);
2825+
f2fs_show_injection_info(sbi, FAULT_KVMALLOC);
28242826
return NULL;
28252827
}
28262828

fs/f2fs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ int f2fs_truncate(struct inode *inode)
681681
trace_f2fs_truncate(inode);
682682

683683
if (time_to_inject(F2FS_I_SB(inode), FAULT_TRUNCATE)) {
684-
f2fs_show_injection_info(FAULT_TRUNCATE);
684+
f2fs_show_injection_info(F2FS_I_SB(inode), FAULT_TRUNCATE);
685685
return -EIO;
686686
}
687687

fs/f2fs/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int gc_thread_func(void *data)
5454
}
5555

5656
if (time_to_inject(sbi, FAULT_CHECKPOINT)) {
57-
f2fs_show_injection_info(FAULT_CHECKPOINT);
57+
f2fs_show_injection_info(sbi, FAULT_CHECKPOINT);
5858
f2fs_stop_checkpoint(sbi, false);
5959
}
6060

fs/f2fs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ void f2fs_evict_inode(struct inode *inode)
681681
err = f2fs_truncate(inode);
682682

683683
if (time_to_inject(sbi, FAULT_EVICT_INODE)) {
684-
f2fs_show_injection_info(FAULT_EVICT_INODE);
684+
f2fs_show_injection_info(sbi, FAULT_EVICT_INODE);
685685
err = -EIO;
686686
}
687687

fs/f2fs/node.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,7 @@ bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
23982398
struct free_nid *i = NULL;
23992399
retry:
24002400
if (time_to_inject(sbi, FAULT_ALLOC_NID)) {
2401-
f2fs_show_injection_info(FAULT_ALLOC_NID);
2401+
f2fs_show_injection_info(sbi, FAULT_ALLOC_NID);
24022402
return false;
24032403
}
24042404

fs/f2fs/segment.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ int f2fs_commit_inmem_pages(struct inode *inode)
480480
void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
481481
{
482482
if (time_to_inject(sbi, FAULT_CHECKPOINT)) {
483-
f2fs_show_injection_info(FAULT_CHECKPOINT);
483+
f2fs_show_injection_info(sbi, FAULT_CHECKPOINT);
484484
f2fs_stop_checkpoint(sbi, false);
485485
}
486486

@@ -1008,8 +1008,9 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi,
10081008

10091009
if (dc->error)
10101010
printk_ratelimited(
1011-
"%sF2FS-fs: Issue discard(%u, %u, %u) failed, ret: %d",
1012-
KERN_INFO, dc->lstart, dc->start, dc->len, dc->error);
1011+
"%sF2FS-fs (%s): Issue discard(%u, %u, %u) failed, ret: %d",
1012+
KERN_INFO, sbi->sb->s_id,
1013+
dc->lstart, dc->start, dc->len, dc->error);
10131014
__detach_discard_cmd(dcc, dc);
10141015
}
10151016

@@ -1149,7 +1150,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
11491150
dc->len += len;
11501151

11511152
if (time_to_inject(sbi, FAULT_DISCARD)) {
1152-
f2fs_show_injection_info(FAULT_DISCARD);
1153+
f2fs_show_injection_info(sbi, FAULT_DISCARD);
11531154
err = -EIO;
11541155
goto submit;
11551156
}

0 commit comments

Comments
 (0)