Skip to content

Commit

Permalink
drbd: don't increase unacked_cnt when error is from resync write
Browse files Browse the repository at this point in the history
In drbd_endio_write_sec_final(), if a write error has occured and the
protocol is not 'C', inc_unacked() will be called.

But when it is a resync write, we shouldn't increase unacked_cnt there
because of there is no corresponding dec_unacked(). If we do then
unacked_cnt will never be zero, which leads to the problem that in
do_start_resync(), start_resync_timer() will be scheduled over and over
again and the resync will never start.

Fix this problem by adding a condition in drbd_endio_write_sec_final().
When the error is from a resync write, don't increase unacked_cnt.

Signed-off-by: Rui Xu <rui.xu@easystack.cn>
Signed-off-by: Joel Colledge <joel.colledge@linbit.com>
  • Loading branch information
xurui-xr authored and Philipp-Reisner committed Apr 28, 2022
1 parent 0353eac commit ecd0bd0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions drbd/drbd_sender.c
Expand Up @@ -152,13 +152,16 @@ void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req) __releases(l
block_id = peer_req->block_id;

if (peer_req->flags & EE_WAS_ERROR) {
/* In protocol != C, we usually do not send write acks.
* In case of a write error, send the neg ack anyways. */
if (!__test_and_set_bit(__EE_SEND_WRITE_ACK, &peer_req->flags))
inc_unacked(peer_device);
drbd_set_out_of_sync(peer_device, peer_req->i.sector, peer_req->i.size);
/* In protocol != C, we usually do not send write acks.
* In case of a write error, send the neg ack anyways.
* This only applies to to application writes, not to resync. */
if (block_id != ID_SYNCER) {
if (!__test_and_set_bit(__EE_SEND_WRITE_ACK, &peer_req->flags))
inc_unacked(peer_device);
}
drbd_set_out_of_sync(peer_device, peer_req->i.sector, peer_req->i.size);
drbd_handle_io_error(device, DRBD_WRITE_ERROR);
}
}

spin_lock_irqsave(&connection->peer_reqs_lock, flags);
device->writ_cnt += peer_req->i.size >> 9;
Expand Down

0 comments on commit ecd0bd0

Please sign in to comment.