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

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

Pull device mapper fixes from Mike Snitzer:

- dm thinp fix for crash that will occur when metadata device failure
races with discard passdown to the underlying data device.

- dm raid fix to not access the superblock's >= 1.9.0 'sectors' member
unconditionally.

* tag 'for-4.12/dm-fixes-5' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm thin: do not queue freed thin mapping for next stage processing
dm raid: fix oops on upgrading to extended superblock format

+27 -16
+14 -3
drivers/md/dm-raid.c
··· 1927 1927 /******************************************************************** 1928 1928 * BELOW FOLLOW V1.9.0 EXTENSIONS TO THE PRISTINE SUPERBLOCK FORMAT!!! 1929 1929 * 1930 - * FEATURE_FLAG_SUPPORTS_V190 in the features member indicates that those exist 1930 + * FEATURE_FLAG_SUPPORTS_V190 in the compat_features member indicates that those exist 1931 1931 */ 1932 1932 1933 1933 __le32 flags; /* Flags defining array states for reshaping */ ··· 2092 2092 sb->layout = cpu_to_le32(mddev->layout); 2093 2093 sb->stripe_sectors = cpu_to_le32(mddev->chunk_sectors); 2094 2094 2095 + /******************************************************************** 2096 + * BELOW FOLLOW V1.9.0 EXTENSIONS TO THE PRISTINE SUPERBLOCK FORMAT!!! 2097 + * 2098 + * FEATURE_FLAG_SUPPORTS_V190 in the compat_features member indicates that those exist 2099 + */ 2095 2100 sb->new_level = cpu_to_le32(mddev->new_level); 2096 2101 sb->new_layout = cpu_to_le32(mddev->new_layout); 2097 2102 sb->new_stripe_sectors = cpu_to_le32(mddev->new_chunk_sectors); ··· 2443 2438 mddev->bitmap_info.default_offset = mddev->bitmap_info.offset; 2444 2439 2445 2440 if (!test_and_clear_bit(FirstUse, &rdev->flags)) { 2446 - /* Retrieve device size stored in superblock to be prepared for shrink */ 2447 - rdev->sectors = le64_to_cpu(sb->sectors); 2441 + /* 2442 + * Retrieve rdev size stored in superblock to be prepared for shrink. 2443 + * Check extended superblock members are present otherwise the size 2444 + * will not be set! 2445 + */ 2446 + if (le32_to_cpu(sb->compat_features) & FEATURE_FLAG_SUPPORTS_V190) 2447 + rdev->sectors = le64_to_cpu(sb->sectors); 2448 + 2448 2449 rdev->recovery_offset = le64_to_cpu(sb->disk_recovery_offset); 2449 2450 if (rdev->recovery_offset == MaxSector) 2450 2451 set_bit(In_sync, &rdev->flags);
+13 -13
drivers/md/dm-thin.c
··· 1094 1094 return; 1095 1095 } 1096 1096 1097 + /* 1098 + * Increment the unmapped blocks. This prevents a race between the 1099 + * passdown io and reallocation of freed blocks. 1100 + */ 1101 + r = dm_pool_inc_data_range(pool->pmd, m->data_block, data_end); 1102 + if (r) { 1103 + metadata_operation_failed(pool, "dm_pool_inc_data_range", r); 1104 + bio_io_error(m->bio); 1105 + cell_defer_no_holder(tc, m->cell); 1106 + mempool_free(m, pool->mapping_pool); 1107 + return; 1108 + } 1109 + 1097 1110 discard_parent = bio_alloc(GFP_NOIO, 1); 1098 1111 if (!discard_parent) { 1099 1112 DMWARN("%s: unable to allocate top level discard bio for passdown. Skipping passdown.", ··· 1126 1113 r = issue_discard(&op, m->data_block, data_end); 1127 1114 end_discard(&op, r); 1128 1115 } 1129 - } 1130 - 1131 - /* 1132 - * Increment the unmapped blocks. This prevents a race between the 1133 - * passdown io and reallocation of freed blocks. 1134 - */ 1135 - r = dm_pool_inc_data_range(pool->pmd, m->data_block, data_end); 1136 - if (r) { 1137 - metadata_operation_failed(pool, "dm_pool_inc_data_range", r); 1138 - bio_io_error(m->bio); 1139 - cell_defer_no_holder(tc, m->cell); 1140 - mempool_free(m, pool->mapping_pool); 1141 - return; 1142 1116 } 1143 1117 } 1144 1118