vlmc: Honor flush req by stall until all reqs done
authorFilippos Giannakos <philipgian@grnet.gr>
Tue, 10 Sep 2013 13:19:12 +0000 (16:19 +0300)
committerFilippos Giannakos <philipgian@grnet.gr>
Wed, 4 Dec 2013 14:51:48 +0000 (16:51 +0200)
xseg/peers/user/mt-vlmcd.c

index 03ed5db..7e99eb6 100644 (file)
@@ -255,6 +255,14 @@ static int conclude_pr(struct peerd *peer, struct peer_req *pr)
        return 0;
 }
 
+static int should_freeze_volume(struct xseg_request *req)
+{
+       if (req->op == X_CLOSE || req->op == X_SNAPSHOT ||
+               (req->op == X_WRITE && !req->size && (req->flags & XF_FLUSH)))
+               return 1;
+       return 0;
+}
+
 static int do_accepted_pr(struct peerd *peer, struct peer_req *pr)
 {
        struct vlmcd *vlmc = __get_vlmcd(peer);
@@ -283,7 +291,7 @@ static int do_accepted_pr(struct peerd *peer, struct peer_req *pr)
                return -1;
        }
 
-       if (pr->req->op == X_CLOSE || pr->req->op == X_SNAPSHOT){
+       if (should_freeze_volume(pr->req)){
                XSEGLOG2(&lc, I, "Freezing volume %s", vi->name);
                vi->flags |= VF_VOLUME_FREEZED;
                if (vi->active_reqs){
@@ -299,6 +307,7 @@ static int do_accepted_pr(struct peerd *peer, struct peer_req *pr)
                        //assert vi->pending_pr == pr
                        vi->pending_pr = NULL;
                }
+
        }
 
        vi->active_reqs++;
@@ -309,6 +318,7 @@ static int do_accepted_pr(struct peerd *peer, struct peer_req *pr)
                        (pr->req->flags & (XF_FLUSH|XF_FUA))){
                //hanlde flush requests here, so we don't mess with mapper
                //because of the -1 offset
+               vi->flags &= ~VF_VOLUME_FREEZED;
                XSEGLOG2(&lc, I, "Completing flush request");
                pr->req->serviced = pr->req->size;
                conclude_pr(peer, pr);