This allows farm to reuse the node list used during recovery instead of
rereading it.

Signed-off-by: Christoph Hellwig <[email protected]>

diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index e2e7522..161a8bc 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -528,31 +528,25 @@ out:
        return ret;
 }
 
-static int farm_end_recover(struct siocb *iocb)
+static int farm_end_recover(int epoch, struct vnode_info *cur,
+               struct vnode_info *old)
 {
        unsigned char snap_sha1[SHA1_LEN];
        unsigned char trunk_sha1[SHA1_LEN];
-       uint32_t epoch = iocb->epoch - 1;
-       struct sd_node nodes[SD_MAX_NODES];
-       int nr_nodes;
+       uint32_t old_epoch = epoch;
 
-       if (epoch == 0)
+       if (old_epoch == 0)
                return SD_RES_SUCCESS;
 
-       nr_nodes = epoch_log_read_nr(epoch, (char *)nodes, sizeof(nodes));
-       if (nr_nodes < 0) {
-               dprintf("failed to read nodes for epoch %d\n", epoch);
-               return SD_RES_EIO;
-       }
-
-       dprintf("epoch %d\n", iocb->epoch);
+       dprintf("epoch %d\n", epoch);
        if (trunk_file_write_recovery(trunk_sha1) < 0)
                return SD_RES_EIO;
 
-       if (snap_file_write(epoch, nodes, nr_nodes, trunk_sha1, snap_sha1) < 0)
+       if (snap_file_write(old_epoch, old->nodes, old->nr_nodes,
+                           trunk_sha1, snap_sha1) < 0)
                return SD_RES_EIO;
 
-       if (snap_log_write(epoch, snap_sha1, 0) < 0)
+       if (snap_log_write(old_epoch, snap_sha1, 0) < 0)
                return SD_RES_EIO;
 
        return SD_RES_SUCCESS;
diff --git a/sheep/recovery.c b/sheep/recovery.c
index fb8395f..b9aa686 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -398,9 +398,9 @@ static void do_recover_main(struct work *work)
        recovering_work = NULL;
 
        sys->recovered_epoch = rw->epoch;
-       free_recovery_work(rw);
 
        if (next_rw) {
+               free_recovery_work(rw);
                rw = next_rw;
                next_rw = NULL;
 
@@ -410,10 +410,10 @@ static void do_recover_main(struct work *work)
                queue_work(sys->recovery_wqueue, &rw->work);
        } else {
                if (sd_store->end_recover) {
-                       struct siocb iocb = { 0 };
-                       iocb.epoch = sys->epoch;
-                       sd_store->end_recover(&iocb);
+                       sd_store->end_recover(sys->epoch, rw->cur_vnodes,
+                                             rw->old_vnodes);
                }
+               free_recovery_work(rw);
        }
 
        resume_pending_requests();
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 0d05c65..e5068de 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -165,7 +165,8 @@ struct store_driver {
        int (*link)(uint64_t oid, struct siocb *, uint32_t tgt_epoch);
        int (*atomic_put)(uint64_t oid, struct siocb *);
        int (*begin_recover)(struct siocb *);
-       int (*end_recover)(struct siocb *);
+       int (*end_recover)(int epoch, struct vnode_info *cur,
+                          struct vnode_info *old);
        int (*purge_obj)(void);
        /* Operations for snapshot */
        int (*snapshot)(struct siocb *);

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to