return (struct drbd_conf *)idr_find(&tconn->volumes, vnr);
}
-/* returns 1 if it was successful,
- * returns 0 if there was no data socket.
- * so wherever you are going to use the data.socket, e.g. do
- * if (!drbd_get_data_sock(mdev->tconn))
- * return 0;
- * CODE();
- * drbd_get_data_sock(mdev->tconn);
- */
static inline int drbd_get_data_sock(struct drbd_tconn *tconn)
{
mutex_lock(&tconn->data.mutex);
- /* drbd_disconnect() could have called drbd_free_sock()
- * while we were waiting in down()... */
- if (unlikely(tconn->data.socket == NULL)) {
+ if (!tconn->data.socket) {
+ /* Disconnected. */
mutex_unlock(&tconn->data.mutex);
- return 0;
+ return -EIO;
}
- return 1;
+ return 0;
}
static inline void drbd_put_data_sock(struct drbd_tconn *tconn)
prepare_header80(&h, cmd, size);
- if (!drbd_get_data_sock(tconn))
+ if (drbd_get_data_sock(tconn))
return 0;
ok = (sizeof(h) ==
{
int err;
- if (!drbd_get_data_sock(mdev->tconn))
+ if (drbd_get_data_sock(mdev->tconn))
return -1;
err = !_drbd_send_bitmap(mdev);
drbd_put_data_sock(mdev->tconn);
void *dgb;
int dgs;
- if (!drbd_get_data_sock(mdev->tconn))
+ if (drbd_get_data_sock(mdev->tconn))
return 0;
dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_w_tfm) ?
* This one may be interrupted by DRBD_SIG and/or DRBD_SIGKILL
* in response to admin command or module unload.
*/
- if (!drbd_get_data_sock(mdev->tconn))
+ if (drbd_get_data_sock(mdev->tconn))
return 0;
ok = sizeof(p) == drbd_send(mdev->tconn, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0);
if (cancel)
return 1;
- if (!drbd_get_data_sock(mdev->tconn))
+ if (drbd_get_data_sock(mdev->tconn))
return 0;
p->barrier = b->br_number;
/* inc_ap_pending was done where this was queued.