From patchwork Mon Nov 2 10:43:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Kliteynik X-Patchwork-Id: 56989 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA2AbtQW025611 for ; Mon, 2 Nov 2009 10:38:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754149AbZKBKiF (ORCPT ); Mon, 2 Nov 2009 05:38:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754150AbZKBKiF (ORCPT ); Mon, 2 Nov 2009 05:38:05 -0500 Received: from mail.mellanox.co.il ([194.90.237.43]:46248 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754149AbZKBKiD (ORCPT ); Mon, 2 Nov 2009 05:38:03 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from kliteyn@dev.mellanox.co.il) with SMTP; 2 Nov 2009 12:43:34 +0200 Received: from [10.4.1.29] ([10.4.1.29]) by mtlexch01.mtl.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 Nov 2009 12:38:06 +0200 Message-ID: <4AEEB7BE.3010406@dev.mellanox.co.il> Date: Mon, 02 Nov 2009 12:43:10 +0200 From: Yevgeny Kliteynik Reply-To: kliteyn@dev.mellanox.co.il User-Agent: Thunderbird 1.5.0.5 (X11/20060719) MIME-Version: 1.0 To: Sasha Khapyorsky CC: Linux RDMA Subject: [PATCH 3/3] opensm SA DB dump/restore: dump SA DB only if modified X-OriginalArrivalTime: 02 Nov 2009 10:38:06.0710 (UTC) FILETIME=[904D5160:01CA5BA8] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/opensm/include/opensm/osm_sa.h b/opensm/include/opensm/osm_sa.h index dad3142..35684cc 100644 --- a/opensm/include/opensm/osm_sa.h +++ b/opensm/include/opensm/osm_sa.h @@ -125,6 +125,7 @@ typedef struct osm_sa { atomic32_t sa_trans_id; osm_sa_mad_ctrl_t mad_ctrl; cl_timer_t sr_timer; + boolean_t dirty; cl_disp_reg_handle_t cpi_disp_h; cl_disp_reg_handle_t nr_disp_h; cl_disp_reg_handle_t pir_disp_h; @@ -178,6 +179,10 @@ typedef struct osm_sa { * mad_ctrl * Mad Controller * +* dirty +* A flag that denotes that SA DB is dirty and needs +* to be written to the dump file (if dumping is enabled) +* * SEE ALSO * SM object *********/ diff --git a/opensm/opensm/osm_inform.c b/opensm/opensm/osm_inform.c index c69ef7a..9155297 100644 --- a/opensm/opensm/osm_inform.c +++ b/opensm/opensm/osm_inform.c @@ -258,6 +258,7 @@ void osm_infr_insert_to_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log, #endif cl_qlist_insert_head(&p_subn->sa_infr_list, &p_infr->list_item); + p_subn->p_osm->sa.dirty = TRUE; OSM_LOG(p_log, OSM_LOG_DEBUG, "Dump after insertion (size %d)\n", cl_qlist_count(&p_subn->sa_infr_list)); @@ -283,6 +284,7 @@ void osm_infr_remove_from_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log, OSM_LOG_DEBUG); cl_qlist_remove_item(&p_subn->sa_infr_list, &p_infr->list_item); + p_subn->p_osm->sa.dirty = TRUE; osm_infr_delete(p_infr); diff --git a/opensm/opensm/osm_multicast.c b/opensm/opensm/osm_multicast.c index 7b7f1e0..b44e77a 100644 --- a/opensm/opensm/osm_multicast.c +++ b/opensm/opensm/osm_multicast.c @@ -205,6 +205,7 @@ osm_mcm_port_t *osm_mgrp_add_port(IN osm_subn_t * subn, osm_log_t * log, ++mgrp->full_members == 1) mgrp_send_notice(subn, log, mgrp, 66); + subn->p_osm->sa.dirty = TRUE; return mcm_port; } @@ -259,6 +260,8 @@ void osm_mgrp_remove_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp, mgrp_send_notice(subn, log, mgrp, 67); osm_mgrp_cleanup(subn, mgrp); } + + subn->p_osm->sa.dirty = TRUE; } void osm_mgrp_delete_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp, diff --git a/opensm/opensm/osm_sa.c b/opensm/opensm/osm_sa.c index a5eb796..849b734 100644 --- a/opensm/opensm/osm_sa.c +++ b/opensm/opensm/osm_sa.c @@ -719,7 +719,12 @@ static void sa_dump_all_sa(osm_opensm_t * p_osm, FILE * file) int osm_sa_db_file_dump(osm_opensm_t * p_osm) { - return opensm_dump_to_file(p_osm, "opensm-sa.dump", sa_dump_all_sa); + int res = 0; + if (p_osm->sa.dirty) { + res = opensm_dump_to_file(p_osm, "opensm-sa.dump", sa_dump_all_sa); + p_osm->sa.dirty = FALSE; + } + return res; } /* diff --git a/opensm/opensm/osm_sa_mcmember_record.c b/opensm/opensm/osm_sa_mcmember_record.c index c3e105f..575cbea 100644 --- a/opensm/opensm/osm_sa_mcmember_record.c +++ b/opensm/opensm/osm_sa_mcmember_record.c @@ -832,6 +832,7 @@ static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa, &(*pp_mgrp)->mcmember_rec.mgid, &(*pp_mgrp)->map_item); sa->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO] = *pp_mgrp; + sa->dirty = TRUE; Exit: OSM_LOG_EXIT(sa->p_log); return status; @@ -958,6 +959,7 @@ static void mcmr_rcv_leave_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw) /* remove port and/or update join state */ osm_mgrp_remove_port(sa->p_subn, sa->p_log, p_mgrp, p_mcm_port, &mcmember_rec); + sa->dirty = TRUE; CL_PLOCK_RELEASE(sa->p_lock); mcmr_rcv_respond(sa, p_madw, &mcmember_rec); @@ -1171,6 +1173,7 @@ static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw) if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG)) osm_dump_mc_record(sa->p_log, &mcmember_rec, OSM_LOG_DEBUG); + sa->dirty = TRUE; mcmr_rcv_respond(sa, p_madw, &mcmember_rec); Exit: @@ -1203,6 +1206,7 @@ static ib_api_status_t mcmr_rcv_new_mcmr(IN osm_sa_t * sa, State, Port Guid, and Proxy */ p_rec_item->rec = *p_rcvd_rec; cl_qlist_insert_tail(p_list, &p_rec_item->list_item); + sa->dirty = TRUE; Exit: OSM_LOG_EXIT(sa->p_log); diff --git a/opensm/opensm/osm_service.c b/opensm/opensm/osm_service.c index a38171d..39541c9 100644 --- a/opensm/opensm/osm_service.c +++ b/opensm/opensm/osm_service.c @@ -46,6 +46,7 @@ #include #include #include +#include /********************************************************************** **********************************************************************/ @@ -134,6 +135,7 @@ void osm_svcr_insert_to_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log, "Inserting new Service Record into Database\n"); cl_qlist_insert_head(&p_subn->sa_sr_list, &p_svcr->list_item); + p_subn->p_osm->sa.dirty = TRUE; OSM_LOG_EXIT(p_log); } @@ -149,6 +151,7 @@ void osm_svcr_remove_from_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log, p_svcr->service_record.service_id); cl_qlist_remove_item(&p_subn->sa_sr_list, &p_svcr->list_item); + p_subn->p_osm->sa.dirty = TRUE; OSM_LOG_EXIT(p_log); }