master - cache: use LV_PENDING_DELETE
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f5e265a07fb3e083416d9f5cf17bd601a1e3f782 Commit: f5e265a07fb3e083416d9f5cf17bd601a1e3f782 Parent: f6932bfcf91cd317629d9c04007a495f2c05ae26 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Nov 10 10:56:43 2014 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Nov 10 22:05:49 2014 +0100
cache: use LV_PENDING_DELETE
--- lib/activate/dev_manager.c | 44 ++++++++++++++++++- lib/cache_segtype/cache.c | 2 + lib/format_text/flags.c | 1 + lib/metadata/cache_manip.c | 86 ++++++++++++++++--------------------- lib/metadata/lv.c | 2 + lib/metadata/lv_manip.c | 12 +++++- lib/metadata/metadata-exported.h | 5 ++- lib/misc/lvm-string.c | 1 + lib/report/report.c | 2 +- 9 files changed, 100 insertions(+), 55 deletions(-)
lib/activate/dev_manager.c +41 -3
@@ -1941,8 +1941,14 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, } } -if (!origin_only &&lv_is_cache (lv)) { -if (!dm->activation) { +if (lv_is_cache (lv)) { +if (lv_is_pending_delete (lv)) { +if (!_add_lv_to_dtree (dm, dtree,first_seg (lv)->pool_lv,1 ))/* stack */ + return_0; +/* Orhan cache LV exits here */ +return 1 ; + } +if (!origin_only && !dm->activation) {/* Setup callback for non-activation partial tree */ /* Activation gets own callback when needed */ /* TODO: extend _cached_dm_info() to return dnode */
@@ -1972,6 +1978,14 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, dm->track_pvmove_deps =1 ; } + dm_list_iterate_items(sl, &lv->segs_using_this_lv) { +if (lv_is_pending_delete (sl->seg->lv) &&lv_is_cache (sl->seg->lv)) { +if (!_add_lv_to_dtree (dm, dtree, sl->seg->lv, origin_only)) + return_0; +break ; + } + } +/* Adding LV head of replicator adds all other related devs */ if (lv_is_replicator_dev (lv) && !_add_partial_replicator_to_dtree (dm, dtree, lv))
@@ -2652,6 +2666,30 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,/* Create table */ dm->pvmove_mirror_count =0u ; +if (lv_is_pending_delete (lv)) { +/* Handle LVs with pending delete */ +if (lv_is_cache (lv)) { +/* Use 'error' for cache, metadata and data volumes */ + seg =first_seg (lv); +if (!dm_tree_node_add_error_target (dnode,seg_lv (seg,0 )->size)) + return_0; + seg =first_seg (seg->pool_lv); +if (!(dlid =build_dm_uuid (dm->mem, seg->metadata_lv,NULL ))) + return_0; +if ((dnode =dm_tree_find_node_by_uuid (dtree, dlid)) && + !dm_tree_node_get_context (dnode) && + !dm_tree_node_add_error_target (dnode, seg->metadata_lv->size)) + return_0; +if (!(dlid =build_dm_uuid (dm->mem,seg_lv (seg,0 ),NULL ))) + return_0; +if ((dnode =dm_tree_find_node_by_uuid (dtree, dlid)) && + !dm_tree_node_get_context (dnode) && + !dm_tree_node_add_error_target (dnode,seg_lv (seg,0 )->size)) + return_0; + } +return 1 ; + } +/* This is unused cache-pool - make metadata accessible */ if (lv_is_cache_pool (lv)) lv =first_seg (lv)->metadata_lv;
@@ -2848,7 +2886,7 @@ static int _clean_tree(struct dev_manager *dm, struct dm_tree_node *root, char * }/* Not meant to be top level? */ -if (!*layer) +if (!*layer && (!(layer =strchr (uuid +4 ,'-' )) ||strstr (layer,"-pool" ) ||strstr (layer,"-tpool" )))continue ;/* If operation was performed on a partial tree, don't remove it */
lib/cache_segtype/cache.c +2 -0
@@ -227,6 +227,8 @@ static int _cache_text_import(struct lv_segment *seg, !dm_config_get_uint32(sn, "cleaner", &seg->cleaner_policy))return SEG_LOG_ERROR ("Could not read cache cleaner in" ); + seg->lv->status |=strstr (seg->lv->name,"_corig" ) ?LV_PENDING_DELETE :0 ; +if (!attach_pool_lv (seg, pool_lv,NULL ,NULL )) return_0;
lib/format_text/flags.c +1 -0
@@ -88,6 +88,7 @@ static const struct flag _lv_flags[] = { {CACHE_POOL, NULL, 0}, {CACHE_POOL_DATA, NULL, 0}, {CACHE_POOL_METADATA, NULL, 0}, + {LV_PENDING_DELETE, NULL, 0}, /* TODO: print as COMPATIBLE_FLAG */ {0, NULL, 0} };
lib/metadata/cache_manip.c +37 -49
128 lines not on this page · raw message
lib/metadata/lv.c +2 -0
@@ -990,6 +990,8 @@ const struct logical_volume *lv_lock_holder(const struct logical_volume *lv)if (lv_is_external_origin (lv) &&lv_is_thin_volume (sl->seg->lv))continue ;/* Skip external origin */ +if (lv_is_pending_delete (sl->seg->lv)) +continue ;/* Skip deleted LVs */ return lv_lock_holder (sl->seg->lv); }
lib/metadata/lv_manip.c +11 -1
@@ -1280,7 +1280,8 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete) return_0;/* Remove cache origin only when removing (not on lv_empty()) */ -if (delete &&seg_is_cache (seg) && !lv_remove (seg_lv (seg,0 ))) +if (delete &&seg_is_cache (seg) && + !lv_is_pending_delete (seg->lv) && !lv_remove (seg_lv (seg,0 ))) return_0;if ((pool_lv = seg->pool_lv)) {
@@ -5322,6 +5323,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,struct lv_segment *cache_seg =NULL ;int ask_discard;struct lv_list *lvl; +struct seg_list *sl;int is_last_pool; vg = lv->vg;
@@ -5420,6 +5422,14 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,if (!archive (vg))return 0 ; +/* When referenced by the LV with pending delete flag, remove this deleted LV first */ + dm_list_iterate_items(sl, &lv->segs_using_this_lv) +if (lv_is_pending_delete (sl->seg->lv) && !lv_remove (sl->seg->lv)) { +log_error ("Error releasing logical volume %s with pending delete." , +display_lvname (sl->seg->lv)); +return 0 ; + } +if (lv_is_cow (lv)) {/* Old format1 code */ if (!(lv->vg->fid->fmt->features &FMT_MDAS ))
lib/metadata/metadata-exported.h +4 -1
@@ -117,7 +117,9 @@#define CACHE_POOL_METADATA UINT64_C(0x0000800000000000)/* LV - Internal use only */ #define CACHE UINT64_C(0x0001000000000000)/* LV - Internal use only */ -/* Next unused flag: UINT64_C(0x0004000000000000) */ +#define LV_PENDING_DELETE UINT64_C(0x0004000000000000)/* LV - Internal use only */ + +/* Next unused flag: UINT64_C(0x0008000000000000) */ /* Format features flags */ #define FMT_SEGMENTS 0x00000001U/* Arbitrary segment params? */
@@ -188,6 +190,7 @@#define lv_is_mirror (lv) (((lv)->status & MIRROR) ? 1 : 0)#define lv_is_mirror_type (lv) (((lv)->status & (MIRROR | MIRROR_LOG | MIRROR_IMAGE)) ? 1 : 0) +#define lv_is_pending_delete (lv) (((lv)->status & LV_PENDING_DELETE) ? 1 : 0)#define lv_is_pvmove (lv) (((lv)->status & PVMOVE) ? 1 : 0)#define lv_is_raid (lv) (((lv)->status & RAID) ? 1 : 0)
lib/misc/lvm-string.c +1 -0
@@ -188,6 +188,7 @@ char *build_dm_uuid(struct dm_pool *mem, const struct logical_volume *lv,*/ /* Suffixes used here MUST match lib/activate/dev_manager.c */ layer =lv_is_cache_origin (lv) ?"real" : + (lv_is_cache (lv) &&lv_is_pending_delete (lv)) ?"real" :lv_is_cache_pool_data (lv) ?"cdata" :lv_is_cache_pool_metadata (lv) ?"cmeta" : // FIXME: dm-tree needs fixes for mirrors/raids
lib/report/report.c +1 -1
@@ -518,7 +518,7 @@ static int _origin_disp(struct dm_report *rh, struct dm_pool *mem,if (lv_is_cow (lv))return _lvname_disp (rh, mem, field,origin_from_cow (lv), private); -if (lv_is_cache (lv)) +if (lv_is_cache (lv) && !lv_is_pending_delete (lv))return _lvname_disp (rh, mem, field,seg_lv (seg,0 ), private);if (lv_is_thin_volume (lv) &&first_seg (lv)->origin)