Skip to content

Commit 83cea81

Browse files
MageekChiunixpanic
authored andcommitted
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 <[email protected]>
1 parent 4d1548c commit 83cea81

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

internal/cephfs/mounter/kernel.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,24 @@ func (m *kernelMounter) mountKernel(
7272
m.needsModprobe = false
7373
}
7474

75+
fsID, err := volOptions.GetFSID()
76+
if err != nil {
77+
return fmt.Errorf("failed to get fsID, stop mounting: %w", err)
78+
}
79+
7580
args := []string{
7681
"-t", "ceph",
77-
fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath),
82+
fmt.Sprintf("%s@%s.%s=%s", cr.ID, fsID, volOptions.FsName, volOptions.RootPath),
7883
mountPoint,
7984
}
8085

81-
optionsStr := fmt.Sprintf("name=%s,secretfile=%s", cr.ID, cr.KeyFile)
82-
mdsNamespace := ""
83-
if volOptions.FsName != "" {
84-
mdsNamespace = "mds_namespace=" + volOptions.FsName
85-
}
86-
optionsStr = util.MountOptionsAdd(optionsStr, mdsNamespace, volOptions.KernelMountOptions, netDev)
86+
optionsStr := fmt.Sprintf("mon_addr=%s,secretfile=%s", strings.ReplaceAll(volOptions.Monitors, ",", "/"), cr.KeyFile)
87+
88+
optionsStr = util.MountOptionsAdd(optionsStr, volOptions.KernelMountOptions, netDev)
8789

8890
args = append(args, "-o", optionsStr)
8991

90-
var (
91-
stderr string
92-
err error
93-
)
92+
var stderr string
9493

9594
if volOptions.NetNamespaceFilePath != "" {
9695
_, stderr, err = util.ExecuteCommandWithNSEnter(ctx, volOptions.NetNamespaceFilePath, "mount", args[:]...)

internal/cephfs/store/volumeoptions.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ func (vo *VolumeOptions) Destroy() {
101101
}
102102
}
103103

104+
func (vo *VolumeOptions) GetFSID() (string, error) {
105+
if vo.conn == nil {
106+
return "", errors.New("cluster not connected yet")
107+
}
108+
109+
fsID, err := vo.conn.GetFSID()
110+
if err != nil {
111+
return "", err
112+
}
113+
114+
return fsID, nil
115+
}
116+
104117
func validateNonEmptyField(field, fieldName string) error {
105118
if field == "" {
106119
return fmt.Errorf("parameter '%s' cannot be empty", fieldName)

0 commit comments

Comments
 (0)