Skip to content

Commit

Permalink
md/raid5: pass gfp_t arg to grow_one_stripe()
Browse files Browse the repository at this point in the history
This is needed for future improvement to stripe cache management.

Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
NeilBrown committed Apr 21, 2015
1 parent d06f191 commit a9683a7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,15 @@ static void shrink_buffers(struct stripe_head *sh)
}
}

static int grow_buffers(struct stripe_head *sh)
static int grow_buffers(struct stripe_head *sh, gfp_t gfp)
{
int i;
int num = sh->raid_conf->pool_size;

for (i = 0; i < num; i++) {
struct page *page;

if (!(page = alloc_page(GFP_KERNEL))) {
if (!(page = alloc_page(gfp))) {
return 1;
}
sh->dev[i].page = page;
Expand Down Expand Up @@ -1963,18 +1963,18 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
put_cpu();
}

static int grow_one_stripe(struct r5conf *conf, int hash)
static int grow_one_stripe(struct r5conf *conf, int hash, gfp_t gfp)
{
struct stripe_head *sh;
sh = kmem_cache_zalloc(conf->slab_cache, GFP_KERNEL);
sh = kmem_cache_zalloc(conf->slab_cache, gfp);
if (!sh)
return 0;

sh->raid_conf = conf;

spin_lock_init(&sh->stripe_lock);

if (grow_buffers(sh)) {
if (grow_buffers(sh, gfp)) {
shrink_buffers(sh);
kmem_cache_free(conf->slab_cache, sh);
return 0;
Expand Down Expand Up @@ -2016,7 +2016,7 @@ static int grow_stripes(struct r5conf *conf, int num)
conf->pool_size = devs;
hash = conf->max_nr_stripes % NR_STRIPE_HASH_LOCKS;
while (num--) {
if (!grow_one_stripe(conf, hash))
if (!grow_one_stripe(conf, hash, GFP_KERNEL))
return 1;
conf->max_nr_stripes++;
hash = (hash + 1) % NR_STRIPE_HASH_LOCKS;
Expand Down Expand Up @@ -5841,7 +5841,7 @@ raid5_set_cache_size(struct mddev *mddev, int size)
return err;
hash = conf->max_nr_stripes % NR_STRIPE_HASH_LOCKS;
while (size > conf->max_nr_stripes) {
if (grow_one_stripe(conf, hash))
if (grow_one_stripe(conf, hash, GFP_KERNEL))
conf->max_nr_stripes++;
else break;
hash = (hash + 1) % NR_STRIPE_HASH_LOCKS;
Expand Down

0 comments on commit a9683a7

Please sign in to comment.