From patchwork Thu Oct 17 11:10:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 3060271 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 15BF49F243 for ; Thu, 17 Oct 2013 11:21:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E290A202E6 for ; Thu, 17 Oct 2013 11:21:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21FFD2030D for ; Thu, 17 Oct 2013 11:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754843Ab3JQLVb (ORCPT ); Thu, 17 Oct 2013 07:21:31 -0400 Received: from mailgw1.uni-kl.de ([131.246.120.220]:49366 "EHLO mailgw1.uni-kl.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753464Ab3JQLVb (ORCPT ); Thu, 17 Oct 2013 07:21:31 -0400 X-Greylist: delayed 643 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Oct 2013 07:21:28 EDT Received: from itwm2.itwm.fhg.de (itwm2.itwm.fhg.de [131.246.191.3]) by mailgw1.uni-kl.de (8.14.3/8.14.3/Debian-9.4) with ESMTP id r9HBAob3012421 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT) for ; Thu, 17 Oct 2013 13:10:51 +0200 Received: from mail2.itwm.fhg.de ([131.246.191.79]:50766) by itwm2.itwm.fhg.de with esmtps (TLSv1:DES-CBC3-SHA:168) (/C=DE/ST=Rheinland-Pfalz/L=Kaiserslautern/O=Fraunhofer ITWM/OU=SLG/CN=mail2.itwm.fhg.de)(verified=1) (Exim 4.74 #1) id 1VWlTe-0006D7-Qj; Thu, 17 Oct 2013 13:10:50 +0200 Subject: [PATCH opensm 2/2] Try default parition config if parsing the partitions.conf failed To: linux-rdma@vger.kernel.org From: Bernd Schubert Cc: hal@dev.mellanox.co.il Date: Thu, 17 Oct 2013 13:10:52 +0200 Message-ID: <20131017111052.177713.67832.stgit@fsdevel2> In-Reply-To: <20131017111041.177713.61634.stgit@fsdevel2> References: <20131017111041.177713.61634.stgit@fsdevel2> User-Agent: StGit/0.15 MIME-Version: 1.0 X-ITWM-CharSet: utf-8 X-ITWM-Scanned-By: mail2.itwm.fhg.de Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If partitions.conf is for some reasons invalid or empty, try again with the default configuration. This will re-use the default configuration created by prtn_make_default(), but osm_prtn_make_new() will automatically overwrite the initial default. Signed-off-by: Bernd Schubert --- opensm/osm_prtn.c | 11 ++++++++++- opensm/osm_prtn_config.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/opensm/osm_prtn.c b/opensm/osm_prtn.c index e76e2e1..4db7e7a 100644 --- a/opensm/osm_prtn.c +++ b/opensm/osm_prtn.c @@ -376,6 +376,7 @@ ib_api_status_t osm_prtn_make_partitions(osm_log_t * p_log, osm_subn_t * p_subn) struct stat statbuf; const char *file_name; boolean_t is_config = TRUE; + boolean_t is_wrong_config = FALSE; ib_api_status_t status = IB_SUCCESS; cl_map_item_t *p_next; osm_prtn_t *p; @@ -389,6 +390,7 @@ ib_api_status_t osm_prtn_make_partitions(osm_log_t * p_log, osm_subn_t * p_subn) is_config = FALSE; } +retry_default: /* clean up current port maps */ p_next = cl_qmap_head(&p_subn->prtn_pkey_tbl); while (p_next != cl_qmap_end(&p_subn->prtn_pkey_tbl)) { @@ -404,9 +406,11 @@ ib_api_status_t osm_prtn_make_partitions(osm_log_t * p_log, osm_subn_t * p_subn) if (status != IB_SUCCESS) goto _err; - if (is_config && osm_prtn_config_parse_file(p_log, p_subn, file_name)) + if (is_config && osm_prtn_config_parse_file(p_log, p_subn, file_name)) { OSM_LOG(p_log, OSM_LOG_VERBOSE, "Partition configuration " "was not fully processed\n"); + is_wrong_config = TRUE; + } /* and now clean up empty partitions */ p_next = cl_qmap_head(&p_subn->prtn_pkey_tbl); @@ -421,6 +425,11 @@ ib_api_status_t osm_prtn_make_partitions(osm_log_t * p_log, osm_subn_t * p_subn) } } + if (is_config && is_wrong_config) { + is_config = FALSE; + goto retry_default; + } + _err: return status; } diff --git a/opensm/osm_prtn_config.c b/opensm/osm_prtn_config.c index 8f4a673..e916582 100644 --- a/opensm/osm_prtn_config.c +++ b/opensm/osm_prtn_config.c @@ -696,6 +696,9 @@ done: return len; } +/** + * @return -1 on error, 0 on success + */ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, const char *file_name) { @@ -703,6 +706,7 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, struct part_conf *conf = NULL; FILE *file; int lineno; + boolean_t is_parse_success = FALSE; file = fopen(file_name, "r"); if (!file) { @@ -753,6 +757,8 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, break; } + is_parse_success = TRUE; + p += len; if (q) { @@ -764,5 +770,8 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, fclose(file); - return 0; + if (is_parse_success) + return 0; + else + return -1; }