errcode.c (0ea5c948cb64bab5bc7a5516774eb8536f05aa0d) | errcode.c (eb386617be4bdfe02eb0972874f726e2bfc7a6e7) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2 3#include "bcachefs.h" 4#include "errcode.h" | 1// SPDX-License-Identifier: GPL-2.0 2 3#include "bcachefs.h" 4#include "errcode.h" |
5#include "trace.h" |
|
5 6#include <linux/errname.h> 7 8static const char * const bch2_errcode_strs[] = { 9#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = #err, 10 BCH_ERRCODES() 11#undef x 12 NULL --- 31 unchanged lines hidden (view full) --- 44 BUG_ON(class >= BCH_ERR_MAX); 45 46 while (err >= BCH_ERR_START && err != class) 47 err = bch2_errcode_parents[err - BCH_ERR_START]; 48 49 return err == class; 50} 51 | 6 7#include <linux/errname.h> 8 9static const char * const bch2_errcode_strs[] = { 10#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = #err, 11 BCH_ERRCODES() 12#undef x 13 NULL --- 31 unchanged lines hidden (view full) --- 45 BUG_ON(class >= BCH_ERR_MAX); 46 47 while (err >= BCH_ERR_START && err != class) 48 err = bch2_errcode_parents[err - BCH_ERR_START]; 49 50 return err == class; 51} 52 |
52int __bch2_err_class(int err) | 53int __bch2_err_class(int bch_err) |
53{ | 54{ |
54 err = -err; 55 BUG_ON((unsigned) err >= BCH_ERR_MAX); | 55 int std_err = -bch_err; 56 BUG_ON((unsigned) std_err >= BCH_ERR_MAX); |
56 | 57 |
57 while (err >= BCH_ERR_START && bch2_errcode_parents[err - BCH_ERR_START]) 58 err = bch2_errcode_parents[err - BCH_ERR_START]; | 58 while (std_err >= BCH_ERR_START && bch2_errcode_parents[std_err - BCH_ERR_START]) 59 std_err = bch2_errcode_parents[std_err - BCH_ERR_START]; |
59 | 60 |
60 return -err; | 61 trace_error_downcast(bch_err, std_err, _RET_IP_); 62 63 return -std_err; |
61} 62 63const char *bch2_blk_status_to_str(blk_status_t status) 64{ 65 if (status == BLK_STS_REMOVED) 66 return "device removed"; 67 return blk_status_to_str(status); 68} | 64} 65 66const char *bch2_blk_status_to_str(blk_status_t status) 67{ 68 if (status == BLK_STS_REMOVED) 69 return "device removed"; 70 return blk_status_to_str(status); 71} |