File: sprandom.h

package info (click to toggle)
fio 3.41-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,012 kB
  • sloc: ansic: 82,290; python: 9,862; sh: 6,067; makefile: 813; yacc: 204; lex: 184
file content (77 lines) | stat: -rw-r--r-- 2,350 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
 * SPDX-License-Identifier: GPL-2.0 only
 *
 * Copyright (c) 2025 Sandisk Corporation or its affiliates.
 */

#ifndef FIO_SPRANDOM_H
#define FIO_SPRANDOM_H

#include <stdint.h>
#include "lib/rand.h"
#include "pcbuf.h"

/**
 * struct sprandom_info - information for sprandom operations.
 *
 * @over_provisioning:  Over-provisioning ratio for the flash device.
 * @region_sz:          Size of each region in bytes.
 * @num_regions:        Number of SPRandom regions.
 * @validity_dist:      validity for each region.
 * @invalid_pct:        invalidation percentages per region.
 * @invalid_buf:        invalidation offsets two pahse buffer.
 * @invalid_capacity:   maximal size of invalidation buffer for a region.
 * @invalid_count:      number of invalid offsets in each phase.
 * @current_region:     index of the current region being processed.
 * @curr_phase:         current phase of the invalidation process (0 or 1).
 * @region_write_count: number of writes performed in the current region.
 * @writes_remaining:   umber of writes left to perform.
 * @rand_state:         state for the random number generator.
 */
struct sprandom_info {
	double    over_provisioning;
	uint64_t  region_sz;
	uint32_t  num_regions;

	uint32_t  *invalid_pct;

	/* Invalidation list*/
	struct pc_buf *invalid_buf;
	uint64_t invalid_capacity;
	size_t   invalid_count[2];
	uint32_t current_region;
	uint32_t curr_phase;

	/* Region and write tracking */
	uint64_t region_write_count;
	uint64_t writes_remaining;

	struct frand_state *rand_state;
};

/**
 * sprandom_init - Initialize the sprandom for a given file and thread.
 * @td: FIO thread data
 * @f: FIO file
 *
 * Returns 0 on success, or a negative error code on failure.
 */
int sprandom_init(struct thread_data *td, struct fio_file *f);

/**
 * sprandom_free - Frees resources associated with a sprandom_info structure.
 * @info: sprandom_info structure to be freed.
 */
void sprandom_free(struct sprandom_info *info);

/**
 * sprandom_get_next_offset - Get the next random offset for a file.
 * @info: sprandom_info structure containing the state
 * @f: FIO file
 * @b: Output pointer to store the next offset.
 *
 * Returns 0 on success, or a negative error code on failure.
 */
int sprandom_get_next_offset(struct sprandom_info *info, struct fio_file *f, uint64_t *b);

#endif /* FIO_SPRANDOM_H */