From: Zach Brown <zach.brown@oracle.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-aio@kvack.org
Subject: Re: [PATCH take2 3/5] dio: formalize bio counters as a dio reference count
Date: Tue, 03 Oct 2006 16:23:30 -0700 [thread overview]
Message-ID: <4522F0F2.3030206@oracle.com> (raw)
In-Reply-To: <20061003154449.daab5dbd.akpm@osdl.org>
>> +static int wait_for_more_bios(struct dio *dio)
>> +{
>> + assert_spin_locked(&dio->bio_lock);
>> +
>> + return (atomic_read(&dio->refcount) > 1) && (dio->bio_list == NULL);
>> +}
>
> This function isn't well-named.
Sure, I'll try harder.
>
>> @@ -1103,7 +1088,11 @@ direct_io_worker(int rw, struct kiocb *i
>> }
>> if (ret == 0)
>> ret = dio->result;
>> - finished_one_bio(dio); /* This can free the dio */
>> +
>> + /* this can free the dio */
>> + if (atomic_dec_and_test(&dio->refcount))
>> + dio_complete_aio(dio);
>
> So... how come it's legitimate to touch *dio if it can be freed by now?
Indeed! This point in the patchset is retaining the existing behaviour
where the 'should_wait' direct_io_worker() path and the
finished_one_bio() path very carefully keep their tests in sync so that
only one of them ends up freeing the dio.
This particular patch doesn't change this part of the behaviour, it's
just bringing the dec and complete that was previously hidden in
finished_one_bio() up into its caller. So I kept the comment.
This mess is replaced with a proper
if (dec_and_test(dio->refcount))
kfree(dio)
construct in the final patch. I hope that means we don't need to patch
in some comments that we later remove.
- z
next prev parent reply other threads:[~2006-10-03 23:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-02 23:21 [PATCH take2 0/5] dio: clean up completion phase of direct_io_worker() Zach Brown
2006-10-02 23:21 ` [PATCH take2 1/5] dio: centralize completion in dio_complete() Zach Brown
2006-10-03 22:26 ` Andrew Morton
2006-10-03 23:05 ` Zach Brown
2006-10-02 23:21 ` [PATCH take2 2/5] dio: call blk_run_address_space() once per op Zach Brown
2006-10-02 23:21 ` [PATCH take2 3/5] dio: formalize bio counters as a dio reference count Zach Brown
2006-10-03 22:44 ` Andrew Morton
2006-10-03 23:23 ` Zach Brown [this message]
2006-10-02 23:21 ` [PATCH take2 4/5] dio: remove duplicate bio wait code Zach Brown
2006-10-02 23:21 ` [PATCH take2 5/5] dio: only call aio_complete() after returning -EIOCBQUEUED Zach Brown
2006-10-03 21:47 ` [PATCH take2 0/5] dio: clean up completion phase of direct_io_worker() Jeff Moyer
2006-10-03 22:20 ` Andrew Morton
2006-10-03 23:00 ` Zach Brown
2006-10-04 10:12 ` 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=4522F0F2.3030206@oracle.com \
--to=zach.brown@oracle.com \
--cc=akpm@osdl.org \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).