mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +00:00
rbd: check for cookie support from kernel
Currently we only check if the rbd-nbd tool supports cookie feature. This change will also defend cookie addition based on kernel version Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
parent
804e2715d8
commit
d760d0ab6d
@ -71,6 +71,25 @@ const (
|
|||||||
var (
|
var (
|
||||||
hasNBD = true
|
hasNBD = true
|
||||||
hasNBDCookieSupport = false
|
hasNBDCookieSupport = false
|
||||||
|
|
||||||
|
kernelCookieSupport = []util.KernelVersion{
|
||||||
|
{
|
||||||
|
Version: 5,
|
||||||
|
PatchLevel: 14,
|
||||||
|
SubLevel: 0,
|
||||||
|
ExtraVersion: 0,
|
||||||
|
Distribution: "",
|
||||||
|
Backport: false,
|
||||||
|
}, // standard 5.14+ versions
|
||||||
|
{
|
||||||
|
Version: 4,
|
||||||
|
PatchLevel: 18,
|
||||||
|
SubLevel: 0,
|
||||||
|
ExtraVersion: 365,
|
||||||
|
Distribution: ".el8",
|
||||||
|
Backport: true,
|
||||||
|
}, // CentOS-8.x
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -207,21 +226,42 @@ func setRbdNbdToolFeatures() {
|
|||||||
_, stderr, err = util.ExecCommand(context.TODO(), "modprobe", moduleNbd)
|
_, stderr, err = util.ExecCommand(context.TODO(), "modprobe", moduleNbd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hasNBD = false
|
hasNBD = false
|
||||||
log.WarningLogMsg("rbd-nbd: nbd modprobe failed (%v): %q", err, stderr)
|
log.WarningLogMsg("nbd modprobe failed (%v): %q", err, stderr)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.DefaultLog("nbd module loaded")
|
||||||
|
|
||||||
|
// fetch the current running kernel info
|
||||||
|
release, err := util.GetKernelVersion()
|
||||||
|
if err != nil {
|
||||||
|
log.WarningLogMsg("fetching current kernel version failed (%v)", err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !util.CheckKernelSupport(release, kernelCookieSupport) {
|
||||||
|
log.WarningLogMsg("kernel version %q doesn't support cookie feature", release)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.DefaultLog("kernel version %q supports cookie feature", release)
|
||||||
|
|
||||||
|
// check if the rbd-nbd tool supports cookie
|
||||||
stdout, stderr, err := util.ExecCommand(context.TODO(), rbdTonbd, "--help")
|
stdout, stderr, err := util.ExecCommand(context.TODO(), rbdTonbd, "--help")
|
||||||
if err != nil || stderr != "" {
|
if err != nil || stderr != "" {
|
||||||
hasNBD = false
|
hasNBD = false
|
||||||
log.WarningLogMsg("running rbd-nbd --help failed with error:%v, stderr:%s", err, stderr)
|
log.WarningLogMsg("running rbd-nbd --help failed with error:%v, stderr:%s", err, stderr)
|
||||||
}
|
|
||||||
|
|
||||||
if strings.Contains(stdout, "--cookie") {
|
return
|
||||||
|
}
|
||||||
|
if !strings.Contains(stdout, "--cookie") {
|
||||||
|
log.WarningLogMsg("rbd-nbd tool doesn't support cookie feature")
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
hasNBDCookieSupport = true
|
hasNBDCookieSupport = true
|
||||||
}
|
log.DefaultLog("rbd-nbd tool supports cookie feature")
|
||||||
|
|
||||||
log.DefaultLog("NBD module loaded: %t, rbd-nbd supported features, cookie: %t", hasNBD, hasNBDCookieSupport)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseMapOptions helps parse formatted mapOptions and unmapOptions and
|
// parseMapOptions helps parse formatted mapOptions and unmapOptions and
|
||||||
|
Loading…
Reference in New Issue
Block a user