mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
d9e8895a96
dm-integrity stores checksums of the data written to an LV, and returns an error if data read from the LV does not match the previously saved checksum. When used on raid images, dm-raid will correct the error by reading the block from another image, and the device user sees no error. The integrity metadata (checksums) are stored on an internal LV allocated by lvm for each linear image. The internal LV is allocated on the same PV as the image. Create a raid LV with an integrity layer over each raid image (for raid levels 1,4,5,6,10): lvcreate --type raidN --raidintegrity y [options] Add an integrity layer to images of an existing raid LV: lvconvert --raidintegrity y LV Remove the integrity layer from images of a raid LV: lvconvert --raidintegrity n LV Settings Use --raidintegritymode journal|bitmap (journal is default) to configure the method used by dm-integrity to ensure crash consistency. Initialization When integrity is added to an LV, the kernel needs to initialize the integrity metadata/checksums for all blocks in the LV. The data corruption checking performed by dm-integrity will only operate on areas of the LV that are already initialized. The progress of integrity initialization is reported by the "syncpercent" LV reporting field (and under the Cpy%Sync lvs column.) Example: create a raid1 LV with integrity: $ lvcreate --type raid1 -m1 --raidintegrity y -n rr -L1G foo Creating integrity metadata LV rr_rimage_0_imeta with size 12.00 MiB. Logical volume "rr_rimage_0_imeta" created. Creating integrity metadata LV rr_rimage_1_imeta with size 12.00 MiB. Logical volume "rr_rimage_1_imeta" created. Logical volume "rr" created. $ lvs -a foo LV VG Attr LSize Origin Cpy%Sync rr foo rwi-a-r--- 1.00g 4.93 [rr_rimage_0] foo gwi-aor--- 1.00g [rr_rimage_0_iorig] 41.02 [rr_rimage_0_imeta] foo ewi-ao---- 12.00m [rr_rimage_0_iorig] foo -wi-ao---- 1.00g [rr_rimage_1] foo gwi-aor--- 1.00g [rr_rimage_1_iorig] 39.45 [rr_rimage_1_imeta] foo ewi-ao---- 12.00m [rr_rimage_1_iorig] foo -wi-ao---- 1.00g [rr_rmeta_0] foo ewi-aor--- 4.00m [rr_rmeta_1] foo ewi-aor--- 4.00m
103 lines
3.4 KiB
C
103 lines
3.4 KiB
C
/*
|
|
* Copyright (C) 2013 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _LVM_DEV_TYPE_H
|
|
#define _LVM_DEV_TYPE_H
|
|
|
|
#include "lib/device/device.h"
|
|
#include "lib/display/display.h"
|
|
#include "lib/label/label.h"
|
|
|
|
#define NUMBER_OF_MAJORS 4096
|
|
|
|
#ifdef __linux__
|
|
# include "libdm/misc/kdev_t.h"
|
|
#else
|
|
# define MAJOR(x) major((x))
|
|
# define MINOR(x) minor((x))
|
|
# define MKDEV(x,y) makedev((x),(y))
|
|
#endif
|
|
|
|
#define PARTITION_SCSI_DEVICE (1 << 0)
|
|
|
|
struct dev_type_def {
|
|
int max_partitions; /* 0 means LVM won't use this major number. */
|
|
int flags;
|
|
};
|
|
|
|
struct dev_types {
|
|
int md_major;
|
|
int blkext_major;
|
|
int drbd_major;
|
|
int device_mapper_major;
|
|
int emcpower_major;
|
|
int vxdmp_major;
|
|
int power2_major;
|
|
int dasd_major;
|
|
int loop_major;
|
|
struct dev_type_def dev_type_array[NUMBER_OF_MAJORS];
|
|
};
|
|
|
|
struct dev_types *create_dev_types(const char *proc_dir, const struct dm_config_node *cn);
|
|
|
|
/* Subsystems */
|
|
int dev_subsystem_part_major(struct dev_types *dt, struct device *dev);
|
|
const char *dev_subsystem_name(struct dev_types *dt, struct device *dev);
|
|
int major_is_scsi_device(struct dev_types *dt, int major);
|
|
|
|
/* Signature/superblock recognition with position returned where found. */
|
|
int dev_is_md_component(struct device *dev, uint64_t *sb, int full);
|
|
int dev_is_swap(struct device *dev, uint64_t *signature, int full);
|
|
int dev_is_luks(struct device *dev, uint64_t *signature, int full);
|
|
int dasd_is_cdl_formatted(struct device *dev);
|
|
int udev_dev_is_mpath_component(struct device *dev);
|
|
int udev_dev_is_md_component(struct device *dev);
|
|
|
|
int dev_is_lvm1(struct device *dev, char *buf, int buflen);
|
|
int dev_is_pool(struct device *dev, char *buf, int buflen);
|
|
|
|
/* Signature wiping. */
|
|
#define TYPE_LVM1_MEMBER 0x001
|
|
#define TYPE_LVM2_MEMBER 0x002
|
|
#define TYPE_DM_SNAPSHOT_COW 0x004
|
|
int wipe_known_signatures(struct cmd_context *cmd, struct device *dev, const char *name,
|
|
uint32_t types_to_exclude, uint32_t types_no_prompt,
|
|
int yes, force_t force, int *wiped);
|
|
|
|
/* Type-specific device properties */
|
|
unsigned long dev_md_stripe_width(struct dev_types *dt, struct device *dev);
|
|
int dev_is_md_with_end_superblock(struct dev_types *dt, struct device *dev);
|
|
|
|
/* Partitioning */
|
|
int major_max_partitions(struct dev_types *dt, int major);
|
|
int dev_is_partitioned(struct dev_types *dt, struct device *dev);
|
|
int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result);
|
|
|
|
/* Various device properties */
|
|
unsigned long dev_alignment_offset(struct dev_types *dt, struct device *dev);
|
|
unsigned long dev_minimum_io_size(struct dev_types *dt, struct device *dev);
|
|
unsigned long dev_optimal_io_size(struct dev_types *dt, struct device *dev);
|
|
unsigned long dev_discard_max_bytes(struct dev_types *dt, struct device *dev);
|
|
unsigned long dev_discard_granularity(struct dev_types *dt, struct device *dev);
|
|
|
|
int dev_is_rotational(struct dev_types *dt, struct device *dev);
|
|
|
|
int dev_is_pmem(struct device *dev);
|
|
|
|
int dev_is_lv(struct device *dev);
|
|
|
|
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size);
|
|
|
|
#endif
|