From patchwork Thu Nov 19 12:24:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 61282 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAJCPE1K016624 for ; Thu, 19 Nov 2009 12:25:14 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 4528661BD72; Thu, 19 Nov 2009 07:25:14 -0500 (EST) Received: from int-mx05.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id nAJCPBK5024727 for ; Thu, 19 Nov 2009 07:25:11 -0500 Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.12]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAJCPARv001024 for ; Thu, 19 Nov 2009 07:25:10 -0500 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAJCOsmm010149 for ; Thu, 19 Nov 2009 07:24:55 -0500 Received: from relay1.suse.de (mail2.suse.de [195.135.221.8]) by mx2.suse.de (Postfix) with ESMTP id 8402486391; Thu, 19 Nov 2009 13:24:54 +0100 (CET) Date: Thu, 19 Nov 2009 13:24:54 +0100 To: James Bottomley User-Agent: Heirloom mailx 12.2 01/07/07 MIME-Version: 1.0 Message-Id: <20091119122454.71A7D3A174@ochil.suse.de> From: hare@suse.de (Hannes Reinecke) X-RedHat-Spam-Score: -3.765 (AWL,RCVD_IN_DNSWL_MED) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.12 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, linux-scsi@vger.kernel.org Subject: [dm-devel] [PATCH] Always pass result and sense on request completion X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index cc0a06f..10aa084 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -722,23 +722,19 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) sense_deferred = scsi_sense_is_deferred(&sshdr); } - if (blk_pc_request(req)) { /* SG_IO ioctl from block level */ - req->errors = result; - if (result) { - if (sense_valid && req->sense) { - /* - * SG_IO wants current and deferred errors - */ - int len = 8 + cmd->sense_buffer[7]; + req->errors = result; + if (sense_valid && req->sense) { + int len = 8 + cmd->sense_buffer[7]; + + if (len > SCSI_SENSE_BUFFERSIZE) + len = SCSI_SENSE_BUFFERSIZE; + memcpy(req->sense, cmd->sense_buffer, len); + req->sense_len = len; + } - if (len > SCSI_SENSE_BUFFERSIZE) - len = SCSI_SENSE_BUFFERSIZE; - memcpy(req->sense, cmd->sense_buffer, len); - req->sense_len = len; - } - if (!sense_deferred) - error = -EIO; - } + if (blk_pc_request(req)) { /* SG_IO ioctl from block level */ + if ((result) && (!sense_deferred)) + error = -EIO; req->resid_len = scsi_get_resid(cmd);