From patchwork Wed Jun 28 05:58:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9813521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0FC676020A for ; Wed, 28 Jun 2017 05:59:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 044BA280CF for ; Wed, 28 Jun 2017 05:59:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED565283CB; Wed, 28 Jun 2017 05:59:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F3D9280CF for ; Wed, 28 Jun 2017 05:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751615AbdF1F7l (ORCPT ); Wed, 28 Jun 2017 01:59:41 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:59669 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751579AbdF1F7k (ORCPT ); Wed, 28 Jun 2017 01:59:40 -0400 X-IronPort-AV: E=Sophos;i="5.40,274,1496073600"; d="scan'208";a="29784203" Received: from sjappemgw12.hgst.com (HELO sjappemgw11.hgst.com) ([199.255.44.66]) by ob1.hgst.iphmx.com with ESMTP; 28 Jun 2017 13:59:40 +0800 Received: from washi.fujisawa.hgst.com ([10.80.170.19]) by sjappemgw11.hgst.com with ESMTP; 27 Jun 2017 22:59:04 -0700 From: Damien Le Moal To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, "Nicholas A . Bellinger" Cc: "Martin K . Petersen" , Hannes Reinecke , Bart Van Assche Subject: [PATCH 3/5] target: pscsi: Fix sense data handling Date: Wed, 28 Jun 2017 14:58:58 +0900 Message-Id: <20170628055900.22889-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170628055900.22889-1-damien.lemoal@wdc.com> References: <20170628055900.22889-1-damien.lemoal@wdc.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On completion of a request sent to the target backstore device, pscsi_req_done() calls target_complete_cmd() which in turn will execute pscsi_transport_complete(). In case of a failed request, this last function will copy the target request sense data to the initiator side request sense data. However, in pscsi_req_done(), the sense data is retreived from the request after calling target_complete_cmd(), which result in the sense data always conatining zeroes. Simply fix this by copying the sense data before calling target_complete_cmd(). Signed-off-by: Damien Le Moal --- drivers/target/target_core_pscsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 97d0318..959d9f6 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -1065,6 +1065,8 @@ static void pscsi_req_done(struct request *req, int uptodate) pt->pscsi_result); } + memcpy(pt->pscsi_sense, scsi_req(req)->sense, TRANSPORT_SENSE_BUFFER); + switch (host_byte(pt->pscsi_result)) { case DID_OK: target_complete_cmd(cmd, cmd->scsi_status); @@ -1077,7 +1079,6 @@ static void pscsi_req_done(struct request *req, int uptodate) break; } - memcpy(pt->pscsi_sense, scsi_req(req)->sense, TRANSPORT_SENSE_BUFFER); __blk_put_request(req->q, req); kfree(pt); }