From 12ba5cbbd2c9eab45b15eae4e6129f31c26c8e4b Mon Sep 17 00:00:00 2001 From: Germano Percossi Date: Tue, 22 Dec 2015 16:02:47 +0000 Subject: [PATCH 1/3] CA-192760: use noop IO scheduler for multipath and non-local devices We need to ensure we use noop IO scheduler for multipath devices and non local devices. We were used to do that in the storage manager but for devices going offline and added back this is not possible, becasue SM is not running all the time. This patch ensures the noop scheduler is set for specific devices and this setting is preserved even when SM is not running or when SM is not managing multipath (a potentially upcoming feature). Whit this rule, we use noop for any multipath device or any block device that is not on the ATA bus (a very weak decision rule to get an idea of locally attached devices). Signed-off-by: Germano Percossi --- Makefile | 2 +- mk/sm.spec.in | 1 + udev/90-xs-ioscheduler.rules | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 udev/90-xs-ioscheduler.rules 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/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..d0f5daf56 --- /dev/null +++ b/udev/90-xs-ioscheduler.rules @@ -0,0 +1,24 @@ +SUBSYSTEM!="block", GOTO="xs_ioscheduler_end" + +# 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" + +# Not interested in partitions and root device. +# For the time being we assume root is on the ATA bus. +LABEL="xs_ioscheduler_sd" +END{ID_BUS}=="ata", 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" From aae75486f3c014fd2ebf8410ca483941d5512506 Mon Sep 17 00:00:00 2001 From: Germano Percossi Date: Tue, 22 Dec 2015 16:27:19 +0000 Subject: [PATCH 2/3] CA-192760: functions to set IO scheduler deprecated A decorator for deprecated functions has been created. Deprecation is this case means replacing them with a no-op function and a warning message. Signed-off-by: Germano Percossi --- drivers/SR.py | 2 ++ drivers/util.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) 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): From 8ff3845f7a49a4626dae716c7b74bc54dcf2f0f0 Mon Sep 17 00:00:00 2001 From: Germano Percossi Date: Wed, 13 Jan 2016 19:54:31 +0000 Subject: [PATCH 3/3] squash on commit 12ba5cb and keep the following commit message CA-192760: use noop IO scheduler for specific device types We need to ensure that a noop scheduler is used for the following devices: - non rotational disks (e.g. SSDs) - multipath devices (we assume they have a clever controller if many paths exist) - remote arrays In the latter case we are not sure the chosen rule is always doing the right thing. We were used to do that in the storage manager but for devices going offline and added back this is not possible, because SM is not running all the time. This patch ensures the noop scheduler is set for specific devices and this setting is preserved even when SM is not running or when SM is not explicitly managing multipath (a potentially upcoming feature). Signed-off-by: Germano Percossi --- udev/90-xs-ioscheduler.rules | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/udev/90-xs-ioscheduler.rules b/udev/90-xs-ioscheduler.rules index d0f5daf56..00379398e 100644 --- a/udev/90-xs-ioscheduler.rules +++ b/udev/90-xs-ioscheduler.rules @@ -1,5 +1,8 @@ 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" @@ -11,10 +14,11 @@ ENV{DM_UUID}=="mpath-?*", GOTO="xs_ioscheduler_action" # Not interested any more GOTO="xs_ioscheduler_end" -# Not interested in partitions and root device. -# For the time being we assume root is on the ATA bus. +# 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" -END{ID_BUS}=="ata", GOTO="xs_ioscheduler_end" +ENV{ID_MODEL}!="LUN", GOTO="xs_ioscheduler_end" ENV{DEVTYPE}=="partition", GOTO="xs_ioscheduler_end" # Now set the scheduler