Skip to content

Commit 1caadd7

Browse files
authored
Merge pull request ceph#50341 from yangdongsheng/ubbd
rbd: add support for new device type of ubbd Reviewed-by: Mykola Golub <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]>
2 parents 5e58d00 + 54853a5 commit 1caadd7

File tree

8 files changed

+319
-8
lines changed

8 files changed

+319
-8
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,14 @@ CMAKE_DEPENDENT_OPTION(WITH_RBD_SSD_CACHE "Enable librbd persistent write back c
270270
CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_PMDK "Require and build with system PMDK" OFF
271271
"WITH_RBD_RWL OR WITH_BLUESTORE_PMEM" OFF)
272272

273+
CMAKE_DEPENDENT_OPTION(WITH_RBD_UBBD "Enable ubbd support for rbd device utility" OFF
274+
"WITH_RBD" OFF)
275+
276+
if(WITH_RBD_UBBD)
277+
include(BuildUBBD)
278+
build_ubbd()
279+
endif()
280+
273281
if(WITH_BLUESTORE_PMEM)
274282
set(HAVE_BLUESTORE_PMEM ON)
275283
endif()

cmake/modules/BuildUBBD.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function(build_ubbd)
2+
include(FindMake)
3+
find_make("MAKE_EXECUTABLE" "make_cmd")
4+
5+
include(ExternalProject)
6+
ExternalProject_Add(ubbd_ext
7+
UPDATE_COMMAND "" # this disables rebuild on each run
8+
GIT_REPOSITORY "https://github.com/DataTravelGuide/ubbd.git"
9+
GIT_CONFIG advice.detachedHead=false
10+
GIT_SHALLOW 1
11+
GIT_TAG "v0.1.4"
12+
SOURCE_DIR "${CMAKE_BINARY_DIR}/src/ubbd"
13+
BUILD_IN_SOURCE 1
14+
CONFIGURE_COMMAND ""
15+
BUILD_COMMAND ${make_cmd} libubbd
16+
INSTALL_COMMAND ""
17+
LOG_CONFIGURE ON
18+
LOG_BUILD ON
19+
LOG_INSTALL ON
20+
LOG_MERGED_STDOUTERR ON
21+
LOG_OUTPUT_ON_FAILURE ON)
22+
endfunction()

doc/man/8/rbd.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Commands
260260

261261
:command:`device map` [-t | --device-type *device-type*] [--cookie *device-cookie*] [--show-cookie] [--snap-id *snap-id*] [--read-only] [--exclusive] [-o | --options *device-options*] *image-spec* | *snap-spec*
262262
Map the specified image to a block device via the rbd kernel module
263-
(default) or other supported device (*nbd* on Linux or *ggate* on
263+
(default) or other supported device (*nbd* or *ubbd* on Linux or *ggate* on
264264
FreeBSD).
265265

266266
The --options argument is a comma separated list of device type

src/include/config-h.in.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@
148148
/* define if kernel rbd enabled */
149149
#cmakedefine WITH_KRBD
150150

151+
/* define if rbd ubbd enabled */
152+
#cmakedefine WITH_RBD_UBBD
153+
151154
/* define if key-value-store is enabled */
152155
#cmakedefine WITH_KVS
153156

src/test/cli/rbd/help.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@
594594
])
595595

596596
Optional arguments
597-
-t [ --device-type ] arg device type [ggate, krbd (default), nbd]
597+
-t [ --device-type ] arg device type [ggate, krbd (default), nbd, ubbd]
598598
-p [ --pool ] arg pool name
599599
--namespace arg namespace name
600600
--image arg image name
@@ -625,7 +625,7 @@
625625
p-name>] or <device-path>
626626

627627
Optional arguments
628-
-t [ --device-type ] arg device type [ggate, krbd (default), nbd]
628+
-t [ --device-type ] arg device type [ggate, krbd (default), nbd, ubbd]
629629
-p [ --pool ] arg pool name
630630
--namespace arg namespace name
631631
--image arg image name
@@ -640,7 +640,7 @@
640640
List mapped rbd images.
641641
642642
Optional arguments
643-
-t [ --device-type ] arg device type [ggate, krbd (default), nbd]
643+
-t [ --device-type ] arg device type [ggate, krbd (default), nbd, ubbd]
644644
--format arg output format (plain, json, or xml) [default: plain]
645645
--pretty-format pretty formatting (json and xml)
646646
@@ -662,7 +662,7 @@
662662
])
663663

664664
Optional arguments
665-
-t [ --device-type ] arg device type [ggate, krbd (default), nbd]
665+
-t [ --device-type ] arg device type [ggate, krbd (default), nbd, ubbd]
666666
-p [ --pool ] arg pool name
667667
--namespace arg namespace name
668668
--image arg image name
@@ -691,7 +691,7 @@
691691
p-name>] or <device-path>
692692

693693
Optional arguments
694-
-t [ --device-type ] arg device type [ggate, krbd (default), nbd]
694+
-t [ --device-type ] arg device type [ggate, krbd (default), nbd, ubbd]
695695
-p [ --pool ] arg pool name
696696
--namespace arg namespace name
697697
--image arg image name

src/tools/rbd/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ set(rbd_srcs
5252
action/Status.cc
5353
action/TrashPurgeSchedule.cc
5454
action/Trash.cc
55+
action/Ubbd.cc
5556
action/Watch.cc
5657
action/Wnbd.cc)
5758

@@ -73,8 +74,19 @@ if(CURSES_FOUND)
7374
target_link_libraries(rbd ${CURSES_LIBRARIES})
7475
endif()
7576
if(WITH_KRBD)
76-
target_link_libraries(rbd
77+
target_link_libraries(rbd
7778
krbd)
7879
endif()
80+
if(WITH_RBD_UBBD)
81+
target_link_directories(rbd
82+
PRIVATE ${CMAKE_BINARY_DIR}/src/ubbd/lib/)
83+
target_include_directories(rbd
84+
PRIVATE ${CMAKE_BINARY_DIR}/src/ubbd/include)
85+
target_include_directories(rbd
86+
PRIVATE ${CMAKE_BINARY_DIR}/src/ubbd/include/ubbd-headers/)
87+
target_link_libraries(rbd
88+
ubbd)
89+
add_dependencies(rbd ubbd_ext)
90+
endif()
7991

8092
install(TARGETS rbd DESTINATION bin)

src/tools/rbd/action/Device.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ DECLARE_DEVICE_OPERATIONS(ggate);
3333
DECLARE_DEVICE_OPERATIONS(kernel);
3434
DECLARE_DEVICE_OPERATIONS(nbd);
3535
DECLARE_DEVICE_OPERATIONS(wnbd);
36+
DECLARE_DEVICE_OPERATIONS(ubbd);
3637

3738
namespace device {
3839

@@ -83,11 +84,20 @@ const DeviceOperations wnbd_operations = {
8384
wnbd::execute_detach,
8485
};
8586

87+
const DeviceOperations ubbd_operations = {
88+
ubbd::execute_list,
89+
ubbd::execute_map,
90+
ubbd::execute_unmap,
91+
ubbd::execute_attach,
92+
ubbd::execute_detach,
93+
};
94+
8695
enum device_type_t {
8796
DEVICE_TYPE_GGATE,
8897
DEVICE_TYPE_KRBD,
8998
DEVICE_TYPE_NBD,
9099
DEVICE_TYPE_WNBD,
100+
DEVICE_TYPE_UBBD,
91101
};
92102

93103
struct DeviceType {};
@@ -107,6 +117,8 @@ void validate(boost::any& v, const std::vector<std::string>& values,
107117
v = boost::any(DEVICE_TYPE_GGATE);
108118
} else if (s == "krbd") {
109119
v = boost::any(DEVICE_TYPE_KRBD);
120+
} else if (s == "ubbd") {
121+
v = boost::any(DEVICE_TYPE_UBBD);
110122
#endif /* _WIN32 */
111123
} else {
112124
throw po::validation_error(po::validation_error::invalid_option_value);
@@ -119,7 +131,7 @@ void add_device_type_option(po::options_description *options) {
119131
#ifdef _WIN32
120132
"device type [wnbd]");
121133
#else
122-
"device type [ggate, krbd (default), nbd]");
134+
"device type [ggate, krbd (default), nbd, ubbd]");
123135
#endif
124136
}
125137

@@ -150,6 +162,8 @@ const DeviceOperations *get_device_operations(const po::variables_map &vm) {
150162
return &nbd_operations;
151163
case DEVICE_TYPE_WNBD:
152164
return &wnbd_operations;
165+
case DEVICE_TYPE_UBBD:
166+
return &ubbd_operations;
153167
default:
154168
ceph_abort();
155169
return nullptr;

0 commit comments

Comments
 (0)