ring-buffer: Fix writing to the buffer with max_data_size