master - Allow dm-integrity to be used for raid images
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d9e8895a96539d75166c0f74e58f5ed4e729e551 Commit: d9e8895a96539d75166c0f74e58f5ed4e729e551 Parent: b6b4ad8e28eff7476cb04c4cb93312b06605b82f Author: David Teigland <[email protected]> AuthorDate: Wed Nov 20 16:07:27 2019 -0600 Committer: David Teigland <[email protected]> CommitterDate: Wed Apr 15 12:10:32 2020 -0500
Allow dm-integrity to be used for raid images
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 --- configure | 27 ++ configure.ac | 18 + device_mapper/all.h | 39 ++ device_mapper/ioctl/libdm-iface.c | 31 +- device_mapper/ioctl/libdm-targets.h | 1 + device_mapper/libdm-deptree.c | 154 ++++++- device_mapper/libdm-targets.c | 27 ++ include/configure.h.in | 3 + lib/Makefile.in | 2 + lib/activate/activate.c | 7 + lib/activate/activate.h | 4 + lib/activate/dev_manager.c | 18 +- lib/commands/toolcontext.c | 5 + lib/device/dev-type.c | 39 ++ lib/device/dev-type.h | 2 + lib/format_text/flags.c | 2 + lib/integrity/integrity.c | 343 +++++++++++++++ lib/metadata/integrity_manip.c | 821 ++++++++++++++++++++++++++++++++++++ lib/metadata/lv.c | 18 +- lib/metadata/lv_manip.c | 150 ++++++- lib/metadata/merge.c | 2 + lib/metadata/metadata-exported.h | 26 ++ lib/metadata/raid_manip.c | 85 +++- lib/metadata/segtype.h | 6 + lib/metadata/snapshot_manip.c | 2 + lib/misc/lvm-string.c | 4 +- lib/report/report.c | 2 +- man/lvmraid.7_main | 83 ++++ test/lib/aux.sh | 8 + test/shell/integrity-blocksize.sh | 183 ++++++++ test/shell/integrity-dmeventd.sh | 289 +++++++++++++ test/shell/integrity-large.sh | 175 ++++++++ test/shell/integrity-misc.sh | 228 ++++++++++ test/shell/integrity.sh | 735 ++++++++++++++++++++++++++++++++ tools/args.h | 20 + tools/command-lines.in | 45 +- tools/lv_props.h | 1 + tools/lv_types.h | 1 + tools/lvchange.c | 5 + tools/lvconvert.c | 137 ++++++ tools/lvcreate.c | 15 +- tools/lvmcmdline.c | 3 + tools/pvmove.c | 10 + tools/toollib.c | 47 +++ tools/tools.h | 4 + 45 files changed, 3790 insertions(+), 37 deletions(-)
configure +27 -0
@@ -918,6 +918,7 @@ enable_cache_check_needs_check with_vdo with_vdo_format with_writecache +with_integrity enable_readline enable_realtime enable_ocf
@@ -1716,6 +1717,7 @@ Optional Packages: --with-vdo=TYPE vdo support: internal/none [internal] --with-vdo-format=PATH vdoformat tool: [autodetect] --with-writecache=TYPE writecache support: internal/none [none] + --with-integrity=TYPE integrity support: internal/none [none] --with-ocfdir=DIR install OCF files in [PREFIX/lib/ocf/resource.d/lvm2] --with-default-pid-dir=PID_DIR
@@ -9761,6 +9763,31 @@ $as_echo "#define WRITECACHE_INTERNAL 1" >>confdefs.h *) as_fn_error $? "--with-writecache parameter invalid" "$LINENO" 5 ;; esac +################################################################################ +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include integrity" >&5 +$as_echo_n "checking whether to include integrity... " >&6; } + +# Check whether --with-integrity was given. +if test "${with_integrity+set}" = set; then : + withval=$with_integrity; INTEGRITY=$withval +else + INTEGRITY="none" +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTEGRITY" >&5 +$as_echo "$INTEGRITY" >&6; } + +case "$INTEGRITY" in + none) ;; + internal) + +$as_echo "#define INTEGRITY_INTERNAL 1" >>confdefs.h + + ;; + *) as_fn_error $? "--with-integrity parameter invalid" "$LINENO" 5 ;; +esac + ################################################################################ # Check whether --enable-readline was given. if test "${enable_readline+set}" = set; then :
configure.ac +18 -0
@@ -667,6 +667,24 @@ case "$WRITECACHE" in *) AC_MSG_ERROR([--with-writecache parameter invalid]) ;; esac +################################################################################ +dnl -- integrity inclusion type +AC_MSG_CHECKING(whether to include integrity) +AC_ARG_WITH(integrity, + AC_HELP_STRING([--with-integrity=TYPE], + [integrity support: internal/none [none]]), + INTEGRITY=$withval, INTEGRITY="none") + +AC_MSG_RESULT($INTEGRITY) + +case "$INTEGRITY" in + none) ;; + internal) + AC_DEFINE([INTEGRITY_INTERNAL], 1, [Define to 1 to include built-in support for integrity.]) + ;; + *) AC_MSG_ERROR([--with-integrity parameter invalid]) ;; +esac + ################################################################################ dnl -- Disable readline AC_ARG_ENABLE([readline],
device_mapper/all.h +39 -0
@@ -234,6 +234,7 @@ int dm_task_suppress_identical_reload(struct dm_task *dmt);int dm_task_secure_data (struct dm_task *dmt);int dm_task_retry_remove (struct dm_task *dmt);int dm_task_deferred_remove (struct dm_task *dmt); +void dm_task_skip_reload_params_compare (struct dm_task *dmt);/* * Record timestamp immediately after the ioctl returns.
@@ -392,6 +393,15 @@ struct dm_status_writecache {int dm_get_status_writecache (struct dm_pool *mem,const char *params,struct dm_status_writecache **status); +struct dm_status_integrity { +uint64_t number_of_mismatches; +uint64_t provided_data_sectors; +uint64_t recalc_sector; +}; + +int dm_get_status_integrity (struct dm_pool *mem,const char *params, +struct dm_status_integrity **status); +/* * Parse params from STATUS call for snapshot target *
@@ -970,6 +980,35 @@ int dm_tree_node_add_writecache_target(struct dm_tree_node *node,uint32_t writecache_block_size, struct writecache_settings *settings); +struct integrity_settings { +char mode[8 ]; +uint32_t tag_size; +uint32_t block_size;/* optional table param always set by lvm */ +const char *internal_hash;/* optional table param always set by lvm */ + +uint32_t journal_sectors; +uint32_t interleave_sectors; +uint32_t buffer_sectors; +uint32_t journal_watermark; +uint32_t commit_time; +uint32_t bitmap_flush_interval; +uint64_t sectors_per_bit; + +unsigned journal_sectors_set:1 ; +unsigned interleave_sectors_set:1 ; +unsigned buffer_sectors_set:1 ; +unsigned journal_watermark_set:1 ; +unsigned commit_time_set:1 ; +unsigned bitmap_flush_interval_set:1 ; +unsigned sectors_per_bit_set:1 ; +}; + +int dm_tree_node_add_integrity_target (struct dm_tree_node *node, +uint64_t size, +const char *origin_uuid, +const char *meta_uuid, +struct integrity_settings *settings, +int recalculate);/* * VDO target
device_mapper/ioctl/libdm-iface.c +27 -4
@@ -805,6 +805,11 @@ int dm_task_suppress_identical_reload(struct dm_task *dmt)return 1 ; } +void dm_task_skip_reload_params_compare (struct dm_task *dmt) +{ + dmt->skip_reload_params_compare =1 ; +} +int dm_task_set_add_node (struct dm_task *dmt,dm_add_node_t add_node) {switch (add_node) {
@@ -1575,11 +1580,29 @@ static int _reload_with_suppression_v4(struct dm_task *dmt) len =strlen (t2->params);while (len-- >0 && t2->params[len] ==' ' ) t2->params[len] ='\0' ; -if ((t1->start != t2->start) || - (t1->length != t2->length) || - (strcmp (t1->type, t2->type)) || - (strcmp (t1->params, t2->params))) + +if (t1->start != t2->start) { +log_debug ("reload %u:%u start diff" , task->major, task->minor); + goto no_match; + } +if (t1->length != t2->length) { +log_debug ("reload %u:%u length diff" , task->major, task->minor); goto no_match; + } +if (strcmp (t1->type, t2->type)) { +log_debug ("reload %u:%u type diff %s %s" , task->major, task->minor, t1->type, t2->type); + goto no_match; + } +if (strcmp (t1->params, t2->params)) { +if (dmt->skip_reload_params_compare) +log_debug ("reload %u:%u skip params ignore %s %s" , + task->major, task->minor, t1->params, t2->params); +else { +log_debug ("reload %u:%u params diff" , task->major, task->minor); + goto no_match; + } + } + t1 = t1->next; t2 = t2->next; }
device_mapper/ioctl/libdm-targets.h +1 -0
@@ -59,6 +59,7 @@ struct dm_task {int skip_lockfs;int query_inactive_table;int suppress_identical_reload; +int skip_reload_params_compare;dm_add_node_t add_node;uint64_t existing_table_size;int cookie_set;
device_mapper/libdm-deptree.c +151 -3
220 lines not on this page · raw message
device_mapper/libdm-targets.c +27 -0
@@ -380,6 +380,33 @@ int dm_get_status_writecache(struct dm_pool *mem, const char *params,return 1 ; } +int dm_get_status_integrity (struct dm_pool *mem,const char *params, +struct dm_status_integrity **status) +{ +struct dm_status_integrity *s; +char recalc_str[16 ] ="\0" ; + +if (!(s =dm_pool_zalloc (mem,sizeof (*s)))) + return_0; + +if (sscanf (params,"%llu %llu %s" , + (unsigned long long *)&s->number_of_mismatches, + (unsigned long long *)&s->provided_data_sectors, + recalc_str) !=3 ) { +log_error ("Failed to parse integrity params: %s." , params); +dm_pool_free (mem, s); +return 0 ; + } + +if (recalc_str[0 ] =='-' ) + s->recalc_sector =0 ; +else + s->recalc_sector =strtoull (recalc_str,NULL ,0 ); + + *status = s; +return 1 ; +} +int parse_thin_pool_status (const char *params,struct dm_status_thin_pool *s) {int pos;
include/configure.h.in +3 -0
@@ -678,6 +678,9 @@ /* Define to 1 to include built-in support for writecache. */ #undef WRITECACHE_INTERNAL +/* Define to 1 to include built-in support for integrity. */ +#undef INTEGRITY_INTERNAL + /* Define to get access to GNU/Linux extension */ #undef _GNU_SOURCE
lib/Makefile.in +2 -0
@@ -20,6 +20,7 @@ SOURCES =\ activate/activate.c \ cache/lvmcache.c \ writecache/writecache.c \ + integrity/integrity.c \ cache_segtype/cache.c \ commands/toolcontext.c \ config/config.c \
@@ -67,6 +68,7 @@ SOURCES =\ log/log.c \ metadata/cache_manip.c \ metadata/writecache_manip.c \ + metadata/integrity_manip.c \ metadata/lv.c \ metadata/lv_manip.c \ metadata/merge.c \
lib/activate/activate.c +7 -0
@@ -2535,6 +2535,13 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s, goto out; } +if ((cmd->partial_activation || cmd->degraded_activation) && +lv_is_partial (lv) &&lv_is_raid (lv) &&lv_raid_has_integrity ((struct logical_volume *)lv)) { + cmd->partial_activation =0 ; + cmd->degraded_activation =0 ; +log_print ("No degraded or partial activation for raid with integrity." ); + } +if ((!lv->vg->cmd->partial_activation) &&lv_is_partial (lv)) {if (!lv_is_raid_type (lv) || !partial_raid_lv_supports_degraded_activation (lv)) { log_error("Refusing activation of partial LV %s. "
lib/activate/activate.h +4 -0
@@ -39,6 +39,7 @@ typedef enum {SEG_STATUS_THIN_POOL ,SEG_STATUS_VDO_POOL ,SEG_STATUS_WRITECACHE , +SEG_STATUS_INTEGRITY , SEG_STATUS_UNKNOWN } lv_seg_status_type_t;
@@ -53,6 +54,7 @@ struct lv_seg_status {struct dm_status_thin *thin;struct dm_status_thin_pool *thin_pool;struct dm_status_writecache *writecache; +struct dm_status_integrity *integrity;struct lv_status_vdo vdo_pool; }; };
@@ -260,6 +262,7 @@ void fs_unlock(void);#define TARGET_NAME_CACHE "cache"#define TARGET_NAME_WRITECACHE "writecache" +#define TARGET_NAME_INTEGRITY "integrity"#define TARGET_NAME_ERROR "error"#define TARGET_NAME_ERROR_OLD "erro"/* Truncated in older kernels */ #define TARGET_NAME_LINEAR "linear"
@@ -277,6 +280,7 @@ void fs_unlock(void);#define MODULE_NAME_CLUSTERED_MIRROR "clog"#define MODULE_NAME_CACHE TARGET_NAME_CACHE#define MODULE_NAME_WRITECACHE TARGET_NAME_WRITECACHE +#define MODULE_NAME_INTEGRITY TARGET_NAME_INTEGRITY#define MODULE_NAME_ERROR TARGET_NAME_ERROR#define MODULE_NAME_LOG_CLUSTERED "log-clustered"#define MODULE_NAME_LOG_USERSPACE "log-userspace"
lib/activate/dev_manager.c +17 -1
@@ -46,7 +46,7 @@ typedef enum { } action_t;/* This list must match lib/misc/lvm-string.c:build_dm_uuid(). */ -const char *uuid_suffix_list[] = {"pool" ,"cdata" ,"cmeta" ,"cvol" ,"tdata" ,"tmeta" ,"vdata" ,"vpool" ,NULL }; +const char *uuid_suffix_list[] = {"pool" ,"cdata" ,"cmeta" ,"cvol" ,"tdata" ,"tmeta" ,"vdata" ,"vpool" ,"imeta" ,NULL };struct dlid_list {struct dm_list list;
@@ -222,6 +222,10 @@ static int _get_segment_status_from_target_params(const char *target_name,if (!dm_get_status_writecache (seg_status->mem, params, &(seg_status->writecache))) return_0; seg_status->type =SEG_STATUS_WRITECACHE ; + }else if (segtype_is_integrity (segtype)) { +if (!dm_get_status_integrity (seg_status->mem, params, &(seg_status->integrity))) + return_0; + seg_status->type =SEG_STATUS_INTEGRITY ; }else /* * TODO: Add support for other segment types too!
@@ -299,6 +303,9 @@ static int _info_run(const char *dlid, struct dm_info *dminfo,if (lv_is_vdo_pool (seg_status->seg->lv)) length =get_vdo_pool_virtual_size (seg_status->seg); +if (lv_is_integrity (seg_status->seg->lv)) + length = seg_status->seg->integrity_data_sectors; + do { target = dm_get_next_target(dmt, target, &target_start, &target_length, &target_name, &target_params);
@@ -2620,6 +2627,10 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,if (!_add_lv_to_dtree (dm, dtree, seg->writecache, dm->activation ? origin_only :1 )) return_0; } +if (seg->integrity_meta_dev &&seg_is_integrity (seg)) { +if (!_add_lv_to_dtree (dm, dtree, seg->integrity_meta_dev, dm->activation ? origin_only :1 )) + return_0; + } if (seg->pool_lv && (lv_is_cache_pool(seg->pool_lv) || lv_is_cache_vol(seg->pool_lv) || dm->track_external_lv_deps) &&/* When activating and not origin_only detect linear 'overlay' over pool */
@@ -3076,6 +3087,11 @@ static int _add_segment_to_dtree(struct dev_manager *dm, lv_layer(seg->writecache))) return_0; +if (seg->integrity_meta_dev && !laopts->origin_only && + !_add_new_lv_to_dtree (dm, dtree, seg->integrity_meta_dev, laopts, +lv_layer (seg->integrity_meta_dev))) + return_0; +/* Add any LVs used by this segment */ for (s =0 ; s < seg->area_count; ++s) { if ((seg_type(seg, s) == AREA_LV) &&
lib/commands/toolcontext.c +5 -0
@@ -1362,6 +1362,11 @@ static int _init_segtypes(struct cmd_context *cmd)return 0 ;#endif +#ifdef INTEGRITY_INTERNAL +if (!init_integrity_segtypes (cmd, &seglib)) +return 0 ; +#endif +return 1 ; }
lib/device/dev-type.c +39 -0
@@ -646,6 +646,45 @@ out:return ret; } +#ifdef BLKID_WIPING_SUPPORT +int get_fs_block_size (struct device *dev,uint32_t *fs_block_size) +{ +blkid_probe probe =NULL ; +const char *block_size_str =NULL ; +uint64_t block_size_val; +int r =0 ; + + *fs_block_size =0 ; + +if (!(probe =blkid_new_probe_from_filename (dev_name (dev)))) { +log_error ("Failed to create a new blkid probe for device %s." ,dev_name (dev)); + goto out; + } + +blkid_probe_enable_partitions (probe,1 ); + + (void )blkid_probe_lookup_value (probe,"BLOCK_SIZE" , &block_size_str,NULL ); + +if (!block_size_str) + goto out; + + block_size_val =strtoull (block_size_str,NULL ,10 ); + + *fs_block_size = (uint32_t )block_size_val; + r =1 ; +out: +if (probe) +blkid_free_probe (probe); +return r; +} +#else +int get_fs_block_size (struct device *dev,uint32_t *fs_block_size) +{ + *fs_block_size =0 ; +return 0 ; +} +#endif +#ifdef BLKID_WIPING_SUPPORT static inline int _type_in_flag_list (const char *type,uint32_t flag_list)
lib/device/dev-type.h +2 -0
@@ -97,4 +97,6 @@ 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
lib/format_text/flags.c +2 -0
@@ -104,6 +104,8 @@ static const struct flag _lv_flags[] = { {LV_VDO_POOL, NULL, 0}, {LV_VDO_POOL_DATA, NULL, 0}, {WRITECACHE, NULL, 0}, + {INTEGRITY, NULL, 0}, + {INTEGRITY_METADATA, NULL, 0}, {LV_PENDING_DELETE, NULL, 0}, /* FIXME Display like COMPATIBLE_FLAG */ {LV_REMOVED, NULL, 0}, {0, NULL, 0}
lib/integrity/integrity.c new file +343 -0
343 lines not on this page · raw message
lib/metadata/integrity_manip.c new file +821 -0
821 lines not on this page · raw message
lib/metadata/lv.c +17 -1
@@ -385,6 +385,17 @@ dm_percent_t lvseg_percent_with_info_and_seg_status(const struct lv_with_info_an* Esentially rework _target_percent API for segtype. */ switch (s->type) { +case SEG_STATUS_INTEGRITY : +if (type !=PERCENT_GET_DIRTY ) + p =DM_PERCENT_INVALID ; +else if (!s->integrity->recalc_sector) + p =DM_PERCENT_INVALID ; +else if (s->integrity->recalc_sector == s->integrity->provided_data_sectors) + p =DM_PERCENT_100 ; +else + p =dm_make_percent (s->integrity->recalc_sector, + s->integrity->provided_data_sectors); +break ;case SEG_STATUS_CACHE :if (s->cache->fail || s->cache->error) p =DM_PERCENT_INVALID ;
@@ -593,6 +604,8 @@ struct logical_volume *lv_origin_lv(const struct logical_volume *lv) origin =first_seg (lv)->external_lv; else if (lv_is_writecache(lv) && first_seg(lv)->origin) origin =first_seg (lv)->origin; + else if (lv_is_integrity(lv) && first_seg(lv)->origin) + origin =first_seg (lv)->origin;return origin; }
@@ -1208,10 +1221,13 @@ char *lv_attr_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_ repstr[0 ] = (lv_is_merging_origin (lv)) ?'O' :'o' ; else if (lv_is_pool_metadata(lv) || lv_is_pool_metadata_spare(lv) || -lv_is_raid_metadata (lv)) + lv_is_raid_metadata(lv) || +lv_is_integrity_metadata (lv)) repstr[0 ] ='e' ; else if (lv_is_cache_type(lv) || lv_is_writecache(lv)) repstr[0 ] ='C' ; + else if (lv_is_integrity(lv)) + repstr[0 ] ='g' ; else if (lv_is_raid(lv)) repstr[0 ] = (lv_is_not_synced (lv)) ?'R' :'r' ; else if (lv_is_mirror(lv))
lib/metadata/lv_manip.c +144 -6
244 lines not on this page · raw message
lib/metadata/merge.c +2 -0
@@ -742,6 +742,8 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg) seg_found++;if (seg->metadata_lv == lv || seg->pool_lv == lv || seg->writecache == lv) seg_found++; +if (seg->integrity_meta_dev == lv) + seg_found++;if (seg_is_thin_volume (seg) && (seg->origin == lv || seg->external_lv == lv)) seg_found++;
lib/metadata/metadata-exported.h +26 -0
@@ -84,12 +84,14 @@#define CONVERTING UINT64_C(0x0000000000400000)/* LV */ #define MISSING_PV UINT64_C(0x0000000000800000)/* PV */ +#define INTEGRITY UINT64_C(0x0000000000800000)/* LV - Internal use only */ #define PV_MOVED_VG UINT64_C(0x4000000000000000)/* PV - Moved to a new VG */ #define PARTIAL_LV UINT64_C(0x0000000001000000)/* LV - derived flag, not written out in metadata*/ //#define POSTORDER_FLAG UINT64_C(0x0000000002000000) /* Not real flags, reserved for //#define POSTORDER_OPEN_FLAG UINT64_C(0x0000000004000000) temporary use inside vg_read_internal. */ +#define INTEGRITY_METADATA UINT64_C(0x0000000004000000)/* LV - Internal use only */ #define VIRTUAL_ORIGIN UINT64_C(0x0000000008000000)/* LV - internal use only */ #define MERGING UINT64_C(0x0000000010000000)/* LV SEG */
@@ -261,6 +263,8 @@#define lv_is_pool_metadata_spare (lv) (((lv)->status & POOL_METADATA_SPARE) ? 1 : 0)#define lv_is_lockd_sanlock_lv (lv) (((lv)->status & LOCKD_SANLOCK_LV) ? 1 : 0)#define lv_is_writecache (lv) (((lv)->status & WRITECACHE) ? 1 : 0) +#define lv_is_integrity (lv) (((lv)->status & INTEGRITY) ? 1 : 0) +#define lv_is_integrity_metadata (lv) (((lv)->status & INTEGRITY_METADATA) ? 1 : 0)#define lv_is_vdo (lv) (((lv)->status & LV_VDO) ? 1 : 0)#define lv_is_vdo_pool (lv) (((lv)->status & LV_VDO_POOL) ? 1 : 0)
@@ -272,9 +276,11 @@/* Recognize component LV (matching lib/misc/lvm-string.c _lvname_has_reserved_component_string()) */ #define lv_is_component (lv) (lv_is_cache_origin(lv) || \ lv_is_writecache_origin(lv) || \ + lv_is_integrity_origin(lv) || \ ((lv)->status & (\ CACHE_POOL_DATA |\ CACHE_POOL_METADATA |\ + INTEGRITY_METADATA |\ LV_CACHE_VOL |\ LV_VDO_POOL_DATA |\ MIRROR_IMAGE |\
@@ -519,6 +525,11 @@ struct lv_segment {uint32_t writecache_block_size;/* For writecache */ struct writecache_settings writecache_settings;/* For writecache */ +uint64_t integrity_data_sectors; +struct logical_volume *integrity_meta_dev; +struct integrity_settings integrity_settings; +uint32_t integrity_recalculate; +struct dm_vdo_target_params vdo_params;/* For VDO-pool */ uint32_t vdo_pool_header_size;/* For VDO-pool */ uint32_t vdo_pool_virtual_extents;/* For VDO-pool */
@@ -992,6 +1003,10 @@ struct lvcreate_params {alloc_policy_t alloc;/* all */ struct dm_vdo_target_params vdo_params;/* vdo */ +int raidintegrity; +const char *raidintegritymode; +struct integrity_settings integrity_settings; +struct dm_list tags;/* all */ int yes;
@@ -1086,6 +1101,8 @@ int lv_is_cache_origin(const struct logical_volume *lv);int lv_is_writecache_origin (const struct logical_volume *lv);int lv_is_writecache_cachevol (const struct logical_volume *lv); +int lv_is_integrity_origin (const struct logical_volume *lv); +int lv_is_merging_cow (const struct logical_volume *cow);uint32_t cow_max_extents (const struct logical_volume *origin,uint32_t chunk_size);int cow_has_min_chunks (const struct volume_group *vg,uint32_t cow_extents,uint32_t chunk_size);
@@ -1389,4 +1406,13 @@ struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int char **argv, int allocatable_only);struct dm_list *clone_pv_list (struct dm_pool *mem,struct dm_list *pvsl); +int lv_add_integrity_to_raid (struct logical_volume *lv,struct integrity_settings *settings,struct dm_list *pvh, +struct logical_volume *lv_imeta_0); +int lv_remove_integrity_from_raid (struct logical_volume *lv); +void lv_clear_integrity_recalculate_metadata (struct logical_volume *lv); +int lv_has_integrity_recalculate_metadata (struct logical_volume *lv); +int lv_raid_has_integrity (struct logical_volume *lv); +int lv_extend_integrity_in_raid (struct logical_volume *lv,struct dm_list *pvh); +int lv_get_raid_integrity_settings (struct logical_volume *lv,struct integrity_settings **isettings); +#endif
lib/metadata/raid_manip.c +80 -5
135 lines not on this page · raw message
lib/metadata/segtype.h +6 -0
@@ -67,6 +67,7 @@ struct dev_manager;#define SEG_RAID6_N_6 (1ULL << 35)#define SEG_RAID6 SEG_RAID6_ZR#define SEG_WRITECACHE (1ULL << 36) +#define SEG_INTEGRITY (1ULL << 37)#define SEG_STRIPED_TARGET (1ULL << 39)#define SEG_LINEAR_TARGET (1ULL << 40)
@@ -84,6 +85,7 @@ struct dev_manager;#define SEG_TYPE_NAME_CACHE "cache"#define SEG_TYPE_NAME_CACHE_POOL "cache-pool"#define SEG_TYPE_NAME_WRITECACHE "writecache" +#define SEG_TYPE_NAME_INTEGRITY "integrity"#define SEG_TYPE_NAME_ERROR "error"#define SEG_TYPE_NAME_FREE "free"#define SEG_TYPE_NAME_ZERO "zero"
@@ -117,6 +119,7 @@ struct dev_manager;#define segtype_is_cache (segtype) ((segtype)->flags & SEG_CACHE ? 1 : 0)#define segtype_is_cache_pool (segtype) ((segtype)->flags & SEG_CACHE_POOL ? 1 : 0)#define segtype_is_writecache (segtype) ((segtype)->flags & SEG_WRITECACHE ? 1 : 0) +#define segtype_is_integrity (segtype) ((segtype)->flags & SEG_INTEGRITY ? 1 : 0)#define segtype_is_mirrored (segtype) ((segtype)->flags & SEG_AREAS_MIRRORED ? 1 : 0)#define segtype_is_mirror (segtype) ((segtype)->flags & SEG_MIRROR ? 1 : 0)#define segtype_is_pool (segtype) ((segtype)->flags & (SEG_CACHE_POOL | SEG_THIN_POOL) ? 1 : 0)
@@ -179,6 +182,7 @@ struct dev_manager;#define seg_is_cache (seg) segtype_is_cache((seg)->segtype)#define seg_is_cache_pool (seg) segtype_is_cache_pool((seg)->segtype)#define seg_is_writecache (seg) segtype_is_writecache((seg)->segtype) +#define seg_is_integrity (seg) segtype_is_integrity((seg)->segtype)#define seg_is_used_cache_pool (seg) (seg_is_cache_pool(seg) && (!dm_list_empty(&(seg->lv)->segs_using_this_lv)))#define seg_is_linear (seg) (seg_is_striped(seg) && ((seg)->area_count == 1))#define seg_is_mirror (seg) segtype_is_mirror((seg)->segtype)
@@ -347,6 +351,8 @@ int init_vdo_segtypes(struct cmd_context *cmd, struct segtype_library *seglib);int init_writecache_segtypes (struct cmd_context *cmd,struct segtype_library *seglib); +int init_integrity_segtypes (struct cmd_context *cmd,struct segtype_library *seglib); +#define CACHE_FEATURE_POLICY_MQ (1U << 0)#define CACHE_FEATURE_POLICY_SMQ (1U << 1)#define CACHE_FEATURE_METADATA2 (1U << 2)
lib/metadata/snapshot_manip.c +2 -0
@@ -387,6 +387,8 @@ int validate_snapshot_origin(const struct logical_volume *origin_lv) } }else if (lv_is_raid_type (origin_lv) && !lv_is_raid (origin_lv)) { err ="raid subvolumes" ; + }else if (lv_is_raid (origin_lv) &&lv_raid_has_integrity ((struct logical_volume *)origin_lv)) { + err ="raid with integrity" ; }else if (lv_is_writecache (origin_lv)) { err ="writecache" ; }
lib/misc/lvm-string.c +3 -1
@@ -166,7 +166,9 @@ static const char *_lvname_has_reserved_component_string(const char *lvname)"_rmeta" ,"_tdata" ,"_tmeta" , - "_vdata" +"_vdata" , +"_imeta" , + "_iorig" };unsigned i;
lib/report/report.c +1 -1
@@ -3173,7 +3173,7 @@ static int _copypercent_disp(struct dm_report *rh,dm_percent_t percent =DM_PERCENT_INVALID ;/* TODO: just cache passes through lvseg_percent... */ -if (lv_is_cache (lv) ||lv_is_used_cache_pool (lv) || +if (lv_is_integrity (lv) ||lv_is_cache (lv) ||lv_is_used_cache_pool (lv) || (!lv_is_merging_origin (lv) &&lv_is_raid (lv) && !seg_is_any_raid0 (first_seg (lv)))) percent =lvseg_percent_with_info_and_seg_status (lvdm,PERCENT_GET_DIRTY );else if (lv_is_raid (lv) && !seg_is_any_raid0 (first_seg (lv)))
man/lvmraid.7_main +83 -0
89 lines not on this page · raw message
test/lib/aux.sh +8 -0
@@ -1563,6 +1563,14 @@ have_writecache() { target_at_least dm-writecache "$@" } +have_integrity() { + lvm segtypes 2>/dev/null | grep -q integrity$ || { + echo "integrity is not built-in." >&2 + return 1 + } + target_at_least dm-integrity "$@" +} + have_raid() { target_at_least dm-raid "$@"
test/shell/integrity-blocksize.sh new file +183 -0
183 lines not on this page · raw message
test/shell/integrity-dmeventd.sh new file +289 -0
289 lines not on this page · raw message
test/shell/integrity-large.sh new file +175 -0
86 lines not on this page · raw message
test/shell/integrity-misc.sh new file +228 -0
228 lines not on this page · raw message
test/shell/integrity.sh new file +735 -0
735 lines not on this page · raw message
tools/command-lines.in +31 -14
45 lines not on this page · raw message
tools/lvconvert.c +137 -0
137 lines not on this page · raw message
tools/toollib.c +47 -0
47 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.