[Drbd-dev] [Patch v0 5/8] Use refcount_t 'atomic' type to implement structref
Roland Kammerer
roland.kammerer at linbit.com
Thu Mar 9 11:33:17 CET 2017
On Tue, Mar 07, 2017 at 11:27:56AM +0800, Nick Wang wrote:
> diff --git a/drbd/drbd_req.c b/drbd/drbd_req.c
> index d6d9dc1..467549a 100644
> --- a/drbd/drbd_req.c
> +++ b/drbd/drbd_req.c
> @@ -124,7 +124,11 @@ void drbd_queue_peer_ack(struct drbd_resource *resource, struct drbd_request *re
> connection->cstate[NOW] != C_CONNECTED ||
> !(req->rq_state[1 + node_id] & RQ_NET_SENT))
> continue;
> +#ifdef COMPAT_HAVE_REFCOUNT_INC
> + refcount_inc(&req->kref.refcount); /* was 0, instead of kref_get() */
> +#else
> atomic_inc(&req->kref.refcount); /* was 0, instead of kref_get() */
> +#endif
We want to avoid #ifdef hell as much as possible in the code itself. In
that case use the new refcount_inc() and if it does not exist, fall back
to atomic_inc() via defining refcount_inc() to atomic_inc.
Regards, rck
More information about the drbd-dev
mailing list