xref: /spdk/lib/ftl/ftl_nv_cache_io.h (revision 83ba9086796471697a4975a58f60e2392bccd08c)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright 2023 Solidigm All Rights Reserved
3  *   Copyright (C) 2022 Intel Corporation.
4  *   All rights reserved.
5  */
6 
7 #ifndef FTL_NV_CACHE_IO_H
8 #define FTL_NV_CACHE_IO_H
9 
10 #include "spdk/bdev.h"
11 #include "ftl_core.h"
12 
13 static inline int
14 ftl_nv_cache_bdev_read_blocks_with_md(struct spdk_ftl_dev *dev,
15 				      struct spdk_bdev_desc *desc,
16 				      struct spdk_io_channel *ch,
17 				      void *buf, void *md,
18 				      uint64_t offset_blocks, uint64_t num_blocks,
19 				      spdk_bdev_io_completion_cb cb, void *cb_arg)
20 {
21 	if (spdk_bdev_get_md_size(spdk_bdev_desc_get_bdev(desc))) {
22 		return spdk_bdev_read_blocks_with_md(desc, ch, buf, md ? : g_ftl_read_buf,
23 						     offset_blocks, num_blocks, cb, cb_arg);
24 	} else {
25 		return spdk_bdev_read_blocks(desc, ch, buf, offset_blocks, num_blocks,
26 					     cb, cb_arg);
27 	}
28 }
29 
30 static inline int
31 ftl_nv_cache_bdev_write_blocks_with_md(struct spdk_ftl_dev *dev,
32 				       struct spdk_bdev_desc *desc,
33 				       struct spdk_io_channel *ch,
34 				       void *buf, void *md,
35 				       uint64_t offset_blocks, uint64_t num_blocks,
36 				       spdk_bdev_io_completion_cb cb, void *cb_arg)
37 {
38 	if (spdk_bdev_get_md_size(spdk_bdev_desc_get_bdev(desc))) {
39 		return spdk_bdev_write_blocks_with_md(desc, ch, buf, md ? : g_ftl_write_buf,
40 						      offset_blocks, num_blocks, cb, cb_arg);
41 	} else {
42 		return spdk_bdev_write_blocks(desc, ch, buf, offset_blocks, num_blocks,
43 					      cb, cb_arg);
44 	}
45 }
46 
47 #endif /* FTL_NV_CACHE_IO_H */
48