]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/krbd.h
Import ceph 15.2.8
[ceph.git] / ceph / src / include / krbd.h
CommitLineData
7c673cae
FG
1/*
2 * Ceph - scalable distributed file system
3 *
4 * Copyright (C) 2014 Inktank Storage, Inc.
5 *
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software
9 * Foundation. See file COPYING.
10 *
11 */
12
13#ifndef CEPH_KRBD_H
14#define CEPH_KRBD_H
15
16#include "rados/librados.h"
17
f91f0fd5
TL
18/*
19 * Don't wait for udev add uevents in krbd_map() and udev remove
20 * uevents in krbd_unmap*(). Instead, make do with the respective
21 * kernel uevents and return as soon as they are received.
22 *
23 * systemd-udevd sends out udev uevents after it finishes processing
24 * the respective kernel uevents, which mostly boils down to executing
25 * all matching udev rules. With this flag set, on return from
26 * krbd_map() systemd-udevd may still be poking at the device: it
27 * may still be open with tools such as blkid and various ioctls to
28 * be run against it, none of the persistent symlinks to the device
29 * node may be there, etc. udev used to be responsible for creating
30 * the device node as well, but that has been handled by devtmpfs in
31 * the kernel for many years now, so the device node (as returned
32 * through @pdevnode) is guaranteed to be there.
33 *
34 * If set, krbd_map() and krbd_unmap*() can be invoked from any
35 * network namespace that is owned by the initial user namespace
36 * (which is a formality because things like loading kernel modules
37 * and creating block devices are not namespaced and require global
38 * privileges, i.e. capabilities in the initial user namespace).
39 * Otherwise, krbd_map() and krbd_unmap*() must be invoked from
40 * the initial network namespace.
41 *
42 * If set, krbd_unmap*() doesn't attempt to settle the udev queue
43 * before retrying unmap for the last time. Some EBUSY errors due
44 * to systemd-udevd poking at the device at the time krbd_unmap*()
45 * is invoked that are otherwise covered by the retry logic may be
46 * returned.
47 */
48#define KRBD_CTX_F_NOUDEV (1U << 0)
49
7c673cae
FG
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54struct krbd_ctx;
55
f91f0fd5
TL
56int krbd_create_from_context(rados_config_t cct, uint32_t flags,
57 struct krbd_ctx **pctx);
7c673cae
FG
58void krbd_destroy(struct krbd_ctx *ctx);
59
11fdf7f2
TL
60int krbd_map(struct krbd_ctx *ctx,
61 const char *pool_name,
62 const char *nspace_name,
63 const char *image_name,
64 const char *snap_name,
65 const char *options,
66 char **pdevnode);
67int krbd_is_mapped(struct krbd_ctx *ctx,
68 const char *pool_name,
69 const char *nspace_name,
70 const char *image_name,
71 const char *snap_name,
72 char **pdevnode);
7c673cae
FG
73
74int krbd_unmap(struct krbd_ctx *ctx, const char *devnode,
75 const char *options);
11fdf7f2
TL
76int krbd_unmap_by_spec(struct krbd_ctx *ctx,
77 const char *pool_name,
78 const char *nspace_name,
79 const char *image_name,
80 const char *snap_name,
7c673cae
FG
81 const char *options);
82
83#ifdef __cplusplus
84}
85#endif
86
87#ifdef __cplusplus
88
89namespace ceph {
90 class Formatter;
91}
92
93int krbd_showmapped(struct krbd_ctx *ctx, ceph::Formatter *f);
94
95#endif /* __cplusplus */
96
97#endif /* CEPH_KRBD_H */