Remove the get_objlist method and just let the store driver call
objlist_cache_insert for every entry it finds.

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

diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index 568fad2..b50d188 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -335,18 +335,6 @@ err:
 	return SD_RES_EIO;
 }
 
-static int farm_get_objlist(struct siocb *iocb)
-{
-	uint64_t *objlist = (uint64_t *)iocb->buf;
-
-	iocb->length = trunk_get_working_objlist(objlist);
-
-	dprintf("%"PRIu32"\n", iocb->length);
-
-	return SD_RES_SUCCESS;
-}
-
-
 static void *read_working_object(uint64_t oid, uint64_t offset,
 				 uint32_t length)
 {
@@ -737,7 +725,6 @@ struct store_driver farm = {
 	.exist = farm_exist,
 	.write = farm_write,
 	.read = farm_read,
-	.get_objlist = farm_get_objlist,
 	.link = farm_link,
 	.atomic_put = farm_atomic_put,
 	.end_recover = farm_end_recover,
diff --git a/sheep/farm/farm.h b/sheep/farm/farm.h
index cc829cd..2a21061 100644
--- a/sheep/farm/farm.h
+++ b/sheep/farm/farm.h
@@ -67,7 +67,6 @@ extern int trunk_update_entry(uint64_t oid);
 extern void trunk_reset(void);
 extern void trunk_put_entry(uint64_t oid);
 extern void trunk_get_entry(uint64_t oid);
-extern int trunk_get_working_objlist(uint64_t *list);
 
 /* snap.c */
 extern int snap_init(void);
diff --git a/sheep/farm/trunk.c b/sheep/farm/trunk.c
index d47c31b..b573460 100644
--- a/sheep/farm/trunk.c
+++ b/sheep/farm/trunk.c
@@ -119,6 +119,7 @@ int trunk_init(void)
 		oid = strtoull(d->d_name, NULL, 16);
 		if (oid == 0 || oid == ULLONG_MAX)
 			continue;
+		objlist_cache_insert(oid);
 		lookup_trunk_entry(oid, 1);
 	}
 
@@ -398,17 +399,3 @@ void trunk_reset(void)
 	eprintf("%s\n", trunk_entry_active_nr ? "WARN: active_list not clean" :
 						"clean");
 }
-
-int trunk_get_working_objlist(uint64_t *list)
-{
-	int nr = 0;
-	struct trunk_entry_incore *entry;
-
-	pthread_mutex_lock(&active_list_lock);
-	list_for_each_entry(entry, &trunk_active_list, active_list) {
-		list[nr++] = entry->raw.oid;
-	}
-	pthread_mutex_unlock(&active_list_lock);
-
-	return nr;
-}
diff --git a/sheep/object_list_cache.c b/sheep/object_list_cache.c
index a3d320e..3dfb8a0 100644
--- a/sheep/object_list_cache.c
+++ b/sheep/object_list_cache.c
@@ -43,34 +43,6 @@ struct objlist_cache obj_list_cache = {
 			RB_ROOT, /* root */
 		};
 
-int init_objlist_cache(void)
-{
-	int i;
-	struct siocb iocb = { 0 };
-	uint64_t *buf;
-
-	pthread_rwlock_init(&obj_list_cache.lock, NULL);
-
-	if (sd_store) {
-		buf = zalloc(1 << 22);
-		if (!buf) {
-			eprintf("no memory to allocate.\n");
-			return -1;
-		}
-
-		iocb.length = 0;
-		iocb.buf = buf;
-		sd_store->get_objlist(&iocb);
-
-		for (i = 0; i < iocb.length; i++)
-			objlist_cache_insert(buf[i]);
-
-		free(buf);
-	}
-
-	return 0;
-}
-
 static struct objlist_cache_entry *objlist_cache_rb_insert(struct rb_root *root,
 		struct objlist_cache_entry *new)
 {
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index a3ade74..28eb5fa 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -158,7 +158,6 @@ struct store_driver {
 	int (*read)(uint64_t oid, struct siocb *);
 	int (*format)(struct siocb *);
 	/* Operations in recovery */
-	int (*get_objlist)(struct siocb *);
 	int (*link)(uint64_t oid, struct siocb *, uint32_t tgt_epoch);
 	int (*atomic_put)(uint64_t oid, struct siocb *);
 	int (*begin_recover)(struct siocb *);
@@ -299,7 +298,6 @@ int get_sheep_fd(uint8_t *addr, uint16_t port, int node_idx, uint32_t epoch);
 
 int prealloc(int fd, uint32_t size);
 
-int init_objlist_cache(void);
 int objlist_cache_insert(uint64_t oid);
 void objlist_cache_remove(uint64_t oid);
 
diff --git a/sheep/store.c b/sheep/store.c
index 3030adb..00f8064 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -503,10 +503,6 @@ int init_store(const char *d, int enable_write_cache)
 	if (ret)
 		return ret;
 
-	ret = init_objlist_cache();
-	if (ret)
-		return ret;
-
 	if (enable_write_cache) {
 		sys->enable_write_cache = 1;
 		ret = object_cache_init(d);


