And use them to optimize list_del/list_add_(tail) pairs. Signed-off-by: Christoph Hellwig <hch at lst.de> Index: sheepdog/include/list.h =================================================================== --- sheepdog.orig/include/list.h 2012-05-28 11:12:30.728363536 +0200 +++ sheepdog/include/list.h 2012-05-28 12:39:31.612497218 +0200 @@ -80,6 +80,11 @@ static inline void __list_del(struct lis prev->next = next; } +static inline void __list_del_entry(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); +} + static inline void list_del(struct list_head *entry) { __list_del(entry->prev, entry->next); @@ -88,10 +93,23 @@ static inline void list_del(struct list_ static inline void list_del_init(struct list_head *entry) { - __list_del(entry->prev, entry->next); + __list_del_entry(entry); INIT_LIST_HEAD(entry); } +static inline void list_move(struct list_head *list, struct list_head *head) +{ + __list_del_entry(list); + list_add(list, head); +} + +static inline void list_move_tail(struct list_head *list, + struct list_head *head) +{ + __list_del_entry(list); + list_add_tail(list, head); +} + static inline void __list_splice(const struct list_head *list, struct list_head *prev, struct list_head *next) diff --git a/collie/treeview.c b/collie/treeview.c index b1d2242..29d265b 100644 --- a/collie/treeview.c +++ b/collie/treeview.c @@ -98,10 +98,8 @@ static void compaction(struct vdi_tree *parent) list_for_each_entry_safe(vdi, e, &parent->children, siblings) { new_parent = find_vdi(root, vdi->pvid, vdi->name); - if (new_parent && parent != new_parent) { - list_del(&vdi->siblings); - list_add_tail(&vdi->siblings, &new_parent->children); - } + if (new_parent && parent != new_parent) + list_move_tail(&vdi->siblings, &new_parent->children); compaction(vdi); } diff --git a/sheep/recovery.c b/sheep/recovery.c index 3fb34c0..f7bc62c 100644 --- a/sheep/recovery.c +++ b/sheep/recovery.c @@ -417,10 +417,8 @@ static void resume_wait_recovery_requests(void) list_for_each_entry_safe(req, t, &sys->wait_rw_queue, request_list) { dprintf("resume wait oid %" PRIx64 "\n", req->local_oid); - if (req->rp.result == SD_RES_OBJ_RECOVERING) { - list_del(&req->request_list); - list_add_tail(&req->request_list, &sys->request_queue); - } + if (req->rp.result == SD_RES_OBJ_RECOVERING) + list_move_tail(&req->request_list, &sys->request_queue); } process_request_event_queues(); diff --git a/sheep/sdnet.c b/sheep/sdnet.c index f4408f7..7fcff4b 100644 --- a/sheep/sdnet.c +++ b/sheep/sdnet.c @@ -65,8 +65,7 @@ static void check_object_consistency(struct sd_req *hdr) nr_bmaps++; if (bmap->vdi_id == vdi_id) { set_bit(data_oid_to_idx(hdr->obj.oid), bmap->dobjs); - list_del(&bmap->list); - list_add_tail(&bmap->list, &sys->consistent_obj_list); + list_move_tail(&bmap->list, &sys->consistent_obj_list); return; } } @@ -267,8 +266,7 @@ void resume_wait_epoch_requests(void) setup_access_to_local_objects(req); /* peer retries the request locally when its epoch changes. */ case SD_RES_NEW_NODE_VER: - list_del(&req->request_list); - list_add_tail(&req->request_list, &sys->request_queue); + list_move_tail(&req->request_list, &sys->request_queue); break; default: break; @@ -287,8 +285,7 @@ void resume_wait_obj_requests(uint64_t oid) * recovered, notify the pending request. */ if (req->local_oid == oid) { dprintf("retry %" PRIx64 "\n", req->local_oid); - list_del(&req->request_list); - list_add_tail(&req->request_list, &sys->request_queue); + list_move_tail(&req->request_list, &sys->request_queue); } } process_request_event_queues(); |