提交 43de7c85 编写于 作者: P Philipp Reisner

drbd: Fixes from the drbd-8.3 branch

* drbd-8.3:
  drbd: O_SYNC gives EIO on ramdisks for some kernels (eg. RHEL6).
  drbd: send intermediate state change results to the peer
Signed-off-by: NPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: NLars Ellenberg <lars.ellenberg@linbit.com>
上级 0cfac5dd
...@@ -1062,8 +1062,8 @@ extern void drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev); ...@@ -1062,8 +1062,8 @@ extern void drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev);
extern int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags flags); extern int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags flags);
extern int _conn_send_state_req(struct drbd_tconn *, int vnr, enum drbd_packet cmd, extern int _conn_send_state_req(struct drbd_tconn *, int vnr, enum drbd_packet cmd,
union drbd_state, union drbd_state); union drbd_state, union drbd_state);
extern int _drbd_send_state(struct drbd_conf *mdev); extern int drbd_send_state(struct drbd_conf *mdev, union drbd_state s);
extern int drbd_send_state(struct drbd_conf *mdev); extern int drbd_send_current_state(struct drbd_conf *mdev);
extern int drbd_send_sync_param(struct drbd_conf *mdev); extern int drbd_send_sync_param(struct drbd_conf *mdev);
extern void drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr, extern void drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr,
u32 set_size); u32 set_size);
......
...@@ -1148,10 +1148,10 @@ int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags fl ...@@ -1148,10 +1148,10 @@ int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags fl
} }
/** /**
* drbd_send_state() - Sends the drbd state to the peer * drbd_send_current_state() - Sends the drbd state to the peer
* @mdev: DRBD device. * @mdev: DRBD device.
*/ */
int drbd_send_state(struct drbd_conf *mdev) int drbd_send_current_state(struct drbd_conf *mdev)
{ {
struct drbd_socket *sock; struct drbd_socket *sock;
struct p_state *p; struct p_state *p;
...@@ -1164,6 +1164,29 @@ int drbd_send_state(struct drbd_conf *mdev) ...@@ -1164,6 +1164,29 @@ int drbd_send_state(struct drbd_conf *mdev)
return drbd_send_command(mdev, sock, P_STATE, sizeof(*p), NULL, 0); return drbd_send_command(mdev, sock, P_STATE, sizeof(*p), NULL, 0);
} }
/**
* drbd_send_state() - After a state change, sends the new state to the peer
* @mdev: DRBD device.
* @state: the state to send, not necessarily the current state.
*
* Each state change queues an "after_state_ch" work, which will eventually
* send the resulting new state to the peer. If more state changes happen
* between queuing and processing of the after_state_ch work, we still
* want to send each intermediary state in the order it occurred.
*/
int drbd_send_state(struct drbd_conf *mdev, union drbd_state state)
{
struct drbd_socket *sock;
struct p_state *p;
sock = &mdev->tconn->data;
p = drbd_prepare_command(mdev, sock);
if (!p)
return -EIO;
p->state = cpu_to_be32(state.i); /* Within the send mutex */
return drbd_send_command(mdev, sock, P_STATE, sizeof(*p), NULL, 0);
}
int drbd_send_state_req(struct drbd_conf *mdev, union drbd_state mask, union drbd_state val) int drbd_send_state_req(struct drbd_conf *mdev, union drbd_state mask, union drbd_state val)
{ {
struct drbd_socket *sock; struct drbd_socket *sock;
...@@ -1176,7 +1199,6 @@ int drbd_send_state_req(struct drbd_conf *mdev, union drbd_state mask, union drb ...@@ -1176,7 +1199,6 @@ int drbd_send_state_req(struct drbd_conf *mdev, union drbd_state mask, union drb
p->mask = cpu_to_be32(mask.i); p->mask = cpu_to_be32(mask.i);
p->val = cpu_to_be32(val.i); p->val = cpu_to_be32(val.i);
return drbd_send_command(mdev, sock, P_STATE_CHG_REQ, sizeof(*p), NULL, 0); return drbd_send_command(mdev, sock, P_STATE_CHG_REQ, sizeof(*p), NULL, 0);
} }
int conn_send_state_req(struct drbd_tconn *tconn, union drbd_state mask, union drbd_state val) int conn_send_state_req(struct drbd_tconn *tconn, union drbd_state mask, union drbd_state val)
...@@ -3003,7 +3025,7 @@ int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev) ...@@ -3003,7 +3025,7 @@ int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev)
goto err; goto err;
} }
if (magic != DRBD_MD_MAGIC_08) { if (magic != DRBD_MD_MAGIC_08) {
if (magic == DRBD_MD_MAGIC_07) if (magic == DRBD_MD_MAGIC_07)
dev_err(DEV, "Found old (0.7) meta data magic. Did you \"drbdadm create-md\"?\n"); dev_err(DEV, "Found old (0.7) meta data magic. Did you \"drbdadm create-md\"?\n");
else else
dev_err(DEV, "Meta data magic not found. Did you \"drbdadm create-md\"?\n"); dev_err(DEV, "Meta data magic not found. Did you \"drbdadm create-md\"?\n");
......
...@@ -654,7 +654,7 @@ drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) ...@@ -654,7 +654,7 @@ drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
/* if this was forced, we should consider sync */ /* if this was forced, we should consider sync */
if (forced) if (forced)
drbd_send_uuids(mdev); drbd_send_uuids(mdev);
drbd_send_state(mdev); drbd_send_current_state(mdev);
} }
drbd_md_sync(mdev); drbd_md_sync(mdev);
......
...@@ -825,7 +825,7 @@ int drbd_connected(struct drbd_conf *mdev) ...@@ -825,7 +825,7 @@ int drbd_connected(struct drbd_conf *mdev)
if (!err) if (!err)
err = drbd_send_uuids(mdev); err = drbd_send_uuids(mdev);
if (!err) if (!err)
err = drbd_send_state(mdev); err = drbd_send_current_state(mdev);
clear_bit(USE_DEGR_WFC_T, &mdev->flags); clear_bit(USE_DEGR_WFC_T, &mdev->flags);
clear_bit(RESIZE_PENDING, &mdev->flags); clear_bit(RESIZE_PENDING, &mdev->flags);
mod_timer(&mdev->request_timer, jiffies + HZ); /* just start it here. */ mod_timer(&mdev->request_timer, jiffies + HZ); /* just start it here. */
...@@ -3873,7 +3873,7 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi) ...@@ -3873,7 +3873,7 @@ static int receive_state(struct drbd_tconn *tconn, struct packet_info *pi)
/* Nowadays only used when forcing a node into primary role and /* Nowadays only used when forcing a node into primary role and
setting its disk to UpToDate with that */ setting its disk to UpToDate with that */
drbd_send_uuids(mdev); drbd_send_uuids(mdev);
drbd_send_state(mdev); drbd_send_current_state(mdev);
} }
} }
......
...@@ -1198,7 +1198,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -1198,7 +1198,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
if (os.pdsk == D_DISKLESS && if (os.pdsk == D_DISKLESS &&
ns.pdsk > D_DISKLESS && ns.pdsk != D_UNKNOWN) { /* attach on the peer */ ns.pdsk > D_DISKLESS && ns.pdsk != D_UNKNOWN) { /* attach on the peer */
drbd_send_uuids(mdev); drbd_send_uuids(mdev);
drbd_send_state(mdev); drbd_send_state(mdev, ns);
} }
/* No point in queuing send_bitmap if we don't have a connection /* No point in queuing send_bitmap if we don't have a connection
* anymore, so check also the _current_ state, not only the new state * anymore, so check also the _current_ state, not only the new state
...@@ -1263,14 +1263,14 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -1263,14 +1263,14 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
os.disk == D_ATTACHING && ns.disk == D_NEGOTIATING) { os.disk == D_ATTACHING && ns.disk == D_NEGOTIATING) {
drbd_send_sizes(mdev, 0, 0); /* to start sync... */ drbd_send_sizes(mdev, 0, 0); /* to start sync... */
drbd_send_uuids(mdev); drbd_send_uuids(mdev);
drbd_send_state(mdev); drbd_send_state(mdev, ns);
} }
/* We want to pause/continue resync, tell peer. */ /* We want to pause/continue resync, tell peer. */
if (ns.conn >= C_CONNECTED && if (ns.conn >= C_CONNECTED &&
((os.aftr_isp != ns.aftr_isp) || ((os.aftr_isp != ns.aftr_isp) ||
(os.user_isp != ns.user_isp))) (os.user_isp != ns.user_isp)))
drbd_send_state(mdev); drbd_send_state(mdev, ns);
/* In case one of the isp bits got set, suspend other devices. */ /* In case one of the isp bits got set, suspend other devices. */
if ((!os.aftr_isp && !os.peer_isp && !os.user_isp) && if ((!os.aftr_isp && !os.peer_isp && !os.user_isp) &&
...@@ -1280,10 +1280,10 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -1280,10 +1280,10 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
/* Make sure the peer gets informed about eventual state /* Make sure the peer gets informed about eventual state
changes (ISP bits) while we were in WFReportParams. */ changes (ISP bits) while we were in WFReportParams. */
if (os.conn == C_WF_REPORT_PARAMS && ns.conn >= C_CONNECTED) if (os.conn == C_WF_REPORT_PARAMS && ns.conn >= C_CONNECTED)
drbd_send_state(mdev); drbd_send_state(mdev, ns);
if (os.conn != C_AHEAD && ns.conn == C_AHEAD) if (os.conn != C_AHEAD && ns.conn == C_AHEAD)
drbd_send_state(mdev); drbd_send_state(mdev, ns);
/* We are in the progress to start a full sync... */ /* We are in the progress to start a full sync... */
if ((os.conn != C_STARTING_SYNC_T && ns.conn == C_STARTING_SYNC_T) || if ((os.conn != C_STARTING_SYNC_T && ns.conn == C_STARTING_SYNC_T) ||
...@@ -1325,7 +1325,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -1325,7 +1325,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
"ASSERT FAILED: disk is %s during detach\n", "ASSERT FAILED: disk is %s during detach\n",
drbd_disk_str(mdev->state.disk)); drbd_disk_str(mdev->state.disk));
drbd_send_state(mdev); drbd_send_state(mdev, ns);
drbd_rs_cancel_all(mdev); drbd_rs_cancel_all(mdev);
/* In case we want to get something to stable storage still, /* In case we want to get something to stable storage still,
...@@ -1353,7 +1353,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -1353,7 +1353,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
mdev->rs_failed = 0; mdev->rs_failed = 0;
atomic_set(&mdev->rs_pending_cnt, 0); atomic_set(&mdev->rs_pending_cnt, 0);
drbd_send_state(mdev); drbd_send_state(mdev, ns);
/* corresponding get_ldev in __drbd_set_state /* corresponding get_ldev in __drbd_set_state
* this may finally trigger drbd_ldev_destroy. */ * this may finally trigger drbd_ldev_destroy. */
put_ldev(mdev); put_ldev(mdev);
...@@ -1361,7 +1361,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -1361,7 +1361,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
/* Notify peer that I had a local IO error, and did not detached.. */ /* Notify peer that I had a local IO error, and did not detached.. */
if (os.disk == D_UP_TO_DATE && ns.disk == D_INCONSISTENT) if (os.disk == D_UP_TO_DATE && ns.disk == D_INCONSISTENT)
drbd_send_state(mdev); drbd_send_state(mdev, ns);
/* Disks got bigger while they were detached */ /* Disks got bigger while they were detached */
if (ns.disk > D_NEGOTIATING && ns.pdsk > D_NEGOTIATING && if (ns.disk > D_NEGOTIATING && ns.pdsk > D_NEGOTIATING &&
...@@ -1379,7 +1379,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, ...@@ -1379,7 +1379,7 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
/* sync target done with resync. Explicitly notify peer, even though /* sync target done with resync. Explicitly notify peer, even though
* it should (at least for non-empty resyncs) already know itself. */ * it should (at least for non-empty resyncs) already know itself. */
if (os.disk < D_UP_TO_DATE && os.conn >= C_SYNC_SOURCE && ns.conn == C_CONNECTED) if (os.disk < D_UP_TO_DATE && os.conn >= C_SYNC_SOURCE && ns.conn == C_CONNECTED)
drbd_send_state(mdev); drbd_send_state(mdev, ns);
/* This triggers bitmap writeout of potentially still unwritten pages /* This triggers bitmap writeout of potentially still unwritten pages
* if the resync finished cleanly, or aborted because of peer disk * if the resync finished cleanly, or aborted because of peer disk
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册