All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-kernel@vger.kernel.org, jeff@garzik.org,
	benh@kernel.crashing.org, htejun@gmail.com, bzolnier@gmail.com,
	alan@lxorguk.ukuu.org.uk, jens.axboe@oracle.com
Subject: Re: [PATCH 2/4] direct-io: make O_DIRECT IO path be page based
Date: Thu, 20 Aug 2009 17:12:04 -0700	[thread overview]
Message-ID: <20090820171204.93c3fdb4.akpm@linux-foundation.org> (raw)
In-Reply-To: <1250763466-24282-4-git-send-email-jens.axboe@oracle.com>

On Thu, 20 Aug 2009 12:17:38 +0200
Jens Axboe <jens.axboe@oracle.com> wrote:

> Currently we pass in the iovec array and let the O_DIRECT core
> handle the get_user_pages() business. This work, but it means that
> we can ever only use user pages for O_DIRECT.
> 
> Switch the aops->direct_IO() and below code to use page arrays
> instead, so that it doesn't make any assumptions about who the pages
> belong to. This works directly for all users but NFS, which just
> uses the same helper that the generic mapping read/write functions
> also call.
>

This:

> +	struct page **pages;		/* page buffer */
> +	unsigned int head_page;		/* next page to process */
> +	unsigned int total_pages;	/* last valid page + 1 */
> +	unsigned int first_page_off;	/* offset into first page in map */

Is a disaster waiting to happen.

>  static struct page *dio_get_page(struct dio *dio)
>  {
> -	if (dio_pages_present(dio) == 0) {
> -		int ret;
> +	if (dio->head_page < dio->total_pages)
> +		return dio->pages[dio->head_page++];
>  
> -		ret = dio_refill_pages(dio);
> -		if (ret)
> -			return ERR_PTR(ret);
> -		BUG_ON(dio_pages_present(dio) == 0);
> -	}
> -	return dio->pages[dio->head++];
> +	return NULL;
>  }
>
> ...
>
> @@ -351,8 +280,10 @@ static void dio_bio_submit(struct dio *dio)
>   */
>  static void dio_cleanup(struct dio *dio)
>  {
> -	while (dio_pages_present(dio))
> -		page_cache_release(dio_get_page(dio));
> +	struct page *page;
> +
> +	while ((page = dio_get_page(dio)) != NULL)
> +		page_cache_release(page);
>  }

What is the value of dio->head_page here?

How are callers to use this function at the start of the operation, at
the end and partway through is IO error, EFAULT etc is detected?

There's good potential for double-releases, leaks etc here.  We need to
be very careful and explicit in documenting the usage and state and
meaning of head_page, and the protocol around managing it.

It's just like that ghastly bio.bi_idx thing - how many bugs did we add
and have to fix due to that thing?

Really I think it'd be better to just nuke .head_page altogether and get
callers to manage their index openly.


  parent reply	other threads:[~2009-08-21  0:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-20 10:17 [PATCH 0/6] Lazy workqueues Jens Axboe
2009-08-20 10:17 ` [PATCH 1/4] direct-io: unify argument passing by adding a dio_args structure Jens Axboe
2009-08-20 10:17   ` [PATCH 1/6] workqueue: replace singlethread/freezable/rt parameters and variables with flags Jens Axboe
2009-08-20 10:17     ` [PATCH 2/4] direct-io: make O_DIRECT IO path be page based Jens Axboe
2009-08-20 10:17       ` [PATCH 2/6] workqueue: add support for lazy workqueues Jens Axboe
2009-08-20 10:17         ` [PATCH 3/6] crypto: use " Jens Axboe
2009-08-20 10:17           ` [PATCH 3/4] direct-io: add a "IO for kernel" flag to kiocb Jens Axboe
2009-08-20 10:17             ` [PATCH 4/6] libata: use lazy workqueues for the pio task Jens Axboe
2009-08-20 10:17               ` [PATCH 4/5] loop: support O_DIRECT transfer mode Jens Axboe
2009-08-20 10:17                 ` [PATCH 5/6] aio: use lazy workqueues Jens Axboe
2009-08-20 10:17                   ` [PATCH 4/4] direct-io: get rid of irq flag saving where it isn't needed Jens Axboe
2009-08-20 10:17                     ` [PATCH 6/6] sunrpc: use lazy workqueues Jens Axboe
2009-08-21  0:20         ` [PATCH 2/6] workqueue: add support for " Andrew Morton
2009-08-24  8:06           ` Jens Axboe
2009-08-20 13:19       ` [PATCH 2/4] direct-io: make O_DIRECT IO path be page based Trond Myklebust
2009-08-24  7:58         ` Jens Axboe
2009-08-21  0:12       ` Andrew Morton [this message]
2009-08-24  8:00         ` Jens Axboe
2009-08-21  0:03   ` [PATCH 1/4] direct-io: unify argument passing by adding a dio_args structure Andrew Morton
2009-08-24  7:58     ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2009-08-18  8:34 [PATCH 0/4] Page based O_DIRECT v2 Jens Axboe
2009-08-18  8:34 ` [PATCH 2/4] direct-io: make O_DIRECT IO path be page based 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=20090820171204.93c3fdb4.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=benh@kernel.crashing.org \
    --cc=bzolnier@gmail.com \
    --cc=htejun@gmail.com \
    --cc=jeff@garzik.org \
    --cc=jens.axboe@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.