Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-5.0/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:

- Fix bug in DM crypt's sizing of its block integrity tag space,
resulting in less memory use when DM crypt layers on DM integrity.

- Fix a long-standing DM thinp crash consistency bug that was due to
improper handling of FUA. This issue is specific to writes that fill
an entire thinp block which needs to be allocated.

* tag 'for-5.0/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm thin: fix bug where bio that overwrites thin block ignores FUA
dm crypt: don't overallocate the integrity tag space

+51 -6
+1 -1
drivers/md/dm-crypt.c
··· 932 932 if (IS_ERR(bip)) 933 933 return PTR_ERR(bip); 934 934 935 - tag_len = io->cc->on_disk_tag_size * bio_sectors(bio); 935 + tag_len = io->cc->on_disk_tag_size * (bio_sectors(bio) >> io->cc->sector_shift); 936 936 937 937 bip->bip_iter.bi_size = tag_len; 938 938 bip->bip_iter.bi_sector = io->cc->start + io->sector;
+50 -5
drivers/md/dm-thin.c
··· 257 257 258 258 spinlock_t lock; 259 259 struct bio_list deferred_flush_bios; 260 + struct bio_list deferred_flush_completions; 260 261 struct list_head prepared_mappings; 261 262 struct list_head prepared_discards; 262 263 struct list_head prepared_discards_pt2; ··· 957 956 mempool_free(m, &m->tc->pool->mapping_pool); 958 957 } 959 958 959 + static void complete_overwrite_bio(struct thin_c *tc, struct bio *bio) 960 + { 961 + struct pool *pool = tc->pool; 962 + unsigned long flags; 963 + 964 + /* 965 + * If the bio has the REQ_FUA flag set we must commit the metadata 966 + * before signaling its completion. 967 + */ 968 + if (!bio_triggers_commit(tc, bio)) { 969 + bio_endio(bio); 970 + return; 971 + } 972 + 973 + /* 974 + * Complete bio with an error if earlier I/O caused changes to the 975 + * metadata that can't be committed, e.g, due to I/O errors on the 976 + * metadata device. 977 + */ 978 + if (dm_thin_aborted_changes(tc->td)) { 979 + bio_io_error(bio); 980 + return; 981 + } 982 + 983 + /* 984 + * Batch together any bios that trigger commits and then issue a 985 + * single commit for them in process_deferred_bios(). 986 + */ 987 + spin_lock_irqsave(&pool->lock, flags); 988 + bio_list_add(&pool->deferred_flush_completions, bio); 989 + spin_unlock_irqrestore(&pool->lock, flags); 990 + } 991 + 960 992 static void process_prepared_mapping(struct dm_thin_new_mapping *m) 961 993 { 962 994 struct thin_c *tc = m->tc; ··· 1022 988 */ 1023 989 if (bio) { 1024 990 inc_remap_and_issue_cell(tc, m->cell, m->data_block); 1025 - bio_endio(bio); 991 + complete_overwrite_bio(tc, bio); 1026 992 } else { 1027 993 inc_all_io_entry(tc->pool, m->cell->holder); 1028 994 remap_and_issue(tc, m->cell->holder, m->data_block); ··· 2351 2317 { 2352 2318 unsigned long flags; 2353 2319 struct bio *bio; 2354 - struct bio_list bios; 2320 + struct bio_list bios, bio_completions; 2355 2321 struct thin_c *tc; 2356 2322 2357 2323 tc = get_first_thin(pool); ··· 2362 2328 } 2363 2329 2364 2330 /* 2365 - * If there are any deferred flush bios, we must commit 2366 - * the metadata before issuing them. 2331 + * If there are any deferred flush bios, we must commit the metadata 2332 + * before issuing them or signaling their completion. 2367 2333 */ 2368 2334 bio_list_init(&bios); 2335 + bio_list_init(&bio_completions); 2336 + 2369 2337 spin_lock_irqsave(&pool->lock, flags); 2370 2338 bio_list_merge(&bios, &pool->deferred_flush_bios); 2371 2339 bio_list_init(&pool->deferred_flush_bios); 2340 + 2341 + bio_list_merge(&bio_completions, &pool->deferred_flush_completions); 2342 + bio_list_init(&pool->deferred_flush_completions); 2372 2343 spin_unlock_irqrestore(&pool->lock, flags); 2373 2344 2374 - if (bio_list_empty(&bios) && 2345 + if (bio_list_empty(&bios) && bio_list_empty(&bio_completions) && 2375 2346 !(dm_pool_changed_this_transaction(pool->pmd) && need_commit_due_to_time(pool))) 2376 2347 return; 2377 2348 2378 2349 if (commit(pool)) { 2350 + bio_list_merge(&bios, &bio_completions); 2351 + 2379 2352 while ((bio = bio_list_pop(&bios))) 2380 2353 bio_io_error(bio); 2381 2354 return; 2382 2355 } 2383 2356 pool->last_commit_jiffies = jiffies; 2357 + 2358 + while ((bio = bio_list_pop(&bio_completions))) 2359 + bio_endio(bio); 2384 2360 2385 2361 while ((bio = bio_list_pop(&bios))) 2386 2362 generic_make_request(bio); ··· 2998 2954 INIT_DELAYED_WORK(&pool->no_space_timeout, do_no_space_timeout); 2999 2955 spin_lock_init(&pool->lock); 3000 2956 bio_list_init(&pool->deferred_flush_bios); 2957 + bio_list_init(&pool->deferred_flush_completions); 3001 2958 INIT_LIST_HEAD(&pool->prepared_mappings); 3002 2959 INIT_LIST_HEAD(&pool->prepared_discards); 3003 2960 INIT_LIST_HEAD(&pool->prepared_discards_pt2);