Commit 99920dc5 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: Make all worker callbacks return 0 upon success and an error code otherwise

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent b2f0ab62
......@@ -106,7 +106,7 @@ struct drbd_atodb_wait {
};
static long w_al_write_transaction(struct drbd_work *, int);
static int w_al_write_transaction(struct drbd_work *, int);
static int _drbd_md_sync_page_io(struct drbd_conf *mdev,
struct drbd_backing_dev *bdev,
......@@ -298,7 +298,7 @@ static unsigned int rs_extent_to_bm_page(unsigned int rs_enr)
(BM_EXT_SHIFT - BM_BLOCK_SHIFT));
}
static long
static int
w_al_write_transaction(struct drbd_work *w, int unused)
{
struct update_al_work *aw = container_of(w, struct update_al_work, w);
......@@ -315,7 +315,7 @@ w_al_write_transaction(struct drbd_work *w, int unused)
drbd_disk_str(mdev->state.disk));
aw->err = -EIO;
complete(&((struct update_al_work *)w)->event);
return 1;
return 0;
}
/* The bitmap write may have failed, causing a state change. */
......@@ -326,7 +326,7 @@ w_al_write_transaction(struct drbd_work *w, int unused)
aw->err = -EIO;
complete(&((struct update_al_work *)w)->event);
put_ldev(mdev);
return 1;
return 0;
}
mutex_lock(&mdev->md_io_mutex); /* protects md_io_buffer, al_tr_cycle, ... */
......@@ -404,7 +404,7 @@ w_al_write_transaction(struct drbd_work *w, int unused)
complete(&((struct update_al_work *)w)->event);
put_ldev(mdev);
return 1;
return 0;
}
/* FIXME
......@@ -698,7 +698,7 @@ void drbd_al_shrink(struct drbd_conf *mdev)
wake_up(&mdev->al_wait);
}
static long w_update_odbm(struct drbd_work *w, int unused)
static int w_update_odbm(struct drbd_work *w, int unused)
{
struct update_odbm_work *udw = container_of(w, struct update_odbm_work, w);
struct drbd_conf *mdev = w->mdev;
......@@ -708,7 +708,7 @@ static long w_update_odbm(struct drbd_work *w, int unused)
if (__ratelimit(&drbd_ratelimit_state))
dev_warn(DEV, "Can not update on disk bitmap, local IO disabled.\n");
kfree(udw);
return 1;
return 0;
}
drbd_bm_write_page(mdev, rs_extent_to_bm_page(udw->enr));
......@@ -728,7 +728,7 @@ static long w_update_odbm(struct drbd_work *w, int unused)
}
drbd_bcast_event(mdev, &sib);
return 1;
return 0;
}
......
......@@ -644,7 +644,7 @@ static inline enum drbd_thread_state get_t_state(struct drbd_thread *thi)
}
struct drbd_work;
typedef long (*drbd_work_cb)(struct drbd_work *, int cancel);
typedef int (*drbd_work_cb)(struct drbd_work *, int cancel);
struct drbd_work {
struct list_head list;
drbd_work_cb cb;
......@@ -1546,24 +1546,24 @@ extern void drbd_csum_bio(struct drbd_conf *, struct crypto_hash *, struct bio *
extern void drbd_csum_ee(struct drbd_conf *, struct crypto_hash *,
struct drbd_peer_request *, void *);
/* worker callbacks */
extern long w_read_retry_remote(struct drbd_work *, int);
extern long w_e_end_data_req(struct drbd_work *, int);
extern long w_e_end_rsdata_req(struct drbd_work *, int);
extern long w_e_end_csum_rs_req(struct drbd_work *, int);
extern long w_e_end_ov_reply(struct drbd_work *, int);
extern long w_e_end_ov_req(struct drbd_work *, int);
extern long w_ov_finished(struct drbd_work *, int);
extern long w_resync_timer(struct drbd_work *, int);
extern long w_send_write_hint(struct drbd_work *, int);
extern long w_make_resync_request(struct drbd_work *, int);
extern long w_send_dblock(struct drbd_work *, int);
extern long w_send_barrier(struct drbd_work *, int);
extern long w_send_read_req(struct drbd_work *, int);
extern long w_prev_work_done(struct drbd_work *, int);
extern long w_e_reissue(struct drbd_work *, int);
extern long w_restart_disk_io(struct drbd_work *, int);
extern long w_send_oos(struct drbd_work *, int);
extern long w_start_resync(struct drbd_work *, int);
extern int w_read_retry_remote(struct drbd_work *, int);
extern int w_e_end_data_req(struct drbd_work *, int);
extern int w_e_end_rsdata_req(struct drbd_work *, int);
extern int w_e_end_csum_rs_req(struct drbd_work *, int);
extern int w_e_end_ov_reply(struct drbd_work *, int);
extern int w_e_end_ov_req(struct drbd_work *, int);
extern int w_ov_finished(struct drbd_work *, int);
extern int w_resync_timer(struct drbd_work *, int);
extern int w_send_write_hint(struct drbd_work *, int);
extern int w_make_resync_request(struct drbd_work *, int);
extern int w_send_dblock(struct drbd_work *, int);
extern int w_send_barrier(struct drbd_work *, int);
extern int w_send_read_req(struct drbd_work *, int);
extern int w_prev_work_done(struct drbd_work *, int);
extern int w_e_reissue(struct drbd_work *, int);
extern int w_restart_disk_io(struct drbd_work *, int);
extern int w_send_oos(struct drbd_work *, int);
extern int w_start_resync(struct drbd_work *, int);
extern void resync_timer_fn(unsigned long data);
extern void start_resync_timer_fn(unsigned long data);
......
......@@ -64,10 +64,10 @@ int drbd_asender(struct drbd_thread *);
int drbd_init(void);
static int drbd_open(struct block_device *bdev, fmode_t mode);
static int drbd_release(struct gendisk *gd, fmode_t mode);
static long w_md_sync(struct drbd_work *w, int unused);
static int w_md_sync(struct drbd_work *w, int unused);
static void md_sync_timer_fn(unsigned long data);
static long w_bitmap_io(struct drbd_work *w, int unused);
static long w_go_diskless(struct drbd_work *w, int unused);
static int w_bitmap_io(struct drbd_work *w, int unused);
static int w_go_diskless(struct drbd_work *w, int unused);
MODULE_AUTHOR("Philipp Reisner <phil@linbit.com>, "
"Lars Ellenberg <lars@linbit.com>");
......@@ -2884,7 +2884,7 @@ int drbd_bmio_clear_n_write(struct drbd_conf *mdev)
return rv;
}
static long w_bitmap_io(struct drbd_work *w, int unused)
static int w_bitmap_io(struct drbd_work *w, int unused)
{
struct bm_io_work *work = container_of(w, struct bm_io_work, w);
struct drbd_conf *mdev = w->mdev;
......@@ -2909,7 +2909,7 @@ static long w_bitmap_io(struct drbd_work *w, int unused)
work->why = NULL;
work->flags = 0;
return 1;
return 0;
}
void drbd_ldev_destroy(struct drbd_conf *mdev)
......@@ -2925,7 +2925,7 @@ void drbd_ldev_destroy(struct drbd_conf *mdev)
clear_bit(GO_DISKLESS, &mdev->flags);
}
static long w_go_diskless(struct drbd_work *w, int unused)
static int w_go_diskless(struct drbd_work *w, int unused)
{
struct drbd_conf *mdev = w->mdev;
......@@ -2935,7 +2935,7 @@ static long w_go_diskless(struct drbd_work *w, int unused)
* the protected members anymore, though, so once put_ldev reaches zero
* again, it will be safe to free them. */
drbd_force_state(mdev, NS(disk, D_DISKLESS));
return 1;
return 0;
}
void drbd_go_diskless(struct drbd_conf *mdev)
......@@ -3041,7 +3041,7 @@ static void md_sync_timer_fn(unsigned long data)
drbd_queue_work_front(&mdev->tconn->data.work, &mdev->md_sync_work);
}
static long w_md_sync(struct drbd_work *w, int unused)
static int w_md_sync(struct drbd_work *w, int unused)
{
struct drbd_conf *mdev = w->mdev;
......@@ -3051,7 +3051,7 @@ static long w_md_sync(struct drbd_work *w, int unused)
mdev->last_md_mark_dirty.func, mdev->last_md_mark_dirty.line);
#endif
drbd_md_sync(mdev);
return 1;
return 0;
}
const char *cmdname(enum drbd_packet cmd)
......
......@@ -70,7 +70,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn);
static int drbd_disconnected(int vnr, void *p, void *data);
static enum finish_epoch drbd_may_finish_epoch(struct drbd_conf *, struct drbd_epoch *, enum epoch_event);
static long e_end_block(struct drbd_work *, int);
static int e_end_block(struct drbd_work *, int);
#define GFP_TRY (__GFP_HIGHMEM | __GFP_NOWARN)
......@@ -425,7 +425,7 @@ static int drbd_process_done_ee(struct drbd_conf *mdev)
*/
list_for_each_entry_safe(peer_req, t, &work_list, w.list) {
/* list_del not necessary, next/prev members not touched */
ok = peer_req->w.cb(&peer_req->w, !ok) && ok;
ok = !peer_req->w.cb(&peer_req->w, !ok) && ok;
drbd_free_ee(mdev, peer_req);
}
wake_up(&mdev->ee_wait);
......@@ -1461,28 +1461,28 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req,
/* e_end_resync_block() is called via
* drbd_process_done_ee() by asender only */
static long e_end_resync_block(struct drbd_work *w, int unused)
static int e_end_resync_block(struct drbd_work *w, int unused)
{
struct drbd_peer_request *peer_req =
container_of(w, struct drbd_peer_request, w);
struct drbd_conf *mdev = w->mdev;
sector_t sector = peer_req->i.sector;
int ok;
int err;
D_ASSERT(drbd_interval_empty(&peer_req->i));
if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
drbd_set_in_sync(mdev, sector, peer_req->i.size);
ok = !drbd_send_ack(mdev, P_RS_WRITE_ACK, peer_req);
err = drbd_send_ack(mdev, P_RS_WRITE_ACK, peer_req);
} else {
/* Record failure to sync */
drbd_rs_failed_io(mdev, sector, peer_req->i.size);
ok = !drbd_send_ack(mdev, P_NEG_ACK, peer_req);
err = drbd_send_ack(mdev, P_NEG_ACK, peer_req);
}
dec_unacked(mdev);
return ok;
return err;
}
static int recv_resync_read(struct drbd_conf *mdev, sector_t sector, int data_size) __releases(local)
......@@ -1597,7 +1597,7 @@ static int receive_RSDataReply(struct drbd_conf *mdev, enum drbd_packet cmd,
return ok;
}
static long w_restart_write(struct drbd_work *w, int cancel)
static int w_restart_write(struct drbd_work *w, int cancel)
{
struct drbd_request *req = container_of(w, struct drbd_request, w);
struct drbd_conf *mdev = w->mdev;
......@@ -1608,7 +1608,7 @@ static long w_restart_write(struct drbd_work *w, int cancel)
spin_lock_irqsave(&mdev->tconn->req_lock, flags);
if (!expect(req->rq_state & RQ_POSTPONED)) {
spin_unlock_irqrestore(&mdev->tconn->req_lock, flags);
return 0;
return -EIO;
}
bio = req->master_bio;
start_time = req->start_time;
......@@ -1618,7 +1618,7 @@ static long w_restart_write(struct drbd_work *w, int cancel)
while (__drbd_make_request(mdev, bio, start_time))
/* retry */ ;
return 1;
return 0;
}
static void restart_conflicting_writes(struct drbd_conf *mdev,
......@@ -1645,13 +1645,13 @@ static void restart_conflicting_writes(struct drbd_conf *mdev,
/* e_end_block() is called via drbd_process_done_ee().
* this means this function only runs in the asender thread
*/
static long e_end_block(struct drbd_work *w, int cancel)
static int e_end_block(struct drbd_work *w, int cancel)
{
struct drbd_peer_request *peer_req =
container_of(w, struct drbd_peer_request, w);
struct drbd_conf *mdev = w->mdev;
sector_t sector = peer_req->i.sector;
int ok = 1, pcmd;
int err = 0, pcmd;
if (mdev->tconn->net_conf->wire_protocol == DRBD_PROT_C) {
if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) {
......@@ -1659,11 +1659,11 @@ static long e_end_block(struct drbd_work *w, int cancel)
mdev->state.conn <= C_PAUSED_SYNC_T &&
peer_req->flags & EE_MAY_SET_IN_SYNC) ?
P_RS_WRITE_ACK : P_WRITE_ACK;
ok &= !drbd_send_ack(mdev, pcmd, peer_req);
err = drbd_send_ack(mdev, pcmd, peer_req);
if (pcmd == P_RS_WRITE_ACK)
drbd_set_in_sync(mdev, sector, peer_req->i.size);
} else {
ok = !drbd_send_ack(mdev, P_NEG_ACK, peer_req);
err = drbd_send_ack(mdev, P_NEG_ACK, peer_req);
/* we expect it to be marked out of sync anyways...
* maybe assert this? */
}
......@@ -1683,7 +1683,7 @@ static long e_end_block(struct drbd_work *w, int cancel)
drbd_may_finish_epoch(mdev, peer_req->epoch, EV_PUT + (cancel ? EV_CLEANUP : 0));
return ok;
return err;
}
static int e_send_ack(struct drbd_work *w, enum drbd_packet ack)
......@@ -1691,20 +1691,20 @@ static int e_send_ack(struct drbd_work *w, enum drbd_packet ack)
struct drbd_conf *mdev = w->mdev;
struct drbd_peer_request *peer_req =
container_of(w, struct drbd_peer_request, w);
int ok;
int err;
ok = !drbd_send_ack(mdev, ack, peer_req);
err = drbd_send_ack(mdev, ack, peer_req);
dec_unacked(mdev);
return ok;
return err;
}
static long e_send_discard_write(struct drbd_work *w, int unused)
static int e_send_discard_write(struct drbd_work *w, int unused)
{
return e_send_ack(w, P_DISCARD_WRITE);
}
static long e_send_retry_write(struct drbd_work *w, int unused)
static int e_send_retry_write(struct drbd_work *w, int unused)
{
struct drbd_tconn *tconn = w->mdev->tconn;
......
......@@ -37,7 +37,7 @@ struct after_state_chg_work {
struct completion *done;
};
static long w_after_state_ch(struct drbd_work *w, int unused);
static int w_after_state_ch(struct drbd_work *w, int unused);
static void after_state_ch(struct drbd_conf *mdev, union drbd_state os,
union drbd_state ns, enum chg_state_flags flags);
static void after_all_state_ch(struct drbd_tconn *tconn);
......@@ -918,7 +918,7 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
return rv;
}
static long w_after_state_ch(struct drbd_work *w, int unused)
static int w_after_state_ch(struct drbd_work *w, int unused)
{
struct after_state_chg_work *ascw =
container_of(w, struct after_state_chg_work, w);
......@@ -931,7 +931,7 @@ static long w_after_state_ch(struct drbd_work *w, int unused)
}
kfree(ascw);
return 1;
return 0;
}
static void abw_start_sync(struct drbd_conf *mdev, int rv)
......@@ -1289,7 +1289,7 @@ static void after_all_state_ch(struct drbd_tconn *tconn)
}
}
static long w_after_conn_state_ch(struct drbd_work *w, int unused)
static int w_after_conn_state_ch(struct drbd_work *w, int unused)
{
struct after_conn_state_chg_work *acscw =
container_of(w, struct after_conn_state_chg_work, w);
......@@ -1306,7 +1306,7 @@ static long w_after_conn_state_ch(struct drbd_work *w, int unused)
//conn_err(tconn, STATE_FMT, STATE_ARGS("nms", nms));
after_all_state_ch(tconn);
return 1;
return 0;
}
static void print_conn_state_change(struct drbd_tconn *tconn, enum drbd_conns oc, enum drbd_conns nc)
......
This diff is collapsed.
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