1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
6 #ifndef UDS_IO_FACTORY_H
7 #define UDS_IO_FACTORY_H
9 #include <linux/dm-bufio.h>
12 * The I/O factory manages all low-level I/O operations to the underlying storage device. Its main
13 * clients are the index layout and the volume. The buffered reader and buffered writer interfaces
14 * are helpers for accessing data in a contiguous range of storage blocks.
17 struct buffered_reader
;
18 struct buffered_writer
;
23 UDS_BLOCK_SIZE
= 4096,
24 SECTORS_PER_BLOCK
= UDS_BLOCK_SIZE
>> SECTOR_SHIFT
,
27 int __must_check
uds_make_io_factory(struct block_device
*bdev
,
28 struct io_factory
**factory_ptr
);
30 int __must_check
uds_replace_storage(struct io_factory
*factory
,
31 struct block_device
*bdev
);
33 void uds_put_io_factory(struct io_factory
*factory
);
35 size_t __must_check
uds_get_writable_size(struct io_factory
*factory
);
37 int __must_check
uds_make_bufio(struct io_factory
*factory
, off_t block_offset
,
38 size_t block_size
, unsigned int reserved_buffers
,
39 struct dm_bufio_client
**client_ptr
);
41 int __must_check
uds_make_buffered_reader(struct io_factory
*factory
, off_t offset
,
43 struct buffered_reader
**reader_ptr
);
45 void uds_free_buffered_reader(struct buffered_reader
*reader
);
47 int __must_check
uds_read_from_buffered_reader(struct buffered_reader
*reader
, u8
*data
,
50 int __must_check
uds_verify_buffered_data(struct buffered_reader
*reader
, const u8
*value
,
53 int __must_check
uds_make_buffered_writer(struct io_factory
*factory
, off_t offset
,
55 struct buffered_writer
**writer_ptr
);
57 void uds_free_buffered_writer(struct buffered_writer
*buffer
);
59 int __must_check
uds_write_to_buffered_writer(struct buffered_writer
*writer
,
60 const u8
*data
, size_t length
);
62 int __must_check
uds_flush_buffered_writer(struct buffered_writer
*writer
);
64 #endif /* UDS_IO_FACTORY_H */