@@ -219,7 +219,6 @@ void drbd_req_complete(struct drbd_request *req, struct bio_and_error *m)
219219{
220220 const unsigned s = req -> rq_state ;
221221 struct drbd_device * device = req -> device ;
222- int rw ;
223222 int error , ok ;
224223
225224 /* we must not complete the master bio, while it is
@@ -243,8 +242,6 @@ void drbd_req_complete(struct drbd_request *req, struct bio_and_error *m)
243242 return ;
244243 }
245244
246- rw = bio_rw (req -> master_bio );
247-
248245 /*
249246 * figure out whether to report success or failure.
250247 *
@@ -268,7 +265,7 @@ void drbd_req_complete(struct drbd_request *req, struct bio_and_error *m)
268265 * epoch number. If they match, increase the current_tle_nr,
269266 * and reset the transfer log epoch write_cnt.
270267 */
271- if (rw == WRITE &&
268+ if (op_is_write ( bio_op ( req -> master_bio )) &&
272269 req -> epoch == atomic_read (& first_peer_device (device )-> connection -> current_tle_nr ))
273270 start_new_tl_epoch (first_peer_device (device )-> connection );
274271
@@ -285,11 +282,14 @@ void drbd_req_complete(struct drbd_request *req, struct bio_and_error *m)
285282 * because no path was available, in which case
286283 * it was not even added to the transfer_log.
287284 *
288- * READA may fail, and will not be retried.
285+ * read-ahead may fail, and will not be retried.
289286 *
290287 * WRITE should have used all available paths already.
291288 */
292- if (!ok && rw == READ && !list_empty (& req -> tl_requests ))
289+ if (!ok &&
290+ bio_op (req -> master_bio ) == REQ_OP_READ &&
291+ !(req -> master_bio -> bi_rw & REQ_RAHEAD ) &&
292+ !list_empty (& req -> tl_requests ))
293293 req -> rq_state |= RQ_POSTPONED ;
294294
295295 if (!(req -> rq_state & RQ_POSTPONED )) {
@@ -645,7 +645,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
645645 __drbd_chk_io_error (device , DRBD_READ_ERROR );
646646 /* fall through. */
647647 case READ_AHEAD_COMPLETED_WITH_ERROR :
648- /* it is legal to fail READA , no __drbd_chk_io_error in that case. */
648+ /* it is legal to fail read-ahead , no __drbd_chk_io_error in that case. */
649649 mod_rq_state (req , m , RQ_LOCAL_PENDING , RQ_LOCAL_COMPLETED );
650650 break ;
651651
@@ -657,7 +657,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
657657 break ;
658658
659659 case QUEUE_FOR_NET_READ :
660- /* READ or READA , and
660+ /* READ, and
661661 * no local disk,
662662 * or target area marked as invalid,
663663 * or just got an io-error. */
@@ -1172,7 +1172,14 @@ drbd_submit_req_private_bio(struct drbd_request *req)
11721172{
11731173 struct drbd_device * device = req -> device ;
11741174 struct bio * bio = req -> private_bio ;
1175- const int rw = bio_rw (bio );
1175+ unsigned int type ;
1176+
1177+ if (bio_op (bio ) != REQ_OP_READ )
1178+ type = DRBD_FAULT_DT_WR ;
1179+ else if (bio -> bi_rw & REQ_RAHEAD )
1180+ type = DRBD_FAULT_DT_RA ;
1181+ else
1182+ type = DRBD_FAULT_DT_RD ;
11761183
11771184 bio -> bi_bdev = device -> ldev -> backing_bdev ;
11781185
@@ -1182,10 +1189,7 @@ drbd_submit_req_private_bio(struct drbd_request *req)
11821189 * stable storage, and this is a WRITE, we may not even submit
11831190 * this bio. */
11841191 if (get_ldev (device )) {
1185- if (drbd_insert_fault (device ,
1186- rw == WRITE ? DRBD_FAULT_DT_WR
1187- : rw == READ ? DRBD_FAULT_DT_RD
1188- : DRBD_FAULT_DT_RA ))
1192+ if (drbd_insert_fault (device , type ))
11891193 bio_io_error (bio );
11901194 else if (bio_op (bio ) == REQ_OP_DISCARD )
11911195 drbd_process_discard_req (req );
@@ -1278,7 +1282,7 @@ static bool may_do_writes(struct drbd_device *device)
12781282static void drbd_send_and_submit (struct drbd_device * device , struct drbd_request * req )
12791283{
12801284 struct drbd_resource * resource = device -> resource ;
1281- const int rw = bio_rw (req -> master_bio );
1285+ const int rw = bio_data_dir (req -> master_bio );
12821286 struct bio_and_error m = { NULL , };
12831287 bool no_remote = false;
12841288 bool submit_private_bio = false;
@@ -1308,7 +1312,7 @@ static void drbd_send_and_submit(struct drbd_device *device, struct drbd_request
13081312 goto out ;
13091313 }
13101314
1311- /* We fail READ/READA early, if we can not serve it.
1315+ /* We fail READ early, if we can not serve it.
13121316 * We must do this before req is registered on any lists.
13131317 * Otherwise, drbd_req_complete() will queue failed READ for retry. */
13141318 if (rw != WRITE ) {
0 commit comments