diff --git a/Makefile b/Makefile index c6b7ee074..10c48d4cc 100755 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/drivers/SR.py b/drivers/SR.py index 2087f2e7c..8627801a4 100755 --- a/drivers/SR.py +++ b/drivers/SR.py @@ -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) diff --git a/drivers/util.py b/drivers/util.py index 3a7d9115f..11147f4cb 100755 --- a/drivers/util.py +++ b/drivers/util.py @@ -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: @@ -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): diff --git a/mk/sm.spec.in b/mk/sm.spec.in index cf2a76fd4..2901659d3 100755 --- a/mk/sm.spec.in +++ b/mk/sm.spec.in @@ -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 diff --git a/udev/90-xs-ioscheduler.rules b/udev/90-xs-ioscheduler.rules new file mode 100644 index 000000000..00379398e --- /dev/null +++ b/udev/90-xs-ioscheduler.rules @@ -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"