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(0, open_buckets_empty) \ 120 x(0, freelist_empty) \ 121 x(BCH_ERR_freelist_empty, no_buckets_found) \ 122 x(0, transaction_restart) \ 123 x(BCH_ERR_transaction_restart, transaction_restart_fault_inject) \ 124 x(BCH_ERR_transaction_restart, transaction_restart_relock) \ 125 x(BCH_ERR_transaction_restart, transaction_restart_relock_path) \ 126 x(BCH_ERR_transaction_restart, transaction_restart_relock_path_intent) \ 127 x(BCH_ERR_transaction_restart, transaction_restart_relock_after_fill) \ 128 x(BCH_ERR_transaction_restart, transaction_restart_too_many_iters) \ 129 x(BCH_ERR_transaction_restart, transaction_restart_lock_node_reused) \ 130 x(BCH_ERR_transaction_restart, transaction_restart_fill_relock) \ 131 x(BCH_ERR_transaction_restart, transaction_restart_fill_mem_alloc_fail)\ 132 x(BCH_ERR_transaction_restart, transaction_restart_mem_realloced) \ 133 x(BCH_ERR_transaction_restart, transaction_restart_in_traverse_all) \ 134 x(BCH_ERR_transaction_restart, transaction_restart_would_deadlock) \ 135 x(BCH_ERR_transaction_restart, transaction_restart_would_deadlock_write)\ 136 x(BCH_ERR_transaction_restart, transaction_restart_deadlock_recursion_limit)\ 137 x(BCH_ERR_transaction_restart, transaction_restart_upgrade) \ 138 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_upgrade) \ 139 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_fill) \ 140 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_raced) \ 141 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_realloced)\ 142 x(BCH_ERR_transaction_restart, transaction_restart_journal_preres_get) \ 143 x(BCH_ERR_transaction_restart, transaction_restart_split_race) \ 144 x(BCH_ERR_transaction_restart, transaction_restart_write_buffer_flush) \ 145 x(BCH_ERR_transaction_restart, transaction_restart_nested) \ 146 x(0, no_btree_node) \ 147 x(BCH_ERR_no_btree_node, no_btree_node_relock) \ 148 x(BCH_ERR_no_btree_node, no_btree_node_upgrade) \ 149 x(BCH_ERR_no_btree_node, no_btree_node_drop) \ 150 x(BCH_ERR_no_btree_node, no_btree_node_lock_root) \ 151 x(BCH_ERR_no_btree_node, no_btree_node_up) \ 152 x(BCH_ERR_no_btree_node, no_btree_node_down) \ 153 x(BCH_ERR_no_btree_node, no_btree_node_init) \ 154 x(BCH_ERR_no_btree_node, no_btree_node_cached) \ 155 x(BCH_ERR_no_btree_node, no_btree_node_srcu_reset) \ 156 x(0, btree_insert_fail) \ 157 x(BCH_ERR_btree_insert_fail, btree_insert_btree_node_full) \ 158 x(BCH_ERR_btree_insert_fail, btree_insert_need_mark_replicas) \ 159 x(BCH_ERR_btree_insert_fail, btree_insert_need_journal_res) \ 160 x(BCH_ERR_btree_insert_fail, btree_insert_need_journal_reclaim) \ 161 x(0, backpointer_to_overwritten_btree_node) \ 162 x(0, lock_fail_root_changed) \ 163 x(0, journal_reclaim_would_deadlock) \ 164 x(EINVAL, fsck) \ 165 x(BCH_ERR_fsck, fsck_fix) \ 166 x(BCH_ERR_fsck, fsck_ignore) \ 167 x(BCH_ERR_fsck, fsck_errors_not_fixed) \ 168 x(BCH_ERR_fsck, fsck_repair_unimplemented) \ 169 x(BCH_ERR_fsck, fsck_repair_impossible) \ 170 x(0, restart_recovery) \ 171 x(0, data_update_done) \ 172 x(EINVAL, device_state_not_allowed) \ 173 x(EINVAL, member_info_missing) \ 174 x(EINVAL, mismatched_block_size) \ 175 x(EINVAL, block_size_too_small) \ 176 x(EINVAL, bucket_size_too_small) \ 177 x(EINVAL, device_size_too_small) \ 178 x(EINVAL, device_size_too_big) \ 179 x(EINVAL, device_not_a_member_of_filesystem) \ 180 x(EINVAL, device_has_been_removed) \ 181 x(EINVAL, device_splitbrain) \ 182 x(EINVAL, device_already_online) \ 183 x(EINVAL, insufficient_devices_to_start) \ 184 x(EINVAL, invalid) \ 185 x(EINVAL, internal_fsck_err) \ 186 x(EINVAL, opt_parse_error) \ 187 x(EINVAL, remove_with_metadata_missing_unimplemented)\ 188 x(EINVAL, remove_would_lose_data) \ 189 x(EINVAL, btree_iter_with_journal_not_supported) \ 190 x(EROFS, erofs_trans_commit) \ 191 x(EROFS, erofs_no_writes) \ 192 x(EROFS, erofs_journal_err) \ 193 x(EROFS, erofs_sb_err) \ 194 x(EROFS, erofs_unfixed_errors) \ 195 x(EROFS, erofs_norecovery) \ 196 x(EROFS, erofs_nochanges) \ 197 x(EROFS, insufficient_devices) \ 198 x(0, operation_blocked) \ 199 x(BCH_ERR_operation_blocked, btree_cache_cannibalize_lock_blocked) \ 200 x(BCH_ERR_operation_blocked, journal_res_get_blocked) \ 201 x(BCH_ERR_operation_blocked, journal_preres_get_blocked) \ 202 x(BCH_ERR_operation_blocked, bucket_alloc_blocked) \ 203 x(BCH_ERR_operation_blocked, stripe_alloc_blocked) \ 204 x(BCH_ERR_invalid, invalid_sb) \ 205 x(BCH_ERR_invalid_sb, invalid_sb_magic) \ 206 x(BCH_ERR_invalid_sb, invalid_sb_version) \ 207 x(BCH_ERR_invalid_sb, invalid_sb_features) \ 208 x(BCH_ERR_invalid_sb, invalid_sb_too_big) \ 209 x(BCH_ERR_invalid_sb, invalid_sb_csum_type) \ 210 x(BCH_ERR_invalid_sb, invalid_sb_csum) \ 211 x(BCH_ERR_invalid_sb, invalid_sb_block_size) \ 212 x(BCH_ERR_invalid_sb, invalid_sb_uuid) \ 213 x(BCH_ERR_invalid_sb, invalid_sb_too_many_members) \ 214 x(BCH_ERR_invalid_sb, invalid_sb_dev_idx) \ 215 x(BCH_ERR_invalid_sb, invalid_sb_time_precision) \ 216 x(BCH_ERR_invalid_sb, invalid_sb_field_size) \ 217 x(BCH_ERR_invalid_sb, invalid_sb_layout) \ 218 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_type) \ 219 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_nr_superblocks) \ 220 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_superblocks_overlap) \ 221 x(BCH_ERR_invalid_sb, invalid_sb_members_missing) \ 222 x(BCH_ERR_invalid_sb, invalid_sb_members) \ 223 x(BCH_ERR_invalid_sb, invalid_sb_disk_groups) \ 224 x(BCH_ERR_invalid_sb, invalid_sb_replicas) \ 225 x(BCH_ERR_invalid_sb, invalid_replicas_entry) \ 226 x(BCH_ERR_invalid_sb, invalid_sb_journal) \ 227 x(BCH_ERR_invalid_sb, invalid_sb_journal_seq_blacklist) \ 228 x(BCH_ERR_invalid_sb, invalid_sb_crypt) \ 229 x(BCH_ERR_invalid_sb, invalid_sb_clean) \ 230 x(BCH_ERR_invalid_sb, invalid_sb_quota) \ 231 x(BCH_ERR_invalid_sb, invalid_sb_errors) \ 232 x(BCH_ERR_invalid_sb, invalid_sb_opt_compression) \ 233 x(BCH_ERR_invalid_sb, invalid_sb_ext) \ 234 x(BCH_ERR_invalid_sb, invalid_sb_downgrade) \ 235 x(BCH_ERR_invalid, invalid_bkey) \ 236 x(BCH_ERR_operation_blocked, nocow_lock_blocked) \ 237 x(EIO, btree_node_read_err) \ 238 x(EIO, sb_not_downgraded) \ 239 x(EIO, btree_node_write_all_failed) \ 240 x(EIO, btree_node_read_error) \ 241 x(EIO, btree_node_read_validate_error) \ 242 x(EIO, btree_need_topology_repair) \ 243 x(BCH_ERR_btree_node_read_err, btree_node_read_err_fixable) \ 244 x(BCH_ERR_btree_node_read_err, btree_node_read_err_want_retry) \ 245 x(BCH_ERR_btree_node_read_err, btree_node_read_err_must_retry) \ 246 x(BCH_ERR_btree_node_read_err, btree_node_read_err_bad_node) \ 247 x(BCH_ERR_btree_node_read_err, btree_node_read_err_incompatible) \ 248 x(0, nopromote) \ 249 x(BCH_ERR_nopromote, nopromote_may_not) \ 250 x(BCH_ERR_nopromote, nopromote_already_promoted) \ 251 x(BCH_ERR_nopromote, nopromote_unwritten) \ 252 x(BCH_ERR_nopromote, nopromote_congested) \ 253 x(BCH_ERR_nopromote, nopromote_in_flight) \ 254 x(BCH_ERR_nopromote, nopromote_no_writes) \ 255 x(BCH_ERR_nopromote, nopromote_enomem) \ 256 x(0, need_inode_lock) \ 257 x(0, invalid_snapshot_node) 258 259 enum bch_errcode { 260 BCH_ERR_START = 2048, 261 #define x(class, err) BCH_ERR_##err, 262 BCH_ERRCODES() 263 #undef x 264 BCH_ERR_MAX 265 }; 266 267 const char *bch2_err_str(int); 268 bool __bch2_err_matches(int, int); 269 270 static inline bool _bch2_err_matches(int err, int class) 271 { 272 return err < 0 && __bch2_err_matches(err, class); 273 } 274 275 #define bch2_err_matches(_err, _class) \ 276 ({ \ 277 BUILD_BUG_ON(!__builtin_constant_p(_class)); \ 278 unlikely(_bch2_err_matches(_err, _class)); \ 279 }) 280 281 int __bch2_err_class(int); 282 283 static inline long bch2_err_class(long err) 284 { 285 return err < 0 ? __bch2_err_class(err) : err; 286 } 287 288 #define BLK_STS_REMOVED ((__force blk_status_t)128) 289 290 const char *bch2_blk_status_to_str(blk_status_t); 291 292 #endif /* _BCACHFES_ERRCODE_H */ 293