]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/lib/blobfs/mkfs/mkfs.c
4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 #include "spdk/blobfs.h"
43 #include "spdk/bdev.h"
44 #include "spdk/event.h"
45 #include "spdk/blob_bdev.h"
48 struct spdk_bs_dev
*g_bs_dev
;
49 const char *g_bdev_name
;
52 stop_cb(void *ctx
, int fserrno
)
58 shutdown_cb(void *arg1
, void *arg2
)
60 struct spdk_filesystem
*fs
= arg1
;
63 spdk_fs_unload(fs
, stop_cb
, NULL
);
67 init_cb(void *ctx
, struct spdk_filesystem
*fs
, int fserrno
)
69 struct spdk_event
*event
;
71 event
= spdk_event_allocate(0, shutdown_cb
, fs
, NULL
);
72 spdk_event_call(event
);
76 spdk_mkfs_run(void *arg1
, void *arg2
)
78 struct spdk_bdev
*bdev
;
80 bdev
= spdk_bdev_get_by_name(g_bdev_name
);
83 SPDK_ERRLOG("bdev %s not found\n", g_bdev_name
);
88 if (!spdk_bdev_claim(bdev
, NULL
, NULL
)) {
89 SPDK_ERRLOG("could not claim bdev %s\n", g_bdev_name
);
94 printf("Initializing filesystem on bdev %s...", g_bdev_name
);
96 g_bs_dev
= spdk_bdev_create_bs_dev(bdev
);
97 spdk_fs_init(g_bs_dev
, NULL
, init_cb
, NULL
);
100 int main(int argc
, char **argv
)
102 struct spdk_app_opts opts
= {};
105 SPDK_ERRLOG("usage: %s <conffile> <bdevname>\n", argv
[0]);
109 spdk_app_opts_init(&opts
);
110 opts
.name
= "spdk_mkfs";
111 opts
.config_file
= argv
[1];
112 opts
.reactor_mask
= "0x3";
113 opts
.dpdk_mem_size
= 1024;
114 opts
.shutdown_cb
= NULL
;
115 spdk_app_init(&opts
);
117 spdk_fs_set_cache_size(512);
119 g_bdev_name
= argv
[2];
120 spdk_app_start(spdk_mkfs_run
, NULL
, NULL
);