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

drbd: register peer requests on read_ee early

Initialize peer_request with timestamp and proper empty list head.
Add peer_request to list early, so debugfs can find this request and
report it as "preparing", even if we sleep before we actually submit it.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>

authored by

Lars Ellenberg and committed by
Philipp Reisner
c5a2c150 21ae5d7f

+14 -11
+14 -11
drivers/block/drbd/drbd_receiver.c
··· 362 362 goto fail; 363 363 } 364 364 365 + memset(peer_req, 0, sizeof(*peer_req)); 366 + INIT_LIST_HEAD(&peer_req->w.list); 365 367 drbd_clear_interval(&peer_req->i); 366 368 peer_req->i.size = data_size; 367 369 peer_req->i.sector = sector; 368 - peer_req->i.local = false; 369 - peer_req->i.waiting = false; 370 - 371 - peer_req->epoch = NULL; 370 + peer_req->submit_jif = jiffies; 372 371 peer_req->peer_device = peer_device; 373 372 peer_req->pages = page; 374 - atomic_set(&peer_req->pending_bios, 0); 375 - peer_req->flags = 0; 376 373 /* 377 374 * The block_id is opaque to the receiver. It is not endianness 378 375 * converted, and sent back to the sender unchanged. ··· 2665 2668 * we would also throttle its application reads. 2666 2669 * In that case, throttling is done on the SyncTarget only. 2667 2670 */ 2671 + 2672 + /* Even though this may be a resync request, we do add to "read_ee"; 2673 + * "sync_ee" is only used for resync WRITEs. 2674 + * Add to list early, so debugfs can find this request 2675 + * even if we have to sleep below. */ 2676 + spin_lock_irq(&device->resource->req_lock); 2677 + list_add_tail(&peer_req->w.list, &device->read_ee); 2678 + spin_unlock_irq(&device->resource->req_lock); 2679 + 2668 2680 if (device->state.peer != R_PRIMARY 2669 2681 && drbd_rs_should_slow_down(device, sector, false)) 2670 2682 schedule_timeout_uninterruptible(HZ/10); ··· 2685 2679 2686 2680 submit: 2687 2681 inc_unacked(device); 2688 - spin_lock_irq(&device->resource->req_lock); 2689 - list_add_tail(&peer_req->w.list, &device->read_ee); 2690 - spin_unlock_irq(&device->resource->req_lock); 2691 - 2692 2682 if (drbd_submit_peer_request(device, peer_req, READ, fault_type) == 0) 2693 2683 return 0; 2694 2684 2695 2685 /* don't care for the reason here */ 2696 2686 drbd_err(device, "submit failed, triggering re-connect\n"); 2687 + 2688 + out_free_e: 2697 2689 spin_lock_irq(&device->resource->req_lock); 2698 2690 list_del(&peer_req->w.list); 2699 2691 spin_unlock_irq(&device->resource->req_lock); 2700 2692 /* no drbd_rs_complete_io(), we are dropping the connection anyways */ 2701 2693 2702 - out_free_e: 2703 2694 put_ldev(device); 2704 2695 drbd_free_peer_req(device, peer_req); 2705 2696 return -EIO;