From patchwork Wed Aug 28 08:19:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 2850562 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 D31E69F313 for ; Wed, 28 Aug 2013 08:19:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C19122035D for ; Wed, 28 Aug 2013 08:19:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 919A420364 for ; Wed, 28 Aug 2013 08:19:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752537Ab3H1ITB (ORCPT ); Wed, 28 Aug 2013 04:19:01 -0400 Received: from mail-bk0-f47.google.com ([209.85.214.47]:33494 "EHLO mail-bk0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752505Ab3H1IS7 (ORCPT ); Wed, 28 Aug 2013 04:18:59 -0400 Received: by mail-bk0-f47.google.com with SMTP id mx12so1991011bkb.6 for ; Wed, 28 Aug 2013 01:18:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type; bh=2KH4ldP1O+r9Lkmgg9+FXmYXCeHYpFFnczku7P+ihTo=; b=GRApCRuuZV1nDkHDMvj0han87JsvDIhy8cLEFPtZ62L5MiiCOD4puO57BFjw50IiSb 9DLVbttNyV/0DY5g7V304HFI9CFyoMbQp3rF0RNzngJrPAP82zUvaHaKWd9zeGhRuAMZ VNiB4kmOOoac73pK8/qXD3imUphiRXfmpt9uPXcSmSikkLHPxxsNfe6MlH7+h53rBgSr 4D8nIf2/jLk9CPD1DGFQ/FqefCT+ZAsLA6nVEYagcd/4RwuTGlvy0/59m8uaTvZgGyVs KDcbzdDNOzFUw6Z2xtJwWparUErSxbQdUKofPEnfaXFV+oexeOcGGpXv0fbGxJKQiN9b QD6A== X-Gm-Message-State: ALoCoQk0F4wxn9jxCqWm8R46JAUNvUYA/qsnTC0iayGPRp4woTiEUEZ1AmMEF3WPT42V2wbx4tIo X-Received: by 10.204.167.74 with SMTP id p10mr8546402bky.26.1377677938545; Wed, 28 Aug 2013 01:18:58 -0700 (PDT) Received: from [192.168.88.32] ([62.217.45.26]) by mx.google.com with ESMTPSA id pk7sm5417186bkb.2.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 01:18:57 -0700 (PDT) Message-ID: <521DB28C.9020803@profitbricks.com> Date: Wed, 28 Aug 2013 10:19:24 +0200 From: Jack Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: David Dillow , Roland Dreier CC: linux-rdma , Sebastian Riemer , Bart Van Assche , Jack Wang Subject: [PATCHv2] IB/srp: add change_queue_depth and change_queue_type support Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, 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 Hi, Below patch is new version which address comments from Bart. From 62d87b4d546066b251e44a3cb468b16783df7ee4 Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Mon, 26 Aug 2013 15:50:03 +0200 Subject: [PATCH] IB/srp: add change_queue_depth/change_queue_type support Currently, it's not possible to change queue depth for device behind SRP host. Sometimes, we need to adjust queue_depth for performance reason(eg storage busy, we need lower queue_depth to avoid running into SCSI error handler), so this patch add support for SRP driver. Signed-off-by: Jack Wang Tested-by: Bart Van Assche Acked-by: David Dillow --- drivers/infiniband/ulp/srp/ib_srp.c | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) { @@ -2260,6 +2312,8 @@ static struct scsi_host_template srp_template = { .slave_configure = srp_slave_configure, .info = srp_target_info, .queuecommand = srp_queuecommand, + .change_queue_depth = srp_change_queue_depth, + .change_queue_type = srp_change_queue_type, .eh_abort_handler = srp_abort, .eh_device_reset_handler = srp_reset_device, .eh_host_reset_handler = srp_reset_host, From e8d655fec4ac74a6af6a0b2471173c74e7c13f51 Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Mon, 26 Aug 2013 15:50:03 +0200 Subject: [PATCH] IB/srp: add change_queue_depth/change_queue_type support Currently, it's not possible to change queue depth for device behind SRP host. Sometimes, we need to adjust queue_depth for performance reason(eg storage busy, we need lower queue_depth to avoid running into SCSI error handler), so this patch add support for SRP driver. Signed-off-by: Jack Wang --- drivers/infiniband/ulp/srp/ib_srp.c | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 06a3e4b..2713e02 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -1875,6 +1876,57 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) return 0; } +/** + * srp_change_queue_type - changing device queue tag type + * @sdev: scsi device struct + * @tag_type: requested tag type + * + * Returns queue tag type. + */ +static int +srp_change_queue_type(struct scsi_device *sdev, int tag_type) +{ + if (sdev->tagged_supported) { + scsi_set_tag_type(sdev, tag_type); + if (tag_type) + scsi_activate_tcq(sdev, sdev->queue_depth); + else + scsi_deactivate_tcq(sdev, sdev->queue_depth); + } else + tag_type = 0; + + return tag_type; +} + +/** + * srp_change_queue_depth - setting device queue depth + * @sdev: scsi device struct + * @qdepth: requested queue depth + * @reason: SCSI_QDEPTH_DEFAULT/SCSI_QDEPTH_QFULL/SCSI_QDEPTH_RAMP_UP + * (see include/scsi/scsi_host.h for definition) + * + * Returns queue depth. + */ +static int +srp_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) +{ + struct Scsi_Host *shost = sdev->host; + int max_depth; + if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP) { + max_depth = shost->can_queue; + if (!sdev->tagged_supported) + max_depth = 1; + if (qdepth > max_depth) + qdepth = max_depth; + scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); + } else if (reason == SCSI_QDEPTH_QFULL) + scsi_track_queue_full(sdev, qdepth); + else + return -EOPNOTSUPP; + + return sdev->queue_depth; +} + static int srp_send_tsk_mgmt(struct srp_target_port *target, u64 req_tag, unsigned int lun, u8 func) { @@ -2260,6 +2312,8 @@ static struct scsi_host_template srp_template = { .slave_configure = srp_slave_configure, .info = srp_target_info, .queuecommand = srp_queuecommand, + .change_queue_depth = srp_change_queue_depth, + .change_queue_type = srp_change_queue_type, .eh_abort_handler = srp_abort, .eh_device_reset_handler = srp_reset_device, .eh_host_reset_handler = srp_reset_host, -- 1.7.10.4