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-4.19/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:

- DM verity fix for crash due to using vmalloc'd buffers with the
asynchronous crypto hadsh API.

- Fix to both DM crypt and DM integrity targets to discontinue using
CRYPTO_TFM_REQ_MAY_SLEEP because its use of GFP_KERNEL can lead to
deadlock by recursing back into a filesystem.

- Various DM raid fixes related to reshape and rebuild races.

- Fix for DM thin-provisioning to avoid data corruption that was a
side-effect of needing to abort DM thin metadata transaction due to
running out of metadata space. Fix is to reserve a small amount of
metadata space so that once it is used the DM thin-pool can finish
its active transaction before switching to read-only mode.

* tag 'for-4.19/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm thin metadata: try to avoid ever aborting transactions
dm raid: bump target version, update comments and documentation
dm raid: fix RAID leg rebuild errors
dm raid: fix rebuild of specific devices by updating superblock
dm raid: fix stripe adding reshape deadlock
dm raid: fix reshape race on small devices
dm: disable CRYPTO_TFM_REQ_MAY_SLEEP to fix a GFP_KERNEL recursion deadlock
dm verity: fix crash on bufio buffer that was allocated with vmalloc

+193 -114
+4
Documentation/device-mapper/dm-raid.txt
··· 348 348 1.13.1 Fix deadlock caused by early md_stop_writes(). Also fix size an 349 349 state races. 350 350 1.13.2 Fix raid redundancy validation and avoid keeping raid set frozen 351 + 1.14.0 Fix reshape race on small devices. Fix stripe adding reshape 352 + deadlock/potential data corruption. Update superblock when 353 + specific devices are requested via rebuild. Fix RAID leg 354 + rebuild errors.
+5 -5
drivers/md/dm-crypt.c
··· 332 332 int err; 333 333 334 334 desc->tfm = essiv->hash_tfm; 335 - desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 335 + desc->flags = 0; 336 336 337 337 err = crypto_shash_digest(desc, cc->key, cc->key_size, essiv->salt); 338 338 shash_desc_zero(desc); ··· 606 606 int i, r; 607 607 608 608 desc->tfm = lmk->hash_tfm; 609 - desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 609 + desc->flags = 0; 610 610 611 611 r = crypto_shash_init(desc); 612 612 if (r) ··· 768 768 769 769 /* calculate crc32 for every 32bit part and xor it */ 770 770 desc->tfm = tcw->crc32_tfm; 771 - desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 771 + desc->flags = 0; 772 772 for (i = 0; i < 4; i++) { 773 773 r = crypto_shash_init(desc); 774 774 if (r) ··· 1251 1251 * requests if driver request queue is full. 1252 1252 */ 1253 1253 skcipher_request_set_callback(ctx->r.req, 1254 - CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, 1254 + CRYPTO_TFM_REQ_MAY_BACKLOG, 1255 1255 kcryptd_async_done, dmreq_of_req(cc, ctx->r.req)); 1256 1256 } 1257 1257 ··· 1268 1268 * requests if driver request queue is full. 1269 1269 */ 1270 1270 aead_request_set_callback(ctx->r.req_aead, 1271 - CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, 1271 + CRYPTO_TFM_REQ_MAY_BACKLOG, 1272 1272 kcryptd_async_done, dmreq_of_req(cc, ctx->r.req_aead)); 1273 1273 } 1274 1274
+2 -2
drivers/md/dm-integrity.c
··· 532 532 unsigned j, size; 533 533 534 534 desc->tfm = ic->journal_mac; 535 - desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; 535 + desc->flags = 0; 536 536 537 537 r = crypto_shash_init(desc); 538 538 if (unlikely(r)) { ··· 676 676 static bool do_crypt(bool encrypt, struct skcipher_request *req, struct journal_completion *comp) 677 677 { 678 678 int r; 679 - skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, 679 + skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 680 680 complete_journal_encrypt, comp); 681 681 if (likely(encrypt)) 682 682 r = crypto_skcipher_encrypt(req);
+62 -94
drivers/md/dm-raid.c
··· 1 1 /* 2 2 * Copyright (C) 2010-2011 Neil Brown 3 - * Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved. 3 + * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. 4 4 * 5 5 * This file is released under the GPL. 6 6 */ ··· 28 28 * Minimum journal space 4 MiB in sectors. 29 29 */ 30 30 #define MIN_RAID456_JOURNAL_SPACE (4*2048) 31 - 32 - /* Global list of all raid sets */ 33 - static LIST_HEAD(raid_sets); 34 31 35 32 static bool devices_handle_discard_safely = false; 36 33 ··· 224 227 225 228 struct raid_set { 226 229 struct dm_target *ti; 227 - struct list_head list; 228 230 229 231 uint32_t stripe_cache_entries; 230 232 unsigned long ctr_flags; ··· 267 271 mddev->new_level = l->new_level; 268 272 mddev->new_layout = l->new_layout; 269 273 mddev->new_chunk_sectors = l->new_chunk_sectors; 270 - } 271 - 272 - /* Find any raid_set in active slot for @rs on global list */ 273 - static struct raid_set *rs_find_active(struct raid_set *rs) 274 - { 275 - struct raid_set *r; 276 - struct mapped_device *md = dm_table_get_md(rs->ti->table); 277 - 278 - list_for_each_entry(r, &raid_sets, list) 279 - if (r != rs && dm_table_get_md(r->ti->table) == md) 280 - return r; 281 - 282 - return NULL; 283 274 } 284 275 285 276 /* raid10 algorithms (i.e. formats) */ ··· 747 764 748 765 mddev_init(&rs->md); 749 766 750 - INIT_LIST_HEAD(&rs->list); 751 767 rs->raid_disks = raid_devs; 752 768 rs->delta_disks = 0; 753 769 ··· 764 782 for (i = 0; i < raid_devs; i++) 765 783 md_rdev_init(&rs->dev[i].rdev); 766 784 767 - /* Add @rs to global list. */ 768 - list_add(&rs->list, &raid_sets); 769 - 770 785 /* 771 786 * Remaining items to be initialized by further RAID params: 772 787 * rs->md.persistent ··· 776 797 return rs; 777 798 } 778 799 779 - /* Free all @rs allocations and remove it from global list. */ 800 + /* Free all @rs allocations */ 780 801 static void raid_set_free(struct raid_set *rs) 781 802 { 782 803 int i; ··· 793 814 if (rs->dev[i].data_dev) 794 815 dm_put_device(rs->ti, rs->dev[i].data_dev); 795 816 } 796 - 797 - list_del(&rs->list); 798 817 799 818 kfree(rs); 800 819 } ··· 2626 2649 return 0; 2627 2650 } 2628 2651 2629 - /* HM FIXME: get InSync raid_dev? */ 2652 + /* HM FIXME: get In_Sync raid_dev? */ 2630 2653 rdev = &rs->dev[0].rdev; 2631 2654 2632 2655 if (rs->delta_disks < 0) { ··· 3126 3149 set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); 3127 3150 rs_set_new(rs); 3128 3151 } else if (rs_is_recovering(rs)) { 3152 + /* Rebuild particular devices */ 3153 + if (test_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags)) { 3154 + set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); 3155 + rs_setup_recovery(rs, MaxSector); 3156 + } 3129 3157 /* A recovering raid set may be resized */ 3130 3158 ; /* skip setup rs */ 3131 3159 } else if (rs_is_reshaping(rs)) { ··· 3224 3242 /* Start raid set read-only and assumed clean to change in raid_resume() */ 3225 3243 rs->md.ro = 1; 3226 3244 rs->md.in_sync = 1; 3245 + 3246 + /* Keep array frozen */ 3227 3247 set_bit(MD_RECOVERY_FROZEN, &rs->md.recovery); 3228 3248 3229 3249 /* Has to be held on running the array */ ··· 3249 3265 rs->callbacks.congested_fn = raid_is_congested; 3250 3266 dm_table_add_target_callbacks(ti->table, &rs->callbacks); 3251 3267 3252 - /* If raid4/5/6 journal mode explictely requested (only possible with journal dev) -> set it */ 3268 + /* If raid4/5/6 journal mode explicitly requested (only possible with journal dev) -> set it */ 3253 3269 if (test_bit(__CTR_FLAG_JOURNAL_MODE, &rs->ctr_flags)) { 3254 3270 r = r5c_journal_mode_set(&rs->md, rs->journal_dev.mode); 3255 3271 if (r) { ··· 3334 3350 return DM_MAPIO_SUBMITTED; 3335 3351 } 3336 3352 3337 - /* Return string describing the current sync action of @mddev */ 3338 - static const char *decipher_sync_action(struct mddev *mddev, unsigned long recovery) 3353 + /* Return sync state string for @state */ 3354 + enum sync_state { st_frozen, st_reshape, st_resync, st_check, st_repair, st_recover, st_idle }; 3355 + static const char *sync_str(enum sync_state state) 3356 + { 3357 + /* Has to be in above sync_state order! */ 3358 + static const char *sync_strs[] = { 3359 + "frozen", 3360 + "reshape", 3361 + "resync", 3362 + "check", 3363 + "repair", 3364 + "recover", 3365 + "idle" 3366 + }; 3367 + 3368 + return __within_range(state, 0, ARRAY_SIZE(sync_strs) - 1) ? sync_strs[state] : "undef"; 3369 + }; 3370 + 3371 + /* Return enum sync_state for @mddev derived from @recovery flags */ 3372 + static const enum sync_state decipher_sync_action(struct mddev *mddev, unsigned long recovery) 3339 3373 { 3340 3374 if (test_bit(MD_RECOVERY_FROZEN, &recovery)) 3341 - return "frozen"; 3375 + return st_frozen; 3342 3376 3343 - /* The MD sync thread can be done with io but still be running */ 3377 + /* The MD sync thread can be done with io or be interrupted but still be running */ 3344 3378 if (!test_bit(MD_RECOVERY_DONE, &recovery) && 3345 3379 (test_bit(MD_RECOVERY_RUNNING, &recovery) || 3346 3380 (!mddev->ro && test_bit(MD_RECOVERY_NEEDED, &recovery)))) { 3347 3381 if (test_bit(MD_RECOVERY_RESHAPE, &recovery)) 3348 - return "reshape"; 3382 + return st_reshape; 3349 3383 3350 3384 if (test_bit(MD_RECOVERY_SYNC, &recovery)) { 3351 3385 if (!test_bit(MD_RECOVERY_REQUESTED, &recovery)) 3352 - return "resync"; 3353 - else if (test_bit(MD_RECOVERY_CHECK, &recovery)) 3354 - return "check"; 3355 - return "repair"; 3386 + return st_resync; 3387 + if (test_bit(MD_RECOVERY_CHECK, &recovery)) 3388 + return st_check; 3389 + return st_repair; 3356 3390 } 3357 3391 3358 3392 if (test_bit(MD_RECOVERY_RECOVER, &recovery)) 3359 - return "recover"; 3393 + return st_recover; 3394 + 3395 + if (mddev->reshape_position != MaxSector) 3396 + return st_reshape; 3360 3397 } 3361 3398 3362 - return "idle"; 3399 + return st_idle; 3363 3400 } 3364 3401 3365 3402 /* ··· 3414 3409 sector_t resync_max_sectors) 3415 3410 { 3416 3411 sector_t r; 3412 + enum sync_state state; 3417 3413 struct mddev *mddev = &rs->md; 3418 3414 3419 3415 clear_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); ··· 3425 3419 set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); 3426 3420 3427 3421 } else { 3428 - if (!test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags) && 3429 - !test_bit(MD_RECOVERY_INTR, &recovery) && 3430 - (test_bit(MD_RECOVERY_NEEDED, &recovery) || 3431 - test_bit(MD_RECOVERY_RESHAPE, &recovery) || 3432 - test_bit(MD_RECOVERY_RUNNING, &recovery))) 3433 - r = mddev->curr_resync_completed; 3434 - else 3435 - r = mddev->recovery_cp; 3422 + state = decipher_sync_action(mddev, recovery); 3436 3423 3437 - if (r >= resync_max_sectors && 3438 - (!test_bit(MD_RECOVERY_REQUESTED, &recovery) || 3439 - (!test_bit(MD_RECOVERY_FROZEN, &recovery) && 3440 - !test_bit(MD_RECOVERY_NEEDED, &recovery) && 3441 - !test_bit(MD_RECOVERY_RUNNING, &recovery)))) { 3424 + if (state == st_idle && !test_bit(MD_RECOVERY_INTR, &recovery)) 3425 + r = mddev->recovery_cp; 3426 + else 3427 + r = mddev->curr_resync_completed; 3428 + 3429 + if (state == st_idle && r >= resync_max_sectors) { 3442 3430 /* 3443 3431 * Sync complete. 3444 3432 */ ··· 3440 3440 if (test_bit(MD_RECOVERY_RECOVER, &recovery)) 3441 3441 set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); 3442 3442 3443 - } else if (test_bit(MD_RECOVERY_RECOVER, &recovery)) { 3443 + } else if (state == st_recover) 3444 3444 /* 3445 3445 * In case we are recovering, the array is not in sync 3446 3446 * and health chars should show the recovering legs. 3447 3447 */ 3448 3448 ; 3449 - 3450 - } else if (test_bit(MD_RECOVERY_SYNC, &recovery) && 3451 - !test_bit(MD_RECOVERY_REQUESTED, &recovery)) { 3449 + else if (state == st_resync) 3452 3450 /* 3453 3451 * If "resync" is occurring, the raid set 3454 3452 * is or may be out of sync hence the health 3455 3453 * characters shall be 'a'. 3456 3454 */ 3457 3455 set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); 3458 - 3459 - } else if (test_bit(MD_RECOVERY_RESHAPE, &recovery) && 3460 - !test_bit(MD_RECOVERY_REQUESTED, &recovery)) { 3456 + else if (state == st_reshape) 3461 3457 /* 3462 3458 * If "reshape" is occurring, the raid set 3463 3459 * is or may be out of sync hence the health ··· 3461 3465 */ 3462 3466 set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); 3463 3467 3464 - } else if (test_bit(MD_RECOVERY_REQUESTED, &recovery)) { 3468 + else if (state == st_check || state == st_repair) 3465 3469 /* 3466 3470 * If "check" or "repair" is occurring, the raid set has 3467 3471 * undergone an initial sync and the health characters ··· 3469 3473 */ 3470 3474 set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); 3471 3475 3472 - } else { 3476 + else { 3473 3477 struct md_rdev *rdev; 3474 3478 3475 3479 /* 3476 3480 * We are idle and recovery is needed, prevent 'A' chars race 3477 - * caused by components still set to in-sync by constrcuctor. 3481 + * caused by components still set to in-sync by constructor. 3478 3482 */ 3479 3483 if (test_bit(MD_RECOVERY_NEEDED, &recovery)) 3480 3484 set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); ··· 3538 3542 progress = rs_get_progress(rs, recovery, resync_max_sectors); 3539 3543 resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ? 3540 3544 atomic64_read(&mddev->resync_mismatches) : 0; 3541 - sync_action = decipher_sync_action(&rs->md, recovery); 3545 + sync_action = sync_str(decipher_sync_action(&rs->md, recovery)); 3542 3546 3543 3547 /* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */ 3544 3548 for (i = 0; i < rs->raid_disks; i++) ··· 3888 3892 struct mddev *mddev = &rs->md; 3889 3893 struct md_personality *pers = mddev->pers; 3890 3894 3895 + /* Don't allow the sync thread to work until the table gets reloaded. */ 3896 + set_bit(MD_RECOVERY_WAIT, &mddev->recovery); 3897 + 3891 3898 r = rs_setup_reshape(rs); 3892 3899 if (r) 3893 3900 return r; 3894 - 3895 - /* Need to be resumed to be able to start reshape, recovery is frozen until raid_resume() though */ 3896 - if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) 3897 - mddev_resume(mddev); 3898 3901 3899 3902 /* 3900 3903 * Check any reshape constraints enforced by the personalility ··· 3918 3923 } 3919 3924 } 3920 3925 3921 - /* Suspend because a resume will happen in raid_resume() */ 3922 - set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags); 3923 - mddev_suspend(mddev); 3924 - 3925 3926 /* 3926 3927 * Now reshape got set up, update superblocks to 3927 3928 * reflect the fact so that a table reload will ··· 3937 3946 /* This is a resume after a suspend of the set -> it's already started. */ 3938 3947 if (test_and_set_bit(RT_FLAG_RS_PRERESUMED, &rs->runtime_flags)) 3939 3948 return 0; 3940 - 3941 - if (!test_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags)) { 3942 - struct raid_set *rs_active = rs_find_active(rs); 3943 - 3944 - if (rs_active) { 3945 - /* 3946 - * In case no rebuilds have been requested 3947 - * and an active table slot exists, copy 3948 - * current resynchonization completed and 3949 - * reshape position pointers across from 3950 - * suspended raid set in the active slot. 3951 - * 3952 - * This resumes the new mapping at current 3953 - * offsets to continue recover/reshape without 3954 - * necessarily redoing a raid set partially or 3955 - * causing data corruption in case of a reshape. 3956 - */ 3957 - if (rs_active->md.curr_resync_completed != MaxSector) 3958 - mddev->curr_resync_completed = rs_active->md.curr_resync_completed; 3959 - if (rs_active->md.reshape_position != MaxSector) 3960 - mddev->reshape_position = rs_active->md.reshape_position; 3961 - } 3962 - } 3963 3949 3964 3950 /* 3965 3951 * The superblocks need to be updated on disk if the ··· 4014 4046 4015 4047 static struct target_type raid_target = { 4016 4048 .name = "raid", 4017 - .version = {1, 13, 2}, 4049 + .version = {1, 14, 0}, 4018 4050 .module = THIS_MODULE, 4019 4051 .ctr = raid_ctr, 4020 4052 .dtr = raid_dtr,
+35 -1
drivers/md/dm-thin-metadata.c
··· 189 189 sector_t data_block_size; 190 190 191 191 /* 192 + * We reserve a section of the metadata for commit overhead. 193 + * All reported space does *not* include this. 194 + */ 195 + dm_block_t metadata_reserve; 196 + 197 + /* 192 198 * Set if a transaction has to be aborted but the attempt to roll back 193 199 * to the previous (good) transaction failed. The only pool metadata 194 200 * operation possible in this state is the closing of the device. ··· 822 816 return dm_tm_commit(pmd->tm, sblock); 823 817 } 824 818 819 + static void __set_metadata_reserve(struct dm_pool_metadata *pmd) 820 + { 821 + int r; 822 + dm_block_t total; 823 + dm_block_t max_blocks = 4096; /* 16M */ 824 + 825 + r = dm_sm_get_nr_blocks(pmd->metadata_sm, &total); 826 + if (r) { 827 + DMERR("could not get size of metadata device"); 828 + pmd->metadata_reserve = max_blocks; 829 + } else { 830 + sector_div(total, 10); 831 + pmd->metadata_reserve = min(max_blocks, total); 832 + } 833 + } 834 + 825 835 struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, 826 836 sector_t data_block_size, 827 837 bool format_device) ··· 870 848 DMWARN("%s: dm_pool_metadata_close() failed.", __func__); 871 849 return ERR_PTR(r); 872 850 } 851 + 852 + __set_metadata_reserve(pmd); 873 853 874 854 return pmd; 875 855 } ··· 1844 1820 down_read(&pmd->root_lock); 1845 1821 if (!pmd->fail_io) 1846 1822 r = dm_sm_get_nr_free(pmd->metadata_sm, result); 1823 + 1824 + if (!r) { 1825 + if (*result < pmd->metadata_reserve) 1826 + *result = 0; 1827 + else 1828 + *result -= pmd->metadata_reserve; 1829 + } 1847 1830 up_read(&pmd->root_lock); 1848 1831 1849 1832 return r; ··· 1963 1932 int r = -EINVAL; 1964 1933 1965 1934 down_write(&pmd->root_lock); 1966 - if (!pmd->fail_io) 1935 + if (!pmd->fail_io) { 1967 1936 r = __resize_space_map(pmd->metadata_sm, new_count); 1937 + if (!r) 1938 + __set_metadata_reserve(pmd); 1939 + } 1968 1940 up_write(&pmd->root_lock); 1969 1941 1970 1942 return r;
+65 -8
drivers/md/dm-thin.c
··· 200 200 enum pool_mode { 201 201 PM_WRITE, /* metadata may be changed */ 202 202 PM_OUT_OF_DATA_SPACE, /* metadata may be changed, though data may not be allocated */ 203 + 204 + /* 205 + * Like READ_ONLY, except may switch back to WRITE on metadata resize. Reported as READ_ONLY. 206 + */ 207 + PM_OUT_OF_METADATA_SPACE, 203 208 PM_READ_ONLY, /* metadata may not be changed */ 209 + 204 210 PM_FAIL, /* all I/O fails */ 205 211 }; 206 212 ··· 1377 1371 1378 1372 static void requeue_bios(struct pool *pool); 1379 1373 1380 - static void check_for_space(struct pool *pool) 1374 + static bool is_read_only_pool_mode(enum pool_mode mode) 1375 + { 1376 + return (mode == PM_OUT_OF_METADATA_SPACE || mode == PM_READ_ONLY); 1377 + } 1378 + 1379 + static bool is_read_only(struct pool *pool) 1380 + { 1381 + return is_read_only_pool_mode(get_pool_mode(pool)); 1382 + } 1383 + 1384 + static void check_for_metadata_space(struct pool *pool) 1385 + { 1386 + int r; 1387 + const char *ooms_reason = NULL; 1388 + dm_block_t nr_free; 1389 + 1390 + r = dm_pool_get_free_metadata_block_count(pool->pmd, &nr_free); 1391 + if (r) 1392 + ooms_reason = "Could not get free metadata blocks"; 1393 + else if (!nr_free) 1394 + ooms_reason = "No free metadata blocks"; 1395 + 1396 + if (ooms_reason && !is_read_only(pool)) { 1397 + DMERR("%s", ooms_reason); 1398 + set_pool_mode(pool, PM_OUT_OF_METADATA_SPACE); 1399 + } 1400 + } 1401 + 1402 + static void check_for_data_space(struct pool *pool) 1381 1403 { 1382 1404 int r; 1383 1405 dm_block_t nr_free; ··· 1431 1397 { 1432 1398 int r; 1433 1399 1434 - if (get_pool_mode(pool) >= PM_READ_ONLY) 1400 + if (get_pool_mode(pool) >= PM_OUT_OF_METADATA_SPACE) 1435 1401 return -EINVAL; 1436 1402 1437 1403 r = dm_pool_commit_metadata(pool->pmd); 1438 1404 if (r) 1439 1405 metadata_operation_failed(pool, "dm_pool_commit_metadata", r); 1440 - else 1441 - check_for_space(pool); 1406 + else { 1407 + check_for_metadata_space(pool); 1408 + check_for_data_space(pool); 1409 + } 1442 1410 1443 1411 return r; 1444 1412 } ··· 1506 1470 return r; 1507 1471 } 1508 1472 1473 + r = dm_pool_get_free_metadata_block_count(pool->pmd, &free_blocks); 1474 + if (r) { 1475 + metadata_operation_failed(pool, "dm_pool_get_free_metadata_block_count", r); 1476 + return r; 1477 + } 1478 + 1479 + if (!free_blocks) { 1480 + /* Let's commit before we use up the metadata reserve. */ 1481 + r = commit(pool); 1482 + if (r) 1483 + return r; 1484 + } 1485 + 1509 1486 return 0; 1510 1487 } 1511 1488 ··· 1550 1501 case PM_OUT_OF_DATA_SPACE: 1551 1502 return pool->pf.error_if_no_space ? BLK_STS_NOSPC : 0; 1552 1503 1504 + case PM_OUT_OF_METADATA_SPACE: 1553 1505 case PM_READ_ONLY: 1554 1506 case PM_FAIL: 1555 1507 return BLK_STS_IOERR; ··· 2514 2464 error_retry_list(pool); 2515 2465 break; 2516 2466 2467 + case PM_OUT_OF_METADATA_SPACE: 2517 2468 case PM_READ_ONLY: 2518 - if (old_mode != new_mode) 2469 + if (!is_read_only_pool_mode(old_mode)) 2519 2470 notify_of_pool_mode_change(pool, "read-only"); 2520 2471 dm_pool_metadata_read_only(pool->pmd); 2521 2472 pool->process_bio = process_bio_read_only; ··· 3454 3403 DMINFO("%s: growing the metadata device from %llu to %llu blocks", 3455 3404 dm_device_name(pool->pool_md), 3456 3405 sb_metadata_dev_size, metadata_dev_size); 3406 + 3407 + if (get_pool_mode(pool) == PM_OUT_OF_METADATA_SPACE) 3408 + set_pool_mode(pool, PM_WRITE); 3409 + 3457 3410 r = dm_pool_resize_metadata_dev(pool->pmd, metadata_dev_size); 3458 3411 if (r) { 3459 3412 metadata_operation_failed(pool, "dm_pool_resize_metadata_dev", r); ··· 3762 3707 struct pool_c *pt = ti->private; 3763 3708 struct pool *pool = pt->pool; 3764 3709 3765 - if (get_pool_mode(pool) >= PM_READ_ONLY) { 3710 + if (get_pool_mode(pool) >= PM_OUT_OF_METADATA_SPACE) { 3766 3711 DMERR("%s: unable to service pool target messages in READ_ONLY or FAIL mode", 3767 3712 dm_device_name(pool->pool_md)); 3768 3713 return -EOPNOTSUPP; ··· 3836 3781 dm_block_t nr_blocks_data; 3837 3782 dm_block_t nr_blocks_metadata; 3838 3783 dm_block_t held_root; 3784 + enum pool_mode mode; 3839 3785 char buf[BDEVNAME_SIZE]; 3840 3786 char buf2[BDEVNAME_SIZE]; 3841 3787 struct pool_c *pt = ti->private; ··· 3907 3851 else 3908 3852 DMEMIT("- "); 3909 3853 3910 - if (pool->pf.mode == PM_OUT_OF_DATA_SPACE) 3854 + mode = get_pool_mode(pool); 3855 + if (mode == PM_OUT_OF_DATA_SPACE) 3911 3856 DMEMIT("out_of_data_space "); 3912 - else if (pool->pf.mode == PM_READ_ONLY) 3857 + else if (is_read_only_pool_mode(mode)) 3913 3858 DMEMIT("ro "); 3914 3859 else 3915 3860 DMEMIT("rw ");
+20 -4
drivers/md/dm-verity-target.c
··· 99 99 { 100 100 struct scatterlist sg; 101 101 102 - sg_init_one(&sg, data, len); 103 - ahash_request_set_crypt(req, &sg, NULL, len); 104 - 105 - return crypto_wait_req(crypto_ahash_update(req), wait); 102 + if (likely(!is_vmalloc_addr(data))) { 103 + sg_init_one(&sg, data, len); 104 + ahash_request_set_crypt(req, &sg, NULL, len); 105 + return crypto_wait_req(crypto_ahash_update(req), wait); 106 + } else { 107 + do { 108 + int r; 109 + size_t this_step = min_t(size_t, len, PAGE_SIZE - offset_in_page(data)); 110 + flush_kernel_vmap_range((void *)data, this_step); 111 + sg_init_table(&sg, 1); 112 + sg_set_page(&sg, vmalloc_to_page(data), this_step, offset_in_page(data)); 113 + ahash_request_set_crypt(req, &sg, NULL, this_step); 114 + r = crypto_wait_req(crypto_ahash_update(req), wait); 115 + if (unlikely(r)) 116 + return r; 117 + data += this_step; 118 + len -= this_step; 119 + } while (len); 120 + return 0; 121 + } 106 122 } 107 123 108 124 /*