linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: linux-raid@vger.kernel.org
Cc: shli@fb.com, kernel-team@fb.com, dan.j.williams@intel.com,
	hch@infradead.org, liuzhengyuang521@gmail.com,
	liuzhengyuan@kylinos.cn, Song Liu <songliubraving@fb.com>
Subject: Re: [PATCH] md/r5cache: handle alloc_page failure
Date: Mon, 21 Nov 2016 16:05:09 +1100	[thread overview]
Message-ID: <874m31e83e.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20161119072057.1302854-1-songliubraving@fb.com>

[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]

On Sat, Nov 19 2016, Song Liu wrote:

> RMW of r5c write back cache uses an extra page to store old data for
> prexor. handle_stripe_dirtying() allocates this page by calling
> alloc_page(). However, alloc_page() may fail.
>
> To handle alloc_page() failures, this patch adds a small mempool
> in r5l_log. When alloc_page fails, the stripe is added to a waiting
> list. Then, these stripes get pages from the mempool (from work queue).
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> ---
>  drivers/md/raid5-cache.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++-
>  drivers/md/raid5.c       |  34 +++++++++++-----
>  drivers/md/raid5.h       |   6 +++
>  3 files changed, 130 insertions(+), 10 deletions(-)

This looks *way* more complex that I feel comfortable with.  I cannot
see any obvious errors, but I find it hard to be confident there aren't
any, or that errors won't creep in.

We already have mechanisms for delaying stripes.  It would be nice to
re-use those.

Ideally, when using a mempool, a single allocation from the mempool
should provide all you need for a single transaction.  For that to work
in this case, each object in the mempool would need to hold raid_disks-1
pages.  However in many cases we don't need that many, usually fewer
than raid_disks/2.  So it would be wasteful or clumsy, or both.
So I would:

 - preallocate a single set of spare pages, and store them, one each, in
   the disk_info structures.
 - add a flag to cache_state to record if these pages are in use.
 - if alloc_page() fails and test_and_set() on the bit succeeds, then
     use pages from disk_info
 - if alloc_page() fails and test_and_set() fails, set STRIPE_DELAYED
 - raid5_activate_delayed() doesn't active stripes if the flag is set,
   showing that the spare pages are in use.

I think that would be much simpler, and should be just as effective.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]

  reply	other threads:[~2016-11-21  5:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-19  7:20 [PATCH] md/r5cache: handle alloc_page failure Song Liu
2016-11-21  5:05 ` NeilBrown [this message]
2016-11-25 11:39 ` [PATCH] raid5-cache: Fix the logic of raid5-cache recovery Jackie Liu
2016-11-27 23:36   ` Song Liu

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=874m31e83e.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=dan.j.williams@intel.com \
    --cc=hch@infradead.org \
    --cc=kernel-team@fb.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=liuzhengyuan@kylinos.cn \
    --cc=liuzhengyuang521@gmail.com \
    --cc=shli@fb.com \
    --cc=songliubraving@fb.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).