Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: Improve bch2_fatal_error()

error messages should always include __func__

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+35 -35
+1 -1
fs/bcachefs/alloc_background.c
··· 853 853 bucket_journal_seq); 854 854 if (ret) { 855 855 bch2_fs_fatal_error(c, 856 - "error setting bucket_needs_journal_commit: %i", ret); 856 + "setting bucket_needs_journal_commit: %s", bch2_err_str(ret)); 857 857 return ret; 858 858 } 859 859 }
+5 -5
fs/bcachefs/btree_io.c
··· 1066 1066 1067 1067 ret = bset_encrypt(c, i, b->written << 9); 1068 1068 if (bch2_fs_fatal_err_on(ret, c, 1069 - "error decrypting btree node: %i", ret)) 1069 + "decrypting btree node: %s", bch2_err_str(ret))) 1070 1070 goto fsck_err; 1071 1071 1072 1072 btree_err_on(btree_node_type_is_extents(btree_node_type(b)) && ··· 1107 1107 1108 1108 ret = bset_encrypt(c, i, b->written << 9); 1109 1109 if (bch2_fs_fatal_err_on(ret, c, 1110 - "error decrypting btree node: %i\n", ret)) 1110 + "decrypting btree node: %s", bch2_err_str(ret))) 1111 1111 goto fsck_err; 1112 1112 1113 1113 sectors = vstruct_sectors(bne, c->block_bits); ··· 1874 1874 return; 1875 1875 err: 1876 1876 set_btree_node_noevict(b); 1877 - if (!bch2_err_matches(ret, EROFS)) 1878 - bch2_fs_fatal_error(c, "fatal error writing btree node: %s", bch2_err_str(ret)); 1877 + bch2_fs_fatal_err_on(!bch2_err_matches(ret, EROFS), c, 1878 + "writing btree node: %s", bch2_err_str(ret)); 1879 1879 goto out; 1880 1880 } 1881 1881 ··· 2131 2131 2132 2132 ret = bset_encrypt(c, i, b->written << 9); 2133 2133 if (bch2_fs_fatal_err_on(ret, c, 2134 - "error encrypting btree node: %i\n", ret)) 2134 + "encrypting btree node: %s", bch2_err_str(ret))) 2135 2135 goto err; 2136 2136 2137 2137 nonce = btree_nonce(i, b->written << 9);
+1 -1
fs/bcachefs/btree_key_cache.c
··· 676 676 !bch2_err_matches(ret, BCH_ERR_transaction_restart) && 677 677 !bch2_err_matches(ret, BCH_ERR_journal_reclaim_would_deadlock) && 678 678 !bch2_journal_error(j), c, 679 - "error flushing key cache: %s", bch2_err_str(ret)); 679 + "flushing key cache: %s", bch2_err_str(ret)); 680 680 if (ret) 681 681 goto out; 682 682
+3 -2
fs/bcachefs/btree_update_interior.c
··· 646 646 bch2_trans_unlock(trans); 647 647 648 648 bch2_fs_fatal_err_on(ret && !bch2_journal_error(&c->journal), c, 649 - "%s(): error %s", __func__, bch2_err_str(ret)); 649 + "%s", bch2_err_str(ret)); 650 650 err: 651 651 if (as->b) { 652 652 ··· 1193 1193 err: 1194 1194 bch2_btree_update_free(as, trans); 1195 1195 if (!bch2_err_matches(ret, ENOSPC) && 1196 - !bch2_err_matches(ret, EROFS)) 1196 + !bch2_err_matches(ret, EROFS) && 1197 + ret != -BCH_ERR_journal_reclaim_would_deadlock) 1197 1198 bch_err_fn_ratelimited(c, ret); 1198 1199 return ERR_PTR(ret); 1199 1200 }
+1 -1
fs/bcachefs/btree_write_buffer.c
··· 378 378 } 379 379 } 380 380 err: 381 - bch2_fs_fatal_err_on(ret, c, "%s: insert error %s", __func__, bch2_err_str(ret)); 381 + bch2_fs_fatal_err_on(ret, c, "%s", bch2_err_str(ret)); 382 382 trace_write_buffer_flush(trans, wb->flushing.keys.nr, skipped, fast, 0); 383 383 bch2_journal_pin_drop(j, &wb->flushing.pin); 384 384 wb->flushing.keys.nr = 0;
+3 -3
fs/bcachefs/buckets.c
··· 990 990 ret = !gc 991 991 ? bch2_update_cached_sectors_list(trans, p.ptr.dev, disk_sectors) 992 992 : update_cached_sectors(c, k, p.ptr.dev, disk_sectors, 0, true); 993 - bch2_fs_fatal_err_on(ret && gc, c, "%s(): no replicas entry while updating cached sectors", 994 - __func__); 993 + bch2_fs_fatal_err_on(ret && gc, c, "%s: no replicas entry while updating cached sectors", 994 + bch2_err_str(ret)); 995 995 if (ret) 996 996 return ret; 997 997 } ··· 1020 1020 struct printbuf buf = PRINTBUF; 1021 1021 1022 1022 bch2_bkey_val_to_text(&buf, c, k); 1023 - bch2_fs_fatal_error(c, "%s(): no replicas entry for %s", __func__, buf.buf); 1023 + bch2_fs_fatal_error(c, ": no replicas entry for %s", buf.buf); 1024 1024 printbuf_exit(&buf); 1025 1025 } 1026 1026 if (ret)
+1 -1
fs/bcachefs/debug.c
··· 170 170 struct printbuf buf = PRINTBUF; 171 171 172 172 bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key)); 173 - bch2_fs_fatal_error(c, "btree node verify failed for : %s\n", buf.buf); 173 + bch2_fs_fatal_error(c, ": btree node verify failed for: %s\n", buf.buf); 174 174 printbuf_exit(&buf); 175 175 } 176 176 out:
+3 -3
fs/bcachefs/ec.c
··· 448 448 struct printbuf buf = PRINTBUF; 449 449 450 450 bch2_bkey_val_to_text(&buf, c, new); 451 - bch2_fs_fatal_error(c, "no replicas entry for %s", buf.buf); 451 + bch2_fs_fatal_error(c, ": no replicas entry for %s", buf.buf); 452 452 printbuf_exit(&buf); 453 453 return ret; 454 454 } ··· 1868 1868 return -BCH_ERR_stripe_alloc_blocked; 1869 1869 1870 1870 ret = get_stripe_key_trans(trans, idx, &h->s->existing_stripe); 1871 + bch2_fs_fatal_err_on(ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart), c, 1872 + "reading stripe key: %s", bch2_err_str(ret)); 1871 1873 if (ret) { 1872 1874 bch2_stripe_close(c, h->s); 1873 - if (!bch2_err_matches(ret, BCH_ERR_transaction_restart)) 1874 - bch2_fs_fatal_error(c, "error reading stripe key: %s", bch2_err_str(ret)); 1875 1875 return ret; 1876 1876 } 1877 1877
+2 -2
fs/bcachefs/error.h
··· 191 191 192 192 void bch2_fatal_error(struct bch_fs *); 193 193 194 - #define bch2_fs_fatal_error(c, ...) \ 194 + #define bch2_fs_fatal_error(c, _msg, ...) \ 195 195 do { \ 196 - bch_err(c, __VA_ARGS__); \ 196 + bch_err(c, "%s(): fatal error " _msg, __func__, ##__VA_ARGS__); \ 197 197 bch2_fatal_error(c); \ 198 198 } while (0) 199 199
+2 -1
fs/bcachefs/fs.c
··· 108 108 goto retry; 109 109 110 110 bch2_fs_fatal_err_on(bch2_err_matches(ret, ENOENT), c, 111 - "inode %u:%llu not found when updating", 111 + "%s: inode %u:%llu not found when updating", 112 + bch2_err_str(ret), 112 113 inode_inum(inode).subvol, 113 114 inode_inum(inode).inum); 114 115
+5 -7
fs/bcachefs/journal_io.c
··· 1082 1082 ret = bch2_encrypt(c, JSET_CSUM_TYPE(j), journal_nonce(j), 1083 1083 j->encrypted_start, 1084 1084 vstruct_end(j) - (void *) j->encrypted_start); 1085 - bch2_fs_fatal_err_on(ret, c, 1086 - "error decrypting journal entry: %s", 1087 - bch2_err_str(ret)); 1085 + bch2_fs_fatal_err_on(ret, c, "decrypting journal entry: %s", bch2_err_str(ret)); 1088 1086 1089 1087 mutex_lock(&jlist->lock); 1090 1088 ret = journal_entry_add(c, ca, (struct journal_ptr) { ··· 1818 1820 jset_entry_for_each_key(i, k) { 1819 1821 ret = bch2_journal_key_to_wb(c, &wb, i->btree_id, k); 1820 1822 if (ret) { 1821 - bch2_fs_fatal_error(c, "-ENOMEM flushing journal keys to btree write buffer"); 1823 + bch2_fs_fatal_error(c, "flushing journal keys to btree write buffer: %s", 1824 + bch2_err_str(ret)); 1822 1825 bch2_journal_keys_to_write_buffer_end(c, &wb); 1823 1826 return ret; 1824 1827 } ··· 1856 1857 bytes = vstruct_bytes(jset); 1857 1858 1858 1859 if (sectors > w->sectors) { 1859 - bch2_fs_fatal_error(c, "aieeee! journal write overran available space, %zu > %u (extra %u reserved %u/%u)", 1860 + bch2_fs_fatal_error(c, ": journal write overran available space, %zu > %u (extra %u reserved %u/%u)", 1860 1861 vstruct_bytes(jset), w->sectors << 9, 1861 1862 u64s, w->u64s_reserved, j->entry_u64s_reserved); 1862 1863 return -EINVAL; ··· 1884 1885 ret = bch2_encrypt(c, JSET_CSUM_TYPE(jset), journal_nonce(jset), 1885 1886 jset->encrypted_start, 1886 1887 vstruct_end(jset) - (void *) jset->encrypted_start); 1887 - if (bch2_fs_fatal_err_on(ret, c, 1888 - "error decrypting journal entry: %i", ret)) 1888 + if (bch2_fs_fatal_err_on(ret, c, "decrypting journal entry: %s", bch2_err_str(ret))) 1889 1889 return ret; 1890 1890 1891 1891 jset->csum = csum_vstruct(c, JSET_CSUM_TYPE(jset),
+2 -2
fs/bcachefs/logged_ops.c
··· 101 101 struct printbuf buf = PRINTBUF; 102 102 103 103 bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(k)); 104 - bch2_fs_fatal_error(c, "%s: error deleting logged operation %s: %s", 105 - __func__, buf.buf, bch2_err_str(ret)); 104 + bch2_fs_fatal_error(c, "deleting logged operation %s: %s", 105 + buf.buf, bch2_err_str(ret)); 106 106 printbuf_exit(&buf); 107 107 } 108 108 }
+1 -2
fs/bcachefs/movinggc.c
··· 155 155 if (bch2_err_matches(ret, EROFS)) 156 156 return ret; 157 157 158 - if (bch2_fs_fatal_err_on(ret, c, "%s: error %s from bch2_btree_write_buffer_tryflush()", 159 - __func__, bch2_err_str(ret))) 158 + if (bch2_fs_fatal_err_on(ret, c, "%s: from bch2_btree_write_buffer_tryflush()", bch2_err_str(ret))) 160 159 return ret; 161 160 162 161 ret = for_each_btree_key_upto(trans, iter, BTREE_ID_lru,
+4 -4
fs/bcachefs/super-io.c
··· 985 985 prt_str(&buf, " > "); 986 986 bch2_version_to_text(&buf, bcachefs_metadata_version_current); 987 987 prt_str(&buf, ")"); 988 - bch2_fs_fatal_error(c, "%s", buf.buf); 988 + bch2_fs_fatal_error(c, ": %s", buf.buf); 989 989 printbuf_exit(&buf); 990 990 return -BCH_ERR_sb_not_downgraded; 991 991 } ··· 1005 1005 1006 1006 if (le64_to_cpu(ca->sb_read_scratch->seq) < ca->disk_sb.seq) { 1007 1007 bch2_fs_fatal_error(c, 1008 - "Superblock write was silently dropped! (seq %llu expected %llu)", 1008 + ": Superblock write was silently dropped! (seq %llu expected %llu)", 1009 1009 le64_to_cpu(ca->sb_read_scratch->seq), 1010 1010 ca->disk_sb.seq); 1011 1011 percpu_ref_put(&ca->io_ref); ··· 1015 1015 1016 1016 if (le64_to_cpu(ca->sb_read_scratch->seq) > ca->disk_sb.seq) { 1017 1017 bch2_fs_fatal_error(c, 1018 - "Superblock modified by another process (seq %llu expected %llu)", 1018 + ": Superblock modified by another process (seq %llu expected %llu)", 1019 1019 le64_to_cpu(ca->sb_read_scratch->seq), 1020 1020 ca->disk_sb.seq); 1021 1021 percpu_ref_put(&ca->io_ref); ··· 1066 1066 !can_mount_with_written || 1067 1067 (can_mount_without_written && 1068 1068 !can_mount_with_written), c, 1069 - "Unable to write superblock to sufficient devices (from %ps)", 1069 + ": Unable to write superblock to sufficient devices (from %ps)", 1070 1070 (void *) _RET_IP_)) 1071 1071 ret = -1; 1072 1072 out:
+1
fs/bcachefs/super.c
··· 87 87 NULL 88 88 }; 89 89 90 + __printf(2, 0) 90 91 static void bch2_print_maybe_redirect(struct stdio_redirect *stdio, const char *fmt, va_list args) 91 92 { 92 93 #ifdef __KERNEL__