diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-03-28 08:23:08 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:45:08 -0500 |
commit | 9f5bdc339e3becd85aa8add305d794b0b1ec8996 (patch) | |
tree | a52dcd2faa3fa88d9d5caf65003c1b2ae56f52d9 /drivers/block/drbd/drbd_worker.c | |
parent | 52b061a44021ca11ee2fd238040e91341ff8066d (diff) |
drbd: Replace and remove old primitives
Centralize sock->mutex locking and unlocking in [drbd|conn]_prepare_command()
and [drbd|conn]_send_comman().
Therefore all *_send_* functions are touched to use these primitives instead
of drbd_get_data_sock()/drbd_put_data_sock() and former helper functions.
That change makes the *_send_* functions more standardized.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_worker.c')
-rw-r--r-- | drivers/block/drbd/drbd_worker.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index 7350466ff30c..78b95e902aae 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c | |||
@@ -1191,10 +1191,10 @@ int w_prev_work_done(struct drbd_work *w, int cancel) | |||
1191 | 1191 | ||
1192 | int w_send_barrier(struct drbd_work *w, int cancel) | 1192 | int w_send_barrier(struct drbd_work *w, int cancel) |
1193 | { | 1193 | { |
1194 | struct drbd_socket *sock; | ||
1194 | struct drbd_tl_epoch *b = container_of(w, struct drbd_tl_epoch, w); | 1195 | struct drbd_tl_epoch *b = container_of(w, struct drbd_tl_epoch, w); |
1195 | struct drbd_conf *mdev = w->mdev; | 1196 | struct drbd_conf *mdev = w->mdev; |
1196 | struct p_barrier *p = mdev->tconn->data.sbuf; | 1197 | struct p_barrier *p; |
1197 | int err = 0; | ||
1198 | 1198 | ||
1199 | /* really avoid racing with tl_clear. w.cb may have been referenced | 1199 | /* really avoid racing with tl_clear. w.cb may have been referenced |
1200 | * just before it was reassigned and re-queued, so double check that. | 1200 | * just before it was reassigned and re-queued, so double check that. |
@@ -1208,26 +1208,28 @@ int w_send_barrier(struct drbd_work *w, int cancel) | |||
1208 | if (cancel) | 1208 | if (cancel) |
1209 | return 0; | 1209 | return 0; |
1210 | 1210 | ||
1211 | err = drbd_get_data_sock(mdev->tconn); | 1211 | sock = &mdev->tconn->data; |
1212 | if (err) | 1212 | p = drbd_prepare_command(mdev, sock); |
1213 | return err; | 1213 | if (!p) |
1214 | return -EIO; | ||
1214 | p->barrier = b->br_number; | 1215 | p->barrier = b->br_number; |
1215 | /* inc_ap_pending was done where this was queued. | 1216 | /* inc_ap_pending was done where this was queued. |
1216 | * dec_ap_pending will be done in got_BarrierAck | 1217 | * dec_ap_pending will be done in got_BarrierAck |
1217 | * or (on connection loss) in w_clear_epoch. */ | 1218 | * or (on connection loss) in w_clear_epoch. */ |
1218 | err = _drbd_send_cmd(mdev, &mdev->tconn->data, P_BARRIER, | 1219 | return drbd_send_command(mdev, sock, P_BARRIER, sizeof(*p), NULL, 0); |
1219 | &p->head, sizeof(*p), 0); | ||
1220 | drbd_put_data_sock(mdev->tconn); | ||
1221 | |||
1222 | return err; | ||
1223 | } | 1220 | } |
1224 | 1221 | ||
1225 | int w_send_write_hint(struct drbd_work *w, int cancel) | 1222 | int w_send_write_hint(struct drbd_work *w, int cancel) |
1226 | { | 1223 | { |
1227 | struct drbd_conf *mdev = w->mdev; | 1224 | struct drbd_conf *mdev = w->mdev; |
1225 | struct drbd_socket *sock; | ||
1226 | |||
1228 | if (cancel) | 1227 | if (cancel) |
1229 | return 0; | 1228 | return 0; |
1230 | return drbd_send_short_cmd(mdev, P_UNPLUG_REMOTE); | 1229 | sock = &mdev->tconn->data; |
1230 | if (!drbd_prepare_command(mdev, sock)) | ||
1231 | return -EIO; | ||
1232 | return drbd_send_command(mdev, sock, P_UNPLUG_REMOTE, sizeof(struct p_header), NULL, 0); | ||
1231 | } | 1233 | } |
1232 | 1234 | ||
1233 | int w_send_out_of_sync(struct drbd_work *w, int cancel) | 1235 | int w_send_out_of_sync(struct drbd_work *w, int cancel) |