[Drbd-dev] [PATCH] drbd: change the variable ov_left to atomic

Joel Colledge joel.colledge at linbit.com
Tue May 3 10:37:28 CEST 2022


Hi Xu,

Your analysis of the problem seems correct to me. Some details of the
fix could be improved.

In verify_progress() there are now 3 separate atomic operations. It
would be better to use atomic64_dec_return() and then use the returned
value instead of calling atomic64_read() separately. This could have
minor effects on the behavior.

Similarly, in receive_DataRequest() there is no need to read ov_left
again after setting it. This should have no effect on the behavior,
but leads to cleaner code.

Also the repeated reads in finish_state_change() could be avoided for
cleaner code. Take care of the read after set_ov_position(), since
that changes the value of ov_left. You could use peer_device->rs_total
instead of peer_device->ov_left there, since that is what it is set to
in set_ov_position().

Best regards,
Joel


More information about the drbd-dev mailing list