Commit 33f7d316 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Jens Axboe
parent 15ce79bd
......@@ -1918,18 +1918,14 @@ static inline void inc_ap_pending(struct drbd_device *device)
atomic_inc(&device->ap_pending_cnt);
}
#define ERR_IF_CNT_IS_NEGATIVE(which, func, line) \
if (atomic_read(&device->which) < 0) \
drbd_err(device, "in %s:%d: " #which " = %d < 0 !\n", \
func, line, \
atomic_read(&device->which))
#define dec_ap_pending(device) _dec_ap_pending(device, __func__, __LINE__)
static inline void _dec_ap_pending(struct drbd_device *device, const char *func, int line)
#define dec_ap_pending(device) ((void)expect((device), __dec_ap_pending(device) >= 0))
static inline int __dec_ap_pending(struct drbd_device *device)
{
if (atomic_dec_and_test(&device->ap_pending_cnt))
int ap_pending_cnt = atomic_dec_return(&device->ap_pending_cnt);
if (ap_pending_cnt == 0)
wake_up(&device->misc_wait);
ERR_IF_CNT_IS_NEGATIVE(ap_pending_cnt, func, line);
return ap_pending_cnt;
}
/* counts how many resync-related answers we still expect from the peer
......@@ -1943,11 +1939,10 @@ static inline void inc_rs_pending(struct drbd_device *device)
atomic_inc(&device->rs_pending_cnt);
}
#define dec_rs_pending(device) _dec_rs_pending(device, __func__, __LINE__)
static inline void _dec_rs_pending(struct drbd_device *device, const char *func, int line)
#define dec_rs_pending(device) ((void)expect((device), __dec_rs_pending(device) >= 0))
static inline int __dec_rs_pending(struct drbd_device *device)
{
atomic_dec(&device->rs_pending_cnt);
ERR_IF_CNT_IS_NEGATIVE(rs_pending_cnt, func, line);
return atomic_dec_return(&device->rs_pending_cnt);
}
/* counts how many answers we still need to send to the peer.
......@@ -1964,18 +1959,16 @@ static inline void inc_unacked(struct drbd_device *device)
atomic_inc(&device->unacked_cnt);
}
#define dec_unacked(device) _dec_unacked(device, __func__, __LINE__)
static inline void _dec_unacked(struct drbd_device *device, const char *func, int line)
#define dec_unacked(device) ((void)expect(device, __dec_unacked(device) >= 0))
static inline int __dec_unacked(struct drbd_device *device)
{
atomic_dec(&device->unacked_cnt);
ERR_IF_CNT_IS_NEGATIVE(unacked_cnt, func, line);
return atomic_dec_return(&device->unacked_cnt);
}
#define sub_unacked(device, n) _sub_unacked(device, n, __func__, __LINE__)
static inline void _sub_unacked(struct drbd_device *device, int n, const char *func, int line)
#define sub_unacked(device, n) ((void)expect(device, __sub_unacked(device) >= 0))
static inline int __sub_unacked(struct drbd_device *device, int n)
{
atomic_sub(n, &device->unacked_cnt);
ERR_IF_CNT_IS_NEGATIVE(unacked_cnt, func, line);
return atomic_sub_return(n, &device->unacked_cnt);
}
static inline bool is_sync_target_state(enum drbd_conns connection_state)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment