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