xref: /spdk/include/spdk/blobfs_bdev.h (revision 86ba16c39c091790f79e99a033db86b6fd502606)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (C) 2019 Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 /** \file
7  * Operations on blobfs whose backing device is spdk_bdev
8  */
9 
10 #ifndef SPDK_BLOBFS_BDEV_H
11 #define SPDK_BLOBFS_BDEV_H
12 
13 #include "spdk/stdinc.h"
14 #include "spdk/bdev.h"
15 #include "spdk/config.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /**
22  * blobfs on bdev operation completion callback.
23  *
24  * \param cb_arg Callback argument.
25  * \param fserrno 0 if it completed successfully, or negative errno if it failed.
26  */
27 typedef void (*spdk_blobfs_bdev_op_complete)(void *cb_arg, int fserrno);
28 
29 /**
30  * Detect whether blobfs exists on the given device.
31  *
32  * \param bdev_name Name of block device.
33  * \param cb_fn Called when the detecting is complete. fserrno is -EILSEQ if no blobfs exists.
34  * \param cb_arg Argument passed to function cb_fn.
35  */
36 void spdk_blobfs_bdev_detect(const char *bdev_name,
37 			     spdk_blobfs_bdev_op_complete cb_fn, void *cb_arg);
38 
39 /**
40  * Create a blobfs on the given device.
41  *
42  * \param bdev_name Name of block device.
43  * \param cluster_sz Size of cluster in bytes. Must be multiple of 4KiB page size.
44  * \param cb_fn Called when the creation is complete.
45  * \param cb_arg Argument passed to function cb_fn.
46  */
47 void spdk_blobfs_bdev_create(const char *bdev_name, uint32_t cluster_sz,
48 			     spdk_blobfs_bdev_op_complete cb_fn, void *cb_arg);
49 
50 /**
51  * Mount a blobfs on given device to a host path by FUSE
52  *
53  * A new thread is created dedicatedly for one mountpoint to handle FUSE request
54  * by blobfs API.
55  *
56  * \param bdev_name Name of block device.
57  * \param mountpoint Host path to mount blobfs.
58  * \param cb_fn Called when mount operation is complete. fserrno is -EILSEQ if no blobfs exists.
59  * \param cb_arg Argument passed to function cb_fn.
60  */
61 void spdk_blobfs_bdev_mount(const char *bdev_name, const char *mountpoint,
62 			    spdk_blobfs_bdev_op_complete cb_fn, void *cb_arg);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif /* SPDK_BLOBFS_BDEV_H */
69