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

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