Blame SOURCES/0223-RHBZ-1452210-unpriv-sgio.patch

4728c8
---
4728c8
 libmultipath/config.c      |    3 +
4728c8
 libmultipath/config.h      |    3 +
4728c8
 libmultipath/configure.c   |    2 
4728c8
 libmultipath/defaults.h    |    1 
4728c8
 libmultipath/dict.c        |  113 +++++++++++++++++++++++++++++++++++++++++++++
4728c8
 libmultipath/discovery.c   |   44 +++++++++++++++++
4728c8
 libmultipath/discovery.h   |    1 
4728c8
 libmultipath/propsel.c     |   26 ++++++++++
4728c8
 libmultipath/propsel.h     |    1 
4728c8
 libmultipath/structs.h     |    8 ++-
4728c8
 multipath/multipath.conf.5 |    9 +++
4728c8
 11 files changed, 210 insertions(+), 1 deletion(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/config.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/config.c
4728c8
+++ multipath-tools-130222/libmultipath/config.c
4728c8
@@ -347,6 +347,7 @@ merge_hwe (struct hwentry * dst, struct
4728c8
 	merge_num(delay_wait_checks);
4728c8
 	merge_num(skip_kpartx);
4728c8
 	merge_num(max_sectors_kb);
4728c8
+	merge_num(unpriv_sgio);
4728c8
 
4728c8
 	/*
4728c8
 	 * Make sure features is consistent with
4728c8
@@ -410,6 +411,7 @@ overwrite_hwe (struct hwentry * dst, str
4728c8
 	overwrite_num(delay_wait_checks);
4728c8
 	overwrite_num(skip_kpartx);
4728c8
 	overwrite_num(max_sectors_kb);
4728c8
+	overwrite_num(unpriv_sgio);
4728c8
 
4728c8
 	/*
4728c8
 	 * Make sure features is consistent with
4728c8
@@ -690,6 +692,7 @@ load_config (char * file, struct udev *u
4728c8
 	conf->remove_retries = 0;
4728c8
 	conf->disable_changed_wwids = 0;
4728c8
 	conf->max_sectors_kb = DEFAULT_MAX_SECTORS_KB;
4728c8
+	conf->unpriv_sgio = DEFAULT_UNPRIV_SGIO;
4728c8
 
4728c8
 	/*
4728c8
 	 * preload default hwtable
4728c8
Index: multipath-tools-130222/libmultipath/config.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/config.h
4728c8
+++ multipath-tools-130222/libmultipath/config.h
4728c8
@@ -67,6 +67,7 @@ struct hwentry {
4728c8
 	int delay_wait_checks;
4728c8
 	int skip_kpartx;
4728c8
 	int max_sectors_kb;
4728c8
+	int unpriv_sgio;
4728c8
 	char * bl_product;
4728c8
 };
4728c8
 
4728c8
@@ -95,6 +96,7 @@ struct mpentry {
4728c8
 	int delay_wait_checks;
4728c8
 	int skip_kpartx;
4728c8
 	int max_sectors_kb;
4728c8
+	int unpriv_sgio;
4728c8
 	uid_t uid;
4728c8
 	gid_t gid;
4728c8
 	mode_t mode;
4728c8
@@ -153,6 +155,7 @@ struct config {
4728c8
 	int remove_retries;
4728c8
 	int disable_changed_wwids;
4728c8
 	int max_sectors_kb;
4728c8
+	int unpriv_sgio;
4728c8
 	unsigned int version[3];
4728c8
 
4728c8
 	char * dev;
4728c8
Index: multipath-tools-130222/libmultipath/configure.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/configure.c
4728c8
+++ multipath-tools-130222/libmultipath/configure.c
4728c8
@@ -297,6 +297,7 @@ setup_map (struct multipath * mpp, char
4728c8
 	select_delay_wait_checks(mpp);
4728c8
 	select_skip_kpartx(mpp);
4728c8
 	select_max_sectors_kb(mpp);
4728c8
+	select_unpriv_sgio(mpp);
4728c8
 
4728c8
 	sysfs_set_scsi_tmo(mpp);
4728c8
 	/*
4728c8
@@ -711,6 +712,7 @@ domap (struct multipath * mpp, char * pa
4728c8
 			}
4728c8
 		}
4728c8
 		dm_setgeometry(mpp);
4728c8
+		sysfs_set_unpriv_sgio(mpp);
4728c8
 		return DOMAP_OK;
4728c8
 	}
4728c8
 	return DOMAP_FAIL;
4728c8
Index: multipath-tools-130222/libmultipath/defaults.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/defaults.h
4728c8
+++ multipath-tools-130222/libmultipath/defaults.h
4728c8
@@ -27,6 +27,7 @@
4728c8
 #define DEFAULT_UEV_WAIT_TIMEOUT 30
4728c8
 #define DEFAULT_SKIP_KPARTX SKIP_KPARTX_OFF
4728c8
 #define DEFAULT_MAX_SECTORS_KB	MAX_SECTORS_KB_UNDEF
4728c8
+#define DEFAULT_UNPRIV_SGIO UNPRIV_SGIO_OFF
4728c8
 
4728c8
 #define DEFAULT_CHECKINT	5
4728c8
 #define MAX_CHECKINT(a)		(a << 2)
4728c8
Index: multipath-tools-130222/libmultipath/dict.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/dict.c
4728c8
+++ multipath-tools-130222/libmultipath/dict.c
4728c8
@@ -1015,6 +1015,28 @@ def_max_sectors_kb_handler(vector strvec
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+static int
4728c8
+def_unpriv_sgio_handler(vector strvec)
4728c8
+{
4728c8
+	char * buff;
4728c8
+
4728c8
+	buff = set_value(strvec);
4728c8
+	if (!buff)
4728c8
+		return 1;
4728c8
+
4728c8
+	if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
4728c8
+	    (strlen(buff) == 1 && !strcmp(buff, "0")))
4728c8
+		conf->unpriv_sgio = UNPRIV_SGIO_OFF;
4728c8
+	else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
4728c8
+		 (strlen(buff) == 1 && !strcmp(buff, "1")))
4728c8
+		conf->unpriv_sgio = UNPRIV_SGIO_ON;
4728c8
+	else
4728c8
+		conf->unpriv_sgio = UNPRIV_SGIO_OFF;
4728c8
+
4728c8
+	FREE(buff);
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 /*
4728c8
  * blacklist block handlers
4728c8
  */
4728c8
@@ -1851,6 +1873,33 @@ hw_max_sectors_kb_handler(vector strvec)
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+static int
4728c8
+hw_unpriv_sgio_handler(vector strvec)
4728c8
+{
4728c8
+	struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
4728c8
+	char * buff;
4728c8
+
4728c8
+	if (!hwe)
4728c8
+		return 1;
4728c8
+
4728c8
+	buff = set_value(strvec);
4728c8
+
4728c8
+	if (!buff)
4728c8
+		return 1;
4728c8
+
4728c8
+	if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
4728c8
+	    (strlen(buff) == 1 && !strcmp(buff, "0")))
4728c8
+		hwe->unpriv_sgio = UNPRIV_SGIO_OFF;
4728c8
+	else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
4728c8
+		 (strlen(buff) == 1 && !strcmp(buff, "1")))
4728c8
+		hwe->unpriv_sgio = UNPRIV_SGIO_ON;
4728c8
+	else
4728c8
+		hwe->unpriv_sgio = UNPRIV_SGIO_UNDEF;
4728c8
+
4728c8
+	FREE(buff);
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 /*
4728c8
  * multipaths block handlers
4728c8
  */
4728c8
@@ -2422,6 +2471,32 @@ mp_max_sectors_kb_handler(vector strvec)
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+static int
4728c8
+mp_unpriv_sgio_handler(vector strvec)
4728c8
+{
4728c8
+	struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
4728c8
+	char * buff;
4728c8
+
4728c8
+	if (!mpe)
4728c8
+		return 1;
4728c8
+
4728c8
+	buff = set_value(strvec);
4728c8
+	if (!buff)
4728c8
+		return 1;
4728c8
+
4728c8
+	if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
4728c8
+	    (strlen(buff) == 1 && strcmp(buff, "0") == 0))
4728c8
+		mpe->unpriv_sgio = UNPRIV_SGIO_OFF;
4728c8
+	else if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
4728c8
+		 (strlen(buff) == 1 && strcmp(buff, "1") == 0))
4728c8
+		mpe->unpriv_sgio = UNPRIV_SGIO_ON;
4728c8
+	else
4728c8
+		mpe->unpriv_sgio = UNPRIV_SGIO_UNDEF;
4728c8
+
4728c8
+	FREE(buff);
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 /*
4728c8
  * config file keywords printing
4728c8
  */
4728c8
@@ -2731,6 +2806,19 @@ snprint_mp_max_sectors_kb(char * buff, i
4728c8
 }
4728c8
 
4728c8
 static int
4728c8
+snprint_mp_unpriv_sgio (char * buff, int len, void * data)
4728c8
+{
4728c8
+	struct mpentry * mpe = (struct mpentry *)data;
4728c8
+
4728c8
+	if (mpe->unpriv_sgio == UNPRIV_SGIO_UNDEF)
4728c8
+		return 0;
4728c8
+	else if (mpe->unpriv_sgio == UNPRIV_SGIO_OFF)
4728c8
+		return snprintf(buff, len, "no");
4728c8
+	else
4728c8
+		return snprintf(buff, len, "yes");
4728c8
+}
4728c8
+
4728c8
+static int
4728c8
 snprint_hw_fast_io_fail(char * buff, int len, void * data)
4728c8
 {
4728c8
 	struct hwentry * hwe = (struct hwentry *)data;
4728c8
@@ -3132,6 +3220,19 @@ snprint_hw_max_sectors_kb(char * buff, i
4728c8
 }
4728c8
 
4728c8
 static int
4728c8
+snprint_hw_unpriv_sgio(char * buff, int len, void * data)
4728c8
+{
4728c8
+	struct hwentry * hwe = (struct hwentry *)data;
4728c8
+
4728c8
+	if (hwe->unpriv_sgio == UNPRIV_SGIO_ON)
4728c8
+		return snprintf(buff, len, "yes");
4728c8
+	else if (hwe->unpriv_sgio == UNPRIV_SGIO_OFF)
4728c8
+		return snprintf(buff, len, "no");
4728c8
+	else
4728c8
+		return 0;
4728c8
+}
4728c8
+
4728c8
+static int
4728c8
 snprint_def_polling_interval (char * buff, int len, void * data)
4728c8
 {
4728c8
 	return snprintf(buff, len, "%i", conf->checkint);
4728c8
@@ -3617,6 +3718,15 @@ snprint_def_max_sectors_kb(char * buff,
4728c8
 }
4728c8
 
4728c8
 static int
4728c8
+snprint_def_unpriv_sgio(char * buff, int len, void * data)
4728c8
+{
4728c8
+	if (conf->unpriv_sgio == UNPRIV_SGIO_ON)
4728c8
+		return snprintf(buff, len, "yes");
4728c8
+	else
4728c8
+		return snprintf(buff, len, "no");
4728c8
+}
4728c8
+
4728c8
+static int
4728c8
 snprint_ble_simple (char * buff, int len, void * data)
4728c8
 {
4728c8
 	struct blentry * ble = (struct blentry *)data;
4728c8
@@ -3699,6 +3809,7 @@ init_keywords(void)
4728c8
 	install_keyword("remove_retries", &def_remove_retries_handler, &snprint_def_remove_retries);
4728c8
 	install_keyword("disable_changed_wwids", &def_disable_changed_wwids_handler, &snprint_def_disable_changed_wwids);
4728c8
 	install_keyword("max_sectors_kb", &def_max_sectors_kb_handler, &snprint_def_max_sectors_kb);
4728c8
+	install_keyword("unpriv_sgio", &def_unpriv_sgio_handler, &snprint_def_unpriv_sgio);
4728c8
 	__deprecated install_keyword("default_selector", &def_selector_handler, NULL);
4728c8
 	__deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
4728c8
 	__deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
4728c8
@@ -3769,6 +3880,7 @@ init_keywords(void)
4728c8
 	install_keyword("delay_wait_checks", &hw_delay_wait_checks_handler, &snprint_hw_delay_wait_checks);
4728c8
 	install_keyword("skip_kpartx", &hw_skip_kpartx_handler, &snprint_hw_skip_kpartx);
4728c8
 	install_keyword("max_sectors_kb", &hw_max_sectors_kb_handler, &snprint_hw_max_sectors_kb);
4728c8
+	install_keyword("unpriv_sgio", &hw_unpriv_sgio_handler, &snprint_hw_unpriv_sgio);
4728c8
 	install_sublevel_end();
4728c8
 
4728c8
 	install_keyword_root("multipaths", &multipaths_handler);
4728c8
@@ -3798,5 +3910,6 @@ init_keywords(void)
4728c8
 	install_keyword("delay_wait_checks", &mp_delay_wait_checks_handler, &snprint_mp_delay_wait_checks);
4728c8
 	install_keyword("skip_kpartx", &mp_skip_kpartx_handler, &snprint_mp_skip_kpartx);
4728c8
 	install_keyword("max_sectors_kb", &mp_max_sectors_kb_handler, &snprint_mp_max_sectors_kb);
4728c8
+	install_keyword("unpriv_sgio", &mp_unpriv_sgio_handler, &snprint_mp_unpriv_sgio);
4728c8
 	install_sublevel_end();
4728c8
 }
4728c8
Index: multipath-tools-130222/libmultipath/propsel.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/propsel.c
4728c8
+++ multipath-tools-130222/libmultipath/propsel.c
4728c8
@@ -944,3 +944,29 @@ select_max_sectors_kb (struct multipath
4728c8
 	mp->max_sectors_kb = MAX_SECTORS_KB_UNDEF;
4728c8
 	return 0;
4728c8
 }
4728c8
+
4728c8
+extern int
4728c8
+select_unpriv_sgio (struct multipath * mp)
4728c8
+{
4728c8
+	if (mp->mpe && mp->mpe->unpriv_sgio != UNPRIV_SGIO_UNDEF) {
4728c8
+		mp->unpriv_sgio = mp->mpe->unpriv_sgio;
4728c8
+		condlog(3, "unpriv_sgio = %i (multipath setting)",
4728c8
+				mp->unpriv_sgio);
4728c8
+		return 0;
4728c8
+	}
4728c8
+	if (mp->hwe && mp->hwe->unpriv_sgio != UNPRIV_SGIO_UNDEF) {
4728c8
+		mp->unpriv_sgio = mp->hwe->unpriv_sgio;
4728c8
+		condlog(3, "unpriv_sgio = %i (controler setting)",
4728c8
+				mp->unpriv_sgio);
4728c8
+		return 0;
4728c8
+	}
4728c8
+	if (conf->unpriv_sgio != UNPRIV_SGIO_UNDEF) {
4728c8
+		mp->unpriv_sgio = conf->unpriv_sgio;
4728c8
+		condlog(3, "unpriv_sgio = %i (config file default)",
4728c8
+				mp->unpriv_sgio);
4728c8
+		return 0;
4728c8
+	}
4728c8
+	mp->unpriv_sgio = DEFAULT_UNPRIV_SGIO;
4728c8
+	condlog(3, "unpriv_sgio = DISABLED (internal default)");
4728c8
+	return 0;
4728c8
+}
4728c8
Index: multipath-tools-130222/libmultipath/propsel.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/propsel.h
4728c8
+++ multipath-tools-130222/libmultipath/propsel.h
4728c8
@@ -26,3 +26,4 @@ int select_delay_watch_checks (struct mu
4728c8
 int select_delay_wait_checks (struct multipath * mp);
4728c8
 int select_skip_kpartx (struct multipath * mp);
4728c8
 int select_max_sectors_kb (struct multipath * mp);
4728c8
+int select_unpriv_sgio (struct multipath * mp);
4728c8
Index: multipath-tools-130222/libmultipath/structs.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/structs.h
4728c8
+++ multipath-tools-130222/libmultipath/structs.h
4728c8
@@ -134,12 +134,17 @@ enum skip_kpartx_states {
4728c8
 	SKIP_KPARTX_ON,
4728c8
 };
4728c8
 
4728c8
-
4728c8
 enum max_sectors_kb_states {
4728c8
 	MAX_SECTORS_KB_UNDEF = 0,
4728c8
 	MAX_SECTORS_KB_MIN = 4,  /* can't be smaller than page size */
4728c8
 };
4728c8
 
4728c8
+enum unpriv_sgio_states {
4728c8
+	UNPRIV_SGIO_UNDEF,
4728c8
+	UNPRIV_SGIO_OFF,
4728c8
+	UNPRIV_SGIO_ON,
4728c8
+};
4728c8
+
4728c8
 enum scsi_protocol {
4728c8
 	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */
4728c8
 	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */
4728c8
@@ -260,6 +265,7 @@ struct multipath {
4728c8
 	int skip_kpartx;
4728c8
 	int max_sectors_kb;
4728c8
 	int force_readonly;
4728c8
+	int unpriv_sgio;
4728c8
 	unsigned int dev_loss;
4728c8
 	uid_t uid;
4728c8
 	gid_t gid;
4728c8
Index: multipath-tools-130222/libmultipath/discovery.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/discovery.c
4728c8
+++ multipath-tools-130222/libmultipath/discovery.c
4728c8
@@ -222,6 +222,50 @@ fail_reload:
4728c8
 }
4728c8
 
4728c8
 int
4728c8
+sysfs_set_unpriv_sgio(struct multipath *mpp)
4728c8
+{
4728c8
+	struct pathgroup * pgp;
4728c8
+	struct path *pp;
4728c8
+	int i, j, ret;
4728c8
+	struct udev_device *udevice = NULL;
4728c8
+
4728c8
+	if (mpp->unpriv_sgio != UNPRIV_SGIO_ON)
4728c8
+		return 0;
4728c8
+	if (!mpp->dmi && dm_get_info(mpp->alias, &mpp->dmi) != 0) {
4728c8
+		condlog(0, "failed to get dm info on %s to set unpriv_sgio",
4728c8
+			mpp->alias);
4728c8
+		return 1;
4728c8
+	}
4728c8
+	udevice = udev_device_new_from_devnum(conf->udev, 'b',
4728c8
+					      makedev(mpp->dmi->major,
4728c8
+						      mpp->dmi->minor));
4728c8
+	if (!udevice) {
4728c8
+		condlog(0, "failed to get udev device to set unpriv_sgio for %s", mpp->alias);
4728c8
+		return 1;
4728c8
+	}
4728c8
+
4728c8
+	ret = sysfs_attr_set_value(udevice, "queue/unpriv_sgio", "1", 1);
4728c8
+	udev_device_unref(udevice);
4728c8
+	if (ret < 0) {
4728c8
+		condlog(0, "failed setting unpriv_sgio on %s: %s", mpp->alias,
4728c8
+			strerror(-ret));
4728c8
+		return 1;
4728c8
+	}
4728c8
+
4728c8
+	vector_foreach_slot(mpp->pg, pgp, i) {
4728c8
+		vector_foreach_slot (pgp->paths, pp, j) {
4728c8
+			ret = sysfs_attr_set_value(pp->udev,
4728c8
+						   "queue/unpriv_sgio", "1", 1);
4728c8
+			if (ret < 0) {
4728c8
+				condlog(0, "failed setting unpriv_sgio on %s: %s", mpp->alias, strerror(-ret));
4728c8
+				return 1;
4728c8
+			}
4728c8
+		}
4728c8
+	}
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
+int
4728c8
 sysfs_get_timeout(struct path *pp, unsigned int *timeout)
4728c8
 {
4728c8
 	const char *attr = NULL;
4728c8
Index: multipath-tools-130222/libmultipath/discovery.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/discovery.h
4728c8
+++ multipath-tools-130222/libmultipath/discovery.h
4728c8
@@ -42,6 +42,7 @@ int store_pathinfo (vector pathvec, vect
4728c8
 		    struct path **pp_ptr);
4728c8
 int sysfs_set_scsi_tmo (struct multipath *mpp);
4728c8
 int sysfs_set_max_sectors_kb(struct multipath *mpp, int is_reload);
4728c8
+int sysfs_set_unpriv_sgio(struct multipath *mpp);
4728c8
 int sysfs_get_timeout(struct path *pp, unsigned int *timeout);
4728c8
 int sysfs_get_host_pci_name(struct path *pp, char *pci_name);
4728c8
 int sysfs_get_iscsi_ip_address(struct path *pp, char *ip_address);
4728c8
Index: multipath-tools-130222/multipath/multipath.conf.5
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipath/multipath.conf.5
4728c8
+++ multipath-tools-130222/multipath/multipath.conf.5
4728c8
@@ -580,6 +580,11 @@ Between each attempt, multipath will sle
4728c8
 .B max_sectors_kb
4728c8
 Sets the max_sectors_kb device parameter on all path devices and the multipath
4728c8
 device to the specified value. Default is device dependent.
4728c8
+.TP
4728c8
+.B unpriv_sgio
4728c8
+If set to \fIyes\fR, multipath will set upriv_sgio on the multipath device and
4728c8
+all its paths, when it is created or reloaded. The default is
4728c8
+.I no
4728c8
 .
4728c8
 .SH "blacklist section"
4728c8
 The
4728c8
@@ -693,6 +698,8 @@ section:
4728c8
 .B skip_kpartx
4728c8
 .TP
4728c8
 .B max_sectors_kb
4728c8
+.TP
4728c8
+.B unpriv_sgio
4728c8
 .RE
4728c8
 .PD
4728c8
 .LP
4728c8
@@ -795,6 +802,8 @@ section:
4728c8
 .B skip_kpartx
4728c8
 .TP
4728c8
 .B max_sectors_kb
4728c8
+.TP
4728c8
+.B unpriv_sgio
4728c8
 .RE
4728c8
 .PD
4728c8
 .LP