Lines Matching refs:peer_req

196 	struct drbd_peer_request *peer_req, *tmp;  in reclaim_finished_net_peer_reqs()  local
203 list_for_each_entry_safe(peer_req, tmp, &device->net_ee, w.list) { in reclaim_finished_net_peer_reqs()
204 if (drbd_peer_req_has_active_page(peer_req)) in reclaim_finished_net_peer_reqs()
206 list_move(&peer_req->w.list, to_be_freed); in reclaim_finished_net_peer_reqs()
213 struct drbd_peer_request *peer_req, *t; in drbd_reclaim_net_peer_reqs() local
218 list_for_each_entry_safe(peer_req, t, &reclaimed, w.list) in drbd_reclaim_net_peer_reqs()
219 drbd_free_net_peer_req(device, peer_req); in drbd_reclaim_net_peer_reqs()
364 struct drbd_peer_request *peer_req; in drbd_alloc_peer_req() local
371 peer_req = mempool_alloc(&drbd_ee_mempool, gfp_mask & ~__GFP_HIGHMEM); in drbd_alloc_peer_req()
372 if (!peer_req) { in drbd_alloc_peer_req()
385 memset(peer_req, 0, sizeof(*peer_req)); in drbd_alloc_peer_req()
386 INIT_LIST_HEAD(&peer_req->w.list); in drbd_alloc_peer_req()
387 drbd_clear_interval(&peer_req->i); in drbd_alloc_peer_req()
388 peer_req->i.size = request_size; in drbd_alloc_peer_req()
389 peer_req->i.sector = sector; in drbd_alloc_peer_req()
390 peer_req->submit_jif = jiffies; in drbd_alloc_peer_req()
391 peer_req->peer_device = peer_device; in drbd_alloc_peer_req()
392 peer_req->pages = page; in drbd_alloc_peer_req()
397 peer_req->block_id = id; in drbd_alloc_peer_req()
399 return peer_req; in drbd_alloc_peer_req()
402 mempool_free(peer_req, &drbd_ee_mempool); in drbd_alloc_peer_req()
406 void __drbd_free_peer_req(struct drbd_device *device, struct drbd_peer_request *peer_req, in __drbd_free_peer_req() argument
410 if (peer_req->flags & EE_HAS_DIGEST) in __drbd_free_peer_req()
411 kfree(peer_req->digest); in __drbd_free_peer_req()
412 drbd_free_pages(device, peer_req->pages, is_net); in __drbd_free_peer_req()
413 D_ASSERT(device, atomic_read(&peer_req->pending_bios) == 0); in __drbd_free_peer_req()
414 D_ASSERT(device, drbd_interval_empty(&peer_req->i)); in __drbd_free_peer_req()
415 if (!expect(device, !(peer_req->flags & EE_CALL_AL_COMPLETE_IO))) { in __drbd_free_peer_req()
416 peer_req->flags &= ~EE_CALL_AL_COMPLETE_IO; in __drbd_free_peer_req()
417 drbd_al_complete_io(device, &peer_req->i); in __drbd_free_peer_req()
419 mempool_free(peer_req, &drbd_ee_mempool); in __drbd_free_peer_req()
425 struct drbd_peer_request *peer_req, *t; in drbd_free_peer_reqs() local
433 list_for_each_entry_safe(peer_req, t, &work_list, w.list) { in drbd_free_peer_reqs()
434 __drbd_free_peer_req(device, peer_req, is_net); in drbd_free_peer_reqs()
447 struct drbd_peer_request *peer_req, *t; in drbd_finish_peer_reqs() local
455 list_for_each_entry_safe(peer_req, t, &reclaimed, w.list) in drbd_finish_peer_reqs()
456 drbd_free_net_peer_req(device, peer_req); in drbd_finish_peer_reqs()
462 list_for_each_entry_safe(peer_req, t, &work_list, w.list) { in drbd_finish_peer_reqs()
466 err2 = peer_req->w.cb(&peer_req->w, !!err); in drbd_finish_peer_reqs()
469 drbd_free_peer_req(device, peer_req); in drbd_finish_peer_reqs()
1593 …drbd_issue_peer_discard_or_zero_out(struct drbd_device *device, struct drbd_peer_request *peer_req) in drbd_issue_peer_discard_or_zero_out() argument
1600 peer_req->flags |= EE_ZEROOUT; in drbd_issue_peer_discard_or_zero_out()
1602 if (drbd_issue_discard_or_zero_out(device, peer_req->i.sector, in drbd_issue_peer_discard_or_zero_out()
1603 peer_req->i.size >> 9, peer_req->flags & (EE_ZEROOUT|EE_TRIM))) in drbd_issue_peer_discard_or_zero_out()
1604 peer_req->flags |= EE_WAS_ERROR; in drbd_issue_peer_discard_or_zero_out()
1605 drbd_endio_write_sec_final(peer_req); in drbd_issue_peer_discard_or_zero_out()
1608 static int peer_request_fault_type(struct drbd_peer_request *peer_req) in peer_request_fault_type() argument
1610 if (peer_req_op(peer_req) == REQ_OP_READ) { in peer_request_fault_type()
1611 return peer_req->flags & EE_APPLICATION ? in peer_request_fault_type()
1614 return peer_req->flags & EE_APPLICATION ? in peer_request_fault_type()
1634 int drbd_submit_peer_request(struct drbd_peer_request *peer_req) in drbd_submit_peer_request() argument
1636 struct drbd_device *device = peer_req->peer_device->device; in drbd_submit_peer_request()
1639 struct page *page = peer_req->pages; in drbd_submit_peer_request()
1640 sector_t sector = peer_req->i.sector; in drbd_submit_peer_request()
1641 unsigned int data_size = peer_req->i.size; in drbd_submit_peer_request()
1651 if (peer_req->flags & (EE_TRIM | EE_ZEROOUT)) { in drbd_submit_peer_request()
1654 conn_wait_active_ee_empty(peer_req->peer_device->connection); in drbd_submit_peer_request()
1657 peer_req->submit_jif = jiffies; in drbd_submit_peer_request()
1658 peer_req->flags |= EE_SUBMITTED; in drbd_submit_peer_request()
1662 if (list_empty(&peer_req->w.list)) { in drbd_submit_peer_request()
1664 list_add_tail(&peer_req->w.list, &device->active_ee); in drbd_submit_peer_request()
1668 drbd_issue_peer_discard_or_zero_out(device, peer_req); in drbd_submit_peer_request()
1686 if (!(peer_req_op(peer_req) == REQ_OP_WRITE || in drbd_submit_peer_request()
1687 peer_req_op(peer_req) == REQ_OP_READ)) { in drbd_submit_peer_request()
1688 drbd_err(device, "Invalid bio op received: 0x%x\n", peer_req->opf); in drbd_submit_peer_request()
1692 bio = bio_alloc(device->ldev->backing_bdev, nr_pages, peer_req->opf, GFP_NOIO); in drbd_submit_peer_request()
1695 bio->bi_private = peer_req; in drbd_submit_peer_request()
1713 atomic_set(&peer_req->pending_bios, n_bios); in drbd_submit_peer_request()
1715 peer_req->submit_jif = jiffies; in drbd_submit_peer_request()
1716 peer_req->flags |= EE_SUBMITTED; in drbd_submit_peer_request()
1722 drbd_submit_bio_noacct(device, peer_request_fault_type(peer_req), bio); in drbd_submit_peer_request()
1728 struct drbd_peer_request *peer_req) in drbd_remove_epoch_entry_interval() argument
1730 struct drbd_interval *i = &peer_req->i; in drbd_remove_epoch_entry_interval()
1852 struct drbd_peer_request *peer_req; in read_in_block() local
1908 peer_req = drbd_alloc_peer_req(peer_device, id, sector, ds, data_size, GFP_NOIO); in read_in_block()
1909 if (!peer_req) in read_in_block()
1912 peer_req->flags |= EE_WRITE; in read_in_block()
1914 peer_req->flags |= EE_TRIM; in read_in_block()
1915 return peer_req; in read_in_block()
1918 peer_req->flags |= EE_ZEROOUT; in read_in_block()
1919 return peer_req; in read_in_block()
1924 page = peer_req->pages; in read_in_block()
1935 drbd_free_peer_req(device, peer_req); in read_in_block()
1942 drbd_csum_ee_size(peer_device->connection->peer_integrity_tfm, peer_req, dig_vv, data_size); in read_in_block()
1946 drbd_free_peer_req(device, peer_req); in read_in_block()
1951 return peer_req; in read_in_block()
2036 struct drbd_peer_request *peer_req = in e_end_resync_block() local
2038 struct drbd_peer_device *peer_device = peer_req->peer_device; in e_end_resync_block()
2040 sector_t sector = peer_req->i.sector; in e_end_resync_block()
2043 D_ASSERT(device, drbd_interval_empty(&peer_req->i)); in e_end_resync_block()
2045 if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) { in e_end_resync_block()
2046 drbd_set_in_sync(peer_device, sector, peer_req->i.size); in e_end_resync_block()
2047 err = drbd_send_ack(peer_device, P_RS_WRITE_ACK, peer_req); in e_end_resync_block()
2050 drbd_rs_failed_io(peer_device, sector, peer_req->i.size); in e_end_resync_block()
2052 err = drbd_send_ack(peer_device, P_NEG_ACK, peer_req); in e_end_resync_block()
2063 struct drbd_peer_request *peer_req; in recv_resync_read() local
2065 peer_req = read_in_block(peer_device, ID_SYNCER, sector, pi); in recv_resync_read()
2066 if (!peer_req) in recv_resync_read()
2075 peer_req->w.cb = e_end_resync_block; in recv_resync_read()
2076 peer_req->opf = REQ_OP_WRITE; in recv_resync_read()
2077 peer_req->submit_jif = jiffies; in recv_resync_read()
2080 list_add_tail(&peer_req->w.list, &device->sync_ee); in recv_resync_read()
2084 if (drbd_submit_peer_request(peer_req) == 0) in recv_resync_read()
2090 list_del(&peer_req->w.list); in recv_resync_read()
2093 drbd_free_peer_req(device, peer_req); in recv_resync_read()
2207 struct drbd_peer_request *peer_req = in e_end_block() local
2209 struct drbd_peer_device *peer_device = peer_req->peer_device; in e_end_block()
2211 sector_t sector = peer_req->i.sector; in e_end_block()
2214 if (peer_req->flags & EE_SEND_WRITE_ACK) { in e_end_block()
2215 if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) { in e_end_block()
2218 peer_req->flags & EE_MAY_SET_IN_SYNC) ? in e_end_block()
2220 err = drbd_send_ack(peer_device, pcmd, peer_req); in e_end_block()
2222 drbd_set_in_sync(peer_device, sector, peer_req->i.size); in e_end_block()
2224 err = drbd_send_ack(peer_device, P_NEG_ACK, peer_req); in e_end_block()
2233 if (peer_req->flags & EE_IN_INTERVAL_TREE) { in e_end_block()
2235 D_ASSERT(device, !drbd_interval_empty(&peer_req->i)); in e_end_block()
2236 drbd_remove_epoch_entry_interval(device, peer_req); in e_end_block()
2237 if (peer_req->flags & EE_RESTART_REQUESTS) in e_end_block()
2238 restart_conflicting_writes(device, sector, peer_req->i.size); in e_end_block()
2241 D_ASSERT(device, drbd_interval_empty(&peer_req->i)); in e_end_block()
2243 …drbd_may_finish_epoch(peer_device->connection, peer_req->epoch, EV_PUT + (cancel ? EV_CLEANUP : 0)… in e_end_block()
2250 struct drbd_peer_request *peer_req = in e_send_ack() local
2252 struct drbd_peer_device *peer_device = peer_req->peer_device; in e_send_ack()
2255 err = drbd_send_ack(peer_device, ack, peer_req); in e_send_ack()
2268 struct drbd_peer_request *peer_req = in e_send_retry_write() local
2270 struct drbd_connection *connection = peer_req->peer_device->connection; in e_send_retry_write()
2313 static bool overlapping_resync_write(struct drbd_device *device, struct drbd_peer_request *peer_req) in overlapping_resync_write() argument
2320 if (overlaps(peer_req->i.sector, peer_req->i.size, in overlapping_resync_write()
2446 struct drbd_peer_request *peer_req) in handle_write_conflicts() argument
2448 struct drbd_connection *connection = peer_req->peer_device->connection; in handle_write_conflicts()
2450 sector_t sector = peer_req->i.sector; in handle_write_conflicts()
2451 const unsigned int size = peer_req->i.size; in handle_write_conflicts()
2460 drbd_insert_interval(&device->write_requests, &peer_req->i); in handle_write_conflicts()
2464 if (i == &peer_req->i) in handle_write_conflicts()
2500 peer_req->w.cb = superseded ? e_send_superseded : in handle_write_conflicts()
2502 list_add_tail(&peer_req->w.list, &device->done_ee); in handle_write_conflicts()
2503 queue_work(connection->ack_sender, &peer_req->peer_device->send_acks_work); in handle_write_conflicts()
2542 peer_req->flags |= EE_RESTART_REQUESTS; in handle_write_conflicts()
2549 drbd_remove_epoch_entry_interval(device, peer_req); in handle_write_conflicts()
2560 struct drbd_peer_request *peer_req; in receive_Data() local
2590 peer_req = read_in_block(peer_device, p->block_id, sector, pi); in receive_Data()
2591 if (!peer_req) { in receive_Data()
2596 peer_req->w.cb = e_end_block; in receive_Data()
2597 peer_req->submit_jif = jiffies; in receive_Data()
2598 peer_req->flags |= EE_APPLICATION; in receive_Data()
2601 peer_req->opf = wire_flags_to_bio(connection, dp_flags); in receive_Data()
2603 D_ASSERT(peer_device, peer_req->i.size > 0); in receive_Data()
2604 D_ASSERT(peer_device, peer_req_op(peer_req) == REQ_OP_DISCARD); in receive_Data()
2605 D_ASSERT(peer_device, peer_req->pages == NULL); in receive_Data()
2609 peer_req->flags |= EE_ZEROOUT; in receive_Data()
2611 D_ASSERT(peer_device, peer_req->i.size > 0); in receive_Data()
2612 D_ASSERT(peer_device, peer_req_op(peer_req) == REQ_OP_WRITE_ZEROES); in receive_Data()
2613 D_ASSERT(peer_device, peer_req->pages == NULL); in receive_Data()
2616 peer_req->flags |= EE_TRIM; in receive_Data()
2617 } else if (peer_req->pages == NULL) { in receive_Data()
2618 D_ASSERT(device, peer_req->i.size == 0); in receive_Data()
2623 peer_req->flags |= EE_MAY_SET_IN_SYNC; in receive_Data()
2626 peer_req->epoch = connection->current_epoch; in receive_Data()
2627 atomic_inc(&peer_req->epoch->epoch_size); in receive_Data()
2628 atomic_inc(&peer_req->epoch->active); in receive_Data()
2647 peer_req->flags |= EE_SEND_WRITE_ACK; in receive_Data()
2656 drbd_send_ack(peer_device, P_RECV_ACK, peer_req); in receive_Data()
2662 peer_req->flags |= EE_IN_INTERVAL_TREE; in receive_Data()
2667 err = handle_write_conflicts(device, peer_req); in receive_Data()
2684 if ((peer_req->flags & (EE_TRIM | EE_ZEROOUT)) == 0) in receive_Data()
2685 list_add_tail(&peer_req->w.list, &device->active_ee); in receive_Data()
2689 wait_event(device->ee_wait, !overlapping_resync_write(device, peer_req)); in receive_Data()
2693 drbd_set_out_of_sync(peer_device, peer_req->i.sector, peer_req->i.size); in receive_Data()
2694 peer_req->flags &= ~EE_MAY_SET_IN_SYNC; in receive_Data()
2695 drbd_al_begin_io(device, &peer_req->i); in receive_Data()
2696 peer_req->flags |= EE_CALL_AL_COMPLETE_IO; in receive_Data()
2699 err = drbd_submit_peer_request(peer_req); in receive_Data()
2706 list_del(&peer_req->w.list); in receive_Data()
2707 drbd_remove_epoch_entry_interval(device, peer_req); in receive_Data()
2709 if (peer_req->flags & EE_CALL_AL_COMPLETE_IO) { in receive_Data()
2710 peer_req->flags &= ~EE_CALL_AL_COMPLETE_IO; in receive_Data()
2711 drbd_al_complete_io(device, &peer_req->i); in receive_Data()
2715 drbd_may_finish_epoch(connection, peer_req->epoch, EV_PUT | EV_CLEANUP); in receive_Data()
2717 drbd_free_peer_req(device, peer_req); in receive_Data()
2808 struct drbd_peer_request *peer_req; in receive_DataRequest() local
2864 peer_req = drbd_alloc_peer_req(peer_device, p->block_id, sector, size, in receive_DataRequest()
2866 if (!peer_req) { in receive_DataRequest()
2870 peer_req->opf = REQ_OP_READ; in receive_DataRequest()
2874 peer_req->w.cb = w_e_end_data_req; in receive_DataRequest()
2876 peer_req->flags |= EE_APPLICATION; in receive_DataRequest()
2884 peer_req->flags |= EE_RS_THIN_REQ; in receive_DataRequest()
2887 peer_req->w.cb = w_e_end_rsdata_req; in receive_DataRequest()
2901 peer_req->digest = di; in receive_DataRequest()
2902 peer_req->flags |= EE_HAS_DIGEST; in receive_DataRequest()
2909 peer_req->w.cb = w_e_end_csum_rs_req; in receive_DataRequest()
2917 peer_req->w.cb = w_e_end_ov_reply; in receive_DataRequest()
2941 peer_req->w.cb = w_e_end_ov_req; in receive_DataRequest()
2976 list_add_tail(&peer_req->w.list, &device->read_ee); in receive_DataRequest()
2993 if (drbd_submit_peer_request(peer_req) == 0) in receive_DataRequest()
3001 list_del(&peer_req->w.list); in receive_DataRequest()
3006 drbd_free_peer_req(device, peer_req); in receive_DataRequest()
4964 struct drbd_peer_request *peer_req; in receive_rs_deallocated() local
4966 peer_req = drbd_alloc_peer_req(peer_device, ID_SYNCER, sector, in receive_rs_deallocated()
4968 if (!peer_req) { in receive_rs_deallocated()
4973 peer_req->w.cb = e_end_resync_block; in receive_rs_deallocated()
4974 peer_req->opf = REQ_OP_DISCARD; in receive_rs_deallocated()
4975 peer_req->submit_jif = jiffies; in receive_rs_deallocated()
4976 peer_req->flags |= EE_TRIM; in receive_rs_deallocated()
4979 list_add_tail(&peer_req->w.list, &device->sync_ee); in receive_rs_deallocated()
4983 err = drbd_submit_peer_request(peer_req); in receive_rs_deallocated()
4987 list_del(&peer_req->w.list); in receive_rs_deallocated()
4990 drbd_free_peer_req(device, peer_req); in receive_rs_deallocated()