From patchwork Mon Oct 12 22:57:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vu Pham X-Patchwork-Id: 53258 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 n9CN8mFq008004 for ; Mon, 12 Oct 2009 23:08:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933214AbZJLXDx (ORCPT ); Mon, 12 Oct 2009 19:03:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933228AbZJLXDx (ORCPT ); Mon, 12 Oct 2009 19:03:53 -0400 Received: from p02c12o145.mxlogic.net ([208.65.145.78]:45601 "EHLO p02c12o145.mxlogic.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933214AbZJLXDw (ORCPT ); Mon, 12 Oct 2009 19:03:52 -0400 Received: from unknown [63.251.237.3] (EHLO p02c12o145.mxlogic.net) by p02c12o145.mxlogic.net(mxl_mta-6.4.0-0) with ESMTP id dd5b3da4.d30fcb90.74097.00-504.159021.p02c12o145.mxlogic.net (envelope-from ); Mon, 12 Oct 2009 17:03:57 -0600 (MDT) X-MXL-Hash: 4ad3b5dd7e752107-774a76f7aac0f30e8c4ec24b54f7fb228cf3ac92 Received: from unknown [63.251.237.3] by p02c12o145.mxlogic.net(mxl_mta-6.4.0-0) with SMTP id 2d4b3da4.0.73309.00-009.157965.p02c12o145.mxlogic.net (envelope-from ); Mon, 12 Oct 2009 17:00:11 -0600 (MDT) X-MXL-Hash: 4ad3b4fb638262e9-bca74597c78f2328aa4ab9d799f7232b006c08dc Received: from [10.2.1.145] ([10.2.1.145]) by mtiexch01.mti.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Oct 2009 16:00:22 -0700 Message-ID: <4AD3B466.8060908@mellanox.com> Date: Mon, 12 Oct 2009 15:57:42 -0700 From: Vu Pham User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Linux RDMA list Subject: [ofa-general][PATCH 4/4] SRP fail-over faster X-OriginalArrivalTime: 12 Oct 2009 23:00:22.0109 (UTC) FILETIME=[C6CB28D0:01CA4B8F] X-Spam: [F=0.2000000000; CM=0.500; S=0.200(2009092101)] X-MAIL-FROM: X-SOURCE-IP: [63.251.237.3] X-AnalysisOut: [v=1.0 c=1 a=V5TwBRVB48UA:10 a=xupnbh4h0YLOHZnncC45HQ==:17 ] X-AnalysisOut: [a=CbDCq_QkAAAA:8 a=PwJ2IG6fAAAA:8 a=AUd_NHdVAAAA:8 a=mK3sZ] X-AnalysisOut: [SMCjvaOSNj2TaAA:9 a=RUCRKCGXcsMEer-8iqgA:7 a=JbqkinxRLUtyw] X-AnalysisOut: [vXwap5Ea2eUg0cA:4 a=E3yz0KKPV6YA:10 a=JfD0Fch1gWkA:10 a=8X] X-AnalysisOut: [QPcrXN_eYyrj6t:21 a=0_tHxY8pDzgPiBFO:21] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Index: ofed_kernel/drivers/infiniband/ulp/srp/ib_srp.c =================================================================== --- ofed_kernel.orig/drivers/infiniband/ulp/srp/ib_srp.c +++ ofed_kernel/drivers/infiniband/ulp/srp/ib_srp.c @@ -2071,6 +2120,77 @@ return NULL; } +static void srp_event_handler(struct ib_event_handler *handler, + struct ib_event *event) +{ + struct srp_device *srp_dev = + ib_get_client_data(event->device, &srp_client); + struct srp_host *host, *tmp_host; + struct srp_target_port *target, *tmp_target; + + if (!srp_dev || srp_dev->dev != event->device) + return; + + printk(KERN_WARNING PFX "ASYNC event= %d on device= %s\n", + event->event, srp_dev->dev->name); + + switch (event->event) { + case IB_EVENT_PORT_ERR: + list_for_each_entry_safe(host, tmp_host, + &srp_dev->dev_list, list) { + if (event->element.port_num == host->port) { + spin_lock(&host->target_lock); + list_for_each_entry_safe(target, tmp_target, + &host->target_list, list) { + unsigned long flags; + + spin_lock_irqsave(target->scsi_host->host_lock, + flags); + if (!target->qp_in_error && + target->state == SRP_TARGET_LIVE) + srp_qp_err_add_timer(target, + srp_dev_loss_tmo); + spin_unlock_irqrestore(target->scsi_host->host_lock, + flags); + } + spin_unlock(&host->target_lock); + } + } + break; + case IB_EVENT_PORT_ACTIVE: + case IB_EVENT_LID_CHANGE: + case IB_EVENT_PKEY_CHANGE: + case IB_EVENT_SM_CHANGE: + list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, + list) { + if (event->element.port_num == host->port) { + spin_lock(&host->target_lock); + list_for_each_entry_safe(target, tmp_target, + &host->target_list, list) { + unsigned long flags; + + spin_lock_irqsave(target->scsi_host->host_lock, + flags); + if (timer_pending(&target->qp_err_timer) + && !target->qp_in_error) { + shost_printk(KERN_WARNING PFX, + target->scsi_host, + "delete qp_in_err timer\n"); + del_timer(&target->qp_err_timer); + } + spin_unlock_irqrestore(target->scsi_host->host_lock, + flags); + } + spin_unlock(&host->target_lock); + } + } + break; + default: + break; + } + +} + static void srp_add_one(struct ib_device *device) { struct srp_device *srp_dev; @@ -2116,6 +2228,11 @@ if (IS_ERR(srp_dev->mr)) goto err_pd; + INIT_IB_EVENT_HANDLER(&srp_dev->event_handler, srp_dev->dev, + srp_event_handler); + if (ib_register_event_handler(&srp_dev->event_handler)) + goto err_pd; + memset(&fmr_param, 0, sizeof fmr_param); fmr_param.pool_size = SRP_FMR_POOL_SIZE; fmr_param.dirty_watermark = SRP_FMR_DIRTY_SIZE; @@ -2160,6 +2284,8 @@ srp_dev = ib_get_client_data(device, &srp_client); + ib_unregister_event_handler(&srp_dev->event_handler); + list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { device_unregister(&host->dev); /* Index: ofed_kernel/drivers/infiniband/ulp/srp/ib_srp.h =================================================================== --- ofed_kernel.orig/drivers/infiniband/ulp/srp/ib_srp.h +++ ofed_kernel/drivers/infiniband/ulp/srp/ib_srp.h @@ -88,6 +88,7 @@ struct srp_device { struct ib_device *dev; struct ib_pd *pd; struct ib_mr *mr; + struct ib_event_handler event_handler; struct ib_fmr_pool *fmr_pool; int fmr_page_shift; int fmr_page_size;