From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755800AbZEPASk (ORCPT ); Fri, 15 May 2009 20:18:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754392AbZEPAS3 (ORCPT ); Fri, 15 May 2009 20:18:29 -0400 Received: from mail-pz0-f115.google.com ([209.85.222.115]:61107 "EHLO mail-pz0-f115.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753907AbZEPAS2 (ORCPT ); Fri, 15 May 2009 20:18:28 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=WRxzEQgZ4RHKYS0KkXKIL7cAC1qzNJf/bWOzlHM70cBj1IfjD6o0e8+WxujMYAD1pr WoPLeq+VOdbVhsWR2H/TPujUI2n9uzyLtsqLKz/2w66/qiMG2pvE1FCN2VYsMg7QuxGk rPsvOzRZMDNZvK71VrEwl0j8twz6qPvJB2v38= Message-ID: <4A0E0650.1020500@gmail.com> Date: Sat, 16 May 2009 09:18:24 +0900 From: Tejun Heo User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: Jens Axboe , James Bottomley , Boaz Harrosh , Linux Kernel , linux-scsi , IDE/ATA development list , Bartlomiej Zolnierkiewicz , Borislav Petkov , Pete Zaitcev , Sergei Shtylyov , Eric Moore , "Darrick J. Wong" Subject: [PATCH UPDATED block#for-2.6.31 2/3] block: set rq->resid_len to blk_rq_bytes() on issue References: <4A0D86DB.9000203@kernel.org> <4A0D87D2.7090806@gmail.com> In-Reply-To: <4A0D87D2.7090806@gmail.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit c3a4d78c580de4edc9ef0f7c59812fb02ceb037f, while introducing rq->resid_len, the default value of residue count was changed from full count to zero. The conversion was done under the assumption that when a request fails residue count wasn't defined. However, Boaz and James pointed out that this wasn't true and the residue count should be preserved for failed requests too. This patchset restores the original behavior by setting rq->resid_len to blk_rq_bytes(rq) on issue and restoring explicit clearing in affected drivers. While at it, take advantage of the fact that rq->resid_len is set to full count where applicable. * ide-cd: rq->resid_len cleared on pc success * mptsas: req->resid_len cleared on success * sas_expander: rsp/req->resid_len cleared on success * mpt2sas_transport: req->resid_len cleared on success * ide-cd, ide-tape, mptsas, sas_host_smp, mpt2sas_transport, ub: take advantage of initial full count to simplify code Signed-off-by: Tejun Heo Cc: Jens Axboe Cc: Boaz Harrosh Cc: James Bottomley Cc: Pete Zaitcev Cc: Bartlomiej Zolnierkiewicz Cc: Borislav Petkov Cc: Sergei Shtylyov Cc: Eric Moore Cc: Darrick J. Wong --- ub updated per Pete's comment. Thanks. block/blk-core.c | 1 + drivers/block/ub.c | 6 ++++-- drivers/ide/ide-cd.c | 4 ++-- drivers/ide/ide-tape.c | 2 +- drivers/message/fusion/mptsas.c | 3 ++- drivers/scsi/libsas/sas_expander.c | 4 ++++ drivers/scsi/libsas/sas_host_smp.c | 3 --- drivers/scsi/mpt2sas/mpt2sas_transport.c | 4 ++-- 8 files changed, 16 insertions(+), 11 deletions(-) Index: block/block/blk-core.c =================================================================== --- block.orig/block/blk-core.c +++ block/block/blk-core.c @@ -2198,6 +2198,7 @@ void blk_rq_bio_prep(struct request_queu rq->buffer = bio_data(bio); } rq->__data_len = bio->bi_size; + rq->resid_len = bio->bi_size; rq->bio = rq->biotail = bio; if (bio->bi_bdev) Index: block/drivers/ide/ide-cd.c =================================================================== --- block.orig/drivers/ide/ide-cd.c +++ block/drivers/ide/ide-cd.c @@ -699,6 +699,7 @@ static ide_startstop_t cdrom_newpc_intr( out_end: if (blk_pc_request(rq) && rc == 0) { + rq->resid_len = 0; blk_end_request_all(rq, 0); hwif->rq = NULL; } else { @@ -718,8 +719,7 @@ out_end: /* make sure it's fully ended */ if (blk_fs_request(rq) == 0) { - rq->resid_len = blk_rq_bytes(rq) - - (cmd->nbytes - cmd->nleft); + rq->resid_len -= cmd->nbytes - cmd->nleft; if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE)) rq->resid_len += cmd->last_xfer_len; } Index: block/drivers/ide/ide-tape.c =================================================================== --- block.orig/drivers/ide/ide-tape.c +++ block/drivers/ide/ide-tape.c @@ -380,7 +380,7 @@ static int ide_tape_callback(ide_drive_t } tape->first_frame += blocks; - rq->resid_len = blk_rq_bytes(rq) - blocks * tape->blk_size; + rq->resid_len -= blocks * tape->blk_size; if (pc->error) { uptodate = 0; Index: block/drivers/message/fusion/mptsas.c =================================================================== --- block.orig/drivers/message/fusion/mptsas.c +++ block/drivers/message/fusion/mptsas.c @@ -1357,7 +1357,8 @@ static int mptsas_smp_handler(struct Scs smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply; memcpy(req->sense, smprep, sizeof(*smprep)); req->sense_len = sizeof(*smprep); - rsp->resid_len = blk_rq_bytes(rsp) - smprep->ResponseDataLength; + req->resid_len = 0; + rsp->resid_len -= smprep->ResponseDataLength; } else { printk(MYIOC_s_ERR_FMT "%s: smp passthru reply failed to be returned\n", ioc->name, __func__); Index: block/drivers/scsi/libsas/sas_expander.c =================================================================== --- block.orig/drivers/scsi/libsas/sas_expander.c +++ block/drivers/scsi/libsas/sas_expander.c @@ -1937,7 +1937,11 @@ int sas_smp_handler(struct Scsi_Host *sh if (ret > 0) { /* positive number is the untransferred residual */ rsp->resid_len = ret; + req->resid_len = 0; ret = 0; + } else if (ret == 0) { + rsp->resid_len = 0; + req->resid_len = 0; } return ret; Index: block/drivers/scsi/libsas/sas_host_smp.c =================================================================== --- block.orig/drivers/scsi/libsas/sas_host_smp.c +++ block/drivers/scsi/libsas/sas_host_smp.c @@ -176,9 +176,6 @@ int sas_smp_host_handler(struct Scsi_Hos resp_data[1] = req_data[1]; resp_data[2] = SMP_RESP_FUNC_UNK; - req->resid_len = blk_rq_bytes(req); - rsp->resid_len = blk_rq_bytes(rsp); - switch (req_data[1]) { case SMP_REPORT_GENERAL: req->resid_len -= 8; Index: block/drivers/scsi/mpt2sas/mpt2sas_transport.c =================================================================== --- block.orig/drivers/scsi/mpt2sas/mpt2sas_transport.c +++ block/drivers/scsi/mpt2sas/mpt2sas_transport.c @@ -1170,8 +1170,8 @@ transport_smp_handler(struct Scsi_Host * memcpy(req->sense, mpi_reply, sizeof(*mpi_reply)); req->sense_len = sizeof(*mpi_reply); - rsp->resid_len = blk_rq_bytes(rsp) - - mpi_reply->ResponseDataLength; + req->resid_len = 0; + rsp->resid_len -= mpi_reply->ResponseDataLength; } else { dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s - no reply\n", ioc->name, __func__)); Index: block/drivers/block/ub.c =================================================================== --- block.orig/drivers/block/ub.c +++ block/drivers/block/ub.c @@ -781,8 +781,10 @@ static void ub_rw_cmd_done(struct ub_dev if (cmd->error == 0) { if (blk_pc_request(rq)) { - if (cmd->act_len < blk_rq_bytes(rq)) - rq->resid_len = blk_rq_bytes(rq) - cmd->act_len; + if (cmd->act_len >= rq->resid_len) + rq->resid_len = 0; + else + rq->resid_len -= cmd->act_len; scsi_status = 0; } else { if (cmd->act_len != cmd->len) {