From patchwork Thu Oct 22 23:17:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vu Pham X-Patchwork-Id: 55506 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 n9MNBtN2019729 for ; Thu, 22 Oct 2009 23:17:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752347AbZJVXRm (ORCPT ); Thu, 22 Oct 2009 19:17:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751542AbZJVXRm (ORCPT ); Thu, 22 Oct 2009 19:17:42 -0400 Received: from p02c12o145.mxlogic.net ([208.65.145.78]:51970 "EHLO p02c12o145.mxlogic.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751120AbZJVXRl (ORCPT ); Thu, 22 Oct 2009 19:17:41 -0400 Received: from unknown [63.251.237.3] (EHLO mtiexch01.mti.com) by p02c12o145.mxlogic.net(mxl_mta-6.4.0-1) with ESMTP id 718e0ea4.0.233723.00-013.453324.p02c12o145.mxlogic.net (envelope-from ); Thu, 22 Oct 2009 17:17:45 -0600 (MDT) X-MXL-Hash: 4ae0e8191dace0ac-9053e7b5d770a18b4ba2eebef038e2c10334e807 Received: from [10.2.1.145] ([10.2.1.145]) by mtiexch01.mti.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 22 Oct 2009 16:20:33 -0700 Message-ID: <4AE0E817.2000802@mellanox.com> Date: Thu, 22 Oct 2009 16:17:43 -0700 From: Vu Pham User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Bart Van Assche CC: Linux RDMA list Subject: Re: [ofa-general][PATCH 4/4] SRP fail-over faster References: <4AD3B466.8060908@mellanox.com> In-Reply-To: X-OriginalArrivalTime: 22 Oct 2009 23:20:33.0718 (UTC) FILETIME=[41198560:01CA536E] X-Spam: [F=0.2000000000; CM=0.500; S=0.200(2009101401)] X-MAIL-FROM: X-SOURCE-IP: [63.251.237.3] X-AnalysisOut: [v=1.0 c=1 a=ZE40ZsVMkSEA:10 a=xupnbh4h0YLOHZnncC45HQ==:17 ] X-AnalysisOut: [a=gy_SgthQ5YpZp0eBz80A:9 a=DSh71V3OJ_VphX_AkjM0X4fp-CgA:4 ] X-AnalysisOut: [a=yuGsItjZKxr1QzMp:21 a=xvDdLtc4UtdUv3kC:21 a=CbDCq_QkAAAA] X-AnalysisOut: [:8 a=u_UJjTHcqt4SnFy8AfAA:9 a=Xq_BYg6E9ZkY2ImPMvoA:7 a=Io-] X-AnalysisOut: [gwmqWuqr-TCV9AOtQ91zJQlMA:4 a=E3yz0KKPV6YA:10 a=-RL3HOEC8y] X-AnalysisOut: [DzSpFU:21 a=33OpPVf364V_vMQJ:21] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 12404d5..88dbc17 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2058,6 +2058,81 @@ free_host: 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: + spin_lock(&srp_dev->dev_lock); + 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, + target->device_loss_timeout); + spin_unlock_irqrestore(target->scsi_host->host_lock, + flags); + } + spin_unlock(&host->target_lock); + } + } + spin_unlock(&srp_dev->dev_lock); + break; + case IB_EVENT_PORT_ACTIVE: + case IB_EVENT_LID_CHANGE: + case IB_EVENT_PKEY_CHANGE: + case IB_EVENT_SM_CHANGE: + spin_lock(&srp_dev->dev_lock); + 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); + } + } + spin_unlock(&srp_dev->dev_lock); + break; + default: + break; + } + +} + static void srp_add_one(struct ib_device *device) { struct srp_device *srp_dev; @@ -2090,6 +2165,7 @@ static void srp_add_one(struct ib_device *device) srp_dev->fmr_page_mask = ~((u64) srp_dev->fmr_page_size - 1); INIT_LIST_HEAD(&srp_dev->dev_list); + spin_lock_init(&srp_dev->dev_lock); srp_dev->dev = device; srp_dev->pd = ib_alloc_pd(device); @@ -2103,6 +2179,11 @@ static void srp_add_one(struct ib_device *device) 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; @@ -2154,6 +2235,9 @@ static void srp_remove_one(struct ib_device *device) srp_dev = ib_get_client_data(device, &srp_client); + ib_unregister_event_handler(&srp_dev->event_handler); + + spin_lock(&srp_dev->dev_lock); list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { device_unregister(&host->dev); /* @@ -2193,6 +2277,7 @@ static void srp_remove_one(struct ib_device *device) kfree(host); } + spin_unlock(&srp_dev->dev_lock); if (srp_dev->fmr_pool) ib_destroy_fmr_pool(srp_dev->fmr_pool); diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index daa4bf7..74d1f09 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h @@ -86,8 +86,10 @@ enum srp_request_type { struct srp_device { struct list_head dev_list; struct ib_device *dev; + spinlock_t dev_lock; 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;