From patchwork Sat Jan 4 17:37:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3434031 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 72839C02DC for ; Sat, 4 Jan 2014 17:38:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8000320158 for ; Sat, 4 Jan 2014 17:38:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0094520145 for ; Sat, 4 Jan 2014 17:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753656AbaADRiF (ORCPT ); Sat, 4 Jan 2014 12:38:05 -0500 Received: from mail-ea0-f170.google.com ([209.85.215.170]:58695 "EHLO mail-ea0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752977AbaADRiE (ORCPT ); Sat, 4 Jan 2014 12:38:04 -0500 Received: by mail-ea0-f170.google.com with SMTP id k10so7256883eaj.1 for ; Sat, 04 Jan 2014 09:38:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=Je+2BtUQ3TP+4Ibq/aV8qDgkZPCWoEYPapINSc1hLmk=; b=C+Cl7VAbiORUAZTDMdWVN0QOv0B/vidoltcuiQLwb2ueBTjoB96Jd+4MKzeD7zYM+f 2xzmSpwf5kBqCA9Z8KTJVVNqUOgoH9/bheOlNB10VMh+7o4BT4bxyGohE9BZg2TUxNh9 iDgzG9phaajGp3RgkjBpvct03OwEWq9EN/A0krwyuMFau/cHjFd+FTtp7jEK4PXeiNFt n3vcgMk52YmelU07cOcqNt0/mim9aew3AQziuLFiiC0WqCxHYLN1GUzheyiAG2YkkLFN eLLYtf9xzooK8RNLFeKXluy41fTcKO9Yg5ChHikjXJyAV2XlJHLFPMYh29AgJOGPwZSV l6Qw== X-Gm-Message-State: ALoCoQlrxyuuz1gDQFhiNYKvDuDNxWnzycUrMfm2ZyY+3HBoRETYlBHQKtqL8RpyzIzUn+p75dOR X-Received: by 10.14.109.5 with SMTP id r5mr4048482eeg.110.1388857082040; Sat, 04 Jan 2014 09:38:02 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id b41sm155187415eef.16.2014.01.04.09.38.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 Jan 2014 09:38:01 -0800 (PST) Message-ID: <52C846F7.6080806@dev.mellanox.co.il> Date: Sat, 04 Jan 2014 12:37:59 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Bernd Schubert , Alex Netes Subject: [PATCH v2 opensm] Try default partition config if parsing partitions.conf fails 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=ham 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 From: Bernd Schubert If partitions.conf is for some reason 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 Signed-off-by: Hal Rosenstock --- Change from v1: Based on Berd's original patch for this, this modifies osm_prtn_config_parse_file determination of is_parse_success to handle more cases than original proposed patch. -- 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..bd0ac67 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,13 @@ ib_api_status_t osm_prtn_make_partitions(osm_log_t * p_log, osm_subn_t * p_subn) } } + if (is_config && is_wrong_config) { + OSM_LOG(p_log, OSM_LOG_ERROR, "Partition configuration " + "in error; retrying with default config\n"); + 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..9bad7a7 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; file = fopen(file_name, "r"); if (!file) { @@ -714,6 +718,8 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, lineno = 0; + is_parse_success = FALSE; + while (fgets(line, sizeof(line) - 1, file) != NULL) { char *q, *p = line; @@ -724,6 +730,8 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, q = strchr(p, '#'); if (q) *q = '\0'; + else + is_parse_success = TRUE; do { int len; @@ -741,6 +749,7 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, "PARSE ERROR: line %d: " "internal: cannot create config\n", lineno); + is_parse_success = FALSE; break; } @@ -750,6 +759,7 @@ int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn, len = parse_part_conf(conf, p, lineno); if (len < 0) { + is_parse_success = FALSE; break; } @@ -764,5 +774,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; }