@@ -1189,6 +1189,33 @@ static int drbd_check_al_size(struct drbd_device *device, struct disk_conf *dc)
1189
1189
return 0 ;
1190
1190
}
1191
1191
1192
+ static unsigned int drbd_max_peer_bio_size (struct drbd_device * device )
1193
+ {
1194
+ /*
1195
+ * We may ignore peer limits if the peer is modern enough. From 8.3.8
1196
+ * onwards the peer can use multiple BIOs for a single peer_request.
1197
+ */
1198
+ if (device -> state .conn < C_WF_REPORT_PARAMS )
1199
+ return device -> peer_max_bio_size ;
1200
+
1201
+ if (first_peer_device (device )-> connection -> agreed_pro_version < 94 )
1202
+ return min (device -> peer_max_bio_size , DRBD_MAX_SIZE_H80_PACKET );
1203
+
1204
+ /*
1205
+ * Correct old drbd (up to 8.3.7) if it believes it can do more than
1206
+ * 32KiB.
1207
+ */
1208
+ if (first_peer_device (device )-> connection -> agreed_pro_version == 94 )
1209
+ return DRBD_MAX_SIZE_H80_PACKET ;
1210
+
1211
+ /*
1212
+ * drbd 8.3.8 onwards, before 8.4.0
1213
+ */
1214
+ if (first_peer_device (device )-> connection -> agreed_pro_version < 100 )
1215
+ return DRBD_MAX_BIO_SIZE_P95 ;
1216
+ return DRBD_MAX_BIO_SIZE ;
1217
+ }
1218
+
1192
1219
static void blk_queue_discard_granularity (struct request_queue * q , unsigned int granularity )
1193
1220
{
1194
1221
q -> limits .discard_granularity = granularity ;
@@ -1303,48 +1330,35 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi
1303
1330
fixup_discard_support (device , q );
1304
1331
}
1305
1332
1306
- void drbd_reconsider_queue_parameters (struct drbd_device * device , struct drbd_backing_dev * bdev , struct o_qlim * o )
1333
+ void drbd_reconsider_queue_parameters (struct drbd_device * device ,
1334
+ struct drbd_backing_dev * bdev , struct o_qlim * o )
1307
1335
{
1308
- unsigned int now , new , local , peer ;
1309
-
1310
- now = queue_max_hw_sectors (device -> rq_queue ) << 9 ;
1311
- local = device -> local_max_bio_size ; /* Eventually last known value, from volatile memory */
1312
- peer = device -> peer_max_bio_size ; /* Eventually last known value, from meta data */
1336
+ unsigned int now = queue_max_hw_sectors (device -> rq_queue ) <<
1337
+ SECTOR_SHIFT ;
1338
+ unsigned int new ;
1313
1339
1314
1340
if (bdev ) {
1315
- local = queue_max_hw_sectors (bdev -> backing_bdev -> bd_disk -> queue ) << 9 ;
1316
- device -> local_max_bio_size = local ;
1317
- }
1318
- local = min (local , DRBD_MAX_BIO_SIZE );
1319
-
1320
- /* We may ignore peer limits if the peer is modern enough.
1321
- Because new from 8.3.8 onwards the peer can use multiple
1322
- BIOs for a single peer_request */
1323
- if (device -> state .conn >= C_WF_REPORT_PARAMS ) {
1324
- if (first_peer_device (device )-> connection -> agreed_pro_version < 94 )
1325
- peer = min (device -> peer_max_bio_size , DRBD_MAX_SIZE_H80_PACKET );
1326
- /* Correct old drbd (up to 8.3.7) if it believes it can do more than 32KiB */
1327
- else if (first_peer_device (device )-> connection -> agreed_pro_version == 94 )
1328
- peer = DRBD_MAX_SIZE_H80_PACKET ;
1329
- else if (first_peer_device (device )-> connection -> agreed_pro_version < 100 )
1330
- peer = DRBD_MAX_BIO_SIZE_P95 ; /* drbd 8.3.8 onwards, before 8.4.0 */
1331
- else
1332
- peer = DRBD_MAX_BIO_SIZE ;
1341
+ struct request_queue * b = bdev -> backing_bdev -> bd_disk -> queue ;
1333
1342
1334
- /* We may later detach and re-attach on a disconnected Primary.
1335
- * Avoid this setting to jump back in that case.
1336
- * We want to store what we know the peer DRBD can handle,
1337
- * not what the peer IO backend can handle. */
1338
- if (peer > device -> peer_max_bio_size )
1339
- device -> peer_max_bio_size = peer ;
1343
+ device -> local_max_bio_size =
1344
+ queue_max_hw_sectors (b ) << SECTOR_SHIFT ;
1340
1345
}
1341
- new = min (local , peer );
1342
1346
1343
- if (device -> state .role == R_PRIMARY && new < now )
1344
- drbd_err (device , "ASSERT FAILED new < now; (%u < %u)\n" , new , now );
1345
-
1346
- if (new != now )
1347
+ /*
1348
+ * We may later detach and re-attach on a disconnected Primary. Avoid
1349
+ * decreasing the value in this case.
1350
+ *
1351
+ * We want to store what we know the peer DRBD can handle, not what the
1352
+ * peer IO backend can handle.
1353
+ */
1354
+ new = min3 (DRBD_MAX_BIO_SIZE , device -> local_max_bio_size ,
1355
+ max (drbd_max_peer_bio_size (device ), device -> peer_max_bio_size ));
1356
+ if (new != now ) {
1357
+ if (device -> state .role == R_PRIMARY && new < now )
1358
+ drbd_err (device , "ASSERT FAILED new < now; (%u < %u)\n" ,
1359
+ new , now );
1347
1360
drbd_info (device , "max BIO size = %u\n" , new );
1361
+ }
1348
1362
1349
1363
drbd_setup_queue_param (device , bdev , new , o );
1350
1364
}
0 commit comments