Cephfs: Use ceph kernel client if kernel version >= 4.17

Ceph kernel client is more performant than ceph fuse client.
The kernel client has Quota support only in the kernel version >=4.17.
Hence use ceph kernel client when the kernel version is >=4.17.

Signed-off-by: Poornima G <pgurusid@redhat.com>
This commit is contained in:
Poornima G 2019-08-25 04:43:23 +00:00 committed by mergify[bot]
parent d03a352abf
commit 90c4d6a451
2 changed files with 28 additions and 24 deletions

View File

@ -50,9 +50,6 @@ type Driver struct {
}
var (
// DefaultVolumeMounter for mounting volumes
DefaultVolumeMounter string
// CSIInstanceID is the instance ID that is unique to an instance of CSI, used when sharing
// ceph clusters across CSI instances, to differentiate omap names per CSI instance
CSIInstanceID = "default"
@ -103,18 +100,9 @@ func (fs *Driver) Run(conf *util.Config, cachePersister util.CachePersister) {
if conf.VolumeMounter != "" {
if err := validateMounter(conf.VolumeMounter); err != nil {
klog.Fatalln(err)
} else {
DefaultVolumeMounter = conf.VolumeMounter
}
} else {
// Pick the first available mounter as the default one.
// The choice is biased towards "fuse" in case both
// ceph fuse and kernel mounters are available.
DefaultVolumeMounter = availableMounters[0]
}
klog.Infof("cephfs: setting default volume mounter to %s", DefaultVolumeMounter)
if err := util.WriteCephConfig(); err != nil {
klog.Fatalf("failed to write ceph configuration file: %v", err)
}

View File

@ -55,12 +55,32 @@ func loadAvailableMounters() error {
// #nosec
kernelMounterProbe := exec.Command("mount.ceph")
if fuseMounterProbe.Run() == nil {
availableMounters = append(availableMounters, volumeMounterFuse)
err := kernelMounterProbe.Run()
if err == nil {
kernelVersion, _, err := execCommand(context.TODO(), "uname", "-r")
if err != nil {
return err
}
vers := strings.Split(string(kernelVersion), ".")
majorVers, err := strconv.Atoi(vers[0])
if err != nil {
return err
}
minorVers, err := strconv.Atoi(vers[1])
if err != nil {
return err
}
if majorVers >= 4 && minorVers >= 17 {
klog.Infof("loaded mounter: %s", volumeMounterKernel)
availableMounters = append(availableMounters, volumeMounterKernel)
} else {
klog.Infof("kernel version < 4.17 might not support quota feature, hence not loading kernel client")
}
}
if kernelMounterProbe.Run() == nil {
availableMounters = append(availableMounters, volumeMounterKernel)
if fuseMounterProbe.Run() == nil {
klog.Infof("loaded mounter: %s", volumeMounterFuse)
availableMounters = append(availableMounters, volumeMounterFuse)
}
if len(availableMounters) == 0 {
@ -80,25 +100,21 @@ func newMounter(volOptions *volumeOptions) (volumeMounter, error) {
wantMounter := volOptions.Mounter
if wantMounter == "" {
wantMounter = DefaultVolumeMounter
}
// Verify that it's available
var chosenMounter string
for _, availMounter := range availableMounters {
if chosenMounter == "" {
if availMounter == wantMounter {
chosenMounter = wantMounter
}
if availMounter == wantMounter {
chosenMounter = wantMounter
break
}
}
if chosenMounter == "" {
// Otherwise pick whatever is left
chosenMounter = availableMounters[0]
klog.Infof("requested mounter: %s, chosen mounter: %s", wantMounter, chosenMounter)
}
// Create the mounter