Skip to content

Commit

Permalink
Merge pull request ceph#49302 from petrutlucian94/adapter_resets
Browse files Browse the repository at this point in the history
rbd-wnbd: optionally handle wnbd adapter restart events

Reviewed-by: Ilya Dryomov <[email protected]>
  • Loading branch information
idryomov authored Mar 24, 2023
2 parents 5976b1f + 98a7aff commit 4431be4
Show file tree
Hide file tree
Showing 14 changed files with 613 additions and 74 deletions.
1 change: 1 addition & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ elseif(AIX)
list(APPEND common_srcs aix_errno.cc)
elseif(WIN32)
list(APPEND common_srcs win32/errno.cc)
list(APPEND common_srcs win32/wstring.cc)
endif()

if(WITH_EVENTTRACE)
Expand Down
8 changes: 4 additions & 4 deletions src/common/win32/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ void WINAPI ServiceBase::run()
s_service->set_status(SERVICE_START_PENDING);

// TODO: should we expect exceptions?
ldout(s_service->cct, 5) << "Starting service." << dendl;
ldout(s_service->cct, 0) << "Starting service." << dendl;
int err = s_service->run_hook();
if (err) {
lderr(s_service->cct) << "Failed to start service. Error code: "
<< err << dendl;
s_service->shutdown(true);
} else {
ldout(s_service->cct, 5) << "Successfully started service." << dendl;
ldout(s_service->cct, 0) << "Successfully started service." << dendl;
s_service->set_status(SERVICE_RUNNING);
}
}
Expand All @@ -98,7 +98,7 @@ void ServiceBase::shutdown(bool ignore_errors)
set_status(original_state);
}
} else {
dout(5) << "Shutdown hook completed." << dendl;
dout(0) << "Shutdown hook completed." << dendl;
set_status(SERVICE_STOPPED);
}
}
Expand All @@ -113,7 +113,7 @@ void ServiceBase::stop()
derr << "Service stop hook failed. Error code: " << err << dendl;
set_status(original_state);
} else {
dout(5) << "Successfully stopped service." << dendl;
dout(0) << "Successfully stopped service." << dendl;
set_status(SERVICE_STOPPED);
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/common/win32/wstring.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2022 Cloudbase Solutions
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/

#include "wstring.h"

#include <boost/locale/encoding_utf.hpp>

using boost::locale::conv::utf_to_utf;

std::wstring to_wstring(const std::string& str)
{
return utf_to_utf<wchar_t>(str.c_str(), str.c_str() + str.size());
}

std::string to_string(const std::wstring& str)
{
return utf_to_utf<char>(str.c_str(), str.c_str() + str.size());
}
18 changes: 18 additions & 0 deletions src/common/win32/wstring.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2022 Cloudbase Solutions
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/

#pragma once

#include <string>

std::wstring to_wstring(const std::string& str);
std::string to_string(const std::wstring& wstr);
1 change: 1 addition & 0 deletions src/dokan/ceph_dokan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "common/dout.h"
#include "common/errno.h"
#include "common/version.h"
#include "common/win32/wstring.h"

#include "global/global_init.h"

Expand Down
1 change: 1 addition & 0 deletions src/dokan/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "common/ceph_argparse.h"
#include "common/config.h"
#include "common/win32/wstring.h"

#include "global/global_init.h"

Expand Down
14 changes: 0 additions & 14 deletions src/dokan/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@

#include "utils.h"

#include <boost/locale/encoding_utf.hpp>

using boost::locale::conv::utf_to_utf;

std::wstring to_wstring(const std::string& str)
{
return utf_to_utf<wchar_t>(str.c_str(), str.c_str() + str.size());
}

std::string to_string(const std::wstring& str)
{
return utf_to_utf<char>(str.c_str(), str.c_str() + str.size());
}

void to_filetime(time_t t, LPFILETIME pft)
{
// Note that LONGLONG is a 64-bit value
Expand Down
5 changes: 2 additions & 3 deletions src/dokan/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
*
*/

#include "include/compat.h"
#pragma once

std::wstring to_wstring(const std::string& str);
std::string to_string(const std::wstring& str);
#include "include/compat.h"

void to_filetime(time_t t, LPFILETIME pft);
void to_unix_time(FILETIME ft, time_t *t);
2 changes: 2 additions & 0 deletions src/include/win32/fs_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Those definitions allow handling information coming from Ceph and should
// not be passed to Windows functions.

#pragma once

#define S_IFLNK 0120000

#define S_ISTYPE(m, TYPE) ((m & S_IFMT) == TYPE)
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rbd_wnbd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
add_executable(rbd-wnbd wnbd_handler.cc rbd_wnbd.cc)
add_executable(rbd-wnbd rbd_wnbd.cc wnbd_handler.cc wnbd_wmi.cc)
set_target_properties(
rbd-wnbd PROPERTIES COMPILE_FLAGS
"-fpermissive -I${WNBD_INCLUDE_DIRS}")
target_link_libraries(
rbd-wnbd setupapi rpcrt4
wbemuuid oleaut32
${WNBD_LIBRARIES}
${Boost_FILESYSTEM_LIBRARY}
librbd librados global)
Expand Down
Loading

0 comments on commit 4431be4

Please sign in to comment.