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