Messages in this thread | | | Date | Tue, 03 Oct 2006 16:23:30 -0700 | From | Zach Brown <> | Subject | Re: [PATCH take2 3/5] dio: formalize bio counters as a dio reference count |
| |
>> +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 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |