]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-wnbd: fix llvm issues
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Tue, 11 Apr 2023 08:54:23 +0000 (08:54 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 17 Aug 2023 13:31:51 +0000 (13:31 +0000)
We're fixing a few rbd-wnbd issues that are currently ignored
by mingw-gcc but not by llvm:

* checking if an uint is smaller than 0
* qualified method names must be used when passing the address
* duplicate symbol "shutdown_lock"
* add missing const cast when passing WNBD interface

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/tools/rbd_wnbd/rbd_wnbd.cc
src/tools/rbd_wnbd/rbd_wnbd.h
src/tools/rbd_wnbd/wnbd_handler.cc

index e7d5ecea0665e3c2d0f537c712dc36be217ae462..e22c43a23df64058c17f1514d52f906dddefc0d5 100644 (file)
@@ -72,6 +72,9 @@ using namespace std;
 // Wait for wmi events up to two seconds
 #define WMI_EVENT_TIMEOUT 2
 
+static WnbdHandler* handler = nullptr;
+static ceph::mutex shutdown_lock = ceph::make_mutex("RbdWnbd::ShutdownLock");
+
 bool is_process_running(DWORD pid)
 {
   HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
@@ -749,8 +752,8 @@ class RBDService : public ServiceBase {
 
     std::thread adapter_monitor_thread;
 
-    ceph::mutex start_lock = ceph::make_mutex("RBDService::StartLocker");
-    ceph::mutex shutdown_lock = ceph::make_mutex("RBDService::ShutdownLocker");
+    ceph::mutex start_hook_lock = ceph::make_mutex("RBDService::StartLocker");
+    ceph::mutex stop_hook_lock = ceph::make_mutex("RBDService::ShutdownLocker");
     bool started = false;
     std::atomic<bool> stop_requsted = false;
 
@@ -976,7 +979,7 @@ exit:
     }
 
     int run_hook() override {
-      std::unique_lock l{start_lock};
+      std::unique_lock l{start_hook_lock};
       if (started) {
         // The run hook is only supposed to be called once per process,
         // however we're staying cautious.
@@ -998,7 +1001,8 @@ exit:
       }
 
       if (adapter_monitoring_enabled) {
-        adapter_monitor_thread = std::thread(&monitor_wnbd_adapter, this);
+        adapter_monitor_thread = std::thread(
+          &RBDService::monitor_wnbd_adapter, this);
       } else {
         dout(0) << "WNBD adapter monitoring disabled." << dendl;
       }
@@ -1008,7 +1012,7 @@ exit:
 
     // Invoked when the service is requested to stop.
     int stop_hook() override {
-      std::unique_lock l{shutdown_lock};
+      std::unique_lock l{stop_hook_lock};
 
       stop_requsted = true;
 
@@ -1636,10 +1640,6 @@ static int parse_args(std::vector<const char*>& args,
         *err_msg << "rbd-wnbd: " << err.str();
         return -EINVAL;
       }
-      if (cfg->wnbd_log_level < 0) {
-        *err_msg << "rbd-wnbd: Invalid argument for wnbd-log-level";
-        return -EINVAL;
-      }
     } else if (ceph_argparse_witharg(args, i, (int*)&cfg->io_req_workers,
                                      err, "--io-req-workers", (char *)NULL)) {
       if (!err.str().empty()) {
index ac298e3180f1dd7474ab53fa126b76f9389eeb4a..049644f12a948ea433e2cd153af6a8ef716561a8 100644 (file)
@@ -42,9 +42,6 @@
 
 #define DEFAULT_SERVICE_THREAD_COUNT 8
 
-static WnbdHandler* handler = nullptr;
-ceph::mutex shutdown_lock = ceph::make_mutex("RbdWnbd::ShutdownLock");
-
 struct Config {
   bool exclusive = false;
   bool readonly = false;
index f6a489836f8c75ed08672c12b9b5b977c00b779a..ba53b872697c07d09283e83c2758c491f4c70882 100644 (file)
@@ -29,8 +29,6 @@
 
 #include "global/global_context.h"
 
-#include "rbd_wnbd.h"
-
 WnbdHandler::~WnbdHandler()
 {
   if (started && wnbd_disk) {
@@ -411,7 +409,8 @@ int WnbdHandler::start()
     wnbd_props.Flags.FlushSupported = 1;
   }
 
-  err = WnbdCreate(&wnbd_props, &RbdWnbdInterface, this, &wnbd_disk);
+  err = WnbdCreate(&wnbd_props, (const PWNBD_INTERFACE) &RbdWnbdInterface,
+                   this, &wnbd_disk);
   if (err)
     goto exit;