mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
![Jeff Layton](/assets/img/avatar_default.png)
An errseq_t is a way of recording errors in one place, and allowing any number of "subscribers" to tell whether an error has been set again since a previous time. It's implemented as an unsigned 32-bit value that is managed with atomic operations. The low order bits are designated to hold an error code (max size of MAX_ERRNO). The upper bits are used as a counter. The API works with consumers sampling an errseq_t value at a particular point in time. Later, that value can be used to tell whether new errors have been set since that time. Note that there is a 1 in 512k risk of collisions here if new errors are being recorded frequently, since we have so few bits to use as a counter. To mitigate this, one bit is used as a flag to tell whether the value has been sampled since a new value was recorded. That allows us to avoid bumping the counter if no one has sampled it since it was last bumped. Later patches will build on this infrastructure to change how writeback errors are tracked in the kernel. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: NeilBrown <neilb@suse.com> Reviewed-by: Jan Kara <jack@suse.cz>
19 lines
473 B
C
19 lines
473 B
C
#ifndef _LINUX_ERRSEQ_H
|
|
#define _LINUX_ERRSEQ_H
|
|
|
|
/* See lib/errseq.c for more info */
|
|
|
|
typedef u32 errseq_t;
|
|
|
|
errseq_t __errseq_set(errseq_t *eseq, int err);
|
|
static inline void errseq_set(errseq_t *eseq, int err)
|
|
{
|
|
/* Optimize for the common case of no error */
|
|
if (unlikely(err))
|
|
__errseq_set(eseq, err);
|
|
}
|
|
|
|
errseq_t errseq_sample(errseq_t *eseq);
|
|
int errseq_check(errseq_t *eseq, errseq_t since);
|
|
int errseq_check_and_advance(errseq_t *eseq, errseq_t *since);
|
|
#endif
|