From: Christoph Hellwig <hch@infradead.org>
To: Josef Bacik <jbacik@fusionio.com>
Cc: hch@infradead.org, linux-fsdevel@vger.kernel.org,
viro@ZenIV.linux.org.uk, jmoyer@redhat.com, zab@redhat.com
Subject: Re: [PATCH] direct-io: allow file systems to do their own waiting for io V2
Date: Wed, 19 Dec 2012 09:38:41 -0500 [thread overview]
Message-ID: <20121219143841.GA13418@infradead.org> (raw)
In-Reply-To: <1355237623-4291-1-git-send-email-jbacik@fusionio.com>
I have to say I still hate the flag magic in here. Spent some time to
look over things to be a bit more constructive in getting what you
guys want in a nicer way:
> static void dio_bio_end_io(struct bio *bio, int error)
> {
> struct dio *dio = bio->bi_private;
> unsigned long flags;
> + unsigned long remaining;
> + bool own_waiting = ((dio->rw & WRITE) &&
> + (dio->flags & DIO_OWN_WAITING));
> +
> + if (own_waiting)
> + dio_bio_complete(dio, bio);
>
> spin_lock_irqsave(&dio->bio_lock, flags);
> + if (!own_waiting) {
> + bio->bi_private = dio->bio_list;
> + dio->bio_list = bio;
> + }
> + remaining = --dio->refcount;
> + if (remaining == 1 && dio->waiter)
> wake_up_process(dio->waiter);
> spin_unlock_irqrestore(&dio->bio_lock, flags);
> +
> + if (remaining == 0) {
> + BUG_ON(!(dio->flags & DIO_OWN_WAITING));
> + dio_complete(dio, dio->iocb->ki_pos, 0, false);
> + kmem_cache_free(dio_cache, dio);
> + }
This own_waiting case of this is not identical to dio_bio_end_aio
except for the inverted is_async argument of dio_complete.
So even if we allow for the flag I think we should test it in dio_end_io
and use common code for the case where we don't use the linked list of
bios to complete. In that case you could also just call the current
aio version from btrfs as it already calls dio_end_io directly and
remove the flag given that dio_await_completion would become a no-op.
That being said I would much, much prefer to consolidate code here
rather than adding more special cases.
What I would really like to understand is what the point for the
bio_list batching is to start with, given that it also requires nasty
workarounds like dio_bio_reap() to work around the amount of memory it
might have to use.
The only thing I could think of is to allow ->end_io callbacks from user
context, but that is a bigger problem as we can't do that for AIO. I'd
much prefer a unified approach with my generic user context callbacks
from a few weeks ago to actually simplify this code. (and yeah, it's
probably up to me to demonstrate at least a prototype of this)
next prev parent reply other threads:[~2012-12-19 14:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-11 14:53 [PATCH] direct-io: allow file systems to do their own waiting for io V2 Josef Bacik
2012-12-19 14:38 ` Christoph Hellwig [this message]
2012-12-19 15:55 ` Chris Mason
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=20121219143841.GA13418@infradead.org \
--to=hch@infradead.org \
--cc=jbacik@fusionio.com \
--cc=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
--cc=zab@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).