From: Liu Yuan <tailai.ly at taobao.com> For now we have a retry-based pull/push method, which privide us mush better robust mechanism, async is no longer required to run Guests seriously because it violate block storage that Guest always expect of. Signed-off-by: Liu Yuan <tailai.ly at taobao.com> --- sheep/object_cache.c | 54 ++++++++------------------------------------------ sheep/sheep.c | 13 +++--------- sheep/sheep_priv.h | 5 +---- 3 files changed, 12 insertions(+), 60 deletions(-) diff --git a/sheep/object_cache.c b/sheep/object_cache.c index fdc8253..9e91b6a 100644 --- a/sheep/object_cache.c +++ b/sheep/object_cache.c @@ -60,12 +60,6 @@ struct object_cache_entry { int create; }; -struct flush_work { - struct object_cache *cache; - struct vnode_info *vnode_info; - struct work work; -}; - static char cache_dir[PATH_MAX]; static int def_open_flags = O_RDWR; @@ -209,9 +203,9 @@ out: return cache; } -static inline void del_from_dirty_tree_and_list( - struct object_cache_entry *entry, - struct rb_root *dirty_tree) +static inline void +del_from_dirty_tree_and_list(struct object_cache_entry *entry, + struct rb_root *dirty_tree) { rb_erase(&entry->rb, dirty_tree); list_del(&entry->list); @@ -539,8 +533,8 @@ static uint64_t idx_to_oid(uint32_t vid, uint32_t idx) return vid_to_data_oid(vid, idx); } -static int push_cache_object(uint32_t vid, uint32_t idx, - uint64_t bmap, int create) +static int push_cache_object(uint32_t vid, uint32_t idx, uint64_t bmap, + int create) { struct sd_req hdr; void *buf; @@ -678,8 +672,7 @@ void object_cache_delete(uint32_t vid) } -static int object_cache_flush_and_delete(struct vnode_info *vnode_info, - struct object_cache *oc) +static int object_cache_flush_and_delete(struct object_cache *oc) { DIR *dir; struct dirent *d; @@ -734,7 +727,7 @@ int bypass_object_cache(struct request *req) if (!cache) return 1; if (req->rq.flags & SD_FLAG_CMD_WRITE) { - object_cache_flush_and_delete(req->vnodes, cache); + object_cache_flush_and_delete(cache); return 1; } else { /* For read requet, we can read cache if any */ @@ -845,25 +838,6 @@ int object_cache_read(uint64_t oid, char *data, unsigned int datalen, return ret; } -static void object_cache_flush_vdi_fn(struct work *work) -{ - struct flush_work *fw = container_of(work, struct flush_work, work); - - dprintf("flush vdi %"PRIx32"\n", fw->cache->vid); - if (object_cache_push(fw->cache) != SD_RES_SUCCESS) - eprintf("failed to flush vdi %"PRIx32"\n", fw->cache->vid); -} - -static void object_cache_flush_vdi_done(struct work *work) -{ - struct flush_work *fw = container_of(work, struct flush_work, work); - - dprintf("flush vdi %"PRIx32" done\n", fw->cache->vid); - - put_vnode_info(fw->vnode_info); - free(fw); -} - int object_cache_flush_vdi(struct request *req) { uint32_t vid = oid_to_vid(req->rq.obj.oid); @@ -873,18 +847,6 @@ int object_cache_flush_vdi(struct request *req) if (!cache) return SD_RES_SUCCESS; - if (sys->async_flush) { - struct flush_work *fw = xzalloc(sizeof(*fw)); - - fw->work.fn = object_cache_flush_vdi_fn; - fw->work.done = object_cache_flush_vdi_done; - fw->cache = cache; - fw->vnode_info = grab_vnode_info(req->vnodes); - - queue_work(sys->flush_wqueue, &fw->work); - return SD_RES_SUCCESS; - } - return object_cache_push(cache); } @@ -894,7 +856,7 @@ int object_cache_flush_and_del(struct request *req) struct object_cache *cache; cache = find_object_cache(vid, 0); - if (cache && object_cache_flush_and_delete(req->vnodes, cache) < 0) + if (cache && object_cache_flush_and_delete(cache) < 0) return SD_RES_EIO; return SD_RES_SUCCESS; } diff --git a/sheep/sheep.c b/sheep/sheep.c index 49d3cda..67db023 100644 --- a/sheep/sheep.c +++ b/sheep/sheep.c @@ -34,7 +34,6 @@ LIST_HEAD(cluster_drivers); static char program_name[] = "sheep"; static struct option const long_options[] = { - {"asyncflush", no_argument, NULL, 'a'}, {"cluster", required_argument, NULL, 'c'}, {"debug", no_argument, NULL, 'd'}, {"directio", no_argument, NULL, 'D'}, @@ -53,7 +52,7 @@ static struct option const long_options[] = { {NULL, 0, NULL, 0}, }; -static const char *short_options = "ac:dDfg:Ghi:l:op:v:Wy:z:"; +static const char *short_options = "c:dDfg:Ghi:l:op:v:Wy:z:"; static void usage(int status) { @@ -65,7 +64,6 @@ static void usage(int status) Sheepdog daemon (version %s)\n\ Usage: %s [OPTION]... [PATH]\n\ Options:\n\ - -a, --asyncflush flush the object cache asynchronously\n\ -c, --cluster specify the cluster driver\n\ -d, --debug include debug messages in the log\n\ -D, --directio use direct IO when accessing the object from object cache\n\ @@ -165,9 +163,6 @@ int main(int argc, char **argv) dprintf("direct IO mode\n"); sys->use_directio = 1; break; - case 'a': - sys->async_flush = 1; - break; case 'g': nr_gateway_worker = strtol(optarg, &p, 10); if (optarg == p || nr_gateway_worker < 4 || nr_gateway_worker > UINT32_MAX) { @@ -281,11 +276,9 @@ int main(int argc, char **argv) sys->io_wqueue = init_work_queue("io", nr_io_worker); sys->recovery_wqueue = init_work_queue("recovery", 1); sys->deletion_wqueue = init_work_queue("deletion", 1); - sys->flush_wqueue = init_work_queue("flush", 1); sys->block_wqueue = init_work_queue("block", 1); - if (!sys->gateway_wqueue || !sys->io_wqueue || - !sys->recovery_wqueue || !sys->deletion_wqueue || - !sys->flush_wqueue || !sys->block_wqueue) + if (!sys->gateway_wqueue || !sys->io_wqueue ||!sys->recovery_wqueue || + !sys->deletion_wqueue || !sys->block_wqueue) exit(1); ret = init_signal(); diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h index bd44073..90c22cc 100644 --- a/sheep/sheep_priv.h +++ b/sheep/sheep_priv.h @@ -131,13 +131,11 @@ struct cluster_info { uint32_t recovered_epoch; int use_directio; - uint8_t async_flush; struct work_queue *gateway_wqueue; struct work_queue *io_wqueue; struct work_queue *deletion_wqueue; struct work_queue *recovery_wqueue; - struct work_queue *flush_wqueue; struct work_queue *block_wqueue; }; @@ -300,7 +298,6 @@ int prealloc(int fd, uint32_t size); int objlist_cache_insert(uint64_t oid); void objlist_cache_remove(uint64_t oid); -void object_cache_remove(uint64_t oid); void req_done(struct request *req); @@ -402,8 +399,8 @@ int object_cache_read(uint64_t oid, char *data, unsigned int datalen, int object_cache_flush_vdi(struct request *req); int object_cache_flush_and_del(struct request *req); void object_cache_delete(uint32_t vid); - int object_cache_init(const char *p); +void object_cache_remove(uint64_t oid); /* sockfd_cache */ struct sockfd { -- 1.7.10.2 |