From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12155 invoked by alias); 3 Nov 2011 14:36:45 -0000 Received: (qmail 12130 invoked by uid 9737); 3 Nov 2011 14:36:42 -0000 Date: Thu, 03 Nov 2011 14:36:00 -0000 Message-ID: <20111103143642.12128.qmail@sourceware.org> From: zkabelac@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/lib/metadata lv_manip.c thin_manip.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2011-11/txt/msg00000.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-11-03 14:36:41 Modified files: lib/metadata : lv_manip.c thin_manip.c Log message: Thin code cleanup Use iterate_items for list processing. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.316&r2=1.317 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/thin_manip.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18 --- LVM2/lib/metadata/lv_manip.c 2011/10/30 22:07:38 1.316 +++ LVM2/lib/metadata/lv_manip.c 2011/11/03 14:36:40 1.317 @@ -137,7 +137,8 @@ return NULL; } - sl = dm_list_item(dm_list_first(&lv->segs_using_this_lv), struct seg_list); + dm_list_iterate_items(sl, &lv->segs_using_this_lv) + break; /* first item */ if (sl->count != 1) { log_error("%s is expected to have only one segment using it, " --- LVM2/lib/metadata/thin_manip.c 2011/10/30 22:52:08 1.17 +++ LVM2/lib/metadata/thin_manip.c 2011/11/03 14:36:40 1.18 @@ -49,18 +49,16 @@ int detach_pool_lv(struct lv_segment *seg) { - struct lv_thin_message *tmsg; - struct dm_list *l, *lt; + struct lv_thin_message *tmsg, *tmp; - if (!lv_is_thin_pool(seg->pool_lv)) { - log_error(INTERNAL_ERROR "LV %s is not a thin pool", - seg->pool_lv->name); + if (!seg->pool_lv || !lv_is_thin_pool(seg->pool_lv)) { + log_error(INTERNAL_ERROR "LV %s is not a thin volume", + seg->lv->name); return 0; } /* Drop any message referencing removed segment */ - dm_list_iterate_safe(l, lt, &first_seg(seg->pool_lv)->thin_messages) { - tmsg = dm_list_item(l, struct lv_thin_message); + dm_list_iterate_items_safe(tmsg, tmp, &first_seg(seg->pool_lv)->thin_messages) { switch (tmsg->type) { case DM_THIN_MESSAGE_CREATE_SNAP: case DM_THIN_MESSAGE_CREATE_THIN: @@ -201,8 +199,8 @@ */ uint32_t get_free_pool_device_id(struct lv_segment *thin_pool_seg) { - uint32_t dev_id, max_id = 0; - struct dm_list *h; + uint32_t max_id = 0; + struct seg_list *sl; if (!seg_is_thin_pool(thin_pool_seg)) { log_error(INTERNAL_ERROR @@ -211,11 +209,9 @@ return 0; } - dm_list_iterate(h, &thin_pool_seg->lv->segs_using_this_lv) { - dev_id = dm_list_item(h, struct seg_list)->seg->device_id; - if (dev_id > max_id) - max_id = dev_id; - } + dm_list_iterate_items(sl, &thin_pool_seg->lv->segs_using_this_lv) + if (sl->seg->device_id > max_id) + max_id = sl->seg->device_id; if (++max_id > DM_THIN_MAX_DEVICE_ID) { // FIXME: try to find empty holes....