f2fs: show simple call stack in fault injection message
authorChao Yu <yuchao0@huawei.com>
Sat, 25 Feb 2017 03:08:28 +0000 (11:08 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 27 Feb 2017 17:59:55 +0000 (09:59 -0800)
Previously kernel message can show that in which function we do the
injection, but unfortunately, most of the caller are the same, for
tracking more information of injection path, it needs to show upper
caller's name. This patch supports that ability.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c
fs/f2fs/data.c
fs/f2fs/dir.c
fs/f2fs/f2fs.h
fs/f2fs/gc.c
fs/f2fs/inode.c
fs/f2fs/node.c
fs/f2fs/segment.c

index cd7132121573003dae69d3794f7dbda0d5b06c69..04d7c244c0f04acabf87006c4a327cf9277fee6d 100644 (file)
@@ -494,6 +494,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
 #ifdef CONFIG_F2FS_FAULT_INJECTION
        if (time_to_inject(sbi, FAULT_ORPHAN)) {
                spin_unlock(&im->ino_lock);
+               f2fs_show_injection_info(FAULT_ORPHAN);
                return -ENOSPC;
        }
 #endif
index 9e51c5e40ce16e36569286cecdd0729ec56f2b46..b0a2e3faabb21d0bd607ea2b8ac23b448ac7d04c 100644 (file)
@@ -55,8 +55,10 @@ static void f2fs_read_end_io(struct bio *bio)
        int i;
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-       if (time_to_inject(F2FS_P_SB(bio->bi_io_vec->bv_page), FAULT_IO))
+       if (time_to_inject(F2FS_P_SB(bio->bi_io_vec->bv_page), FAULT_IO)) {
+               f2fs_show_injection_info(FAULT_IO);
                bio->bi_error = -EIO;
+       }
 #endif
 
        if (f2fs_bio_encrypted(bio)) {
index 54aa30ee028f64375ff57a415d94b28b61973188..295a223ae11e5853a25c8b4c3dd8845d7762098f 100644 (file)
@@ -549,8 +549,10 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
 
 start:
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-       if (time_to_inject(F2FS_I_SB(dir), FAULT_DIR_DEPTH))
+       if (time_to_inject(F2FS_I_SB(dir), FAULT_DIR_DEPTH)) {
+               f2fs_show_injection_info(FAULT_DIR_DEPTH);
                return -ENOSPC;
+       }
 #endif
        if (unlikely(current_depth == MAX_DIR_HASH_DEPTH))
                return -ENOSPC;
index d1156cdd211edcad5e6d2bbd169db40d1258ae96..8c0916ae0bea0e788c268b8f685f36b13adb23b7 100644 (file)
@@ -952,6 +952,10 @@ struct f2fs_sb_info {
 };
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
+#define f2fs_show_injection_info(type)                         \
+       printk("%sF2FS-fs : inject %s in %s of %pF\n",          \
+               KERN_INFO, fault_name[type],                    \
+               __func__, __builtin_return_address(0))
 static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
 {
        struct f2fs_fault_info *ffi = &sbi->fault_info;
@@ -965,10 +969,6 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
        atomic_inc(&ffi->inject_ops);
        if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
                atomic_set(&ffi->inject_ops, 0);
-               printk("%sF2FS-fs : inject %s in %pF\n",
-                               KERN_INFO,
-                               fault_name[type],
-                               __builtin_return_address(0));
                return true;
        }
        return false;
@@ -1277,8 +1277,10 @@ static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
        blkcnt_t diff;
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-       if (time_to_inject(sbi, FAULT_BLOCK))
+       if (time_to_inject(sbi, FAULT_BLOCK)) {
+               f2fs_show_injection_info(FAULT_BLOCK);
                return false;
+       }
 #endif
        /*
         * let's increase this in prior to actual block count change in order
@@ -1518,8 +1520,10 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
        if (page)
                return page;
 
-       if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC))
+       if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC)) {
+               f2fs_show_injection_info(FAULT_PAGE_ALLOC);
                return NULL;
+       }
 #endif
        if (!for_write)
                return grab_cache_page(mapping, index);
@@ -1995,8 +1999,10 @@ static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
                                        size_t size, gfp_t flags)
 {
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-       if (time_to_inject(sbi, FAULT_KMALLOC))
+       if (time_to_inject(sbi, FAULT_KMALLOC)) {
+               f2fs_show_injection_info(FAULT_KMALLOC);
                return NULL;
+       }
 #endif
        return kmalloc(size, flags);
 }
index 6c996e39b59a0d999e9eae7bfd4097735e24af3e..8be5144da8e63672426ca1e57fc96695d10fd619 100644 (file)
@@ -48,8 +48,10 @@ static int gc_thread_func(void *data)
                }
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-               if (time_to_inject(sbi, FAULT_CHECKPOINT))
+               if (time_to_inject(sbi, FAULT_CHECKPOINT)) {
+                       f2fs_show_injection_info(FAULT_CHECKPOINT);
                        f2fs_stop_checkpoint(sbi, false);
+               }
 #endif
 
                /*
index af06bda51a5438a62f58695a8496f2844cf3b4c6..24bb8213d974b710b43f286b1089ccff7946a50e 100644 (file)
@@ -373,8 +373,10 @@ void f2fs_evict_inode(struct inode *inode)
                goto no_delete;
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-       if (time_to_inject(sbi, FAULT_EVICT_INODE))
+       if (time_to_inject(sbi, FAULT_EVICT_INODE)) {
+               f2fs_show_injection_info(FAULT_EVICT_INODE);
                goto no_delete;
+       }
 #endif
 
        remove_ino_entry(sbi, inode->i_ino, APPEND_INO);
index 43d35ec11851c3295beb2c36b6463b402beffd67..24ea49f988917889b8d00d608626e7646ebdb815 100644 (file)
@@ -1987,8 +1987,10 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
        struct free_nid *i = NULL;
 retry:
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-       if (time_to_inject(sbi, FAULT_ALLOC_NID))
+       if (time_to_inject(sbi, FAULT_ALLOC_NID)) {
+               f2fs_show_injection_info(FAULT_ALLOC_NID);
                return false;
+       }
 #endif
        spin_lock(&nm_i->nid_list_lock);
 
index 9eb6d89bf9e22a2b0c26bace044bb29b21186071..1bab09097590a030e047befa3b018517e8515cf8 100644 (file)
@@ -352,8 +352,10 @@ int commit_inmem_pages(struct inode *inode)
 void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
 {
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-       if (time_to_inject(sbi, FAULT_CHECKPOINT))
+       if (time_to_inject(sbi, FAULT_CHECKPOINT)) {
+               f2fs_show_injection_info(FAULT_CHECKPOINT);
                f2fs_stop_checkpoint(sbi, false);
+       }
 #endif
 
        if (!need)