DRBD requires stable pages because it may read the same bio data multiple times for local disk I/O and network transmission, and in some cases for calculating checksums. The BLK_FEAT_STABLE_WRITES flag is set when the device is first created, but blk_set_stacking_limits() clears it whenever a backing device is attached. In some cases the flag may be inherited from the backing device, but we want it to be enabled at all times. Unconditionally re-enable BLK_FEAT_STABLE_WRITES in drbd_reconsider_queue_parameters() after the queue parameter negotiations. Also, document why we want this flag enabled in the first place.
Unified · Split
| @@ -2659,9 +2659,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig · 2658 unmodified lines | |||
| 2659 | * connect. | 2659 | * connect. |
| 2660 | */ | 2660 | */ |
| 2661 | .max_hw_sectors = DRBD_MAX_BIO_SIZE_SAFE >> 8, | 2661 | .max_hw_sectors = DRBD_MAX_BIO_SIZE_SAFE >> 8, |
| 2662 | .features = BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA | | ||
| 2663 | BLK_FEAT_ROTATIONAL | | ||
| 2664 | BLK_FEAT_STABLE_WRITES, | ||
| 2665 | }; | 2662 | }; |
| 2666 | 2663 | ||
| 2667 | device = minor_to_device(minor); | 2664 | device = minor_to_device(minor); |
| @@ -1296,6 +1296,8 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device, · 1295 unmodified lines | |||
| 1296 | lim.max_segments = drbd_backing_dev_max_segments(device); | 1296 | lim.max_segments = drbd_backing_dev_max_segments(device); |
| 1297 | } else { | 1297 | } else { |
| 1298 | lim.max_segments = BLK_MAX_SEGMENTS; | 1298 | lim.max_segments = BLK_MAX_SEGMENTS; |
| 1299 | lim.features = BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA | | ||
| 1300 | BLK_FEAT_ROTATIONAL | BLK_FEAT_STABLE_WRITES; | ||
| 1299 | } | 1301 | } |
| 1300 | 1302 | ||
| 1301 | lim.max_hw_sectors = new >> SECTOR_SHIFT; | 1303 | lim.max_hw_sectors = new >> SECTOR_SHIFT; |
| @@ -1318,8 +1320,24 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device, · 16 unmodified lines | |||
| 1318 | lim.max_hw_discard_sectors = 0; | 1320 | lim.max_hw_discard_sectors = 0; |
| 1319 | } | 1321 | } |
| 1320 | 1322 | ||
| 1321 | if (bdev) | 1323 | if (bdev) { |
| 1322 | blk_stack_limits(&lim, &b->limits, 0); | 1324 | blk_stack_limits(&lim, &b->limits, 0); |
| 1325 | /* | ||
| 1326 | * blk_set_stacking_limits() cleared the features, and | ||
| 1327 | * blk_stack_limits() may or may not have inherited | ||
| 1328 | * BLK_FEAT_STABLE_WRITES from the backing device. | ||
| 1329 | * | ||
| 1330 | * DRBD always requires stable writes because: | ||
| 1331 | * 1. The same bio data is read for both local disk I/O and | ||
| 1332 | * network transmission. If the page changes mid-flight, | ||
| 1333 | * the local and remote copies could diverge. | ||
| 1334 | * 2. When data integrity is enabled, DRBD calculates a | ||
| 1335 | * checksum before sending the data. If the page changes | ||
| 1336 | * between checksum calculation and transmission, the | ||
| 1337 | * receiver will detect a checksum mismatch. | ||
| 1338 | */ | ||
| 1339 | lim.features |= BLK_FEAT_STABLE_WRITES; | ||
| 1340 | } | ||
| 1323 | 1341 | ||
| 1324 | /* | 1342 | /* |
| 1325 | * If we can handle "zeroes" efficiently on the protocol, we want to do | 1343 | * If we can handle "zeroes" efficiently on the protocol, we want to do |