Multiple execution of "dog vdi snapshot" can be overlapped. The variable should not be boolean.
Signed-off-by: Hitoshi Mitake <mitake.hito...@lab.ntt.co.jp> --- sheep/ops.c | 6 ++++-- sheep/request.c | 2 +- sheep/sheep_priv.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sheep/ops.c b/sheep/ops.c index 3432c83..3bf4838 100644 --- a/sheep/ops.c +++ b/sheep/ops.c @@ -1207,7 +1207,7 @@ static int local_prevent_cow(const struct sd_req *req, struct sd_rsp *rsp, sd_debug("preventing COW request, ongoing COW requests: %d", sys->nr_ongoing_cow_request); - sys->prevent_cow = true; + sys->nr_prevent_cow++; if (sys->nr_ongoing_cow_request) { list_add_tail(&rq->pending_prevent_cow_request_list, @@ -1224,8 +1224,10 @@ static int local_allow_cow(const struct sd_req *req, struct sd_rsp *rsp, struct request *rq; sd_debug("allowing COW request"); + sys->nr_prevent_cow--; - sys->prevent_cow = false; + if (sys->nr_prevent_cow) + return SD_RES_SUCCESS; list_for_each_entry(rq, &sys->prevented_cow_request_queue, prevented_cow_request_list) { diff --git a/sheep/request.c b/sheep/request.c index f5150d5..5a251c2 100644 --- a/sheep/request.c +++ b/sheep/request.c @@ -353,7 +353,7 @@ queue_work: } if (req->rq.opcode == SD_OP_WRITE_OBJ && is_data_vid_update(&req->rq)) { - if (sys->prevent_cow) { + if (sys->nr_prevent_cow) { sd_debug("preventing COW"); list_add_tail(&req->prevented_cow_request_list, &sys->prevented_cow_request_queue); diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h index a876fe5..0c590c0 100644 --- a/sheep/sheep_priv.h +++ b/sheep/sheep_priv.h @@ -166,7 +166,7 @@ struct system_info { bool upgrade; struct sd_stat stat; - bool prevent_cow; + int nr_prevent_cow; int nr_ongoing_cow_request; struct list_head prevented_cow_request_queue; struct list_head pending_prevent_cow_request_queue; -- 1.7.1 -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog