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

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