From: Liu Yuan <tailai.ly at taobao.com> - refine the interface to get name string directly Signed-off-by: Liu Yuan <tailai.ly at taobao.com> --- sheep/farm/farm.c | 26 +------------------------- sheep/ops.c | 2 +- sheep/plain_store.c | 3 +-- sheep/sheep_priv.h | 4 ++-- 4 files changed, 5 insertions(+), 30 deletions(-) diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c index a680a10..69198a1 100644 --- a/sheep/farm/farm.c +++ b/sheep/farm/farm.c @@ -318,30 +318,6 @@ out: return ret; } -static int farm_format(struct siocb *iocb) -{ - char path[PATH_MAX]; - unsigned ret; - const char name[] = "farm"; - - dprintf("try get a clean store\n"); - snprintf(path, sizeof(path), "%s", obj_path); - ret = rmdir_r(path); - if (ret && ret != -ENOENT) { - eprintf("failed to remove %s: %s\n", path, strerror(-ret)); - return SD_RES_EIO; - } - if (mkdir(path, def_dmode) < 0) { - eprintf("%m\n"); - return SD_RES_EIO; - } - - if (set_cluster_store(name) < 0) - return SD_RES_EIO; - - return SD_RES_SUCCESS; -} - struct store_driver farm = { .name = "farm", .init = farm_init, @@ -355,7 +331,7 @@ struct store_driver farm = { .cleanup = default_cleanup, .restore = farm_restore, .get_snap_file = farm_get_snap_file, - .format = farm_format, + .format = default_format, .purge_obj = default_purge_obj, .remove_object = default_remove_object, }; diff --git a/sheep/ops.c b/sheep/ops.c index f30b8ba..9f2e04f 100644 --- a/sheep/ops.c +++ b/sheep/ops.c @@ -227,7 +227,7 @@ static int cluster_make_fs(const struct sd_req *req, struct sd_rsp *rsp, latest_epoch = get_latest_epoch(); iocb.epoch = latest_epoch; - ret = sd_store->format(&iocb); + ret = sd_store->format(data); if (ret != SD_RES_SUCCESS) return ret; diff --git a/sheep/plain_store.c b/sheep/plain_store.c index 0f946c9..324a139 100644 --- a/sheep/plain_store.c +++ b/sheep/plain_store.c @@ -356,10 +356,9 @@ int default_end_recover(uint32_t old_epoch, struct vnode_info *old_vnode_info) return for_each_objects(move_object_to_stale_dir); } -int default_format(struct siocb *iocb) +int default_format(char *name) { unsigned ret; - const char name[] = "plain"; dprintf("try get a clean store\n"); ret = rmdir_r(obj_path); diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h index bbc1ee5..7a54268 100644 --- a/sheep/sheep_priv.h +++ b/sheep/sheep_priv.h @@ -144,7 +144,7 @@ struct store_driver { int (*exist)(uint64_t oid); int (*write)(uint64_t oid, struct siocb *, int create); int (*read)(uint64_t oid, struct siocb *); - int (*format)(struct siocb *); + int (*format)(char *name); int (*remove_object)(uint64_t oid); /* Operations in recovery */ int (*link)(uint64_t oid, struct siocb *, uint32_t tgt_epoch); @@ -167,7 +167,7 @@ int default_link(uint64_t oid, struct siocb *iocb, uint32_t tgt_epoch); int default_atomic_put(uint64_t oid, struct siocb *iocb); int default_end_recover(uint32_t old_epoch, struct vnode_info *old_vnode_info); int default_cleanup(void); -int default_format(struct siocb *iocb); +int default_format(char *name); int default_remove_object(uint64_t oid); int default_purge_obj(void); -- 1.7.10.2 |