1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib/metadata/metadata.h

546 lines
18 KiB
C
Raw Normal View History

2001-09-25 16:49:28 +04:00
/*
2004-03-30 23:35:44 +04:00
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
2001-09-25 16:49:28 +04:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2.
2001-09-25 16:49:28 +04:00
*
2004-03-30 23:35:44 +04:00
* 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.
2004-03-30 23:35:44 +04:00
*
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 23:35:44 +04:00
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2004-03-30 23:35:44 +04:00
*/
/*
* This is the in core representation of a volume group and its
2001-09-28 17:15:30 +04:00
* associated physical and logical volumes.
2001-09-25 16:49:28 +04:00
*/
2001-10-01 19:14:39 +04:00
#ifndef _LVM_METADATA_H
#define _LVM_METADATA_H
2001-09-25 16:49:28 +04:00
2002-11-18 17:04:08 +03:00
#include "ctype.h"
#include "lib/device/dev-cache.h"
#include "lib/misc/lvm-string.h"
#include "lib/metadata/metadata-exported.h"
//#define MAX_STRIPES 128U
//#define SECTOR_SHIFT 9L
//#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
//#define STRIPE_SIZE_MIN ( (unsigned) lvm_getpagesize() >> SECTOR_SHIFT) /* PAGESIZE in sectors */
//#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
//#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
#define MIN_PE_SIZE (8192L >> SECTOR_SHIFT) /* 8 KB in sectors - format1 only */
#define MAX_PE_SIZE (16L * 1024L * (1024L >> SECTOR_SHIFT) * 1024L) /* format1 only */
#define MIRROR_LOG_OFFSET 2 /* sectors */
#define VG_MEMPOOL_CHUNK 10240 /* in bytes, hint only */
/*
* Ceiling(n / sz)
*/
#define dm_div_up(n, sz) (((n) + (sz) - 1) / (sz))
/*
* Ceiling(n / size) * size
*/
#define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
2018-04-20 18:43:50 +03:00
/* Various flags */
/* See metadata-exported.h for the complete list. */
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
2002-11-18 17:04:08 +03:00
/* May any free extents on this PV be used or must they be left free? */
#define BADBLOCK_ON UINT64_C(0x00000020) /* LV */
//#define VIRTUAL UINT64_C(0x00010000) /* LV - internal use only */
#define PRECOMMITTED UINT64_C(0x00200000) /* VG - internal use only */
#define POSTORDER_FLAG UINT64_C(0x02000000) /* Not real flags, reserved for */
#define POSTORDER_OPEN_FLAG UINT64_C(0x04000000) /* temporary use inside vg_read_internal. */
#define SHARED UINT64_C(0x00000800) /* VG */
2002-11-18 17:04:08 +03:00
/* Format features flags */
#define FMT_PRECOMMIT 0x00000040U /* Supports pre-commit? */
2002-11-18 17:04:08 +03:00
struct dm_config_tree;
2002-11-18 17:04:08 +03:00
struct metadata_area;
struct alloc_handle;
struct lvmcache_info;
struct cached_vg_fmtdata;
2002-11-18 17:04:08 +03:00
/* Per-format per-metadata area operations */
struct metadata_area_ops {
struct volume_group *(*vg_read) (struct cmd_context *cmd,
struct format_instance * fi,
2002-11-18 17:04:08 +03:00
const char *vg_name,
struct metadata_area * mda,
struct cached_vg_fmtdata **vg_fmtdata,
unsigned *use_previous_vg);
struct volume_group *(*vg_read_precommit) (struct cmd_context *cmd,
struct format_instance * fi,
const char *vg_name,
struct metadata_area * mda,
struct cached_vg_fmtdata **vg_fmtdata,
2018-04-20 18:43:50 +03:00
unsigned *use_previous_vg);
2002-11-18 17:04:08 +03:00
/*
* Write out complete VG metadata. You must ensure internal
* consistency before calling. eg. PEs can't refer to PVs not
* part of the VG.
*
* It is also the responsibility of the caller to ensure external
* consistency, eg by calling pv_write() if removing PVs from
* a VG or calling vg_write() a second time if splitting a VG
* into two.
*
* vg_write() should not read or write from any PVs not included
* in the volume_group structure it is handed.
* (format1 currently breaks this rule.)
*/
int (*vg_write) (struct format_instance * fid, struct volume_group * vg,
struct metadata_area * mda);
int (*vg_precommit) (struct format_instance * fid,
struct volume_group * vg,
struct metadata_area * mda);
2002-11-18 17:04:08 +03:00
int (*vg_commit) (struct format_instance * fid,
struct volume_group * vg, struct metadata_area * mda);
int (*vg_revert) (struct format_instance * fid,
struct volume_group * vg, struct metadata_area * mda);
2002-11-18 17:04:08 +03:00
int (*vg_remove) (struct format_instance * fi, struct volume_group * vg,
struct metadata_area * mda);
/*
* Per location copy constructor.
*/
void *(*mda_metadata_locn_copy) (struct dm_pool *mem, void *metadata_locn);
2010-06-30 17:51:11 +04:00
/*
2010-06-30 17:51:11 +04:00
* Per location description for logging.
*/
2010-06-30 17:51:11 +04:00
const char *(*mda_metadata_locn_name) (void *metadata_locn);
uint64_t (*mda_metadata_locn_offset) (void *metadata_locn);
/*
* Returns number of free sectors in given metadata area.
*/
uint64_t (*mda_free_sectors) (struct metadata_area *mda);
/*
* Returns number of total sectors in given metadata area.
*/
uint64_t (*mda_total_sectors) (struct metadata_area *mda);
/*
* Check if metadata area belongs to vg
*/
int (*mda_in_vg) (struct format_instance * fi,
struct volume_group * vg, struct metadata_area *mda);
/*
* Analyze a metadata area on a PV.
*/
int (*pv_analyze_mda) (const struct format_type * fmt,
struct metadata_area *mda);
/*
* Do these two metadata_area structures match with respect to
* their underlying location?
*/
unsigned (*mda_locns_match)(struct metadata_area *mda1,
struct metadata_area *mda2);
struct device *(*mda_get_device)(struct metadata_area *mda);
int (*mda_export_text)(struct metadata_area *mda, struct dm_config_tree *cft,
struct dm_config_node *parent);
int (*mda_import_text)(struct lvmcache_info *info, const struct dm_config_node *cn);
2002-11-18 17:04:08 +03:00
};
#define MDA_IGNORED 0x00000001
#define MDA_INCONSISTENT 0x00000002
#define MDA_FAILED 0x00000004
/* The primary metadata area on a device if the format supports more than one. */
#define MDA_PRIMARY 0x00000008
#define mda_is_primary(mda) (((mda->status) & MDA_PRIMARY) ? 1 : 0)
#define MDA_CONTENT_REASON(primary_mda) ((primary_mda) ? DEV_IO_MDA_CONTENT : DEV_IO_MDA_EXTRA_CONTENT)
#define MDA_HEADER_REASON(primary_mda) ((primary_mda) ? DEV_IO_MDA_HEADER : DEV_IO_MDA_EXTRA_HEADER)
/*
* Flags describing errors found while reading.
*/
#define BAD_MDA_INTERNAL 0x00000001 /* internal lvm error */
#define BAD_MDA_READ 0x00000002 /* read io failed */
#define BAD_MDA_HEADER 0x00000004 /* general problem with header */
#define BAD_MDA_TEXT 0x00000008 /* general problem with text */
#define BAD_MDA_CHECKSUM 0x00000010
#define BAD_MDA_MAGIC 0x00000020
#define BAD_MDA_VERSION 0x00000040
#define BAD_MDA_START 0x00000080
#define BAD_MDA_MISMATCH 0x00000100 /* lvmcache found difference from prev metadata */
struct metadata_area {
struct dm_list list;
const struct metadata_area_ops *ops;
void *metadata_locn;
uint32_t status;
uint64_t header_start; /* mda_header.start */
uint64_t scan_text_offset; /* rlocn->offset seen during scan */
uint32_t scan_text_checksum; /* rlocn->checksum seen during scan */
int mda_num;
uint32_t bad_fields; /* BAD_MDA_ flags are set to indicate errors found when reading */
uint32_t ignore_bad_fields; /* BAD_MDA_ flags are set to indicate errors to ignore */
};
struct metadata_area *mda_copy(struct dm_pool *mem,
struct metadata_area *mda);
unsigned mda_is_ignored(struct metadata_area *mda);
void mda_set_ignored(struct metadata_area *mda, unsigned mda_ignored);
unsigned mda_locns_match(struct metadata_area *mda1, struct metadata_area *mda2);
struct device *mda_get_device(struct metadata_area *mda);
/*
* fic is used to create an fid. It's used to pass fmt/vgname/vgid args
* to create_instance() which creates an fid for the specified vg.
*/
struct format_instance_ctx {
uint32_t type;
union {
const char *pv_id;
struct {
const char *vg_name;
const char *vg_id;
} vg_ref;
void *private;
} context;
};
struct format_instance *alloc_fid(const struct format_type *fmt,
const struct format_instance_ctx *fic);
/*
* Format instance must always be set using pv_set_fid or vg_set_fid
* (NULL value as well), never assign it directly! This is essential
* for proper reference counting for the format instance.
*/
void pv_set_fid(struct physical_volume *pv, struct format_instance *fid);
void vg_set_fid(struct volume_group *vg, struct format_instance *fid);
/* FIXME: Add generic interface for mda counts based on given key. */
int fid_add_mda(struct format_instance *fid, struct metadata_area *mda,
const char *key, size_t key_len, const unsigned sub_key);
int fid_add_mdas(struct format_instance *fid, struct dm_list *mdas,
const char *key, size_t key_len);
int fid_remove_mda(struct format_instance *fid, struct metadata_area *mda,
const char *key, size_t key_len, const unsigned sub_key);
struct metadata_area *fid_get_mda_indexed(struct format_instance *fid,
const char *key, size_t key_len, const unsigned sub_key);
int mdas_empty_or_ignored(struct dm_list *mdas);
#define seg_pvseg(seg, s) (seg)->areas[(s)].u.pv.pvseg
#define seg_dev(seg, s) (seg)->areas[(s)].u.pv.pvseg->pv->dev
#define seg_pe(seg, s) (seg)->areas[(s)].u.pv.pvseg->pe
#define seg_le(seg, s) (seg)->areas[(s)].u.lv.le
#define seg_metale(seg, s) (seg)->meta_areas[(s)].u.lv.le
2005-06-01 20:51:55 +04:00
struct name_list {
struct dm_list list;
2001-10-08 20:08:16 +04:00
char *name;
2001-10-02 21:09:05 +04:00
};
2002-11-18 17:04:08 +03:00
struct mda_list {
struct dm_list list;
struct metadata_area *mda;
2002-11-18 17:04:08 +03:00
};
2005-04-20 00:52:35 +04:00
struct peg_list {
struct dm_list list;
2005-04-20 00:52:35 +04:00
struct pv_segment *peg;
};
struct seg_list {
struct dm_list list;
unsigned count;
struct lv_segment *seg;
};
/*
* Ownership of objects passes to caller.
*/
struct format_handler {
/*
2002-11-18 17:04:08 +03:00
* Scan any metadata areas that aren't referenced in PV labels
*/
int (*scan) (const struct format_type * fmt, const char *vgname);
2001-09-25 16:49:28 +04:00
/*
* Return PV with given path.
*/
int (*pv_read) (const struct format_type * fmt, const char *pv_name,
struct physical_volume * pv, int scan_label_only);
/*
* Initialise a new PV.
*/
int (*pv_initialise) (const struct format_type * fmt,
struct pv_create_args *pva,
struct physical_volume * pv);
/*
* Tweak an already filled out a pv ready for importing into a
* vg. eg. pe_count is format specific.
*/
int (*pv_setup) (const struct format_type * fmt,
struct physical_volume * pv,
struct volume_group * vg);
/*
* Add metadata area to a PV. Changes will take effect on pv_write.
*/
int (*pv_add_metadata_area) (const struct format_type * fmt,
struct physical_volume * pv,
int pe_start_locked,
unsigned metadata_index,
uint64_t metadata_size,
unsigned metadata_ignored);
/*
* Remove metadata area from a PV. Changes will take effect on pv_write.
*/
int (*pv_remove_metadata_area) (const struct format_type *fmt,
struct physical_volume *pv,
unsigned metadata_index);
/*
* Recalculate the PV size taking into account any existing metadata areas.
*/
int (*pv_resize) (const struct format_type *fmt,
struct physical_volume *pv,
struct volume_group *vg,
uint64_t size);
/*
* Write a PV structure to disk. Fails if the PV is in a VG ie
* pv->vg_name must be a valid orphan VG name
*/
int (*pv_write) (struct cmd_context *cmd, const struct format_type * fmt,
struct physical_volume * pv);
2001-09-25 16:49:28 +04:00
/*
* Check if PV needs rewriting. This is used to check whether there are any
* format-specific changes before actually writing the PV (by calling pv_write).
* With this, we can call pv_write conditionally only if it's really needed.
*/
int (*pv_needs_rewrite) (const struct format_type *fmt,
struct physical_volume *pv,
int *needs_rewrite);
2002-01-24 20:15:49 +03:00
/*
* Tweak an already filled out a lv eg, check there
* aren't too many extents.
*/
2002-11-18 17:04:08 +03:00
int (*lv_setup) (struct format_instance * fi,
struct logical_volume * lv);
2002-01-24 20:15:49 +03:00
2001-10-12 18:25:53 +04:00
/*
* Tweak an already filled out vg. eg, max_pv is format
* specific.
2001-10-12 18:25:53 +04:00
*/
2002-11-18 17:04:08 +03:00
int (*vg_setup) (struct format_instance * fi, struct volume_group * vg);
/*
* Check whether particular segment type is supported.
*/
int (*segtype_supported) (struct format_instance *fid,
const struct segment_type *segtype);
/*
* Create format instance with a particular metadata area
*/
struct format_instance *(*create_instance) (const struct format_type *fmt,
const struct format_instance_ctx *fic);
/*
* Destructor for format instance
*/
2002-11-18 17:04:08 +03:00
void (*destroy_instance) (struct format_instance * fid);
/*
* Destructor for format type
*/
void (*destroy) (struct format_type * fmt);
2001-09-28 17:15:30 +04:00
};
2001-09-25 16:49:28 +04:00
/*
* Utility functions
*/
Place the first PE at 1 MiB for all defaults . When using default settings, this commit should change nothing. The first PE continues to be placed at 1 MiB resulting in a metadata area size of 1020 KiB (for 4K page sizes; slightly smaller for larger page sizes.) . When default_data_alignment is disabled in lvm.conf, align pe_start at 1 MiB, based on a default metadata area size that adapts to the page size. Previously, disabling this option would result in mda_size that was too small for common use, and produced a 64 KiB aligned pe_start. . Customized pe_start and mda_size values continue to be set as before in lvm.conf and command line. . Remove the configure option for setting default_data_alignment at build time. . Improve alignment related option descriptions. . Add section about alignment to pvcreate man page. Previously, DEFAULT_PVMETADATASIZE was 255 sectors. However, the fact that the config setting named "default_data_alignment" has a default value of 1 (MiB) meant that DEFAULT_PVMETADATASIZE was having no effect. The metadata area size is the space between the start of the metadata area (page size offset from the start of the device) and the first PE (1 MiB by default due to default_data_alignment 1.) The result is a 1020 KiB metadata area on machines with 4KiB page size (1024 KiB - 4 KiB), and smaller on machines with larger page size. If default_data_alignment was set to 0 (disabled), then DEFAULT_PVMETADATASIZE 255 would take effect, and produce a metadata area that was 188 KiB and pe_start of 192 KiB. This was too small for common use. This is fixed by making the default metadata area size a computed value that matches the value produced by default_data_alignment.
2018-11-14 00:00:11 +03:00
int get_default_pvmetadatasize_sectors(void);
void set_pe_align(struct physical_volume *pv, uint64_t data_alignment);
void set_pe_align_offset(struct physical_volume *pv, uint64_t data_alignment_offset);
int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv);
2001-11-12 22:28:50 +03:00
int check_dev_block_size_for_vg(struct device *dev, const struct volume_group *vg,
unsigned int *max_phys_block_size_found);
int check_pv_dev_sizes(struct volume_group *vg);
uint32_t vg_bad_status_bits(const struct volume_group *vg, uint64_t status);
int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
struct physical_volume *pv, int new_pv);
2021-03-10 23:58:57 +03:00
struct logical_volume *find_lv_in_vg_by_lvid(const struct volume_group *vg,
const union lvid *lvid);
2001-10-29 16:52:23 +03:00
/* FIXME Merge these functions with ones above */
struct physical_volume *find_pv(struct volume_group *vg, struct device *dev);
2001-09-28 17:15:30 +04:00
struct pv_list *find_pv_in_pv_list(const struct dm_list *pl,
const struct physical_volume *pv);
/* Find LV segment containing given LE */
2007-12-20 21:55:46 +03:00
struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le);
/* Find pool LV segment given a thin pool data or metadata segment. */
struct lv_segment *find_pool_seg(const struct lv_segment *seg);
/* Find some unused device_id for thin pool LV segment. */
uint32_t get_free_thin_pool_device_id(struct lv_segment *thin_pool_seg);
/* Check if the new thin-pool could be used for lvm2 thin volumes */
int check_new_thin_pool(const struct logical_volume *pool_lv);
/*
2001-11-14 16:52:38 +03:00
* Remove a dev_dir if present.
*/
const char *strip_dir(const char *vg_name, const char *dev_dir);
2001-10-15 22:39:40 +04:00
struct logical_volume *alloc_lv(struct dm_pool *mem);
/*
* Checks that an lv has no gaps or overlapping segments.
2005-10-28 01:51:28 +04:00
* Set complete_vg to perform additional VG level checks.
*/
2005-10-28 01:51:28 +04:00
int check_lv_segments(struct logical_volume *lv, int complete_vg);
/*
* Does every LV segment have the same number of stripes?
*/
int lv_has_constant_stripes(struct logical_volume *lv);
/*
* Sometimes (eg, after an lvextend), it is possible to merge two
* adjacent segments into a single segment. This function tries
* to merge as many segments as possible.
*/
int lv_merge_segments(struct logical_volume *lv);
2003-09-15 22:22:50 +04:00
/*
* Ensure there's a segment boundary at a given LE, splitting if necessary
*/
int lv_split_segment(struct logical_volume *lv, uint32_t le);
/*
* Add/remove upward link from underlying LV to the segment using it
* FIXME: ridiculously long name
*/
int add_seg_to_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg);
int remove_seg_from_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg);
int add_glv_to_indirect_glvs(struct dm_pool *mem,
struct generic_logical_volume *origin_glv,
struct generic_logical_volume *glv);
int remove_glv_from_indirect_glvs(struct generic_logical_volume *origin_glv,
struct generic_logical_volume *glv);
int for_each_sub_lv(struct logical_volume *lv,
2015-01-30 14:27:16 +03:00
int (*fn)(struct logical_volume *lv, void *data),
void *data);
int move_lv_segments(struct logical_volume *lv_to,
struct logical_volume *lv_from,
uint64_t set_status, uint64_t reset_status);
/* Widen existing segment areas */
int add_lv_segment_areas(struct lv_segment *seg, uint32_t new_area_count);
/*
* Calculate readahead from underlying PV devices
*/
void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahead);
/*
* For internal metadata caching.
*/
struct dm_config_tree *export_vg_to_config_tree(struct volume_group *vg);
struct volume_group *import_vg_from_config_tree(struct cmd_context *cmd,
struct format_instance *fid,
const struct dm_config_tree *cft);
struct volume_group *vg_from_config_tree(struct cmd_context *cmd, const struct dm_config_tree *cft);
2003-04-30 19:23:43 +04:00
/*
* Mirroring functions
*/
2005-11-29 21:20:23 +03:00
/*
* Given mirror image or mirror log segment, find corresponding mirror segment
*/
2005-10-28 01:51:28 +04:00
int fixup_imported_mirrors(struct volume_group *vg);
2005-06-14 22:22:31 +04:00
/*
* From pool_manip.c
*/
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv,
struct logical_volume *origin,
struct generic_logical_volume *indirect_origin,
struct logical_volume *merge_lv);
int detach_pool_lv(struct lv_segment *seg);
int create_pool(struct logical_volume *pool_lv, const struct segment_type *segtype,
struct alloc_handle *ah, uint32_t stripes, uint32_t stripe_size);
thin: improve 16g support for thin pool metadata Initial support for thin-pool used slightly smaller max size 15.81GiB for thin-pool metadata. However the real limit later settled at 15.88GiB (difference is ~64MiB - 16448 4K blocks). lvm2 could not simply increase the size as it has been using hard cropping of the loaded metadata device to avoid warnings printing warning of kernel when the size was bigger (i.e. due to bigger extent_size). This patch adds the new lvm.conf configurable setting: allocation/thin_pool_crop_metadata which defaults to 0 -> no crop of metadata beyond 15.81GiB. Only user with these sizes of metadata will be affected. Without cropping lvm2 now limits metadata allocation size to 15.88GiB. Any space beyond is currently not used by thin-pool target. Even if i.e. bigger LV is used for metadata via lvconvert, or allocated bigger because of to large extent size. With cropping enabled (=1) lvm2 preserves the old limitation 15.81GiB and should allow to work in the evironement with older lvm2 tools (i.e. older distribution). Thin-pool metadata with size bigger then 15.81G is now using CROP_METADATA flag within lvm2 metadata, so older lvm2 recognizes an incompatible thin-pool and cannot activate such pool! Users should use uncropped version as it is not suffering from various issues between thin_repair results and allocated metadata LV as thin_repair limit is 15.88GiB Users should use cropping only when really needed! Patch also better handles resize of thin-pool metadata and prevents resize beoyond usable size 15.88GiB. Resize beyond 15.81GiB automatically switches pool to no-crop version. Even with existing bigger thin-pool metadata command 'lvextend -l+1 vg/pool_tmeta' does the change. Patch gives better controls 'coverted' metadata LV and reports less confusing message during conversion. Patch set also moves the code for updating min/max into pool_manip.c for better sharing with cache_pool code.
2021-01-12 19:59:29 +03:00
int update_pool_metadata_min_max(struct cmd_context *cmd,
uint32_t extent_size,
uint64_t min_metadata_size, /* required min */
uint64_t max_metadata_size, /* writable max */
uint64_t *metadata_size, /* current calculated */
struct logical_volume *metadata_lv, /* name of converted LV or NULL */
uint32_t *metadata_extents); /* resulting extent count */
/*
* From thin_manip.c
*/
int attach_thin_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
struct logical_volume *lv, uint32_t delete_id,
int no_update);
int lv_is_merging_thin_snapshot(const struct logical_volume *lv);
int thin_pool_has_message(const struct lv_segment *seg,
const struct logical_volume *lv, uint32_t device_id);
int thin_pool_metadata_min_threshold(const struct lv_segment *pool_seg);
int thin_pool_below_threshold(const struct lv_segment *pool_seg);
int thin_pool_check_overprovisioning(const struct logical_volume *lv);
uint64_t get_thin_pool_max_metadata_size(struct cmd_context *cmd, struct profile *profile,
thin_crop_metadata_t *crop);
thin_crop_metadata_t get_thin_pool_crop_metadata(struct cmd_context *cmd,
thin_crop_metadata_t crop,
uint64_t metadata_size);
uint64_t estimate_thin_pool_metadata_size(uint32_t data_extents, uint32_t extent_size, uint32_t chunk_size);
/*
* Begin skeleton for external LVM library
*/
struct id pv_id(const struct physical_volume *pv);
const struct format_type *pv_format_type(const struct physical_volume *pv);
struct id pv_vg_id(const struct physical_volume *pv);
uint64_t find_min_mda_size(struct dm_list *mdas);
char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tagsl);
void set_pv_devices(struct format_instance *fid, struct volume_group *vg);
pvscan: add options listlvs listvg checkcomplete pvscan --cache <dev> . read only dev . create online file for dev pvscan --listvg <dev> . read only dev . list VG using dev pvscan --listlvs <dev> . read only dev . list VG using dev . list LVs using dev pvscan --cache --listvg [--checkcomplete] <dev> . read only dev . create online file for dev . list VG using dev . [check online files and report if VG is complete] pvscan --cache --listlvs [--checkcomplete] <dev> . read only dev . create online file for dev . list VG using dev . list LVs using dev . [check online files and report if VG is complete] . [check online files and report if LVs are complete] [--vgonline] can be used with --checkcomplete, to enable use of a vg online file. This results in only the first pvscan command to see the complete VG to report 'VG complete', and others will report 'VG finished'. This allows the caller to easily run a single activation of the VG. [--udevoutput] can be used with --cache --listvg --checkcomplete, to enable an output mode that prints LVM_VG_NAME_COMPLETE='vgname' that a udev rule can import, and prevents other output from the command (other output causes udev to ignore the command.) The list of complete LVs is meant to be passed to lvchange -aay, or the complete VG used with vgchange -aay. When --checkcomplete is used, lvm assumes that that the output will be used to trigger event-based autoactivation, so the pvscan does nothing if event_activation=0 and --checkcomplete is used. Example of listlvs ------------------ $ lvs -a vg -olvname,devices LV Devices lv_a /dev/loop0(0) lv_ab /dev/loop0(1),/dev/loop1(1) lv_abc /dev/loop0(3),/dev/loop1(3),/dev/loop2(1) lv_b /dev/loop1(0) lv_c /dev/loop2(0) $ pvscan --cache --listlvs --checkcomplete /dev/loop0 pvscan[35680] PV /dev/loop0 online, VG vg incomplete (need 2). VG vg incomplete LV vg/lv_a complete LV vg/lv_ab incomplete LV vg/lv_abc incomplete $ pvscan --cache --listlvs --checkcomplete /dev/loop1 pvscan[35681] PV /dev/loop1 online, VG vg incomplete (need 1). VG vg incomplete LV vg/lv_b complete LV vg/lv_ab complete LV vg/lv_abc incomplete $ pvscan --cache --listlvs --checkcomplete /dev/loop2 pvscan[35682] PV /dev/loop2 online, VG vg is complete. VG vg complete LV vg/lv_c complete LV vg/lv_abc complete Example of listvg ----------------- $ pvscan --cache --listvg --checkcomplete /dev/loop0 pvscan[35684] PV /dev/loop0 online, VG vg incomplete (need 2). VG vg incomplete $ pvscan --cache --listvg --checkcomplete /dev/loop1 pvscan[35685] PV /dev/loop1 online, VG vg incomplete (need 1). VG vg incomplete $ pvscan --cache --listvg --checkcomplete /dev/loop2 pvscan[35686] PV /dev/loop2 online, VG vg is complete. VG vg complete
2020-12-09 19:59:40 +03:00
int get_visible_lvs_using_pv(struct cmd_context *cmd, struct volume_group *vg, struct device *dev,
struct dm_list *lvs_list);
lvresize: add new options and defaults for fs handling The new option "--fs String" for lvresize/lvreduce/lvextend controls the handling of file systems before/after resizing the LV. --resizefs is the same as --fs resize. The new option "--fsmode String" can be used to control mounting and unmounting of the fs during resizing. Possible --fs values: checksize Only applies to reducing size; does nothing for extend. Check the fs size and reduce the LV if the fs is not using the affected space, i.e. the fs does not need to be shrunk. Fail the command without reducing the fs or LV if the fs is using the affected space. resize Resize the fs using the fs-specific resize command. This may include mounting, unmounting, or running fsck. See --fsmode to control mounting behavior, and --nofsck to disable fsck. resize_fsadm Use the old method of calling fsadm to handle the fs (deprecated.) Warning: this option does not prevent lvreduce from destroying file systems that are unmounted (or mounted if prompts are skipped.) ignore Resize the LV without checking for or handling a file system. Warning: using ignore when reducing the LV size may destroy the file system. Possible --fsmode values: manage Mount or unmount the fs as needed to resize the fs, and attempt to restore the original mount state at the end. nochange Do not mount or unmount the fs. If mounting or unmounting is required to resize the fs, then do not resize the fs or the LV and fail the command. offline Unmount the fs if it is mounted, and resize the fs while it is unmounted. If mounting is required to resize the fs, then do not resize the fs or the LV and fail the command. Notes on lvreduce: When no --fs or --resizefs option is specified: . lvextend default behavior is fs ignore. . lvreduce default behavior is fs checksize (includes activating the LV.) With the exception of --fs resize_fsadm|ignore, lvreduce requires the recent libblkid fields FSLASTBLOCK and FSBLOCKSIZE. FSLASTBLOCK*FSBLOCKSIZE is the last byte used by the fs on the LV, which determines if reducing the fs is necessary.
2022-06-14 23:20:21 +03:00
bool scan_text_mismatch(struct cmd_context *cmd, const char *vgname, const char *vgid);
pvscan: add options listlvs listvg checkcomplete pvscan --cache <dev> . read only dev . create online file for dev pvscan --listvg <dev> . read only dev . list VG using dev pvscan --listlvs <dev> . read only dev . list VG using dev . list LVs using dev pvscan --cache --listvg [--checkcomplete] <dev> . read only dev . create online file for dev . list VG using dev . [check online files and report if VG is complete] pvscan --cache --listlvs [--checkcomplete] <dev> . read only dev . create online file for dev . list VG using dev . list LVs using dev . [check online files and report if VG is complete] . [check online files and report if LVs are complete] [--vgonline] can be used with --checkcomplete, to enable use of a vg online file. This results in only the first pvscan command to see the complete VG to report 'VG complete', and others will report 'VG finished'. This allows the caller to easily run a single activation of the VG. [--udevoutput] can be used with --cache --listvg --checkcomplete, to enable an output mode that prints LVM_VG_NAME_COMPLETE='vgname' that a udev rule can import, and prevents other output from the command (other output causes udev to ignore the command.) The list of complete LVs is meant to be passed to lvchange -aay, or the complete VG used with vgchange -aay. When --checkcomplete is used, lvm assumes that that the output will be used to trigger event-based autoactivation, so the pvscan does nothing if event_activation=0 and --checkcomplete is used. Example of listlvs ------------------ $ lvs -a vg -olvname,devices LV Devices lv_a /dev/loop0(0) lv_ab /dev/loop0(1),/dev/loop1(1) lv_abc /dev/loop0(3),/dev/loop1(3),/dev/loop2(1) lv_b /dev/loop1(0) lv_c /dev/loop2(0) $ pvscan --cache --listlvs --checkcomplete /dev/loop0 pvscan[35680] PV /dev/loop0 online, VG vg incomplete (need 2). VG vg incomplete LV vg/lv_a complete LV vg/lv_ab incomplete LV vg/lv_abc incomplete $ pvscan --cache --listlvs --checkcomplete /dev/loop1 pvscan[35681] PV /dev/loop1 online, VG vg incomplete (need 1). VG vg incomplete LV vg/lv_b complete LV vg/lv_ab complete LV vg/lv_abc incomplete $ pvscan --cache --listlvs --checkcomplete /dev/loop2 pvscan[35682] PV /dev/loop2 online, VG vg is complete. VG vg complete LV vg/lv_c complete LV vg/lv_abc complete Example of listvg ----------------- $ pvscan --cache --listvg --checkcomplete /dev/loop0 pvscan[35684] PV /dev/loop0 online, VG vg incomplete (need 2). VG vg incomplete $ pvscan --cache --listvg --checkcomplete /dev/loop1 pvscan[35685] PV /dev/loop1 online, VG vg incomplete (need 1). VG vg incomplete $ pvscan --cache --listvg --checkcomplete /dev/loop2 pvscan[35686] PV /dev/loop2 online, VG vg is complete. VG vg complete
2020-12-09 19:59:40 +03:00
2001-09-28 17:15:30 +04:00
#endif