bcache: remove the redundant judgment on bi_size
OK. Thanks for our explanation. ^_^
Feng fei
-----邮件原件-----
发件人: Coly Li [mailto:[email protected]]
发送时间: 2021年8月31日 9:35
收件人: xifengfei (RD) <[email protected]>
抄送: [email protected]; [email protected]; [email protected] 主题: Re: [PATCH] bcache: remove the redundant judgment on bi_size
Quoted 6 lines · Xifengfei
(Sorry, there was an obvious typo in the last email) Thanks a lot. I understand the purpose.
So is the original judgment process too complicated? Can we judgebi_sizedirectly? This will be more concise
Review static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) · line 429
Quoted 8 lines
(quoted diff) +1
-1@@ -423,7 +423,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) add_sequential(task); i->sequential = 0; found: - if (i->sequential + bio->bi_iter.bi_size > i->sequential) + if (bio->bi_iter.bi_size) i->sequential += bio->bi_iter.bi_size; i->last = bio_end_sector(bio);
The above change works, but the code readability decreased because how/why i->sequential is maintained is not that directly visible.
This is a difference of coding styles. IMHO for this particular case, the readability is more important than less CPU instructions.
Thanks.
Coly Li
Quoted 39 lines
Thanks
Fengfei-----邮件原件-----
发件人: Coly Li [mailto:[email protected]]
发送时间: 2021年8月29日 15:50
收件人: xifengfei (RD) <[email protected]>
抄送: [email protected]; [email protected]; [email protected]
主题: Re: [PATCH] bcache: remove the redundant judgment onbi_sizeQuoted 4 lines · Fengfei Xi
The
bi_sizeis unsigned int type data not less than 0, so we can directly addbi_sizewithout extra judgmentSigned-off-by Fengfei Xi <[email protected]>NACK. The check is necessary to avoid redundant and unnecessary memory write.
Coly Li
Quoted 19 lines
--- drivers/md/bcache/request.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)(quoted diff) +0
-0
b/drivers/md/bcache/request.cindex6d1de889b..2788eec3a100644drivers/md/bcache/request.c +1
-3@@ -423,9 +423,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)add_sequential (task); i->sequential =0 ; found: -if (i->sequential + bio->bi_iter.bi_size > i->sequential) - i->sequential += bio->bi_iter.bi_size; - + i->sequential += bio->bi_iter.bi_size; i->last =bio_end_sector (bio); i->jiffies = jiffies +msecs_to_jiffies (5000 ); task->sequential_io = i->sequential;