drbd: Be more explicit about functions that return an enum drbd_state_rv
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
parent
c8b325632f
commit
bf885f8a67
|
@ -1174,14 +1174,19 @@ enum dds_flags {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void drbd_init_set_defaults(struct drbd_conf *mdev);
|
extern void drbd_init_set_defaults(struct drbd_conf *mdev);
|
||||||
extern int drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f,
|
extern enum drbd_state_rv drbd_change_state(struct drbd_conf *mdev,
|
||||||
union drbd_state mask, union drbd_state val);
|
enum chg_state_flags f,
|
||||||
|
union drbd_state mask,
|
||||||
|
union drbd_state val);
|
||||||
extern void drbd_force_state(struct drbd_conf *, union drbd_state,
|
extern void drbd_force_state(struct drbd_conf *, union drbd_state,
|
||||||
union drbd_state);
|
union drbd_state);
|
||||||
extern int _drbd_request_state(struct drbd_conf *, union drbd_state,
|
extern enum drbd_state_rv _drbd_request_state(struct drbd_conf *,
|
||||||
union drbd_state, enum chg_state_flags);
|
union drbd_state,
|
||||||
extern int __drbd_set_state(struct drbd_conf *, union drbd_state,
|
union drbd_state,
|
||||||
enum chg_state_flags, struct completion *done);
|
enum chg_state_flags);
|
||||||
|
extern enum drbd_state_rv __drbd_set_state(struct drbd_conf *, union drbd_state,
|
||||||
|
enum chg_state_flags,
|
||||||
|
struct completion *done);
|
||||||
extern void print_st_err(struct drbd_conf *, union drbd_state,
|
extern void print_st_err(struct drbd_conf *, union drbd_state,
|
||||||
union drbd_state, int);
|
union drbd_state, int);
|
||||||
extern int drbd_thread_start(struct drbd_thread *thi);
|
extern int drbd_thread_start(struct drbd_thread *thi);
|
||||||
|
@ -1245,7 +1250,7 @@ extern int drbd_send_ov_request(struct drbd_conf *mdev,sector_t sector,int size)
|
||||||
|
|
||||||
extern int drbd_send_bitmap(struct drbd_conf *mdev);
|
extern int drbd_send_bitmap(struct drbd_conf *mdev);
|
||||||
extern int _drbd_send_bitmap(struct drbd_conf *mdev);
|
extern int _drbd_send_bitmap(struct drbd_conf *mdev);
|
||||||
extern int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode);
|
extern int drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode);
|
||||||
extern void drbd_free_bc(struct drbd_backing_dev *ldev);
|
extern void drbd_free_bc(struct drbd_backing_dev *ldev);
|
||||||
extern void drbd_mdev_cleanup(struct drbd_conf *mdev);
|
extern void drbd_mdev_cleanup(struct drbd_conf *mdev);
|
||||||
|
|
||||||
|
@ -1493,8 +1498,9 @@ enum determine_dev_size { dev_size_error = -1, unchanged = 0, shrunk = 1, grew =
|
||||||
extern enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local);
|
extern enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local);
|
||||||
extern void resync_after_online_grow(struct drbd_conf *);
|
extern void resync_after_online_grow(struct drbd_conf *);
|
||||||
extern void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int) __must_hold(local);
|
extern void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int) __must_hold(local);
|
||||||
extern int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role,
|
extern enum drbd_state_rv drbd_set_role(struct drbd_conf *mdev,
|
||||||
int force);
|
enum drbd_role new_role,
|
||||||
|
int force);
|
||||||
extern enum drbd_disk_state drbd_try_outdate_peer(struct drbd_conf *mdev);
|
extern enum drbd_disk_state drbd_try_outdate_peer(struct drbd_conf *mdev);
|
||||||
extern void drbd_try_outdate_peer_async(struct drbd_conf *mdev);
|
extern void drbd_try_outdate_peer_async(struct drbd_conf *mdev);
|
||||||
extern int drbd_khelper(struct drbd_conf *mdev, char *cmd);
|
extern int drbd_khelper(struct drbd_conf *mdev, char *cmd);
|
||||||
|
@ -1761,11 +1767,11 @@ static inline void drbd_state_unlock(struct drbd_conf *mdev)
|
||||||
wake_up(&mdev->misc_wait);
|
wake_up(&mdev->misc_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int _drbd_set_state(struct drbd_conf *mdev,
|
static inline enum drbd_state_rv
|
||||||
union drbd_state ns, enum chg_state_flags flags,
|
_drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
|
||||||
struct completion *done)
|
enum chg_state_flags flags, struct completion *done)
|
||||||
{
|
{
|
||||||
int rv;
|
enum drbd_state_rv rv;
|
||||||
|
|
||||||
read_lock(&global_state_lock);
|
read_lock(&global_state_lock);
|
||||||
rv = __drbd_set_state(mdev, ns, flags, done);
|
rv = __drbd_set_state(mdev, ns, flags, done);
|
||||||
|
|
|
@ -473,12 +473,13 @@ static int cl_wide_st_chg(struct drbd_conf *mdev,
|
||||||
(os.conn == C_CONNECTED && ns.conn == C_VERIFY_S);
|
(os.conn == C_CONNECTED && ns.conn == C_VERIFY_S);
|
||||||
}
|
}
|
||||||
|
|
||||||
int drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f,
|
enum drbd_state_rv
|
||||||
union drbd_state mask, union drbd_state val)
|
drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f,
|
||||||
|
union drbd_state mask, union drbd_state val)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
union drbd_state os, ns;
|
union drbd_state os, ns;
|
||||||
int rv;
|
enum drbd_state_rv rv;
|
||||||
|
|
||||||
spin_lock_irqsave(&mdev->req_lock, flags);
|
spin_lock_irqsave(&mdev->req_lock, flags);
|
||||||
os = mdev->state;
|
os = mdev->state;
|
||||||
|
@ -502,9 +503,10 @@ void drbd_force_state(struct drbd_conf *mdev,
|
||||||
drbd_change_state(mdev, CS_HARD, mask, val);
|
drbd_change_state(mdev, CS_HARD, mask, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns);
|
static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state);
|
||||||
static int is_valid_state_transition(struct drbd_conf *,
|
static enum drbd_state_rv is_valid_state_transition(struct drbd_conf *,
|
||||||
union drbd_state, union drbd_state);
|
union drbd_state,
|
||||||
|
union drbd_state);
|
||||||
static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os,
|
static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os,
|
||||||
union drbd_state ns, const char **warn_sync_abort);
|
union drbd_state ns, const char **warn_sync_abort);
|
||||||
int drbd_send_state_req(struct drbd_conf *,
|
int drbd_send_state_req(struct drbd_conf *,
|
||||||
|
@ -516,7 +518,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask,
|
||||||
{
|
{
|
||||||
union drbd_state os, ns;
|
union drbd_state os, ns;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int rv;
|
enum drbd_state_rv rv;
|
||||||
|
|
||||||
if (test_and_clear_bit(CL_ST_CHG_SUCCESS, &mdev->flags))
|
if (test_and_clear_bit(CL_ST_CHG_SUCCESS, &mdev->flags))
|
||||||
return SS_CW_SUCCESS;
|
return SS_CW_SUCCESS;
|
||||||
|
@ -537,7 +539,7 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask,
|
||||||
if (rv == SS_SUCCESS) {
|
if (rv == SS_SUCCESS) {
|
||||||
rv = is_valid_state_transition(mdev, ns, os);
|
rv = is_valid_state_transition(mdev, ns, os);
|
||||||
if (rv == SS_SUCCESS)
|
if (rv == SS_SUCCESS)
|
||||||
rv = 0; /* cont waiting, otherwise fail. */
|
rv = SS_UNKNOWN_ERROR; /* cont waiting, otherwise fail. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&mdev->req_lock, flags);
|
spin_unlock_irqrestore(&mdev->req_lock, flags);
|
||||||
|
@ -555,14 +557,14 @@ _req_st_cond(struct drbd_conf *mdev, union drbd_state mask,
|
||||||
* Should not be called directly, use drbd_request_state() or
|
* Should not be called directly, use drbd_request_state() or
|
||||||
* _drbd_request_state().
|
* _drbd_request_state().
|
||||||
*/
|
*/
|
||||||
static int drbd_req_state(struct drbd_conf *mdev,
|
static enum drbd_state_rv
|
||||||
union drbd_state mask, union drbd_state val,
|
drbd_req_state(struct drbd_conf *mdev, union drbd_state mask,
|
||||||
enum chg_state_flags f)
|
union drbd_state val, enum chg_state_flags f)
|
||||||
{
|
{
|
||||||
struct completion done;
|
struct completion done;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
union drbd_state os, ns;
|
union drbd_state os, ns;
|
||||||
int rv;
|
enum drbd_state_rv rv;
|
||||||
|
|
||||||
init_completion(&done);
|
init_completion(&done);
|
||||||
|
|
||||||
|
@ -637,10 +639,11 @@ abort:
|
||||||
* Cousin of drbd_request_state(), useful with the CS_WAIT_COMPLETE
|
* Cousin of drbd_request_state(), useful with the CS_WAIT_COMPLETE
|
||||||
* flag, or when logging of failed state change requests is not desired.
|
* flag, or when logging of failed state change requests is not desired.
|
||||||
*/
|
*/
|
||||||
int _drbd_request_state(struct drbd_conf *mdev, union drbd_state mask,
|
enum drbd_state_rv
|
||||||
union drbd_state val, enum chg_state_flags f)
|
_drbd_request_state(struct drbd_conf *mdev, union drbd_state mask,
|
||||||
|
union drbd_state val, enum chg_state_flags f)
|
||||||
{
|
{
|
||||||
int rv;
|
enum drbd_state_rv rv;
|
||||||
|
|
||||||
wait_event(mdev->state_wait,
|
wait_event(mdev->state_wait,
|
||||||
(rv = drbd_req_state(mdev, mask, val, f)) != SS_IN_TRANSIENT_STATE);
|
(rv = drbd_req_state(mdev, mask, val, f)) != SS_IN_TRANSIENT_STATE);
|
||||||
|
@ -664,8 +667,8 @@ static void print_st(struct drbd_conf *mdev, char *name, union drbd_state ns)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_st_err(struct drbd_conf *mdev,
|
void print_st_err(struct drbd_conf *mdev, union drbd_state os,
|
||||||
union drbd_state os, union drbd_state ns, int err)
|
union drbd_state ns, enum drbd_state_rv err)
|
||||||
{
|
{
|
||||||
if (err == SS_IN_TRANSIENT_STATE)
|
if (err == SS_IN_TRANSIENT_STATE)
|
||||||
return;
|
return;
|
||||||
|
@ -680,12 +683,13 @@ void print_st_err(struct drbd_conf *mdev,
|
||||||
* @mdev: DRBD device.
|
* @mdev: DRBD device.
|
||||||
* @ns: State to consider.
|
* @ns: State to consider.
|
||||||
*/
|
*/
|
||||||
static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns)
|
static enum drbd_state_rv
|
||||||
|
is_valid_state(struct drbd_conf *mdev, union drbd_state ns)
|
||||||
{
|
{
|
||||||
/* See drbd_state_sw_errors in drbd_strings.c */
|
/* See drbd_state_sw_errors in drbd_strings.c */
|
||||||
|
|
||||||
enum drbd_fencing_p fp;
|
enum drbd_fencing_p fp;
|
||||||
int rv = SS_SUCCESS;
|
enum drbd_state_rv rv = SS_SUCCESS;
|
||||||
|
|
||||||
fp = FP_DONT_CARE;
|
fp = FP_DONT_CARE;
|
||||||
if (get_ldev(mdev)) {
|
if (get_ldev(mdev)) {
|
||||||
|
@ -748,10 +752,11 @@ static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns)
|
||||||
* @ns: new state.
|
* @ns: new state.
|
||||||
* @os: old state.
|
* @os: old state.
|
||||||
*/
|
*/
|
||||||
static int is_valid_state_transition(struct drbd_conf *mdev,
|
static enum drbd_state_rv
|
||||||
union drbd_state ns, union drbd_state os)
|
is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns,
|
||||||
|
union drbd_state os)
|
||||||
{
|
{
|
||||||
int rv = SS_SUCCESS;
|
enum drbd_state_rv rv = SS_SUCCESS;
|
||||||
|
|
||||||
if ((ns.conn == C_STARTING_SYNC_T || ns.conn == C_STARTING_SYNC_S) &&
|
if ((ns.conn == C_STARTING_SYNC_T || ns.conn == C_STARTING_SYNC_S) &&
|
||||||
os.conn > C_CONNECTED)
|
os.conn > C_CONNECTED)
|
||||||
|
@ -1029,12 +1034,12 @@ static void drbd_resume_al(struct drbd_conf *mdev)
|
||||||
*
|
*
|
||||||
* Caller needs to hold req_lock, and global_state_lock. Do not call directly.
|
* Caller needs to hold req_lock, and global_state_lock. Do not call directly.
|
||||||
*/
|
*/
|
||||||
int __drbd_set_state(struct drbd_conf *mdev,
|
enum drbd_state_rv
|
||||||
union drbd_state ns, enum chg_state_flags flags,
|
__drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
|
||||||
struct completion *done)
|
enum chg_state_flags flags, struct completion *done)
|
||||||
{
|
{
|
||||||
union drbd_state os;
|
union drbd_state os;
|
||||||
int rv = SS_SUCCESS;
|
enum drbd_state_rv rv = SS_SUCCESS;
|
||||||
const char *warn_sync_abort = NULL;
|
const char *warn_sync_abort = NULL;
|
||||||
struct after_state_chg_work *ascw;
|
struct after_state_chg_work *ascw;
|
||||||
|
|
||||||
|
@ -2031,7 +2036,7 @@ int drbd_send_state_req(struct drbd_conf *mdev,
|
||||||
(struct p_header80 *)&p, sizeof(p));
|
(struct p_header80 *)&p, sizeof(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode)
|
int drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode)
|
||||||
{
|
{
|
||||||
struct p_req_state_reply p;
|
struct p_req_state_reply p;
|
||||||
|
|
||||||
|
|
|
@ -288,10 +288,11 @@ void drbd_try_outdate_peer_async(struct drbd_conf *mdev)
|
||||||
dev_err(DEV, "out of mem, failed to invoke fence-peer helper\n");
|
dev_err(DEV, "out of mem, failed to invoke fence-peer helper\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
|
enum drbd_state_rv
|
||||||
|
drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
|
||||||
{
|
{
|
||||||
const int max_tries = 4;
|
const int max_tries = 4;
|
||||||
int r = 0;
|
enum drbd_state_rv rv = SS_UNKNOWN_ERROR;
|
||||||
int try = 0;
|
int try = 0;
|
||||||
int forced = 0;
|
int forced = 0;
|
||||||
union drbd_state mask, val;
|
union drbd_state mask, val;
|
||||||
|
@ -306,17 +307,17 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
|
||||||
val.i = 0; val.role = new_role;
|
val.i = 0; val.role = new_role;
|
||||||
|
|
||||||
while (try++ < max_tries) {
|
while (try++ < max_tries) {
|
||||||
r = _drbd_request_state(mdev, mask, val, CS_WAIT_COMPLETE);
|
rv = _drbd_request_state(mdev, mask, val, CS_WAIT_COMPLETE);
|
||||||
|
|
||||||
/* in case we first succeeded to outdate,
|
/* in case we first succeeded to outdate,
|
||||||
* but now suddenly could establish a connection */
|
* but now suddenly could establish a connection */
|
||||||
if (r == SS_CW_FAILED_BY_PEER && mask.pdsk != 0) {
|
if (rv == SS_CW_FAILED_BY_PEER && mask.pdsk != 0) {
|
||||||
val.pdsk = 0;
|
val.pdsk = 0;
|
||||||
mask.pdsk = 0;
|
mask.pdsk = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r == SS_NO_UP_TO_DATE_DISK && force &&
|
if (rv == SS_NO_UP_TO_DATE_DISK && force &&
|
||||||
(mdev->state.disk < D_UP_TO_DATE &&
|
(mdev->state.disk < D_UP_TO_DATE &&
|
||||||
mdev->state.disk >= D_INCONSISTENT)) {
|
mdev->state.disk >= D_INCONSISTENT)) {
|
||||||
mask.disk = D_MASK;
|
mask.disk = D_MASK;
|
||||||
|
@ -325,7 +326,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r == SS_NO_UP_TO_DATE_DISK &&
|
if (rv == SS_NO_UP_TO_DATE_DISK &&
|
||||||
mdev->state.disk == D_CONSISTENT && mask.pdsk == 0) {
|
mdev->state.disk == D_CONSISTENT && mask.pdsk == 0) {
|
||||||
D_ASSERT(mdev->state.pdsk == D_UNKNOWN);
|
D_ASSERT(mdev->state.pdsk == D_UNKNOWN);
|
||||||
nps = drbd_try_outdate_peer(mdev);
|
nps = drbd_try_outdate_peer(mdev);
|
||||||
|
@ -341,9 +342,9 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r == SS_NOTHING_TO_DO)
|
if (rv == SS_NOTHING_TO_DO)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (r == SS_PRIMARY_NOP && mask.pdsk == 0) {
|
if (rv == SS_PRIMARY_NOP && mask.pdsk == 0) {
|
||||||
nps = drbd_try_outdate_peer(mdev);
|
nps = drbd_try_outdate_peer(mdev);
|
||||||
|
|
||||||
if (force && nps > D_OUTDATED) {
|
if (force && nps > D_OUTDATED) {
|
||||||
|
@ -356,7 +357,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (r == SS_TWO_PRIMARIES) {
|
if (rv == SS_TWO_PRIMARIES) {
|
||||||
/* Maybe the peer is detected as dead very soon...
|
/* Maybe the peer is detected as dead very soon...
|
||||||
retry at most once more in this case. */
|
retry at most once more in this case. */
|
||||||
__set_current_state(TASK_INTERRUPTIBLE);
|
__set_current_state(TASK_INTERRUPTIBLE);
|
||||||
|
@ -365,16 +366,16 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
|
||||||
try = max_tries - 1;
|
try = max_tries - 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (r < SS_SUCCESS) {
|
if (rv < SS_SUCCESS) {
|
||||||
r = _drbd_request_state(mdev, mask, val,
|
rv = _drbd_request_state(mdev, mask, val,
|
||||||
CS_VERBOSE + CS_WAIT_COMPLETE);
|
CS_VERBOSE + CS_WAIT_COMPLETE);
|
||||||
if (r < SS_SUCCESS)
|
if (rv < SS_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r < SS_SUCCESS)
|
if (rv < SS_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (forced)
|
if (forced)
|
||||||
|
@ -423,7 +424,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
|
||||||
kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE);
|
kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE);
|
||||||
fail:
|
fail:
|
||||||
mutex_unlock(&mdev->state_mutex);
|
mutex_unlock(&mdev->state_mutex);
|
||||||
return r;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct drbd_conf *ensure_mdev(int minor, int create)
|
static struct drbd_conf *ensure_mdev(int minor, int create)
|
||||||
|
|
|
@ -3112,7 +3112,7 @@ static int receive_req_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsi
|
||||||
{
|
{
|
||||||
struct p_req_state *p = &mdev->data.rbuf.req_state;
|
struct p_req_state *p = &mdev->data.rbuf.req_state;
|
||||||
union drbd_state mask, val;
|
union drbd_state mask, val;
|
||||||
int rv;
|
enum drbd_state_rv rv;
|
||||||
|
|
||||||
mask.i = be32_to_cpu(p->mask);
|
mask.i = be32_to_cpu(p->mask);
|
||||||
val.i = be32_to_cpu(p->val);
|
val.i = be32_to_cpu(p->val);
|
||||||
|
|
Loading…
Reference in New Issue