MEDIUM: ring: remove the struct buffer from the ring
authorWilly Tarreau <w@1wt.eu>
Tue, 27 Feb 2024 08:17:45 +0000 (09:17 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Mar 2024 17:34:19 +0000 (17:34 +0000)
commitbf3dead20cdb36ad11230585d61da47c519af3f8
treec79bddd685c76fea7f0bd726fc0bf0777dfbf1fb
parent01aa0a057c1553590891078854ddbbccf0eeffe3
MEDIUM: ring: remove the struct buffer from the ring

The purpose is to store a head and a tail that are independent so that
we can further improve the API to update them independently from each
other.

The struct was arranged like the original one so that as long as a ring
has its head set to zero (i.e. no recycling) it will continue to work.
The new format is already detectable thanks to the "rsvd" field which
indicates the number of reserved bytes at the beginning. It's located
where the buffer's area pointer previously was, so that older versions
of haring can continue to open the ring in repair mode, and newer ones
can use the fact that the upper bits of that variable are zero to guess
that it's working with the new format instead of the old one. Also let's
keep in mind that the layout will further change to place some alignment
constraints.

The haring tool will thus updated based on this and it detects that the
rsvd field is smaller than a page and that the sum of it with the size
equals the mapped size, in which case it uses the new dump_v2() function
instead of dump_v1(). The new function also creates a buffer from the
ring's area, size, head and tail and calls the generic one so that no
other code had to be adapted.
dev/haring/haring.c
include/haproxy/ring-t.h
include/haproxy/ring.h
src/ring.c
src/sink.c