From: Boaz Harrosh <bharrosh@panasas.com>
To: Tejun Heo <htejun@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
axboe@kernel.dk, linux-kernel@vger.kernel.org,
bzolnier@gmail.com
Subject: Re: [PATCH UPDATED 09/14] block: clean up request completion API
Date: Thu, 23 Apr 2009 12:43:06 +0300 [thread overview]
Message-ID: <49F0382A.6050306@panasas.com> (raw)
In-Reply-To: <49EFCD82.4050000@gmail.com>
On 04/23/2009 05:08 AM, Tejun Heo wrote:
> Request completion has gone through several changes and became a bit
> messy over the time. Clean it up.
>
> 1. end_that_request_data() is a thin wrapper around
> end_that_request_data_first() which checks whether bio is NULL
> before doing anything and handles bidi completion.
> blk_update_request() is a thin wrapper around
> end_that_request_data() which clears nr_sectors on the last
> iteration but doesn't use the bidi completion.
>
> Clean it up by moving the initial bio NULL check and nr_sectors
> clearing on the last iteration into end_that_request_data() and
> renaming it to blk_update_request(), which makes blk_end_io() the
> only user of end_that_request_data(). Collapse
> end_that_request_data() into blk_end_io().
>
> 2. There are four visible completion variants - blk_end_request(),
> __blk_end_request(), blk_end_bidi_request() and end_request().
> blk_end_request() and blk_end_bidi_request() uses blk_end_request()
> as the backend but __blk_end_request() and end_request() use
> separate implementation in __blk_end_request() due to different
> locking rules.
>
> blk_end_bidi_request() is identical to blk_end_io(). Collapse
> blk_end_io() into blk_end_bidi_request(), separate out request
> update into internal helper blk_update_bidi_request() and add
> __blk_end_bidi_request(). Redefine [__]blk_end_request() as thin
> inline wrappers around [__]blk_end_bidi_request().
>
> 3. As the whole request issue/completion usages are about to be
> modified and audited, it's a good chance to convert completion
> functions return bool which better indicates the intended meaning
> of return values.
>
> 4. The function name end_that_request_last() is from the days when it
> was a public interface and slighly confusing. Give it a proper
> internal name - blk_finish_request().
>
> 5. Add description explaning that blk_end_bidi_request() can be safely
> used for uni requests as suggested by Boaz Harrosh.
>
> The only visible behavior change is from #1. nr_sectors counts are
> cleared after the final iteration no matter which function is used to
> complete the request. I couldn't find any place where the code
> assumes those nr_sectors counters contain the values for the last
> segment and this change is good as it makes the API much more
> consistent as the end result is now same whether a request is
> completed using [__]blk_end_request() alone or in combination with
> blk_update_request().
>
> API further cleaned up per Christoph's suggestion.
>
Rrrr.
This patch could be nice, but not after I've seen the previous one.
The first one was much^3 nicer.
Maybe all you need to do is push the lock flag into blk_finish_request()
<original patch>
+ if (!locked) {
> + spin_lock_irqsave(q->queue_lock, flags);
> + finish_request(rq, error);
> + spin_unlock_irqrestore(q->queue_lock, flags);
> + } else
> + finish_request(rq, error);
>
</original patch>
Then you have only one call site to finish_request() inside blk_end_io().
finish_request() will become the ugly site, but if looking at the alternative
I think it is worth it. Code is smaller, cleaner, and clearer. (Sometimes principles
must be sacrificed)
At the end, I hate that lock around finish_request(), I wish the req->end_io()
was not called with the lock held and the plain blk_put_request() (locking version)
could be called. Having req->end_io() under lock is a pain in the ass that makes
you go through loops when you need proper error handling. One day I will get rid of
it.
Tejun? now that you done both, which one do you like better? or is it just me?
Thanks
Boaz
next prev parent reply other threads:[~2009-04-23 9:43 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-21 16:37 [GIT PATCH linux-2.6-block] block: cleanup patches, take#3 Tejun Heo
2009-04-21 16:37 ` [PATCH 01/14] block: merge blk_invoke_request_fn() into __blk_run_queue() Tejun Heo
2009-04-21 16:37 ` [PATCH 02/14] block: kill blk_start_queueing() Tejun Heo
2009-04-21 16:37 ` [PATCH 03/14] block: don't set REQ_NOMERGE unnecessarily Tejun Heo
2009-04-21 16:37 ` [PATCH 04/14] block: cleanup REQ_SOFTBARRIER usages Tejun Heo
2009-04-21 16:37 ` [PATCH 05/14] block: clean up misc stuff after block layer timeout conversion Tejun Heo
2009-04-21 16:37 ` [PATCH 06/14] block: reorder request completion functions Tejun Heo
2009-04-21 16:37 ` [PATCH 07/14] block: reorganize request fetching functions Tejun Heo
2009-04-21 17:07 ` Christoph Hellwig
2009-04-22 10:09 ` Jens Axboe
2009-04-23 1:23 ` Tejun Heo
2009-04-21 16:37 ` [PATCH 08/14] block: kill blk_end_request_callback() Tejun Heo
2009-04-21 16:37 ` [PATCH 09/14] block: clean up request completion API Tejun Heo
2009-04-21 17:59 ` Christoph Hellwig
2009-04-23 1:24 ` Tejun Heo
2009-04-23 2:08 ` [PATCH UPDATED " Tejun Heo
2009-04-23 9:43 ` Boaz Harrosh [this message]
2009-04-23 9:59 ` Tejun Heo
2009-04-21 16:37 ` [PATCH 10/14] block: move rq->start_time initialization to blk_rq_init() Tejun Heo
2009-04-21 16:37 ` [PATCH 11/14] block: implement and use [__]blk_end_request_all() Tejun Heo
2009-04-21 16:37 ` [PATCH 12/14] block: replace end_request() with [__]blk_end_request_cur() Tejun Heo
2009-04-21 18:25 ` Joerg Dorchain
2009-04-21 20:35 ` Laurent Vivier
2009-04-22 9:25 ` Geert Uytterhoeven
2009-04-22 16:04 ` Grant Likely
2009-04-21 16:38 ` [PATCH 13/14] block: don't abuse rq->data Tejun Heo
2009-04-21 16:38 ` [PATCH 14/14] block-kill-data Tejun Heo
2009-04-21 16:42 ` [PATCH 14/14] block: kill rq->data Tejun Heo
2009-04-22 10:10 ` [GIT PATCH linux-2.6-block] block: cleanup patches, take#3 Jens Axboe
2009-04-23 2:10 ` Tejun Heo
2009-04-23 6:09 ` 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=49F0382A.6050306@panasas.com \
--to=bharrosh@panasas.com \
--cc=axboe@kernel.dk \
--cc=bzolnier@gmail.com \
--cc=hch@infradead.org \
--cc=htejun@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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