public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 2/4 infiniband-diags] ibqueryerrors: Close global file descriptor before running ibnd_discover_fabric
@ 2015-04-26 19:33 Hal Rosenstock
       [not found] ` <553D3D9E.3020804-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Hal Rosenstock @ 2015-04-26 19:33 UTC (permalink / raw)
  To: Ira Weiny
  Cc: Vladimir Koushnir,
	linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)

From: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Date: Sun, 26 Apr 2015 12:24:06 +0300

Global file descriptor for SMPs and GMPs should be closed before running
ibnd_discover_fabric() to avoid parallel usage of two SMP file descriptors

Signed-off-by: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
Changes since v1:
Fixed direct route (-D) option

diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
index 06fcbac..80436d3 100644
--- a/src/ibqueryerrors.c
+++ b/src/ibqueryerrors.c
@@ -1000,18 +1002,20 @@ int main(int argc, char **argv)
 	config.flags = ibd_ibnetdisc_flags;
 	config.mkey = ibd_mkey;
 
-	node_name_map = open_node_name_map(node_name_map_file);
-
 	if (dr_path && load_cache_file) {
+		mad_rpc_close_port(ibmad_port);
 		fprintf(stderr, "Cannot specify cache and direct route path\n");
 		exit(-1);
 	}
 
 	if (resolve_self(ibd_ca, ibd_ca_port, &self_portid, &port, &self_gid.raw) < 0) {
+		mad_rpc_close_port(ibmad_port);
 		IBEXIT("can't resolve self port %s", argv[0]);
 		goto close_port;
 	}
 
+	node_name_map = open_node_name_map(node_name_map_file);
+
 	/* limit the scan the fabric around the target */
 	if (dr_path) {
 		if ((resolved =
@@ -1030,10 +1034,13 @@ int main(int argc, char **argv)
 			lid2sl_table[portid.lid] = portid.sl;
 	}
 
+	mad_rpc_close_port(ibmad_port);
+
 	if (load_cache_file) {
 		if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) {
 			fprintf(stderr, "loading cached fabric failed\n");
-			exit(-1);
+			rc = -1;
+			goto close_port;
 		}
 	} else {
 		if (resolved >= 0) {
@@ -1057,6 +1064,21 @@ int main(int argc, char **argv)
 
 	set_thresholds(threshold_file);
 
+	/* reopen the global ibmad_port */
+	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port,
+				       mgmt_classes, 4);
+	if (!ibmad_port) {
+		ibnd_destroy_fabric(fabric);
+		close_node_name_map(node_name_map);
+		IBEXIT("Failed to reopen port: %s:%d\n",
+			ibd_ca, ibd_ca_port);
+	}
+
+	smp_mkey_set(ibmad_port, ibd_mkey);
+
+	if (ibd_timeout)
+		mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+
 	if (port_guid_str) {
 		ibnd_port_t *port = ibnd_find_port_guid(fabric, port_guid);
 		if (port)
@@ -1067,12 +1089,12 @@ int main(int argc, char **argv)
 	} else if (dr_path) {
 		ibnd_port_t *port = ibnd_find_port_dr(fabric, dr_path);
 		uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
-
 		if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0,
-				   ibd_timeout, ibmad_port)) {
-			rc = -1;
-			goto destroy_fabric;
+			   ibd_timeout, ibmad_port)) {
+				fprintf(stderr, "Failed to query local Node Info\n");
+				goto destroy_fabric;
 		}
+
 		mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(port_guid));
 
 		port = ibnd_find_port_guid(fabric, port_guid);
@@ -1087,6 +1109,7 @@ int main(int argc, char **argv)
 		if(obtain_sl)
 			if(path_record_query(self_gid,0))
 				goto destroy_fabric;
+
 		ibnd_iter_nodes(fabric, print_node, NULL);
 	}
 
@@ -1095,10 +1118,10 @@ int main(int argc, char **argv)
 		rc = 1;
 
 destroy_fabric:
+	mad_rpc_close_port(ibmad_port);
 	ibnd_destroy_fabric(fabric);
 
 close_port:
-	mad_rpc_close_port(ibmad_port);
 	close_node_name_map(node_name_map);
 	exit(rc);
 }
-- 
1.7.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/4 infiniband-diags] ibqueryerrors: Close global file descriptor before running ibnd_discover_fabric
       [not found] ` <553D3D9E.3020804-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2015-07-03 15:24   ` ira.weiny
       [not found]     ` <20150703152421.GF15224-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: ira.weiny @ 2015-07-03 15:24 UTC (permalink / raw)
  To: Hal Rosenstock
  Cc: Vladimir Koushnir,
	linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)

On Sun, Apr 26, 2015 at 03:33:50PM -0400, Hal Rosenstock wrote:
> From: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Date: Sun, 26 Apr 2015 12:24:06 +0300
> 
> Global file descriptor for SMPs and GMPs should be closed before running
> ibnd_discover_fabric() to avoid parallel usage of two SMP file descriptors
> 
> Signed-off-by: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

This patch made the goto labels misleading when reading the code.  I changed
the name of the goto labels.

Please verify I did not break anything on your end.

Applied with fix ups to the goto labels.

Ira

> ---
> Changes since v1:
> Fixed direct route (-D) option
> 
> diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
> index 06fcbac..80436d3 100644
> --- a/src/ibqueryerrors.c
> +++ b/src/ibqueryerrors.c
> @@ -1000,18 +1002,20 @@ int main(int argc, char **argv)
>  	config.flags = ibd_ibnetdisc_flags;
>  	config.mkey = ibd_mkey;
>  
> -	node_name_map = open_node_name_map(node_name_map_file);
> -
>  	if (dr_path && load_cache_file) {
> +		mad_rpc_close_port(ibmad_port);
>  		fprintf(stderr, "Cannot specify cache and direct route path\n");
>  		exit(-1);
>  	}
>  
>  	if (resolve_self(ibd_ca, ibd_ca_port, &self_portid, &port, &self_gid.raw) < 0) {
> +		mad_rpc_close_port(ibmad_port);
>  		IBEXIT("can't resolve self port %s", argv[0]);
>  		goto close_port;
>  	}
>  
> +	node_name_map = open_node_name_map(node_name_map_file);
> +
>  	/* limit the scan the fabric around the target */
>  	if (dr_path) {
>  		if ((resolved =
> @@ -1030,10 +1034,13 @@ int main(int argc, char **argv)
>  			lid2sl_table[portid.lid] = portid.sl;
>  	}
>  
> +	mad_rpc_close_port(ibmad_port);
> +
>  	if (load_cache_file) {
>  		if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) {
>  			fprintf(stderr, "loading cached fabric failed\n");
> -			exit(-1);
> +			rc = -1;
> +			goto close_port;
>  		}
>  	} else {
>  		if (resolved >= 0) {
> @@ -1057,6 +1064,21 @@ int main(int argc, char **argv)
>  
>  	set_thresholds(threshold_file);
>  
> +	/* reopen the global ibmad_port */
> +	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port,
> +				       mgmt_classes, 4);
> +	if (!ibmad_port) {
> +		ibnd_destroy_fabric(fabric);
> +		close_node_name_map(node_name_map);
> +		IBEXIT("Failed to reopen port: %s:%d\n",
> +			ibd_ca, ibd_ca_port);
> +	}
> +
> +	smp_mkey_set(ibmad_port, ibd_mkey);
> +
> +	if (ibd_timeout)
> +		mad_rpc_set_timeout(ibmad_port, ibd_timeout);
> +
>  	if (port_guid_str) {
>  		ibnd_port_t *port = ibnd_find_port_guid(fabric, port_guid);
>  		if (port)
> @@ -1067,12 +1089,12 @@ int main(int argc, char **argv)
>  	} else if (dr_path) {
>  		ibnd_port_t *port = ibnd_find_port_dr(fabric, dr_path);
>  		uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
> -
>  		if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0,
> -				   ibd_timeout, ibmad_port)) {
> -			rc = -1;
> -			goto destroy_fabric;
> +			   ibd_timeout, ibmad_port)) {
> +				fprintf(stderr, "Failed to query local Node Info\n");
> +				goto destroy_fabric;
>  		}
> +
>  		mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(port_guid));
>  
>  		port = ibnd_find_port_guid(fabric, port_guid);
> @@ -1087,6 +1109,7 @@ int main(int argc, char **argv)
>  		if(obtain_sl)
>  			if(path_record_query(self_gid,0))
>  				goto destroy_fabric;
> +
>  		ibnd_iter_nodes(fabric, print_node, NULL);
>  	}
>  
> @@ -1095,10 +1118,10 @@ int main(int argc, char **argv)
>  		rc = 1;
>  
>  destroy_fabric:
> +	mad_rpc_close_port(ibmad_port);
>  	ibnd_destroy_fabric(fabric);
>  
>  close_port:
> -	mad_rpc_close_port(ibmad_port);
>  	close_node_name_map(node_name_map);
>  	exit(rc);
>  }
> -- 
> 1.7.8.2
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/4 infiniband-diags] ibqueryerrors: Close global file descriptor before running ibnd_discover_fabric
       [not found]     ` <20150703152421.GF15224-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
@ 2015-07-15 16:00       ` Hal Rosenstock
  0 siblings, 0 replies; 3+ messages in thread
From: Hal Rosenstock @ 2015-07-15 16:00 UTC (permalink / raw)
  To: ira.weiny
  Cc: Vladimir Koushnir,
	linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)

On 7/3/2015 11:24 AM, ira.weiny wrote:
> On Sun, Apr 26, 2015 at 03:33:50PM -0400, Hal Rosenstock wrote:
>> From: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>> Date: Sun, 26 Apr 2015 12:24:06 +0300
>>
>> Global file descriptor for SMPs and GMPs should be closed before running
>> ibnd_discover_fabric() to avoid parallel usage of two SMP file descriptors
>>
>> Signed-off-by: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>> Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> 
> This patch made the goto labels misleading when reading the code.  I changed
> the name of the goto labels.

These label name changes look fine to me. Thanks.

-- Hal

> Please verify I did not break anything on your end.
> 
> Applied with fix ups to the goto labels.
> 
> Ira
> 
>> ---
>> Changes since v1:
>> Fixed direct route (-D) option
>>
>> diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
>> index 06fcbac..80436d3 100644
>> --- a/src/ibqueryerrors.c
>> +++ b/src/ibqueryerrors.c
>> @@ -1000,18 +1002,20 @@ int main(int argc, char **argv)
>>  	config.flags = ibd_ibnetdisc_flags;
>>  	config.mkey = ibd_mkey;
>>  
>> -	node_name_map = open_node_name_map(node_name_map_file);
>> -
>>  	if (dr_path && load_cache_file) {
>> +		mad_rpc_close_port(ibmad_port);
>>  		fprintf(stderr, "Cannot specify cache and direct route path\n");
>>  		exit(-1);
>>  	}
>>  
>>  	if (resolve_self(ibd_ca, ibd_ca_port, &self_portid, &port, &self_gid.raw) < 0) {
>> +		mad_rpc_close_port(ibmad_port);
>>  		IBEXIT("can't resolve self port %s", argv[0]);
>>  		goto close_port;
>>  	}
>>  
>> +	node_name_map = open_node_name_map(node_name_map_file);
>> +
>>  	/* limit the scan the fabric around the target */
>>  	if (dr_path) {
>>  		if ((resolved =
>> @@ -1030,10 +1034,13 @@ int main(int argc, char **argv)
>>  			lid2sl_table[portid.lid] = portid.sl;
>>  	}
>>  
>> +	mad_rpc_close_port(ibmad_port);
>> +
>>  	if (load_cache_file) {
>>  		if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) {
>>  			fprintf(stderr, "loading cached fabric failed\n");
>> -			exit(-1);
>> +			rc = -1;
>> +			goto close_port;
>>  		}
>>  	} else {
>>  		if (resolved >= 0) {
>> @@ -1057,6 +1064,21 @@ int main(int argc, char **argv)
>>  
>>  	set_thresholds(threshold_file);
>>  
>> +	/* reopen the global ibmad_port */
>> +	ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port,
>> +				       mgmt_classes, 4);
>> +	if (!ibmad_port) {
>> +		ibnd_destroy_fabric(fabric);
>> +		close_node_name_map(node_name_map);
>> +		IBEXIT("Failed to reopen port: %s:%d\n",
>> +			ibd_ca, ibd_ca_port);
>> +	}
>> +
>> +	smp_mkey_set(ibmad_port, ibd_mkey);
>> +
>> +	if (ibd_timeout)
>> +		mad_rpc_set_timeout(ibmad_port, ibd_timeout);
>> +
>>  	if (port_guid_str) {
>>  		ibnd_port_t *port = ibnd_find_port_guid(fabric, port_guid);
>>  		if (port)
>> @@ -1067,12 +1089,12 @@ int main(int argc, char **argv)
>>  	} else if (dr_path) {
>>  		ibnd_port_t *port = ibnd_find_port_dr(fabric, dr_path);
>>  		uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
>> -
>>  		if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0,
>> -				   ibd_timeout, ibmad_port)) {
>> -			rc = -1;
>> -			goto destroy_fabric;
>> +			   ibd_timeout, ibmad_port)) {
>> +				fprintf(stderr, "Failed to query local Node Info\n");
>> +				goto destroy_fabric;
>>  		}
>> +
>>  		mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(port_guid));
>>  
>>  		port = ibnd_find_port_guid(fabric, port_guid);
>> @@ -1087,6 +1109,7 @@ int main(int argc, char **argv)
>>  		if(obtain_sl)
>>  			if(path_record_query(self_gid,0))
>>  				goto destroy_fabric;
>> +
>>  		ibnd_iter_nodes(fabric, print_node, NULL);
>>  	}
>>  
>> @@ -1095,10 +1118,10 @@ int main(int argc, char **argv)
>>  		rc = 1;
>>  
>>  destroy_fabric:
>> +	mad_rpc_close_port(ibmad_port);
>>  	ibnd_destroy_fabric(fabric);
>>  
>>  close_port:
>> -	mad_rpc_close_port(ibmad_port);
>>  	close_node_name_map(node_name_map);
>>  	exit(rc);
>>  }
>> -- 
>> 1.7.8.2
>>
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-15 16:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-26 19:33 [PATCH v2 2/4 infiniband-diags] ibqueryerrors: Close global file descriptor before running ibnd_discover_fabric Hal Rosenstock
     [not found] ` <553D3D9E.3020804-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-07-03 15:24   ` ira.weiny
     [not found]     ` <20150703152421.GF15224-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2015-07-15 16:00       ` Hal Rosenstock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox