From: Andrew Morton <akpm@linux-foundation.org>
To: Philipp Reisner <philipp.reisner@linbit.com>
Cc: linux-kernel@vger.kernel.org, Jens Axboe <jens.axboe@oracle.com>,
Greg KH <gregkh@suse.de>, Neil Brown <neilb@suse.de>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
Sam Ravnborg <sam@ravnborg.org>, Dave Jones <davej@redhat.com>,
Nikanth Karthikesan <knikanth@suse.de>,
"Lars Marowsky-Bree" <lmb@suse.de>,
"Nicholas A. Bellinger" <nab@linux-iscsi.org>,
Kyle Moffett <kyle@moffetthome.net>,
Bart Van Assche <bart.vanassche@gmail.com>,
Christoph Hellwig <hch@infradead.org>,
drbd-dev@lists.linbit.com,
Lars Ellenberg <lars.ellenberg@linbit.com>
Subject: Re: [PATCH 04/16] drbd: dirty bitmap
Date: Mon, 20 Jul 2009 22:49:57 -0700 [thread overview]
Message-ID: <20090720224957.a8a36701.akpm@linux-foundation.org> (raw)
In-Reply-To: <1246894775-10855-5-git-send-email-philipp.reisner@linbit.com>
On Mon, 6 Jul 2009 17:39:23 +0200 Philipp Reisner <philipp.reisner@linbit.com> wrote:
> DRBD maintains a dirty bitmap in case it has to run without peer node or
> without local disk. Writes to the on disk dirty bitmap are minimized by the
> activity log (=AL). Each time an extent is evicted from the AL the part of
> the bitmap no longer covered by the AL is written to disk.
>
> ...
>
> +static struct page **bm_realloc_pages(struct drbd_bitmap *b, unsigned long want)
> +{
> + struct page **old_pages = b->bm_pages;
> + struct page **new_pages, *page;
> + unsigned int i, bytes, vmalloced = 0;
> + unsigned long have = b->bm_number_of_pages;
> +
> + BUG_ON(have == 0 && old_pages != NULL);
> + BUG_ON(have != 0 && old_pages == NULL);
> +
> + if (have == want)
> + return old_pages;
> +
> + /* Trying kmalloc first, falling back to vmalloc.
> + * GFP_KERNEL is ok, as this is done when a lower level disk is
> + * "attached" to the drbd. Context is receiver thread or cqueue
> + * thread. As we have no disk yet, we are not in the IO path,
> + * not even the IO path of the peer. */
> + bytes = sizeof(struct page *)*want;
> + new_pages = kmalloc(bytes, GFP_KERNEL);
> + if (!new_pages) {
> + new_pages = vmalloc(bytes);
> + if (!new_pages)
> + return NULL;
> + vmalloced = 1;
> + }
> +
> + memset(new_pages, 0, bytes);
> + if (want >= have) {
> + for (i = 0; i < have; i++)
> + new_pages[i] = old_pages[i];
> + for (; i < want; i++) {
> + page = alloc_page(GFP_HIGHUSER);
> + if (!page) {
> + bm_free_pages(new_pages + have, i - have);
> + bm_vk_free(new_pages, vmalloced);
> + return NULL;
> + }
> + new_pages[i] = page;
> + }
> + } else {
> + for (i = 0; i < want; i++)
> + new_pages[i] = old_pages[i];
> + /* NOT HERE, we are outside the spinlock!
> + bm_free_pages(old_pages + want, have - want);
> + */
> + }
> +
> + if (vmalloced)
> + set_bit(BM_P_VMALLOCED, &b->bm_flags);
> + else
> + clear_bit(BM_P_VMALLOCED, &b->bm_flags);
> +
> + return new_pages;
> +}
The vmalloc is always troublesome.
It's a pretty commonly-occurring pattern and I've been suggesting that
we implement a generic dynamic-array facility so that those callsites
which wish to do huge contiguous allocations need no longer do that.
Please take a look at this thread: http://lkml.org/lkml/2009/7/2/464
and let's see if there's any useful commonality here. I think there
is...
next prev parent reply other threads:[~2009-07-21 5:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-06 15:39 [PATCH 00/16] drbd: a block device for HA clusters Philipp Reisner
2009-07-06 15:39 ` [PATCH 01/16] drbd: Entry in the MAINTAINERS file for DRBD Philipp Reisner
2009-07-06 15:39 ` [PATCH 02/16] lru_cache: track a fixed size cache of equal sized objects Philipp Reisner
2009-07-06 15:39 ` [PATCH 03/16] drbd: tracking of active extents Philipp Reisner
2009-07-06 15:39 ` [PATCH 04/16] drbd: dirty bitmap Philipp Reisner
2009-07-06 15:39 ` [PATCH 05/16] drbd: request state processing Philipp Reisner
2009-07-06 15:39 ` [PATCH 06/16] drbd: user space interface (based upon connector/netlink) Philipp Reisner
2009-07-06 15:39 ` [PATCH 07/16] drbd: internal data structures Philipp Reisner
2009-07-06 15:39 ` [PATCH 08/16] drbd: device state engine Philipp Reisner
2009-07-06 15:39 ` [PATCH 09/16] drbd: network IO threads Philipp Reisner
2009-07-06 15:39 ` [PATCH 10/16] drbd: the /proc/drbd interface Philipp Reisner
2009-07-06 15:39 ` [PATCH 11/16] drbd: worker thread Philipp Reisner
2009-07-06 15:39 ` [PATCH 12/16] drbd: variable length integer encoding Philipp Reisner
2009-07-06 15:39 ` [PATCH 13/16] drbd: String constants Philipp Reisner
2009-07-06 15:39 ` [PATCH 14/16] drbd: tracepoint probes Philipp Reisner
2009-07-06 15:39 ` [PATCH 15/16] drbd: documentation Philipp Reisner
2009-07-06 15:39 ` [PATCH 16/16] drbd: Kconfig and Makefile bits Philipp Reisner
2009-07-21 5:49 ` Andrew Morton [this message]
2009-07-21 5:49 ` [PATCH 00/16] drbd: a block device for HA clusters Andrew Morton
2009-07-21 18:51 ` [Drbd-dev] " Lars Ellenberg
2009-07-22 4:59 ` Stephen Rothwell
2009-07-24 15:20 ` Philipp Reisner
2009-07-26 23:24 ` Stephen Rothwell
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=20090720224957.a8a36701.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bart.vanassche@gmail.com \
--cc=davej@redhat.com \
--cc=drbd-dev@lists.linbit.com \
--cc=gregkh@suse.de \
--cc=hch@infradead.org \
--cc=jens.axboe@oracle.com \
--cc=knikanth@suse.de \
--cc=kyle@moffetthome.net \
--cc=lars.ellenberg@linbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lmb@suse.de \
--cc=nab@linux-iscsi.org \
--cc=neilb@suse.de \
--cc=philipp.reisner@linbit.com \
--cc=sam@ravnborg.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