diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-18 15:43:50 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:40 -0400 |
commit | 5c1ef830f6786059f85bebe7501b63dffed0b633 (patch) | |
tree | 3a6f94498dd5f0d4f9d416db36d97ed01cf31373 /fs/bcachefs/errcode.c | |
parent | 57ce827442c4e7b0f38b14b91c97413c5d779697 (diff) | |
download | linux-5c1ef830f6786059f85bebe7501b63dffed0b633.tar.gz linux-5c1ef830f6786059f85bebe7501b63dffed0b633.tar.bz2 linux-5c1ef830f6786059f85bebe7501b63dffed0b633.zip |
bcachefs: Errcodes can now subtype standard error codes
The next patch is going to be adding private error codes for all the
places we return -ENOSPC.
Additionally, this patch updates return paths at all module boundaries
to call bch2_err_class(), to return the standard error code.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/errcode.c')
-rw-r--r-- | fs/bcachefs/errcode.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/bcachefs/errcode.c b/fs/bcachefs/errcode.c index 9da8a5973af0..cc9ce0be356e 100644 --- a/fs/bcachefs/errcode.c +++ b/fs/bcachefs/errcode.c @@ -15,7 +15,7 @@ static const char * const bch2_errcode_strs[] = { #define BCH_ERR_0 0 static unsigned bch2_errcode_parents[] = { -#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = BCH_ERR_##class, +#define x(class, err) [BCH_ERR_##err - BCH_ERR_START] = class, BCH_ERRCODES() #undef x }; @@ -49,3 +49,14 @@ bool __bch2_err_matches(int err, int class) return err == class; } + +int __bch2_err_class(int err) +{ + err = -err; + BUG_ON((unsigned) err >= BCH_ERR_MAX); + + while (err >= BCH_ERR_START && bch2_errcode_parents[err - BCH_ERR_START]) + err = bch2_errcode_parents[err - BCH_ERR_START]; + + return -err; +} |