brintos

brintos / linux-shallow public Read only

0
0
Text · 1.4 KiB · 2cccaa0 Raw
31 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3bcachefs private error codes4----------------------------5 6In bcachefs, as a hard rule we do not throw or directly use standard error7codes (-EINVAL, -EBUSY, etc.). Instead, we define private error codes as needed8in fs/bcachefs/errcode.h.9 10This gives us much better error messages and makes debugging much easier. Any11direct uses of standard error codes you see in the source code are simply old12code that has yet to be converted - feel free to clean it up!13 14Private error codes may subtype another error code, this allows for grouping of15related errors that should be handled similarly (e.g. transaction restart16errors), as well as specifying which standard error code should be returned at17the bcachefs module boundary.18 19At the module boundary, we use bch2_err_class() to convert to a standard error20code; this also emits a trace event so that the original error code be21recovered even if it wasn't logged.22 23Do not reuse error codes! Generally speaking, a private error code should only24be thrown in one place. That means that when we see it in a log message we can25see, unambiguously, exactly which file and line number it was returned from.26 27Try to give error codes names that are as reasonably descriptive of the error28as possible. Frequently, the error will be logged at a place far removed from29where the error was generated; good names for error codes mean much more30descriptive and useful error messages.31