Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1619598
| From | NeilBrown <neilb@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] dm-region-hash: fix strange usage of mempool_alloc. |
| Date | 2017-04-10 04:20 +0200 |
| Message-ID | <tux5T-2WR-13@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
mempool_alloc() should only be called with GFP_ATOMIC when
it is not safe to wait. Passing __GFP_NOFAIL to kmalloc()
says that it is safe to wait indefinitely. So this code is
inconsistent.
Clearly it is OK to wait indefinitely in this code, and
mempool_alloc() is able to do that. So just use
mempool_alloc, and allow it to sleep. If no memory is
available it will wait for something to be returned to the
pool, and will retry a normal allocation regularly.
Signed-off-by: NeilBrown <neilb@suse.com>
---
drivers/md/dm-region-hash.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c
index 85c32b22a420..a6279f5d779e 100644
--- a/drivers/md/dm-region-hash.c
+++ b/drivers/md/dm-region-hash.c
@@ -287,9 +287,7 @@ static struct dm_region *__rh_alloc(struct dm_region_hash *rh, region_t region)
{
struct dm_region *reg, *nreg;
- nreg = mempool_alloc(rh->region_pool, GFP_ATOMIC);
- if (unlikely(!nreg))
- nreg = kmalloc(sizeof(*nreg), GFP_NOIO | __GFP_NOFAIL);
+ nreg = mempool_alloc(rh->region_pool, GFP_NOIO);
nreg->state = rh->log->type->in_sync(rh->log, region, 1) ?
DM_RH_CLEAN : DM_RH_NOSYNC;
--
2.12.2
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] dm-region-hash: fix strange usage of mempool_alloc. NeilBrown <neilb@suse.com> - 2017-04-10 04:20 +0200
Re: [PATCH] dm-region-hash: fix strange usage of mempool_alloc. Mikulas Patocka <mpatocka@redhat.com> - 2017-04-21 15:10 +0200
Re: [dm-devel] [PATCH] dm-region-hash: fix strange usage of mempool_alloc. NeilBrown <neilb@suse.com> - 2017-04-24 03:50 +0200
csiph-web