cephfs: upgrading mount syntax

The old syntax is almost deprecated,and there are reasons to upgrade it
- old syntax is lack of fsid(critical for debugging and observability)
- mds_namespace is deprecated, it might be inappropriate to continue using it
- kernel will try new syntax first and then the old one, it's a waste

Signed-off-by: mageekchiu <qiukang@mail.ustc.edu.cn>
This commit is contained in:
mageekchiu
2025-03-09 18:58:55 +08:00
committed by mergify[bot]
parent 91baf7681d
commit 0c60fd28ea
3 changed files with 46 additions and 20 deletions

View File

@ -72,25 +72,24 @@ func (m *kernelMounter) mountKernel(
m.needsModprobe = false
}
fsID, err := volOptions.GetFSID()
if err != nil {
return fmt.Errorf("failed to get fsID, stop mounting: %w", err)
}
args := []string{
"-t", "ceph",
fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath),
fmt.Sprintf("%s@%s.%s=%s", cr.ID, fsID, volOptions.FsName, volOptions.RootPath),
mountPoint,
}
optionsStr := fmt.Sprintf("name=%s,secretfile=%s", cr.ID, cr.KeyFile)
mdsNamespace := ""
if volOptions.FsName != "" {
mdsNamespace = "mds_namespace=" + volOptions.FsName
}
optionsStr = util.MountOptionsAdd(optionsStr, mdsNamespace, volOptions.KernelMountOptions, netDev)
optionsStr := fmt.Sprintf("mon_addr=%s,secretfile=%s", strings.ReplaceAll(volOptions.Monitors, ",", "/"), cr.KeyFile)
optionsStr = util.MountOptionsAdd(optionsStr, volOptions.KernelMountOptions, netDev)
args = append(args, "-o", optionsStr)
var (
stderr string
err error
)
var stderr string
if volOptions.NetNamespaceFilePath != "" {
_, stderr, err = util.ExecuteCommandWithNSEnter(ctx, volOptions.NetNamespaceFilePath, "mount", args[:]...)