Re: [PATCH 2/3] direct-io: add a hook for the fs to provide itsown submit_bio function

From: Christoph Hellwig
Date: Thu May 06 2010 - 17:09:42 EST


On Thu, May 06, 2010 at 03:00:38PM -0400, Josef Bacik wrote:
> +void dio_end_io(struct bio *bio, int error)
> +{
> + struct dio *dio = bio->bi_private;
> +
> + if (dio->is_async)
> + dio_bio_end_aio(bio, error);
> + else
> + dio_bio_end_io(bio, error);
> +}
> +EXPORT_SYMBOL(dio_end_io);

_GPL export please as it's quite internal.

> @@ -340,7 +352,10 @@ static void dio_bio_submit(struct dio *dio)
> if (dio->is_async && dio->rw == READ)
> bio_set_pages_dirty(bio);
>
> - submit_bio(dio->rw, bio);
> + if (!dio->submit_io)
> + submit_bio(dio->rw, bio);
> + else
> + dio->submit_io(dio->rw, bio, dio->inode);

What about making sure that dio->submit_io is always set in
direct_io_worker?

> static int dio_send_cur_page(struct dio *dio)
> {
> + int boundary = dio->boundary;
> int ret = 0;
>
> if (dio->bio) {
> @@ -612,7 +628,7 @@ static int dio_send_cur_page(struct dio *dio)
> * Submit now if the underlying fs is about to perform a
> * metadata read
> */
> - if (dio->boundary)
> + if (boundary)
> dio_bio_submit(dio);
> }
>
> @@ -629,6 +645,8 @@ static int dio_send_cur_page(struct dio *dio)
> ret = dio_bio_add_page(dio);
> BUG_ON(ret != 0);
> }
> + } else if (boundary) {
> + dio_bio_submit(dio);
> }

These hunk seem like they're unrealted to the actual hook, I'd rather
have them in a separate patch.

> +static inline ssize_t blockdev_direct_IO_own_submit(int rw, struct kiocb *iocb,
> + struct inode *inode, struct block_device *bdev, const struct iovec *iov,
> + loff_t offset, unsigned long nr_segs, get_block_t get_block,
> + dio_submit_t submit_io)
> +{
> + return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
> + nr_segs, get_block, NULL, submit_io, 0);
> }

Please don't add another wrapper. At this point I'd suggest just using
__blockdev_direct_IO for everything but the trivial blockdev_direct_IO
and also kill blockdev_direct_IO_no_locking.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/