This allows farm to reuse the old epoch node list instead of re-reading it.

Signed-off-by: Christoph Hellwig <hch@lst.de>

---
 sheep/farm/farm.c  |   21 ++++++++-------------
 sheep/recovery.c   |    9 ++++-----
 sheep/sheep_priv.h |    2 +-
 3 files changed, 13 insertions(+), 19 deletions(-)

Index: sheepdog/sheep/farm/farm.c
===================================================================
--- sheepdog.orig/sheep/farm/farm.c	2012-06-15 17:01:25.124638875 +0200
+++ sheepdog/sheep/farm/farm.c	2012-06-15 17:02:30.772640557 +0200
@@ -528,31 +528,26 @@ out:
 	return ret;
 }
 
-static int farm_end_recover(struct siocb *iocb)
+static int farm_end_recover(uint32_t old_epoch,
+		struct vnode_info *old_vnode_info)
 {
 	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;
 
-	if (epoch == 0)
+	if (old_epoch == 0)
 		return SD_RES_SUCCESS;
 
-	nr_nodes = epoch_log_read(epoch, nodes, sizeof(nodes));
-	if (nr_nodes < 0) {
-		dprintf("failed to read nodes for epoch %d\n", epoch);
-		return SD_RES_EIO;
-	}
+	dprintf("old epoch %d\n", old_epoch);
 
-	dprintf("epoch %d\n", iocb->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_vnode_info->nodes,
+			    old_vnode_info->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;
Index: sheepdog/sheep/recovery.c
===================================================================
--- sheepdog.orig/sheep/recovery.c	2012-06-15 16:59:42.576636250 +0200
+++ sheepdog/sheep/recovery.c	2012-06-15 17:02:11.796640071 +0200
@@ -336,13 +336,12 @@ static inline void finish_recovery(struc
 {
 	recovering_work = NULL;
 	sys->recovered_epoch = rw->epoch;
+
+	if (sd_store->end_recover)
+		sd_store->end_recover(sys->epoch - 1, rw->old_vnodes);
+
 	free_recovery_work(rw);
 
-	if (sd_store->end_recover) {
-		struct siocb iocb = { 0 };
-		iocb.epoch = sys->epoch;
-		sd_store->end_recover(&iocb);
-	}
 	dprintf("recovery complete: new epoch %"PRIu32"\n",
 		sys->recovered_epoch);
 }
Index: sheepdog/sheep/sheep_priv.h
===================================================================
--- sheepdog.orig/sheep/sheep_priv.h	2012-06-15 17:00:49.516637963 +0200
+++ sheepdog/sheep/sheep_priv.h	2012-06-15 17:02:11.796640071 +0200
@@ -169,7 +169,7 @@ 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)(uint32_t epoch, struct vnode_info *old_vnode_info);
 	int (*purge_obj)(void);
 	/* Operations for snapshot */
 	int (*snapshot)(struct siocb *);


