Skip to content

Commit

Permalink
Cephfs: Use ceph kernel client if kernel version >= 4.17
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Poornima G authored and mergify[bot] committed Sep 5, 2019
1 parent d03a352 commit 90c4d6a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
12 changes: 0 additions & 12 deletions pkg/cephfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
40 changes: 28 additions & 12 deletions pkg/cephfs/volumemounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 90c4d6a

Please sign in to comment.