From: Liu Yuan <tailai.ly at taobao.com> if it jumps out of prepare_object_list() with next_rw set, we should really run_next_rw() instead of starting recovery phase. Signed-off-by: Liu Yuan <tailai.ly at taobao.com> --- sheep/recovery.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sheep/recovery.c b/sheep/recovery.c index eefcf3e..a2999f5 100644 --- a/sheep/recovery.c +++ b/sheep/recovery.c @@ -337,18 +337,23 @@ static void free_recovery_work(struct recovery_work *rw) free(rw); } +static inline void run_next_rw(struct recovery_work *rw) +{ + free_recovery_work(rw); + rw = next_rw; + next_rw = NULL; + recovering_work = rw; + flush_wait_obj_requests(); + queue_work(sys->recovery_wqueue, &rw->work); + dprintf("recovery work is superseded\n"); +} + static void recover_object_main(struct work *work) { struct recovery_work *rw = container_of(work, struct recovery_work, work); if (next_rw) { - free_recovery_work(rw); - rw = next_rw; - next_rw = NULL; - recovering_work = rw; - flush_wait_obj_requests(); - queue_work(sys->recovery_wqueue, &rw->work); - dprintf("recovery work is superseded\n"); + run_next_rw(rw); return; } @@ -390,6 +395,10 @@ static void finish_object_list(struct work *work) struct recovery_work *rw = container_of(work, struct recovery_work, work); rw->state = RW_RUN; + if (next_rw) { + run_next_rw(rw); + return; + } /* * We have got the object list to be recovered locally, most of * objects are actually already being there, so let's resume -- 1.7.10.2 |