Re: [PATCH 1/4] cconv: Support pattern buffers of arbitrary size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/26/22 15:40, Logan Gunthorpe wrote:
From: Logan Gunthorpe <logan.gunthorpe@xxxxxxxxxxxxx>

Change the thread_options_pack structure to support pattern buffers
of arbitrary size by using a flexible array at the end of the the
structure to store both the verify_pattern and the buffer_pattern
in that order.

In this way, only the actual bytes of each pattern will be sent over
the wire and patterns of an arbitrary size can be used with the packed
structure.

In order to determine the required size of the structure the function
thread_options_pack_size() is introduced which returns the total
number of bytes required for a given thread_options instance.

The two callsites of convert_thread_options_to_net() are then converted
to dynamically allocate a pdu of the appropriate size and the
two callsites of convert_thread_options_to_cpu() are modified to
take the size of the received data to prevent buffer overruns.

Also add specific testing of this feature in fio_test_cconv().

Seeing this changes the client/server protocol, the FIO_SERVER_VER
is bumped.

Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
---

<snip>

diff --git a/thread_options.h b/thread_options.h
index 634070af00ec..8a1340f23e97 100644
--- a/thread_options.h
+++ b/thread_options.h
@@ -464,7 +464,6 @@ struct thread_options_pack {
  	uint32_t do_verify;
  	uint32_t verify_interval;
  	uint32_t verify_offset;
-	uint8_t verify_pattern[MAX_PATTERN_SIZE];
  	uint32_t verify_pattern_bytes;
  	uint32_t verify_fatal;
  	uint32_t verify_dump;
@@ -572,7 +571,6 @@ struct thread_options_pack {
  	uint32_t zero_buffers;
  	uint32_t refill_buffers;
  	uint32_t scramble_buffers;
-	uint8_t buffer_pattern[MAX_PATTERN_SIZE];
  	uint32_t buffer_pattern_bytes;
  	uint32_t compress_percentage;
  	uint32_t compress_chunk;
@@ -699,9 +697,13 @@ struct thread_options_pack {
uint32_t log_entries;
  	uint32_t log_prio;
+
+	uint8_t patterns[];

Since there is typically a 1:1 correspondence between the members of this struct and the unpacked version, I would add a comment here noting that patterns[] includes the contents of verify_pattern and buffer_pattern from the unpacked struct.




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux