summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-vdo/indexer/io-factory.h
blob: 7fb5a0616a791ca877bd36eecd90c4a323c627f3 (plain)
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
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright 2023 Red Hat
 */

#ifndef UDS_IO_FACTORY_H
#define UDS_IO_FACTORY_H

#include <linux/dm-bufio.h>

/*
 * The I/O factory manages all low-level I/O operations to the underlying storage device. Its main
 * clients are the index layout and the volume. The buffered reader and buffered writer interfaces
 * are helpers for accessing data in a contiguous range of storage blocks.
 */

struct buffered_reader;
struct buffered_writer;

struct io_factory;

enum {
	UDS_BLOCK_SIZE = 4096,
	SECTORS_PER_BLOCK = UDS_BLOCK_SIZE >> SECTOR_SHIFT,
};

int __must_check uds_make_io_factory(struct block_device *bdev,
				     struct io_factory **factory_ptr);

int __must_check uds_replace_storage(struct io_factory *factory,
				     struct block_device *bdev);

void uds_put_io_factory(struct io_factory *factory);

size_t __must_check uds_get_writable_size(struct io_factory *factory);

int __must_check uds_make_bufio(struct io_factory *factory, off_t block_offset,
				size_t block_size, unsigned int reserved_buffers,
				struct dm_bufio_client **client_ptr);

int __must_check uds_make_buffered_reader(struct io_factory *factory, off_t offset,
					  u64 block_count,
					  struct buffered_reader **reader_ptr);

void uds_free_buffered_reader(struct buffered_reader *reader);

int __must_check uds_read_from_buffered_reader(struct buffered_reader *reader, u8 *data,
					       size_t length);

int __must_check uds_verify_buffered_data(struct buffered_reader *reader, const u8 *value,
					  size_t length);

int __must_check uds_make_buffered_writer(struct io_factory *factory, off_t offset,
					  u64 block_count,
					  struct buffered_writer **writer_ptr);

void uds_free_buffered_writer(struct buffered_writer *buffer);

int __must_check uds_write_to_buffered_writer(struct buffered_writer *writer,
					      const u8 *data, size_t length);

int __must_check uds_flush_buffered_writer(struct buffered_writer *writer);

#endif /* UDS_IO_FACTORY_H */