1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_ERRCODE_H 3 #define _BCACHEFS_ERRCODE_H 4 5 #define BCH_ERRCODES() \ 6 x(ENOMEM, ENOMEM_stripe_buf) \ 7 x(ENOMEM, ENOMEM_replicas_table) \ 8 x(ENOMEM, ENOMEM_cpu_replicas) \ 9 x(ENOMEM, ENOMEM_replicas_gc) \ 10 x(ENOMEM, ENOMEM_disk_groups_validate) \ 11 x(ENOMEM, ENOMEM_disk_groups_to_cpu) \ 12 x(ENOMEM, ENOMEM_mark_snapshot) \ 13 x(ENOMEM, ENOMEM_mark_stripe) \ 14 x(ENOMEM, ENOMEM_mark_stripe_ptr) \ 15 x(ENOMEM, ENOMEM_btree_key_cache_create) \ 16 x(ENOMEM, ENOMEM_btree_key_cache_fill) \ 17 x(ENOMEM, ENOMEM_btree_key_cache_insert) \ 18 x(ENOMEM, ENOMEM_trans_kmalloc) \ 19 x(ENOMEM, ENOMEM_trans_log_msg) \ 20 x(ENOMEM, ENOMEM_do_encrypt) \ 21 x(ENOMEM, ENOMEM_ec_read_extent) \ 22 x(ENOMEM, ENOMEM_ec_stripe_mem_alloc) \ 23 x(ENOMEM, ENOMEM_ec_new_stripe_alloc) \ 24 x(ENOMEM, ENOMEM_fs_btree_cache_init) \ 25 x(ENOMEM, ENOMEM_fs_btree_key_cache_init) \ 26 x(ENOMEM, ENOMEM_fs_counters_init) \ 27 x(ENOMEM, ENOMEM_fs_btree_write_buffer_init) \ 28 x(ENOMEM, ENOMEM_io_clock_init) \ 29 x(ENOMEM, ENOMEM_blacklist_table_init) \ 30 x(ENOMEM, ENOMEM_sb_realloc_injected) \ 31 x(ENOMEM, ENOMEM_sb_bio_realloc) \ 32 x(ENOMEM, ENOMEM_sb_buf_realloc) \ 33 x(ENOMEM, ENOMEM_sb_journal_validate) \ 34 x(ENOMEM, ENOMEM_sb_journal_v2_validate) \ 35 x(ENOMEM, ENOMEM_journal_entry_add) \ 36 x(ENOMEM, ENOMEM_journal_read_buf_realloc) \ 37 x(ENOMEM, ENOMEM_btree_interior_update_worker_init)\ 38 x(ENOMEM, ENOMEM_btree_interior_update_pool_init) \ 39 x(ENOMEM, ENOMEM_bio_read_init) \ 40 x(ENOMEM, ENOMEM_bio_read_split_init) \ 41 x(ENOMEM, ENOMEM_bio_write_init) \ 42 x(ENOMEM, ENOMEM_bio_bounce_pages_init) \ 43 x(ENOMEM, ENOMEM_writepage_bioset_init) \ 44 x(ENOMEM, ENOMEM_dio_read_bioset_init) \ 45 x(ENOMEM, ENOMEM_dio_write_bioset_init) \ 46 x(ENOMEM, ENOMEM_nocow_flush_bioset_init) \ 47 x(ENOMEM, ENOMEM_promote_table_init) \ 48 x(ENOMEM, ENOMEM_compression_bounce_read_init) \ 49 x(ENOMEM, ENOMEM_compression_bounce_write_init) \ 50 x(ENOMEM, ENOMEM_compression_workspace_init) \ 51 x(ENOMEM, ENOMEM_decompression_workspace_init) \ 52 x(ENOMEM, ENOMEM_bucket_gens) \ 53 x(ENOMEM, ENOMEM_buckets_nouse) \ 54 x(ENOMEM, ENOMEM_usage_init) \ 55 x(ENOMEM, ENOMEM_btree_node_read_all_replicas) \ 56 x(ENOMEM, ENOMEM_btree_node_reclaim) \ 57 x(ENOMEM, ENOMEM_btree_node_mem_alloc) \ 58 x(ENOMEM, ENOMEM_btree_cache_cannibalize_lock) \ 59 x(ENOMEM, ENOMEM_buckets_waiting_for_journal_init)\ 60 x(ENOMEM, ENOMEM_buckets_waiting_for_journal_set) \ 61 x(ENOMEM, ENOMEM_set_nr_journal_buckets) \ 62 x(ENOMEM, ENOMEM_dev_journal_init) \ 63 x(ENOMEM, ENOMEM_journal_pin_fifo) \ 64 x(ENOMEM, ENOMEM_journal_buf) \ 65 x(ENOMEM, ENOMEM_gc_start) \ 66 x(ENOMEM, ENOMEM_gc_alloc_start) \ 67 x(ENOMEM, ENOMEM_gc_reflink_start) \ 68 x(ENOMEM, ENOMEM_gc_gens) \ 69 x(ENOMEM, ENOMEM_gc_repair_key) \ 70 x(ENOMEM, ENOMEM_fsck_extent_ends_at) \ 71 x(ENOMEM, ENOMEM_fsck_add_nlink) \ 72 x(ENOMEM, ENOMEM_journal_key_insert) \ 73 x(ENOMEM, ENOMEM_journal_keys_sort) \ 74 x(ENOMEM, ENOMEM_journal_replay) \ 75 x(ENOMEM, ENOMEM_read_superblock_clean) \ 76 x(ENOMEM, ENOMEM_fs_alloc) \ 77 x(ENOMEM, ENOMEM_fs_name_alloc) \ 78 x(ENOMEM, ENOMEM_fs_other_alloc) \ 79 x(ENOMEM, ENOMEM_dev_alloc) \ 80 x(ENOSPC, ENOSPC_disk_reservation) \ 81 x(ENOSPC, ENOSPC_bucket_alloc) \ 82 x(ENOSPC, ENOSPC_disk_label_add) \ 83 x(ENOSPC, ENOSPC_stripe_create) \ 84 x(ENOSPC, ENOSPC_inode_create) \ 85 x(ENOSPC, ENOSPC_str_hash_create) \ 86 x(ENOSPC, ENOSPC_snapshot_create) \ 87 x(ENOSPC, ENOSPC_subvolume_create) \ 88 x(ENOSPC, ENOSPC_sb) \ 89 x(ENOSPC, ENOSPC_sb_journal) \ 90 x(ENOSPC, ENOSPC_sb_journal_seq_blacklist) \ 91 x(ENOSPC, ENOSPC_sb_quota) \ 92 x(ENOSPC, ENOSPC_sb_replicas) \ 93 x(ENOSPC, ENOSPC_sb_members) \ 94 x(ENOSPC, ENOSPC_sb_members_v2) \ 95 x(ENOSPC, ENOSPC_sb_crypt) \ 96 x(ENOSPC, ENOSPC_btree_slot) \ 97 x(ENOSPC, ENOSPC_snapshot_tree) \ 98 x(ENOENT, ENOENT_bkey_type_mismatch) \ 99 x(ENOENT, ENOENT_str_hash_lookup) \ 100 x(ENOENT, ENOENT_str_hash_set_must_replace) \ 101 x(ENOENT, ENOENT_inode) \ 102 x(ENOENT, ENOENT_not_subvol) \ 103 x(ENOENT, ENOENT_not_directory) \ 104 x(ENOENT, ENOENT_directory_dead) \ 105 x(ENOENT, ENOENT_subvolume) \ 106 x(ENOENT, ENOENT_snapshot_tree) \ 107 x(ENOENT, ENOENT_dirent_doesnt_match_inode) \ 108 x(ENOENT, ENOENT_dev_not_found) \ 109 x(ENOENT, ENOENT_dev_idx_not_found) \ 110 x(0, open_buckets_empty) \ 111 x(0, freelist_empty) \ 112 x(BCH_ERR_freelist_empty, no_buckets_found) \ 113 x(0, transaction_restart) \ 114 x(BCH_ERR_transaction_restart, transaction_restart_fault_inject) \ 115 x(BCH_ERR_transaction_restart, transaction_restart_relock) \ 116 x(BCH_ERR_transaction_restart, transaction_restart_relock_path) \ 117 x(BCH_ERR_transaction_restart, transaction_restart_relock_path_intent) \ 118 x(BCH_ERR_transaction_restart, transaction_restart_relock_after_fill) \ 119 x(BCH_ERR_transaction_restart, transaction_restart_too_many_iters) \ 120 x(BCH_ERR_transaction_restart, transaction_restart_lock_node_reused) \ 121 x(BCH_ERR_transaction_restart, transaction_restart_fill_relock) \ 122 x(BCH_ERR_transaction_restart, transaction_restart_fill_mem_alloc_fail)\ 123 x(BCH_ERR_transaction_restart, transaction_restart_mem_realloced) \ 124 x(BCH_ERR_transaction_restart, transaction_restart_in_traverse_all) \ 125 x(BCH_ERR_transaction_restart, transaction_restart_would_deadlock) \ 126 x(BCH_ERR_transaction_restart, transaction_restart_would_deadlock_write)\ 127 x(BCH_ERR_transaction_restart, transaction_restart_deadlock_recursion_limit)\ 128 x(BCH_ERR_transaction_restart, transaction_restart_upgrade) \ 129 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_upgrade) \ 130 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_fill) \ 131 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_raced) \ 132 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_realloced)\ 133 x(BCH_ERR_transaction_restart, transaction_restart_journal_preres_get) \ 134 x(BCH_ERR_transaction_restart, transaction_restart_split_race) \ 135 x(BCH_ERR_transaction_restart, transaction_restart_write_buffer_flush) \ 136 x(BCH_ERR_transaction_restart, transaction_restart_nested) \ 137 x(0, no_btree_node) \ 138 x(BCH_ERR_no_btree_node, no_btree_node_relock) \ 139 x(BCH_ERR_no_btree_node, no_btree_node_upgrade) \ 140 x(BCH_ERR_no_btree_node, no_btree_node_drop) \ 141 x(BCH_ERR_no_btree_node, no_btree_node_lock_root) \ 142 x(BCH_ERR_no_btree_node, no_btree_node_up) \ 143 x(BCH_ERR_no_btree_node, no_btree_node_down) \ 144 x(BCH_ERR_no_btree_node, no_btree_node_init) \ 145 x(BCH_ERR_no_btree_node, no_btree_node_cached) \ 146 x(BCH_ERR_no_btree_node, no_btree_node_srcu_reset) \ 147 x(0, btree_insert_fail) \ 148 x(BCH_ERR_btree_insert_fail, btree_insert_btree_node_full) \ 149 x(BCH_ERR_btree_insert_fail, btree_insert_need_mark_replicas) \ 150 x(BCH_ERR_btree_insert_fail, btree_insert_need_journal_res) \ 151 x(BCH_ERR_btree_insert_fail, btree_insert_need_journal_reclaim) \ 152 x(BCH_ERR_btree_insert_fail, btree_insert_need_flush_buffer) \ 153 x(0, backpointer_to_overwritten_btree_node) \ 154 x(0, lock_fail_root_changed) \ 155 x(0, journal_reclaim_would_deadlock) \ 156 x(EINVAL, fsck) \ 157 x(BCH_ERR_fsck, fsck_fix) \ 158 x(BCH_ERR_fsck, fsck_ignore) \ 159 x(BCH_ERR_fsck, fsck_errors_not_fixed) \ 160 x(BCH_ERR_fsck, fsck_repair_unimplemented) \ 161 x(BCH_ERR_fsck, fsck_repair_impossible) \ 162 x(0, restart_recovery) \ 163 x(0, unwritten_extent_update) \ 164 x(EINVAL, device_state_not_allowed) \ 165 x(EINVAL, member_info_missing) \ 166 x(EINVAL, mismatched_block_size) \ 167 x(EINVAL, block_size_too_small) \ 168 x(EINVAL, bucket_size_too_small) \ 169 x(EINVAL, device_size_too_small) \ 170 x(EINVAL, device_not_a_member_of_filesystem) \ 171 x(EINVAL, device_has_been_removed) \ 172 x(EINVAL, device_already_online) \ 173 x(EINVAL, insufficient_devices_to_start) \ 174 x(EINVAL, invalid) \ 175 x(EINVAL, internal_fsck_err) \ 176 x(EROFS, erofs_trans_commit) \ 177 x(EROFS, erofs_no_writes) \ 178 x(EROFS, erofs_journal_err) \ 179 x(EROFS, erofs_sb_err) \ 180 x(EROFS, erofs_unfixed_errors) \ 181 x(EROFS, erofs_norecovery) \ 182 x(EROFS, erofs_nochanges) \ 183 x(EROFS, insufficient_devices) \ 184 x(0, operation_blocked) \ 185 x(BCH_ERR_operation_blocked, btree_cache_cannibalize_lock_blocked) \ 186 x(BCH_ERR_operation_blocked, journal_res_get_blocked) \ 187 x(BCH_ERR_operation_blocked, journal_preres_get_blocked) \ 188 x(BCH_ERR_operation_blocked, bucket_alloc_blocked) \ 189 x(BCH_ERR_operation_blocked, stripe_alloc_blocked) \ 190 x(BCH_ERR_invalid, invalid_sb) \ 191 x(BCH_ERR_invalid_sb, invalid_sb_magic) \ 192 x(BCH_ERR_invalid_sb, invalid_sb_version) \ 193 x(BCH_ERR_invalid_sb, invalid_sb_features) \ 194 x(BCH_ERR_invalid_sb, invalid_sb_too_big) \ 195 x(BCH_ERR_invalid_sb, invalid_sb_csum_type) \ 196 x(BCH_ERR_invalid_sb, invalid_sb_csum) \ 197 x(BCH_ERR_invalid_sb, invalid_sb_block_size) \ 198 x(BCH_ERR_invalid_sb, invalid_sb_uuid) \ 199 x(BCH_ERR_invalid_sb, invalid_sb_too_many_members) \ 200 x(BCH_ERR_invalid_sb, invalid_sb_dev_idx) \ 201 x(BCH_ERR_invalid_sb, invalid_sb_time_precision) \ 202 x(BCH_ERR_invalid_sb, invalid_sb_field_size) \ 203 x(BCH_ERR_invalid_sb, invalid_sb_layout) \ 204 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_type) \ 205 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_nr_superblocks) \ 206 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_superblocks_overlap) \ 207 x(BCH_ERR_invalid_sb, invalid_sb_members_missing) \ 208 x(BCH_ERR_invalid_sb, invalid_sb_members) \ 209 x(BCH_ERR_invalid_sb, invalid_sb_disk_groups) \ 210 x(BCH_ERR_invalid_sb, invalid_sb_replicas) \ 211 x(BCH_ERR_invalid_sb, invalid_sb_journal) \ 212 x(BCH_ERR_invalid_sb, invalid_sb_journal_seq_blacklist) \ 213 x(BCH_ERR_invalid_sb, invalid_sb_crypt) \ 214 x(BCH_ERR_invalid_sb, invalid_sb_clean) \ 215 x(BCH_ERR_invalid_sb, invalid_sb_quota) \ 216 x(BCH_ERR_invalid, invalid_bkey) \ 217 x(BCH_ERR_operation_blocked, nocow_lock_blocked) \ 218 x(EIO, btree_node_read_err) \ 219 x(BCH_ERR_btree_node_read_err, btree_node_read_err_fixable) \ 220 x(BCH_ERR_btree_node_read_err, btree_node_read_err_want_retry) \ 221 x(BCH_ERR_btree_node_read_err, btree_node_read_err_must_retry) \ 222 x(BCH_ERR_btree_node_read_err, btree_node_read_err_bad_node) \ 223 x(BCH_ERR_btree_node_read_err, btree_node_read_err_incompatible) \ 224 x(0, nopromote) \ 225 x(BCH_ERR_nopromote, nopromote_may_not) \ 226 x(BCH_ERR_nopromote, nopromote_already_promoted) \ 227 x(BCH_ERR_nopromote, nopromote_unwritten) \ 228 x(BCH_ERR_nopromote, nopromote_congested) \ 229 x(BCH_ERR_nopromote, nopromote_in_flight) \ 230 x(BCH_ERR_nopromote, nopromote_enomem) 231 232 enum bch_errcode { 233 BCH_ERR_START = 2048, 234 #define x(class, err) BCH_ERR_##err, 235 BCH_ERRCODES() 236 #undef x 237 BCH_ERR_MAX 238 }; 239 240 const char *bch2_err_str(int); 241 bool __bch2_err_matches(int, int); 242 243 static inline bool _bch2_err_matches(int err, int class) 244 { 245 return err < 0 && __bch2_err_matches(err, class); 246 } 247 248 #define bch2_err_matches(_err, _class) \ 249 ({ \ 250 BUILD_BUG_ON(!__builtin_constant_p(_class)); \ 251 unlikely(_bch2_err_matches(_err, _class)); \ 252 }) 253 254 int __bch2_err_class(int); 255 256 static inline long bch2_err_class(long err) 257 { 258 return err < 0 ? __bch2_err_class(err) : err; 259 } 260 261 #define BLK_STS_REMOVED ((__force blk_status_t)128) 262 263 const char *bch2_blk_status_to_str(blk_status_t); 264 265 #endif /* _BCACHFES_ERRCODE_H */ 266