mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
add thin_manip.c like the other manip files
move basic lv_is_* to macros data_lv -> pool_lv - we decided to call it 'pool' everywhere now
This commit is contained in:
parent
2ef5b7cca6
commit
b88362ff95
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
@ -93,6 +93,7 @@ SOURCES =\
|
||||
metadata/replicator_manip.c \
|
||||
metadata/segtype.c \
|
||||
metadata/snapshot_manip.c \
|
||||
metadata/thin_manip.c \
|
||||
metadata/vg.c \
|
||||
misc/crc.c \
|
||||
misc/lvm-exec.c \
|
||||
|
@ -198,22 +198,6 @@ uint32_t find_free_lvnum(struct logical_volume *lv)
|
||||
return i;
|
||||
}
|
||||
|
||||
static int _attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata)
|
||||
{
|
||||
// FIXME Housekeeping needed here (cf attach_mirror_log)
|
||||
seg->metadata_lv = thin_pool_metadata;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv)
|
||||
{
|
||||
// FIXME Housekeeping needed here (cf attach_mirror_log)
|
||||
seg->thin_pool_lv = thin_pool_lv;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* All lv_segments get created here.
|
||||
*/
|
||||
@ -268,12 +252,12 @@ struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
|
||||
seg->pvmove_source_seg = pvmove_source_seg;
|
||||
dm_list_init(&seg->tags);
|
||||
|
||||
if (thin_pool_lv && !_attach_pool_lv(seg, thin_pool_lv))
|
||||
if (thin_pool_lv && !attach_pool_lv(seg, thin_pool_lv))
|
||||
return_NULL;
|
||||
|
||||
if (log_lv) {
|
||||
if (thin_pool_lv) {
|
||||
if (!_attach_pool_metadata(seg, log_lv))
|
||||
if (!attach_pool_metadata(seg, log_lv))
|
||||
return_NULL;
|
||||
} else if (!attach_mirror_log(seg, log_lv))
|
||||
return_NULL;
|
||||
|
@ -132,6 +132,11 @@
|
||||
#define VGMETADATACOPIES_ALL UINT32_MAX
|
||||
#define VGMETADATACOPIES_UNMANAGED 0
|
||||
|
||||
#define lv_is_thin_volume(lv) ((lv)->status & THIN_VOLUME ? 1 : 0)
|
||||
#define lv_is_thin_pool(lv) ((lv)->status & THIN_POOL ? 1 : 0)
|
||||
#define lv_is_mirrored(lv) ((lv)->status & MIRRORED ? 1 : 0)
|
||||
#define lv_is_rlog(lv) ((lv)->status & REPLICATOR_LOG ? 1 : 0)
|
||||
|
||||
/* Ordered list - see lv_manip.c */
|
||||
typedef enum {
|
||||
AREA_UNASSIGNED,
|
||||
@ -318,7 +323,7 @@ struct lv_segment {
|
||||
|
||||
struct lv_segment_area *areas;
|
||||
struct lv_segment_area *meta_areas; /* For RAID */
|
||||
struct logical_volume *data_lv; /* For thin_pool */
|
||||
struct logical_volume *pool_lv; /* For thin_pool */
|
||||
struct logical_volume *metadata_lv; /* For thin_pool */
|
||||
uint64_t transaction_id; /* For thin_pool */
|
||||
uint32_t zero_new_blocks; /* For thin_pool */
|
||||
@ -696,7 +701,6 @@ int lv_remove_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
int is_temporary_mirror_layer(const struct logical_volume *lv);
|
||||
struct logical_volume * find_temporary_mirror(const struct logical_volume *lv);
|
||||
int lv_is_mirrored(const struct logical_volume *lv);
|
||||
uint32_t lv_mirror_count(const struct logical_volume *lv);
|
||||
uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
|
||||
uint32_t region_size);
|
||||
@ -742,7 +746,6 @@ int lv_is_active_replicator_dev(const struct logical_volume *lv);
|
||||
int lv_is_replicator(const struct logical_volume *lv);
|
||||
int lv_is_replicator_dev(const struct logical_volume *lv);
|
||||
int lv_is_rimage(const struct logical_volume *lv);
|
||||
int lv_is_rlog(const struct logical_volume *lv);
|
||||
int lv_is_slog(const struct logical_volume *lv);
|
||||
struct logical_volume *first_replicator_dev(const struct logical_volume *lv);
|
||||
/* -- metadata/replicator_manip.c */
|
||||
|
@ -439,6 +439,13 @@ struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft
|
||||
*/
|
||||
int fixup_imported_mirrors(struct volume_group *vg);
|
||||
|
||||
/*
|
||||
* From thin_manip.c
|
||||
*/
|
||||
int attach_pool_metadata(struct lv_segment *seg,
|
||||
struct logical_volume *thin_pool_metadata);
|
||||
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv);
|
||||
|
||||
/*
|
||||
* Begin skeleton for external LVM library
|
||||
*/
|
||||
|
@ -72,14 +72,6 @@ struct logical_volume *find_temporary_mirror(const struct logical_volume *lv)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int lv_is_mirrored(const struct logical_volume *lv)
|
||||
{
|
||||
if (lv->status & MIRRORED)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* cluster_mirror_is_available
|
||||
*
|
||||
|
@ -445,14 +445,6 @@ int lv_is_rimage(const struct logical_volume *lv)
|
||||
return (lv->rdevice && lv->rdevice->lv == lv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this LV rlog
|
||||
*/
|
||||
int lv_is_rlog(const struct logical_volume *lv)
|
||||
{
|
||||
return (lv->status & REPLICATOR_LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this LV sync log
|
||||
*/
|
||||
|
33
lib/metadata/thin_manip.c
Normal file
33
lib/metadata/thin_manip.c
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
#include "metadata.h"
|
||||
|
||||
int attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata)
|
||||
{
|
||||
// FIXME Housekeeping needed here (cf attach_mirror_log)
|
||||
seg->metadata_lv = thin_pool_metadata;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv)
|
||||
{
|
||||
// FIXME Housekeeping needed here (cf attach_mirror_log)
|
||||
seg->thin_pool_lv = thin_pool_lv;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -51,12 +51,14 @@ static int _thin_pool_text_import(struct lv_segment *seg, const struct dm_config
|
||||
if (!dm_config_get_str(sn, "data", &lv_name))
|
||||
return SEG_LOG_ERROR("Thin pool data must be a string in");
|
||||
|
||||
if (!(seg->data_lv = find_lv(seg->lv->vg, lv_name)))
|
||||
// Use attach_pool_lv
|
||||
if (!(seg->pool_lv = find_lv(seg->lv->vg, lv_name)))
|
||||
return SEG_LOG_ERROR("Unknown pool data %s in", lv_name);
|
||||
|
||||
if (!dm_config_get_str(sn, "metadata", &lv_name))
|
||||
return SEG_LOG_ERROR("Thin pool metadata must be a string in");
|
||||
|
||||
// Use attach_pool_metadata()
|
||||
if (!(seg->metadata_lv = find_lv(seg->lv->vg, lv_name)))
|
||||
return SEG_LOG_ERROR("Unknown pool metadata %s in", lv_name);
|
||||
|
||||
@ -72,7 +74,7 @@ static int _thin_pool_text_import(struct lv_segment *seg, const struct dm_config
|
||||
|
||||
static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter *f)
|
||||
{
|
||||
outf(f, "data = \"%s\"", seg->data_lv->name);
|
||||
outf(f, "data = \"%s\"", seg->pool_lv->name);
|
||||
outf(f, "metadata = \"%s\"", seg->metadata_lv->name);
|
||||
outf(f, "transaction_id = %" PRIu64, seg->transaction_id);
|
||||
if (seg->zero_new_blocks)
|
||||
|
@ -192,7 +192,6 @@ static int _determine_snapshot_type(struct volume_group *vg,
|
||||
struct lvcreate_params *lp)
|
||||
{
|
||||
struct lv_list *lvl;
|
||||
struct lv_segment *seg;
|
||||
|
||||
if (!(lvl = find_lv_in_vg(vg, lp->origin))) {
|
||||
log_error("Snapshot origin LV %s not found in Volume group %s.", lp->origin, vg->name);
|
||||
@ -200,12 +199,12 @@ static int _determine_snapshot_type(struct volume_group *vg,
|
||||
}
|
||||
|
||||
/* FIXME Replace with lv_is_thin_volume() once more flags are added */
|
||||
if (seg_is_thin_volume(seg = first_seg(lvl->lv))) {
|
||||
if (lv_is_thin_volume(lvl->lv)) {
|
||||
lp->thin = 1;
|
||||
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
|
||||
return_0;
|
||||
|
||||
lp->pool = seg->thin_pool_lv->name;
|
||||
lp->pool = first_seg(lvl->lv)->thin_pool_lv->name;
|
||||
}
|
||||
|
||||
if (!lp->thin && !arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
|
||||
@ -804,8 +803,7 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
|
||||
log_error("Pool %s not found in Volume group %s.", lp->pool, vg->name);
|
||||
return 0;
|
||||
}
|
||||
/* FIXME Use lv_is_thin_pool() */
|
||||
if (!seg_is_thin_pool(first_seg(lvl->lv))) {
|
||||
if (!lv_is_thin_pool(lvl->lv)) {
|
||||
log_error("Logical volume %s is not a thin pool.", lp->pool);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user