]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
f2fs: show f2fs instance in printk_ratelimited
authorChao Yu <yuchao0@huawei.com>
Fri, 1 Nov 2019 09:53:23 +0000 (17:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 10:26:23 +0000 (12:26 +0200)
[ Upstream commit c45d6002ff7a322022560e9b19ad867b01fec77f ]

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 <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/checkpoint.c
fs/f2fs/data.c
fs/f2fs/dir.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/gc.c
fs/f2fs/inode.c
fs/f2fs/node.c
fs/f2fs/segment.c

index a57219c51c01a79d53d41264b5a349419455e5e5..f7d27cbbeb860ed0090921fd7e1c736d90f9695e 100644 (file)
@@ -583,7 +583,7 @@ int f2fs_acquire_orphan_inode(struct f2fs_sb_info *sbi)
 
        if (time_to_inject(sbi, FAULT_ORPHAN)) {
                spin_unlock(&im->ino_lock);
-               f2fs_show_injection_info(FAULT_ORPHAN);
+               f2fs_show_injection_info(sbi, FAULT_ORPHAN);
                return -ENOSPC;
        }
 
index 64ee2a064e3392e0980f0fbdd359a3e949fbe22c..df2c361feade6b25fe4f3da1e605d137fe1d6970 100644 (file)
@@ -167,9 +167,10 @@ static bool f2fs_bio_post_read_required(struct bio *bio)
 
 static void f2fs_read_end_io(struct bio *bio)
 {
-       if (time_to_inject(F2FS_P_SB(bio_first_page_all(bio)),
-                                               FAULT_READ_IO)) {
-               f2fs_show_injection_info(FAULT_READ_IO);
+       struct f2fs_sb_info *sbi = F2FS_P_SB(bio_first_page_all(bio));
+
+       if (time_to_inject(sbi, FAULT_READ_IO)) {
+               f2fs_show_injection_info(sbi, FAULT_READ_IO);
                bio->bi_status = BLK_STS_IOERR;
        }
 
@@ -191,7 +192,7 @@ static void f2fs_write_end_io(struct bio *bio)
        struct bvec_iter_all iter_all;
 
        if (time_to_inject(sbi, FAULT_WRITE_IO)) {
-               f2fs_show_injection_info(FAULT_WRITE_IO);
+               f2fs_show_injection_info(sbi, FAULT_WRITE_IO);
                bio->bi_status = BLK_STS_IOERR;
        }
 
index 78d041f9775a49b017673e0b064f7cb6f1c500d1..7b3fbfe68f8cf6cbeaf9270d9e3aad72119fb37d 100644 (file)
@@ -618,7 +618,7 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
 
 start:
        if (time_to_inject(F2FS_I_SB(dir), FAULT_DIR_DEPTH)) {
-               f2fs_show_injection_info(FAULT_DIR_DEPTH);
+               f2fs_show_injection_info(F2FS_I_SB(dir), FAULT_DIR_DEPTH);
                return -ENOSPC;
        }
 
@@ -909,8 +909,9 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
                        bit_pos++;
                        ctx->pos = start_pos + bit_pos;
                        printk_ratelimited(
-                               "%s, invalid namelen(0), ino:%u, run fsck to fix.",
-                               KERN_WARNING, le32_to_cpu(de->ino));
+                               "%sF2FS-fs (%s): invalid namelen(0), ino:%u, run fsck to fix.",
+                               KERN_WARNING, sbi->sb->s_id,
+                               le32_to_cpu(de->ino));
                        set_sbi_flag(sbi, SBI_NEED_FSCK);
                        continue;
                }
index 4ca3c2a0a0f5b7b890e07c2b9de9a82053791910..031a17bf52a24002fb27ab022c4b7cb708ea8a1d 100644 (file)
@@ -1374,9 +1374,10 @@ struct f2fs_private_dio {
 };
 
 #ifdef CONFIG_F2FS_FAULT_INJECTION
-#define f2fs_show_injection_info(type)                                 \
-       printk_ratelimited("%sF2FS-fs : inject %s in %s of %pS\n",      \
-               KERN_INFO, f2fs_fault_name[type],                       \
+#define f2fs_show_injection_info(sbi, type)                                    \
+       printk_ratelimited("%sF2FS-fs (%s) : inject %s in %s of %pS\n", \
+               KERN_INFO, sbi->sb->s_id,                               \
+               f2fs_fault_name[type],                                  \
                __func__, __builtin_return_address(0))
 static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
 {
@@ -1396,7 +1397,7 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
        return false;
 }
 #else
-#define f2fs_show_injection_info(type) do { } while (0)
+#define f2fs_show_injection_info(sbi, type) do { } while (0)
 static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
 {
        return false;
@@ -1781,7 +1782,7 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
                return ret;
 
        if (time_to_inject(sbi, FAULT_BLOCK)) {
-               f2fs_show_injection_info(FAULT_BLOCK);
+               f2fs_show_injection_info(sbi, FAULT_BLOCK);
                release = *count;
                goto release_quota;
        }
@@ -2033,7 +2034,7 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,
        }
 
        if (time_to_inject(sbi, FAULT_BLOCK)) {
-               f2fs_show_injection_info(FAULT_BLOCK);
+               f2fs_show_injection_info(sbi, FAULT_BLOCK);
                goto enospc;
        }
 
@@ -2148,7 +2149,8 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
                        return page;
 
                if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC)) {
-                       f2fs_show_injection_info(FAULT_PAGE_ALLOC);
+                       f2fs_show_injection_info(F2FS_M_SB(mapping),
+                                                       FAULT_PAGE_ALLOC);
                        return NULL;
                }
        }
@@ -2163,7 +2165,7 @@ static inline struct page *f2fs_pagecache_get_page(
                                int fgp_flags, gfp_t gfp_mask)
 {
        if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_GET)) {
-               f2fs_show_injection_info(FAULT_PAGE_GET);
+               f2fs_show_injection_info(F2FS_M_SB(mapping), FAULT_PAGE_GET);
                return NULL;
        }
 
@@ -2232,7 +2234,7 @@ static inline struct bio *f2fs_bio_alloc(struct f2fs_sb_info *sbi,
                return bio;
        }
        if (time_to_inject(sbi, FAULT_ALLOC_BIO)) {
-               f2fs_show_injection_info(FAULT_ALLOC_BIO);
+               f2fs_show_injection_info(sbi, FAULT_ALLOC_BIO);
                return NULL;
        }
 
@@ -2797,7 +2799,7 @@ static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
                                        size_t size, gfp_t flags)
 {
        if (time_to_inject(sbi, FAULT_KMALLOC)) {
-               f2fs_show_injection_info(FAULT_KMALLOC);
+               f2fs_show_injection_info(sbi, FAULT_KMALLOC);
                return NULL;
        }
 
@@ -2814,7 +2816,7 @@ static inline void *f2fs_kvmalloc(struct f2fs_sb_info *sbi,
                                        size_t size, gfp_t flags)
 {
        if (time_to_inject(sbi, FAULT_KVMALLOC)) {
-               f2fs_show_injection_info(FAULT_KVMALLOC);
+               f2fs_show_injection_info(sbi, FAULT_KVMALLOC);
                return NULL;
        }
 
index 6e58b2e62b18963e2214ff907d5fd36f548fba42..f98dce4d07b30bb713a4a94956e693cb795cfc10 100644 (file)
@@ -682,7 +682,7 @@ int f2fs_truncate(struct inode *inode)
        trace_f2fs_truncate(inode);
 
        if (time_to_inject(F2FS_I_SB(inode), FAULT_TRUNCATE)) {
-               f2fs_show_injection_info(FAULT_TRUNCATE);
+               f2fs_show_injection_info(F2FS_I_SB(inode), FAULT_TRUNCATE);
                return -EIO;
        }
 
index a78aa5480454f9bac8fa7e66a199cee05787f947..6b13a1a8920661e3874eed9031a0455553d09a85 100644 (file)
@@ -54,7 +54,7 @@ static int gc_thread_func(void *data)
                }
 
                if (time_to_inject(sbi, FAULT_CHECKPOINT)) {
-                       f2fs_show_injection_info(FAULT_CHECKPOINT);
+                       f2fs_show_injection_info(sbi, FAULT_CHECKPOINT);
                        f2fs_stop_checkpoint(sbi, false);
                }
 
index 386ad54c13c3a3abf9812f3621328322862afd9a..502bd491336a8200861232e9b3ba60ccc94965c3 100644 (file)
@@ -681,7 +681,7 @@ retry:
                err = f2fs_truncate(inode);
 
        if (time_to_inject(sbi, FAULT_EVICT_INODE)) {
-               f2fs_show_injection_info(FAULT_EVICT_INODE);
+               f2fs_show_injection_info(sbi, FAULT_EVICT_INODE);
                err = -EIO;
        }
 
index 48bb5d3c709db938353cfbf54c1726c74dfdde0d..4cb182c20eeddcb8ca4dbb8a19277d6dd788caef 100644 (file)
@@ -2406,7 +2406,7 @@ bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
        struct free_nid *i = NULL;
 retry:
        if (time_to_inject(sbi, FAULT_ALLOC_NID)) {
-               f2fs_show_injection_info(FAULT_ALLOC_NID);
+               f2fs_show_injection_info(sbi, FAULT_ALLOC_NID);
                return false;
        }
 
index 5ba677f85533c414624920cd11c88340c07e7df2..78c54bb7898dfb9ccade324247bbf73e206e2584 100644 (file)
@@ -489,7 +489,7 @@ int f2fs_commit_inmem_pages(struct inode *inode)
 void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
 {
        if (time_to_inject(sbi, FAULT_CHECKPOINT)) {
-               f2fs_show_injection_info(FAULT_CHECKPOINT);
+               f2fs_show_injection_info(sbi, FAULT_CHECKPOINT);
                f2fs_stop_checkpoint(sbi, false);
        }
 
@@ -1017,8 +1017,9 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi,
 
        if (dc->error)
                printk_ratelimited(
-                       "%sF2FS-fs: Issue discard(%u, %u, %u) failed, ret: %d",
-                       KERN_INFO, dc->lstart, dc->start, dc->len, dc->error);
+                       "%sF2FS-fs (%s): Issue discard(%u, %u, %u) failed, ret: %d",
+                       KERN_INFO, sbi->sb->s_id,
+                       dc->lstart, dc->start, dc->len, dc->error);
        __detach_discard_cmd(dcc, dc);
 }
 
@@ -1158,7 +1159,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
                dc->len += len;
 
                if (time_to_inject(sbi, FAULT_DISCARD)) {
-                       f2fs_show_injection_info(FAULT_DISCARD);
+                       f2fs_show_injection_info(sbi, FAULT_DISCARD);
                        err = -EIO;
                        goto submit;
                }