bcachefs: Replace ERANGE with private error codes
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 3 Nov 2023 15:40:32 +0000 (11:40 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 5 Nov 2023 18:12:18 +0000 (13:12 -0500)
We avoid using standard error codes: private, per-callsite error codes
make debugging easier.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/errcode.h
fs/bcachefs/opts.c

index 2a11f32cf30a24050f6237ddaf506f9bb87f31de..68a1a96bb7caf526a148a988c12913151c57b6d5 100644 (file)
@@ -3,6 +3,8 @@
 #define _BCACHEFS_ERRCODE_H
 
 #define BCH_ERRCODES()                                                         \
+       x(ERANGE,                       ERANGE_option_too_small)                \
+       x(ERANGE,                       ERANGE_option_too_big)                  \
        x(ENOMEM,                       ENOMEM_stripe_buf)                      \
        x(ENOMEM,                       ENOMEM_replicas_table)                  \
        x(ENOMEM,                       ENOMEM_cpu_replicas)                    \
index 4ad5880664b0fbf8105ae4b175ede930cae43e14..8dd4046cca41ef23b061f4aeac1892f82a504d65 100644 (file)
@@ -265,14 +265,14 @@ int bch2_opt_validate(const struct bch_option *opt, u64 v, struct printbuf *err)
                if (err)
                        prt_printf(err, "%s: too small (min %llu)",
                               opt->attr.name, opt->min);
-               return -ERANGE;
+               return -BCH_ERR_ERANGE_option_too_small;
        }
 
        if (opt->max && v >= opt->max) {
                if (err)
                        prt_printf(err, "%s: too big (max %llu)",
                               opt->attr.name, opt->max);
-               return -ERANGE;
+               return -BCH_ERR_ERANGE_option_too_big;
        }
 
        if ((opt->flags & OPT_SB_FIELD_SECTORS) && (v & 511)) {