Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] CA-192760: use noop scheduler for multipath devices #293

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ SM_LIBS += wwid_conf
SM_LIBS += trim_util
SM_LIBS += pluginutil

UDEV_RULES = 39-multipath 40-multipath 55-xs-mpath-scsidev 58-xapi
UDEV_RULES = 39-multipath 40-multipath 55-xs-mpath-scsidev 58-xapi 90-xs-ioscheduler
MPATH_DAEMON = sm-multipath
MPATH_CONF = multipath.conf
CIFS_CONF = cifs.conf
Expand Down
2 changes: 2 additions & 0 deletions drivers/SR.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def from_uuid(session, sr_uuid):

return target(cmd, sr_uuid)


@util.disabled("udev rules")
def block_setscheduler(self, dev):
try:
realdev = os.path.realpath(dev)
Expand Down
29 changes: 29 additions & 0 deletions drivers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,33 @@ class SRBusyException(SMException):
"""The SR could not be locked"""
pass


def disabled(reason = None):
"""This function is used as decorator to deprecate functions.

It does that by making the decorated function a no-op and printing
a warning message in the logs.
It is possible to pass an optional parameter to explain why it was
replaced (if replaced).

For example:
@disabled("foo function")
will add to the message ": use foo function instead"
"""
if reason:
str_append = ": use {} instead".format(reason)
else:
str_append = ""

def disabled_decor(fun):
SMlog("WARNING: {} has been disabled{}".format(fun.__name__,
str_append))
def wrapper(*args, **kwargs):
pass
return wrapper
return disabled_decor


def logException(tag):
info = sys.exc_info()
if info[0] == exceptions.SystemExit:
Expand Down Expand Up @@ -995,6 +1022,8 @@ def dom0_disks():
SMlog("Dom0 disks: %s" % disks)
return disks


@disabled("udev rules")
def set_scheduler(dev, str):
devices = []
if not scsiutil.match_dm(dev):
Expand Down
1 change: 1 addition & 0 deletions mk/sm.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ fi
%config /etc/udev/rules.d/40-multipath.rules
%config /etc/udev/rules.d/55-xs-mpath-scsidev.rules
%config /etc/udev/rules.d/58-xapi.rules
%config /etc/udev/rules.d/90-xs-ioscheduler.rules
%config /etc/multipath.xenserver/multipath.conf
%config /etc/udev/rules.d/69-dm-lvm-metad.rules
%config /etc/modprobe.d/cifs.conf
Expand Down
28 changes: 28 additions & 0 deletions udev/90-xs-ioscheduler.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SUBSYSTEM!="block", GOTO="xs_ioscheduler_end"

# If non-rotational it is a no-brainer
ATTR{queue/rotational}=="0", GOTO="xs_ioscheduler_action"

# Take care of physical devices
KERNEL=="sd*", GOTO="xs_ioscheduler_sd"

# Multipath devices have their own scheduler unlike
# LVM ones, so make sure their defaults are right.
# We use a property set by a previous dm rule not by the kernel
ENV{DM_UUID}=="mpath-?*", GOTO="xs_ioscheduler_action"

# Not interested any more
GOTO="xs_ioscheduler_end"

# We assume if the model is "LUN" there is a clever array that
# can do the job.
# Not interested in partitions.
LABEL="xs_ioscheduler_sd"
ENV{ID_MODEL}!="LUN", GOTO="xs_ioscheduler_end"
ENV{DEVTYPE}=="partition", GOTO="xs_ioscheduler_end"

# Now set the scheduler
LABEL="xs_ioscheduler_action"
ACTION=="add|change", ATTR{queue/scheduler}="noop"

LABEL="xs_ioscheduler_end"