linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Pete Zaitcev <zaitcev@redhat.com>
Cc: Jens Axboe <jens.axboe@oracle.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Boaz Harrosh <bharrosh@panasas.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	IDE/ATA development list <linux-ide@vger.kernel.org>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	Borislav Petkov <petkovbb@googlemail.com>,
	Sergei Shtylyov <sshtylyov@ru.mvista.com>,
	Eric Moore <Eric.Moore@lsi.com>,
	"Darrick J. Wong" <djwong@us.ibm.com>
Subject: Re: [PATCH block#for-2.6.31 2/3] block: set rq->resid_len to blk_rq_bytes() on issue
Date: Sat, 16 May 2009 07:14:44 +0900	[thread overview]
Message-ID: <4A0DE954.4020102@gmail.com> (raw)
In-Reply-To: <20090515112901.84d4dd97.zaitcev@redhat.com>

Pete Zaitcev wrote:
> On Sat, 16 May 2009 00:18:42 +0900, Tejun Heo <htejun@gmail.com> wrote:
> 
>> In commit c3a4d78c580de4edc9ef0f7c59812fb02ceb037f, while introducing
>> rq->resid_len, the default value of residue count was changed from
>> full count to zero. []
> 
> So it's not a residue anymore, right? You should've renamed it to
> rq->count or something, then. Now we have this:

It still is.  It just is restoring the original behavior.

>> +++ block/drivers/block/ub.c
>> @@ -781,8 +781,7 @@ 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;
>> +			rq->resid_len -= min(cmd->act_len, rq->resid_len);
>>  			scsi_status = 0;
> 
> You are subtracting resid_len from itself. Just how in the world
> can this be correct?
>
> Even it if is, in fact, correct, it's such an eggregious violation
> of good style, that your good programmer's card is going to lose
> a big coupon and have a hole punched in it.

The original code was

 if (cmd->act_len >= rq->data_len)
	rq->data_len = 0;
 else
	rq->data_len -= cmd->act_len

So, I could have written

 if (cmd->act_len >= rq->resid_len)
	rq->resid_len = 0;
 else
	rq->resid_len -= cmd->act_len

Instead I wrote

 rq->resid_len -= min(cmd->act_len, rq->resid_len);

It's just capping the amount to be subtracted so that resid_len
doesn't underflow.  What is so wrong or bad style about that?

> This is not in Linus' tree yet, but I'm going to take a hard look
> at this once it shows up.

It would be great if you do before it hits Linus's tree.

Thanks.

-- 
tejun

  reply	other threads:[~2009-05-15 22:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4A0D86DB.9000203@kernel.org>
2009-05-15 15:18 ` [PATCH block#for-2.6.31 2/3] block: set rq->resid_len to blk_rq_bytes() on issue Tejun Heo
2009-05-15 17:31 ` [PATCH block#for-2.6.31 1/3] ub: use __blk_end_request_all() Pete Zaitcev
2009-05-15 22:19   ` Tejun Heo
     [not found] ` <4A0D87D2.7090806@gmail.com>
2009-05-15 15:19   ` [PATCH block#for-2.6.31 3/3] bio: always copy back data for copied kernel requests Tejun Heo
2009-05-15 15:38   ` [PATCH block#for-2.6.31 2/3] block: set rq->resid_len to blk_rq_bytes() on issue Sergei Shtylyov
2009-05-15 22:18     ` Tejun Heo
2009-05-16 12:29       ` Sergei Shtylyov
2009-05-16 13:48         ` Tejun Heo
2009-05-15 17:29   ` Pete Zaitcev
2009-05-15 22:14     ` Tejun Heo [this message]
2009-05-15 23:16       ` Pete Zaitcev
2009-05-16  0:14         ` Tejun Heo
2009-05-16  0:18   ` [PATCH UPDATED " Tejun Heo
2009-05-16  7:13   ` [PATCH " Borislav Petkov
2009-05-16 13:52     ` Tejun Heo
     [not found]   ` <4A0E0650.1020500@gmail.com>
2009-05-17  8:48     ` [PATCH UPDATED " Boaz Harrosh
2009-05-17 11:32       ` Tejun Heo
2009-05-17 11:41         ` Tejun Heo
2009-05-17 12:05     ` [PATCH UPDATED2 " Tejun Heo
2009-05-18 12:49       ` Jens Axboe
2009-05-19  9:14         ` Tejun Heo
2009-05-19  9:17           ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A0DE954.4020102@gmail.com \
    --to=htejun@gmail.com \
    --cc=Eric.Moore@lsi.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=bharrosh@panasas.com \
    --cc=bzolnier@gmail.com \
    --cc=djwong@us.ibm.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=petkovbb@googlemail.com \
    --cc=sshtylyov@ru.mvista.com \
    --cc=zaitcev@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).