]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-dokan: Made max path length configurable
authorStefan Chivu <schivu@cloudbasesolutions.com>
Wed, 9 Nov 2022 13:50:17 +0000 (15:50 +0200)
committerStefan Chivu <schivu@cloudbasesolutions.com>
Mon, 21 Nov 2022 09:48:59 +0000 (11:48 +0200)
Added ceph-dokan CLI optarg for configuring the value of
the maximum path length. By default, it will be set to 256 and
it will have a maximum value of 32767.

Signed-off-by: Stefan Chivu <schivu@cloudbasesolutions.com>
src/dokan/ceph_dokan.cc
src/dokan/ceph_dokan.h
src/dokan/options.cc

index 8147b4542dbb09e962968bdc8fa0fcc7a49b7e43..4a4f78cdb66e83b9a2e935d5b0e243b2c6c96201 100644 (file)
@@ -789,7 +789,8 @@ static NTSTATUS WinCephGetVolumeInformation(
   g_cfg->win_vol_name.copy(VolumeNameBuffer, VolumeNameSize);
   *VolumeSerialNumber = g_cfg->win_vol_serial;
 
-  *MaximumComponentLength = 256;
+  *MaximumComponentLength = g_cfg->max_path_len;
+
   *FileSystemFlags = FILE_CASE_SENSITIVE_SEARCH |
             FILE_CASE_PRESERVED_NAMES |
             FILE_SUPPORTS_REMOTE_STORAGE |
@@ -949,6 +950,15 @@ int do_map() {
     }
   }
 
+  if (g_cfg->max_path_len > 260) {
+    dout(0) << "maximum path length set to " << g_cfg->max_path_len 
+            << ". Some Windows utilities may not be able to handle "
+            << "paths that exceed MAX_PATH (260) characters. "
+            << "CreateDirectoryW, used by Powershell, has also been "
+            << "observed to fail when paths exceed 16384 characters."
+            << dendl;
+  }
+
   atexit(unmount_atexit);
   dout(0) << "Mounted cephfs directory: " << g_cfg->root_path.c_str()
           <<". Mountpoint: " << to_string(g_cfg->mountpoint) << dendl;
index 7f98126a22a18cb13155b00ae61844c993a3b957..489ed6d26872b75c46bbe58fc2ec3803eb83c155 100644 (file)
@@ -33,6 +33,7 @@ struct Config {
 
   std::wstring win_vol_name = L"";
   unsigned long win_vol_serial = 0;
+  unsigned long max_path_len = 256;
 };
 
 extern Config *g_cfg;
index 910f3a45c77dd28d2ed98d0705c31157c968caf8..27b8569441eef41a96f66e9afbdd88a0e4dd981d 100644 (file)
@@ -40,6 +40,7 @@ Map options:
   --removable                 use a removable drive
   --win-vol-name arg          The Windows volume name. Default: Ceph - <fs_name>.
   --win-vol-serial arg        The Windows volume serial number. Default: <fs_id>.
+  --max-path-len              The value of the maximum path length. Default: 256.
 
 Unmap options:
   -l [ --mountpoint ] arg     mountpoint (path or drive letter) (e.g -l x).
@@ -85,6 +86,7 @@ int parse_args(
   std::string mountpoint;
   std::string win_vol_name;
   std::string win_vol_serial;
+  std::string max_path_len;
 
   int thread_count;
 
@@ -115,6 +117,23 @@ int parse_args(
     } else if (ceph_argparse_witharg(args, i, &win_vol_serial,
                                      "--win-vol-serial", (char *)NULL)) {
       cfg->win_vol_serial = std::stoul(win_vol_serial);
+    } else if (ceph_argparse_witharg(args, i, &max_path_len,
+                                     "--max-path-len", (char*)NULL)) {
+      unsigned long max_path_length = std::stoul(max_path_len);
+
+      if (max_path_length > 32767) {
+        *err_msg << "ceph-dokan: maximum path length should not "
+                 << "exceed " << 32767;
+        return -EINVAL;
+      }
+
+      if (max_path_length < 256) {
+        *err_msg << "ceph-dokan: maximum path length should not "
+                 << "have a value lower than 256";
+        return -EINVAL;
+      }
+
+      cfg->max_path_len = max_path_length;
     } else if (ceph_argparse_flag(args, i, "--current-session-only", (char *)NULL)) {
       cfg->current_session_only = true;
     } else if (ceph_argparse_witharg(args, i, &thread_count,