Skip to content

Commit

Permalink
dm snapshot: use GFP_KERNEL when initializing exceptions
Browse files Browse the repository at this point in the history
The list of initial exceptions is loaded in the target constructor.  We
are allowed to allocate memory with GFP_KERNEL at this point.  So,
change alloc_completed_exception to use GFP_KERNEL when being called
from the constructor.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Mikulas Patocka authored and Mike Snitzer committed Jan 14, 2014
1 parent 6a38861 commit 119bc54
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,12 @@ static struct dm_exception *dm_lookup_exception(struct dm_exception_table *et,
return NULL;
}

static struct dm_exception *alloc_completed_exception(void)
static struct dm_exception *alloc_completed_exception(gfp_t gfp)
{
struct dm_exception *e;

e = kmem_cache_alloc(exception_cache, GFP_NOIO);
if (!e)
e = kmem_cache_alloc(exception_cache, gfp);
if (!e && gfp == GFP_NOIO)
e = kmem_cache_alloc(exception_cache, GFP_ATOMIC);

return e;
Expand Down Expand Up @@ -697,7 +697,7 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new)
struct dm_snapshot *s = context;
struct dm_exception *e;

e = alloc_completed_exception();
e = alloc_completed_exception(GFP_KERNEL);
if (!e)
return -ENOMEM;

Expand Down Expand Up @@ -1405,7 +1405,7 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
goto out;
}

e = alloc_completed_exception();
e = alloc_completed_exception(GFP_NOIO);
if (!e) {
down_write(&s->lock);
__invalidate_snapshot(s, -ENOMEM);
Expand Down

0 comments on commit 119bc54

Please sign in to comment.