From patchwork Tue Feb 21 09:04:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9584065 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 B769C600C1 for ; Tue, 21 Feb 2017 09:05:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 984642875D for ; Tue, 21 Feb 2017 09:05:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89C0B288E2; Tue, 21 Feb 2017 09:05:07 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 D87862875D for ; Tue, 21 Feb 2017 09:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751107AbdBUJFF (ORCPT ); Tue, 21 Feb 2017 04:05:05 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:52366 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbdBUJFE (ORCPT ); Tue, 21 Feb 2017 04:05:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=78HDxKOs1672Ig6iiz3jQGQQ7HZea5qFNgQCzIJS83I=; b=UFze/PqQPFEUHuaXfM7aeqp/d ciEQ5pwyqvrpHIxecD5osy7l++8Hr/dLT82uF3L26XlqW9s4oKs1xblOlqXLM3a2iWFdAP6gGtYwX J6sxePyjPem8SrkxcC3zGW0cVYc+XLrJsyZMTeNWVIt1lOL5tRICDQH5ksrUTyxDtm/PXi0qGtNbu KPnfiY8TND03amnUvXWdpFUxclE+l7YeIvs4tfAmeYWZIrUMTHc3usGFtjYyW86r0rEKIqI9Viz1P Z4sffdy1wzmhBOh5Tdh7hWuer7lNBgMUb6s8ql/wwAASkGafo8oH02ma18m+0U03GeTy8/sT0mwpS EqkeucXhA==; Received: from [91.114.64.3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cg6NV-0002ZT-Ci; Tue, 21 Feb 2017 09:04:57 +0000 From: Christoph Hellwig To: axboe@kernel.dk, martin.petersen@oracle.com Cc: decui@microsoft.com, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH v2] scsi: zero per-cmd driver data before each I/O Date: Tue, 21 Feb 2017 10:04:55 +0100 Message-Id: <20170221090455.4633-1-hch@lst.de> X-Mailer: git-send-email 2.11.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Without this drivers that don't clear the state themselves can see off effects. For example Hyper-V VMs using the storvsc driver will often hang during boot due to uncleared Test Unit Ready failures. Fixes: e9c787e6 ("scsi: allocate scsi_cmnd structures as part of struct request") Signed-off-by: Christoph Hellwig Reported-by: Dexuan Cui Tested-by: Dexuan Cui Reviewed-by: Bart Van Assche --- Changes since V1: - use a single memset as suggested by Bart drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 90f65c8f487a..1d87a809944d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1166,7 +1166,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd) /* zero out the cmd, except for the embedded scsi_request */ memset((char *)cmd + sizeof(cmd->req), 0, - sizeof(*cmd) - sizeof(cmd->req)); + sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size); cmd->device = dev; cmd->sense_buffer = buf;