Skip to content

Commit 60c42a3

Browse files
committed
Merge tag 'for-4.12/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper fixes from Mike Snitzer: - a DM verity fix for a mode when no salt is used - a fix to DM to account for the possibility that PREFLUSH or FUA are used without the SYNC flag if the underlying storage doesn't have a volatile write-cache - a DM ioctl memory allocation flag fix to use __GFP_HIGH to allow emergency forward progress (by using memory reserves as last resort) - a small DM integrity cleanup to use kvmalloc() instead of duplicating the same * tag 'for-4.12/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm: make flush bios explicitly sync dm ioctl: restore __GFP_HIGH in copy_params() dm integrity: use kvmalloc() instead of dm_integrity_kvmalloc() dm verity: fix no salt use case
2 parents 6f37fa4 + ff0361b commit 60c42a3

File tree

7 files changed

+18
-30
lines changed

7 files changed

+18
-30
lines changed

drivers/md/dm-bufio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ int dm_bufio_issue_flush(struct dm_bufio_client *c)
13341334
{
13351335
struct dm_io_request io_req = {
13361336
.bi_op = REQ_OP_WRITE,
1337-
.bi_op_flags = REQ_PREFLUSH,
1337+
.bi_op_flags = REQ_PREFLUSH | REQ_SYNC,
13381338
.mem.type = DM_IO_KMEM,
13391339
.mem.ptr.addr = NULL,
13401340
.client = c->dm_io,

drivers/md/dm-integrity.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ static void write_journal(struct dm_integrity_c *ic, unsigned commit_start, unsi
783783
for (i = 0; i < commit_sections; i++)
784784
rw_section_mac(ic, commit_start + i, true);
785785
}
786-
rw_journal(ic, REQ_OP_WRITE, REQ_FUA, commit_start, commit_sections, &io_comp);
786+
rw_journal(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, commit_start,
787+
commit_sections, &io_comp);
787788
} else {
788789
unsigned to_end;
789790
io_comp.in_flight = (atomic_t)ATOMIC_INIT(2);
@@ -2374,21 +2375,6 @@ static void dm_integrity_set(struct dm_target *ti, struct dm_integrity_c *ic)
23742375
blk_queue_max_integrity_segments(disk->queue, UINT_MAX);
23752376
}
23762377

2377-
/* FIXME: use new kvmalloc */
2378-
static void *dm_integrity_kvmalloc(size_t size, gfp_t gfp)
2379-
{
2380-
void *ptr = NULL;
2381-
2382-
if (size <= PAGE_SIZE)
2383-
ptr = kmalloc(size, GFP_KERNEL | gfp);
2384-
if (!ptr && size <= KMALLOC_MAX_SIZE)
2385-
ptr = kmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY | gfp);
2386-
if (!ptr)
2387-
ptr = __vmalloc(size, GFP_KERNEL | gfp, PAGE_KERNEL);
2388-
2389-
return ptr;
2390-
}
2391-
23922378
static void dm_integrity_free_page_list(struct dm_integrity_c *ic, struct page_list *pl)
23932379
{
23942380
unsigned i;
@@ -2407,7 +2393,7 @@ static struct page_list *dm_integrity_alloc_page_list(struct dm_integrity_c *ic)
24072393
struct page_list *pl;
24082394
unsigned i;
24092395

2410-
pl = dm_integrity_kvmalloc(page_list_desc_size, __GFP_ZERO);
2396+
pl = kvmalloc(page_list_desc_size, GFP_KERNEL | __GFP_ZERO);
24112397
if (!pl)
24122398
return NULL;
24132399

@@ -2437,7 +2423,7 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int
24372423
struct scatterlist **sl;
24382424
unsigned i;
24392425

2440-
sl = dm_integrity_kvmalloc(ic->journal_sections * sizeof(struct scatterlist *), __GFP_ZERO);
2426+
sl = kvmalloc(ic->journal_sections * sizeof(struct scatterlist *), GFP_KERNEL | __GFP_ZERO);
24412427
if (!sl)
24422428
return NULL;
24432429

@@ -2453,7 +2439,7 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int
24532439

24542440
n_pages = (end_index - start_index + 1);
24552441

2456-
s = dm_integrity_kvmalloc(n_pages * sizeof(struct scatterlist), 0);
2442+
s = kvmalloc(n_pages * sizeof(struct scatterlist), GFP_KERNEL);
24572443
if (!s) {
24582444
dm_integrity_free_journal_scatterlist(ic, sl);
24592445
return NULL;
@@ -2617,7 +2603,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
26172603
goto bad;
26182604
}
26192605

2620-
sg = dm_integrity_kvmalloc((ic->journal_pages + 1) * sizeof(struct scatterlist), 0);
2606+
sg = kvmalloc((ic->journal_pages + 1) * sizeof(struct scatterlist), GFP_KERNEL);
26212607
if (!sg) {
26222608
*error = "Unable to allocate sg list";
26232609
r = -ENOMEM;
@@ -2673,7 +2659,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
26732659
r = -ENOMEM;
26742660
goto bad;
26752661
}
2676-
ic->sk_requests = dm_integrity_kvmalloc(ic->journal_sections * sizeof(struct skcipher_request *), __GFP_ZERO);
2662+
ic->sk_requests = kvmalloc(ic->journal_sections * sizeof(struct skcipher_request *), GFP_KERNEL | __GFP_ZERO);
26772663
if (!ic->sk_requests) {
26782664
*error = "Unable to allocate sk requests";
26792665
r = -ENOMEM;
@@ -2740,7 +2726,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
27402726
r = -ENOMEM;
27412727
goto bad;
27422728
}
2743-
ic->journal_tree = dm_integrity_kvmalloc(journal_tree_size, 0);
2729+
ic->journal_tree = kvmalloc(journal_tree_size, GFP_KERNEL);
27442730
if (!ic->journal_tree) {
27452731
*error = "Could not allocate memory for journal tree";
27462732
r = -ENOMEM;

drivers/md/dm-ioctl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,12 +1710,13 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
17101710
}
17111711

17121712
/*
1713-
* Try to avoid low memory issues when a device is suspended.
1713+
* Use __GFP_HIGH to avoid low memory issues when a device is
1714+
* suspended and the ioctl is needed to resume it.
17141715
* Use kmalloc() rather than vmalloc() when we can.
17151716
*/
17161717
dmi = NULL;
17171718
noio_flag = memalloc_noio_save();
1718-
dmi = kvmalloc(param_kernel->data_size, GFP_KERNEL);
1719+
dmi = kvmalloc(param_kernel->data_size, GFP_KERNEL | __GFP_HIGH);
17191720
memalloc_noio_restore(noio_flag);
17201721

17211722
if (!dmi) {

drivers/md/dm-raid1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static int mirror_flush(struct dm_target *ti)
260260
struct mirror *m;
261261
struct dm_io_request io_req = {
262262
.bi_op = REQ_OP_WRITE,
263-
.bi_op_flags = REQ_PREFLUSH,
263+
.bi_op_flags = REQ_PREFLUSH | REQ_SYNC,
264264
.mem.type = DM_IO_KMEM,
265265
.mem.ptr.addr = NULL,
266266
.client = ms->io_client,

drivers/md/dm-snap-persistent.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ static void persistent_commit_exception(struct dm_exception_store *store,
741741
/*
742742
* Commit exceptions to disk.
743743
*/
744-
if (ps->valid && area_io(ps, REQ_OP_WRITE, REQ_PREFLUSH | REQ_FUA))
744+
if (ps->valid && area_io(ps, REQ_OP_WRITE,
745+
REQ_PREFLUSH | REQ_FUA | REQ_SYNC))
745746
ps->valid = 0;
746747

747748
/*

drivers/md/dm-verity-target.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int verity_hash_init(struct dm_verity *v, struct ahash_request *req,
166166
return r;
167167
}
168168

169-
if (likely(v->version >= 1))
169+
if (likely(v->salt_size && (v->version >= 1)))
170170
r = verity_hash_update(v, req, v->salt, v->salt_size, res);
171171

172172
return r;
@@ -177,7 +177,7 @@ static int verity_hash_final(struct dm_verity *v, struct ahash_request *req,
177177
{
178178
int r;
179179

180-
if (unlikely(!v->version)) {
180+
if (unlikely(v->salt_size && (!v->version))) {
181181
r = verity_hash_update(v, req, v->salt, v->salt_size, res);
182182

183183
if (r < 0) {

drivers/md/dm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ static struct mapped_device *alloc_dev(int minor)
16571657

16581658
bio_init(&md->flush_bio, NULL, 0);
16591659
md->flush_bio.bi_bdev = md->bdev;
1660-
md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
1660+
md->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_SYNC;
16611661

16621662
dm_stats_init(&md->stats);
16631663

0 commit comments

Comments
 (0)