CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-12-12 18:45:58 Modified files: libdm : libdm-deptree.c Log message: Use dm_snprintf to avoid duplicating the snprintf compatibility code. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49 --- LVM2/libdm/libdm-deptree.c 2008/12/11 16:25:51 1.48 +++ LVM2/libdm/libdm-deptree.c 2008/12/12 18:45:58 1.49 @@ -1224,17 +1224,14 @@ /* simplify string emiting code */ #define EMIT_PARAMS(p, str...)\ - do {\ - const size_t bufsize = paramsize - (size_t)p;\ - int w;\ - \ - if ((w = snprintf(params + p, bufsize, str)) < 0\ - || ((size_t)w >= bufsize)) {\ - stack; /* Out of space */\ - return -1;\ - }\ - p += w;\ - } while (0) +do {\ + int w;\ + if ((w = dm_snprintf(params + p, paramsize - (size_t) p, str)) < 0) {\ + stack; /* Out of space */\ + return -1;\ + }\ + p += w;\ +} while (0) static int _emit_areas_line(struct dm_task *dmt __attribute((unused)), struct load_segment *seg, char *params,
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2009-07-07 16:36:05 Modified files: libdm : libdm-deptree.c Log message: Fix whitespace in linear target line to fix identical table line detection. (only tested with linear so far) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53 --- LVM2/libdm/libdm-deptree.c 2009/07/03 12:45:56 1.52 +++ LVM2/libdm/libdm-deptree.c 2009/07/07 16:36:05 1.53 @@ -1252,12 +1252,16 @@ { struct seg_area *area; char devbuf[DM_FORMAT_DEV_BUFSIZE]; + unsigned first_time = 1; dm_list_iterate_items(area, &seg->areas) { if (!_build_dev_string(devbuf, sizeof(devbuf), area->dev_node)) return_0; - EMIT_PARAMS(*pos, " %s %" PRIu64, devbuf, area->offset); + EMIT_PARAMS(*pos, "%s%s %" PRIu64, first_time ? "" : " ", + devbuf, area->offset); + + first_time = 0; } return 1; @@ -1320,7 +1324,7 @@ if ((seg->flags & DM_BLOCK_ON_ERROR)) EMIT_PARAMS(pos, " block_on_error"); - EMIT_PARAMS(pos, " %u", seg->mirror_area_count); + EMIT_PARAMS(pos, " %u ", seg->mirror_area_count); break; case SEG_SNAPSHOT: @@ -1337,10 +1341,10 @@ EMIT_PARAMS(pos, "%s", originbuf); break; case SEG_STRIPED: - EMIT_PARAMS(pos, "%u %u", seg->area_count, seg->stripe_size); + EMIT_PARAMS(pos, "%u %u ", seg->area_count, seg->stripe_size); break; case SEG_CRYPT: - EMIT_PARAMS(pos, "%s%s%s%s%s %s %" PRIu64, seg->cipher, + EMIT_PARAMS(pos, "%s%s%s%s%s %s %" PRIu64 " ", seg->cipher, seg->chainmode ? "-" : "", seg->chainmode ?: "", seg->iv ? "-" : "", seg->iv ?: "", seg->key, seg->iv_offset != DM_CRYPT_IV_DEFAULT ?
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2009-09-22 16:26:59 Modified files: libdm : libdm-deptree.c Log message: '_emit_areas_line' returns 1 for success and 0 for failure. This always confuses me, so I've added a comment at the top of the function to remind me of this. I also found that 'mirror_emit_segment_line' was returning 0 (return_0) on failure /and/ success. It now returns 1 for success and 0 for failure - just like '_emit_areas_line' and its calling function, '_emit_segment_line'. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/libdm/libdm-deptree.c 2009/08/13 16:31:01 1.56 +++ LVM2/libdm/libdm-deptree.c 2009/09/22 16:26:59 1.57 @@ -1258,6 +1258,11 @@ p += w;\ } while (0) +/* + * _emit_areas_line + * + * Returns: 1 on success, 0 on failure + */ static int _emit_areas_line(struct dm_task *dmt __attribute((unused)), struct load_segment *seg, char *params, size_t paramsize, int *pos) @@ -1279,6 +1284,11 @@ return 1; } +/* + * mirror_emit_segment_line + * + * Returns: 1 on success, 0 on failure + */ static int mirror_emit_segment_line(struct dm_task *dmt, uint32_t major, uint32_t minor, struct load_segment *seg, uint64_t *seg_start, char *params, @@ -1386,15 +1396,13 @@ EMIT_PARAMS(pos, " %u ", seg->mirror_area_count); - if ((r = _emit_areas_line(dmt, seg, params, paramsize, &pos)) <= 0) { - stack; - return r; - } + if ((r = _emit_areas_line(dmt, seg, params, paramsize, &pos)) <= 0) + return_0; if (handle_errors) EMIT_PARAMS(pos, " 1 handle_errors"); - return 0; + return 1; } static int _emit_segment_line(struct dm_task *dmt, uint32_t major, @@ -1415,8 +1423,8 @@ /* Mirrors are pretty complicated - now in separate function */ r = mirror_emit_segment_line(dmt, major, minor, seg, seg_start, params, paramsize); - if (r) - return r; + if (!r) + return_0; break; case SEG_SNAPSHOT: if (!_build_dev_string(originbuf, sizeof(originbuf), seg->origin))
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: snitzer@sourceware.org 2010-01-05 21:04:37 Modified files: libdm : libdm-deptree.c Log message: Return error to dm_tree_preload_children() and dm_tree_activate_children() callers. Otherwise resume_lv and its variants can fail silently. Catching these failures is especially important now that dm targets like crypt and snapshot-merge can fail in .preresume Signed-off-by: Mike Snitzer <snitzer@redhat.com> Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65 --- LVM2/libdm/libdm-deptree.c 2009/12/11 13:16:39 1.64 +++ LVM2/libdm/libdm-deptree.c 2010/01/05 21:04:37 1.65 @@ -1140,6 +1140,7 @@ const char *uuid_prefix, size_t uuid_prefix_len) { + int r = 1; void *handle = NULL; struct dm_tree_node *child = dnode; struct dm_info newinfo; @@ -1158,7 +1159,8 @@ continue; if (dm_tree_node_num_children(child, 0)) - dm_tree_activate_children(child, uuid_prefix, uuid_prefix_len); + if (!dm_tree_activate_children(child, uuid_prefix, uuid_prefix_len)) + return_0; } handle = NULL; @@ -1204,6 +1206,7 @@ log_error("Unable to resume %s (%" PRIu32 ":%" PRIu32 ")", child->name, child->info.major, child->info.minor); + r = 0; continue; } @@ -1214,7 +1217,7 @@ handle = NULL; - return 1; + return r; } static int _create_node(struct dm_tree_node *dnode) @@ -1605,6 +1608,7 @@ const char *uuid_prefix, size_t uuid_prefix_len) { + int r = 1; void *handle = NULL; struct dm_tree_node *child; struct dm_info newinfo; @@ -1621,7 +1625,8 @@ continue; if (dm_tree_node_num_children(child, 0)) - dm_tree_preload_children(child, uuid_prefix, uuid_prefix_len); + if (!dm_tree_preload_children(child, uuid_prefix, uuid_prefix_len)) + return_0; /* FIXME Cope if name exists with no uuid? */ if (!child->info.exists) { @@ -1655,6 +1660,7 @@ log_error("Unable to resume %s (%" PRIu32 ":%" PRIu32 ")", child->name, child->info.major, child->info.minor); + r = 0; continue; } @@ -1664,7 +1670,7 @@ handle = NULL; - return 1; + return r; } /*
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: snitzer@sourceware.org 2010-01-05 21:05:40 Modified files: libdm : libdm-deptree.c Log message: Return error to dm_tree_suspend_children() callers. Otherwise suspend_lv and its variants can fail silently. Signed-off-by: Mike Snitzer <snitzer@redhat.com> Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66 --- LVM2/libdm/libdm-deptree.c 2010/01/05 21:04:37 1.65 +++ LVM2/libdm/libdm-deptree.c 2010/01/05 21:05:40 1.66 @@ -1067,6 +1067,7 @@ const char *uuid_prefix, size_t uuid_prefix_len) { + int r = 1; void *handle = NULL; struct dm_tree_node *child = dnode; struct dm_info info, newinfo; @@ -1109,6 +1110,7 @@ log_error("Unable to suspend %s (%" PRIu32 ":%" PRIu32 ")", name, info.major, info.minor); + r = 0; continue; } @@ -1130,10 +1132,11 @@ continue; if (dm_tree_node_num_children(child, 0)) - dm_tree_suspend_children(child, uuid_prefix, uuid_prefix_len); + if (!dm_tree_suspend_children(child, uuid_prefix, uuid_prefix_len)) + return_0; } - return 1; + return r; } int dm_tree_activate_children(struct dm_tree_node *dnode,
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: snitzer@sourceware.org 2010-01-05 21:06:26 Modified files: libdm : libdm-deptree.c Log message: Return error to dm_tree_deactivate_children() callers. Otherwise deactivate_lv can fail silently. Signed-off-by: Mike Snitzer <snitzer@redhat.com> Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67 --- LVM2/libdm/libdm-deptree.c 2010/01/05 21:05:40 1.66 +++ LVM2/libdm/libdm-deptree.c 2010/01/05 21:06:26 1.67 @@ -1006,6 +1006,7 @@ const char *uuid_prefix, size_t uuid_prefix_len) { + int r = 1; void *handle = NULL; struct dm_tree_node *child = dnode; struct dm_info info; @@ -1043,14 +1044,16 @@ log_error("Unable to deactivate %s (%" PRIu32 ":%" PRIu32 ")", name, info.major, info.minor); + r = 0; continue; } if (dm_tree_node_num_children(child, 0)) - dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len); + if (!dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len)) + return_0; } - return 1; + return r; } void dm_tree_skip_lockfs(struct dm_tree_node *dnode)
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2010-01-15 16:00:23 Modified files: libdm : libdm-deptree.c Log message: Off-by-one count was causing not all the mirror table parameters that were necessary to be passed on to userspace. The cluster mirror table (log portion only) used to look like this: clustered-disk <parm_count> <disk> <region_size> <uuid> \ [[no]sync] [block_on_error] Now it looks like this: userspace <parm_count> <uuid> clustered-disk <disk> <region_size> \ [[no]sync] So, there is one extra argument in the latter case - this was unaccounted for. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71 --- LVM2/libdm/libdm-deptree.c 2010/01/14 10:15:23 1.70 +++ LVM2/libdm/libdm-deptree.c 2010/01/15 16:00:23 1.71 @@ -1408,6 +1408,9 @@ if (!dm_log_userspace) EMIT_PARAMS(pos, "clustered-"); + else + /* For clustered-* type field inserted later */ + log_parm_count++; } if (!seg->log)
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-04-07 21:25:09 Modified files: libdm : libdm-deptree.c Log message: Issue a message if the new type of deactivation failure happens. If this can happen during 'normal' operations, I need to know. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74 --- LVM2/libdm/libdm-deptree.c 2010/04/07 20:04:42 1.73 +++ LVM2/libdm/libdm-deptree.c 2010/04/07 21:25:09 1.74 @@ -1051,6 +1051,9 @@ continue; if (info.open_count) { + log_error("Unable to deactivate open %s (%" PRIu32 + ":%" PRIu32 ")", name, info.major, + info.minor); r = 0; continue; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-04-07 23:51:34 Modified files: libdm : libdm-deptree.c Log message: Only fail if the top-level LV fails to be deactivated - allow deactivation of its dependencies to fail. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75 --- LVM2/libdm/libdm-deptree.c 2010/04/07 21:25:09 1.74 +++ LVM2/libdm/libdm-deptree.c 2010/04/07 23:51:34 1.75 @@ -1013,9 +1013,13 @@ return r; } -int dm_tree_deactivate_children(struct dm_tree_node *dnode, - const char *uuid_prefix, - size_t uuid_prefix_len) +/* + * FIXME Don't attempt to deactivate known internal dependencies. + */ +static int _dm_tree_deactivate_children(struct dm_tree_node *dnode, + const char *uuid_prefix, + size_t uuid_prefix_len, + unsigned level) { int r = 1; void *handle = NULL; @@ -1051,10 +1055,13 @@ continue; if (info.open_count) { - log_error("Unable to deactivate open %s (%" PRIu32 - ":%" PRIu32 ")", name, info.major, - info.minor); - r = 0; + /* Only report error from (likely non-internal) dependency at top level */ + if (!level) { + log_error("Unable to deactivate open %s (%" PRIu32 + ":%" PRIu32 ")", name, info.major, + info.minor); + r = 0; + } continue; } @@ -1067,14 +1074,22 @@ continue; } - if (dm_tree_node_num_children(child, 0)) - if (!dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len)) + if (dm_tree_node_num_children(child, 0)) { + if (!_dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len, level + 1)) return_0; + } } return r; } +int dm_tree_deactivate_children(struct dm_tree_node *dnode, + const char *uuid_prefix, + size_t uuid_prefix_len) +{ + return _dm_tree_deactivate_children(dnode, uuid_prefix, uuid_prefix_len, 0); +} + void dm_tree_skip_lockfs(struct dm_tree_node *dnode) { dnode->dtree->skip_lockfs = 1;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-25 08:40:37 Modified files: libdm : libdm-deptree.c Log message: Fix copy&paste detection of kernel release version. Add log_error to avoid return_0 without log_error. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82 --- LVM2/libdm/libdm-deptree.c 2010/05/24 23:11:35 1.81 +++ LVM2/libdm/libdm-deptree.c 2010/05/25 08:40:36 1.82 @@ -1542,8 +1542,10 @@ const char *logtype; unsigned kmaj, kmin, krel; - if (!uname(&uts) || sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) != 3) - return_0; + if (uname(&uts) == -1 || sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) != 3) { + log_error("Cannot read kernel release version"); + return 0; + } if ((seg->flags & DM_BLOCK_ON_ERROR)) { /*
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-11-29 11:26:00 Modified files: libdm : libdm-deptree.c Log message: Remove dead assignment in dm_tree_node_add_mirror_target_log 'seg' is never used - remove it. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88 --- LVM2/libdm/libdm-deptree.c 2010/11/23 18:29:06 1.87 +++ LVM2/libdm/libdm-deptree.c 2010/11/29 11:26:00 1.88 @@ -2199,9 +2199,7 @@ int dm_tree_node_add_mirror_target(struct dm_tree_node *node, uint64_t size) { - struct load_segment *seg; - - if (!(seg = _add_segment(node, SEG_MIRRORED, size))) + if (!_add_segment(node, SEG_MIRRORED, size)) return_0; return 1;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-11-29 12:42:11 Modified files: libdm : libdm-deptree.c Log message: Remove dead assignment in _mirror_emit_segment_line Remove unused 'r' assignment. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89 --- LVM2/libdm/libdm-deptree.c 2010/11/29 11:26:00 1.88 +++ LVM2/libdm/libdm-deptree.c 2010/11/29 12:42:10 1.89 @@ -1536,7 +1536,6 @@ uint64_t *seg_start, char *params, size_t paramsize) { - int r; int block_on_error = 0; int handle_errors = 0; int dm_log_userspace = 0; @@ -1643,7 +1642,7 @@ EMIT_PARAMS(pos, " %u ", seg->mirror_area_count); - if ((r = _emit_areas_line(dmt, seg, params, paramsize, &pos)) <= 0) + if (_emit_areas_line(dmt, seg, params, paramsize, &pos) <= 0) return_0; if (handle_errors)
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 15:53:00 Modified files: libdm : libdm-deptree.c Log message: Fix another occurrence of linux kernel version check. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93 --- LVM2/libdm/libdm-deptree.c 2011/03/29 20:19:04 1.92 +++ LVM2/libdm/libdm-deptree.c 2011/06/09 15:52:59 1.93 @@ -1544,13 +1544,20 @@ int dm_log_userspace = 0; struct utsname uts; unsigned log_parm_count; - int pos = 0; + int pos = 0, parts; char logbuf[DM_FORMAT_DEV_BUFSIZE]; const char *logtype; - unsigned kmaj, kmin, krel; + unsigned kmaj = 0, kmin = 0, krel = 0; + + if (uname(&uts) == -1) { + log_error("Cannot read kernel release version."); + return 0; + } - if (uname(&uts) == -1 || sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) != 3) { - log_error("Cannot read kernel release version"); + /* Kernels with a major number of 2 always had 3 parts. */ + parts = sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel); + if (parts < 1 || (kmaj < 3 && parts < 3)) { + log_error("Wrong kernel release version %s.", uts.release); return 0; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-11 12:55:31 Modified files: libdm : libdm-deptree.c Log message: Fix --mirrorlog mirrored. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95 --- LVM2/libdm/libdm-deptree.c 2011/06/11 00:03:07 1.94 +++ LVM2/libdm/libdm-deptree.c 2011/06/11 12:55:31 1.95 @@ -2210,6 +2210,10 @@ if (clustered) log_node->props.immediate_dev_node = 1; + /* The kernel validates the size of disk logs. */ + /* FIXME Propagate to any devices below */ + log_node->props.delay_resume_if_new = 0; + if (!_link_tree_nodes(node, log_node)) return_0; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-06-22 12:56:02 Modified files: libdm : libdm-deptree.c Log message: Add check for library fallback in _deactivate_node. This fn calls rm_dev_node directly - an exceptional case. It needs to check the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag directly (it's called in dm_task_run normally where it's checked already). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97 --- LVM2/libdm/libdm-deptree.c 2011/06/13 03:32:46 1.96 +++ LVM2/libdm/libdm-deptree.c 2011/06/22 12:56:02 1.97 @@ -984,8 +984,9 @@ r = dm_task_run(dmt); /* FIXME Until kernel returns actual name so dm-ioctl.c can handle it */ - rm_dev_node(name, dmt->cookie_set && - !(udev_flags & DM_UDEV_DISABLE_DM_RULES_FLAG)); + if (!(udev_flags & DM_UDEV_DISABLE_LIBRARY_FALLBACK)) + rm_dev_node(name, dmt->cookie_set && + !(udev_flags & DM_UDEV_DISABLE_DM_RULES_FLAG)); /* FIXME Remove node from tree or mark invalid? */
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-07-08 19:13:05 Modified files: libdm : libdm-deptree.c Log message: Downgrade error message - it isn't strictly an internal error in the library, and the known cause within lvm2 got fixed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.101&r2=1.102 --- LVM2/libdm/libdm-deptree.c 2011/06/30 09:24:58 1.101 +++ LVM2/libdm/libdm-deptree.c 2011/07/08 19:13:05 1.102 @@ -1754,10 +1754,12 @@ stack; return r; } - if (!params[0]) - log_error(INTERNAL_ERROR "Empty parameters for " - "%s %u:%u.", dm_segtypes[seg->type].target, + if (!params[0]) { + log_error("No parameters supplied for %s target " + "%u:%u.", dm_segtypes[seg->type].target, major, minor); + return 0; + } break; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-29 08:50:55 Modified files: libdm : libdm-deptree.c Log message: Just add warning about potential problem exteding dm_segtypes Since raid target is using now dm_segtypes also for search purpose. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114 --- LVM2/libdm/libdm-deptree.c 2011/09/27 22:43:41 1.113 +++ LVM2/libdm/libdm-deptree.c 2011/09/29 08:50:54 1.114 @@ -80,6 +80,11 @@ { SEG_RAID6_ZR, "raid6_zr"}, { SEG_RAID6_NR, "raid6_nr"}, { SEG_RAID6_NC, "raid6_nc"}, + + /* + *WARNING: Since 'raid' target overloads this 1:1 mapping table + * for search do not add new enum elements past them! + */ { SEG_RAID5_LS, "raid5"}, /* same as "raid5_ls" (default for MD also) */ { SEG_RAID6_ZR, "raid6"}, /* same as "raid6_zr" */ { SEG_LAST, NULL },
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-03 18:29:49 Modified files: libdm : libdm-deptree.c Log message: Move priority check in front Just a minor code mode - make a test for priority before more complex uuid checks. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118 --- LVM2/libdm/libdm-deptree.c 2011/10/03 18:28:25 1.117 +++ LVM2/libdm/libdm-deptree.c 2011/10/03 18:29:48 1.118 @@ -1419,6 +1419,9 @@ for (priority = 0; priority < 3; priority++) { while ((child = dm_tree_next_child(&handle, dnode, 0))) { + if (priority != child->activation_priority) + continue; + if (!(uuid = dm_tree_node_get_uuid(child))) { stack; continue; @@ -1427,9 +1430,6 @@ if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len)) continue; - if (priority != child->activation_priority) - continue; - if (!(name = dm_tree_node_get_name(child))) { stack; continue;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-17 14:14:33 Modified files: libdm : libdm-deptree.c Log message: Drop old check for transaction_id (revert) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125 --- LVM2/libdm/libdm-deptree.c 2011/10/17 13:15:35 1.124 +++ LVM2/libdm/libdm-deptree.c 2011/10/17 14:14:33 1.125 @@ -1512,18 +1512,6 @@ /* Update cached info */ child->info = newinfo; - - /* FIXME: trial version - to avoid use of unsynchronized thin_pool transaction_id */ - if (child->props.thin_pool_transaction_id && - !_check_thin_pool_transaction_id(child->name, child->info.major, - child->info.minor, - child->props.thin_pool_transaction_id)) { - stack; - if (!(dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len))) - log_error("Failed to deactivate %s", child->name); - r = 0; - continue; - } } } @@ -2207,18 +2195,6 @@ */ if (child->props.immediate_dev_node) update_devs_flag = 1; - - /* FIXME: trial version - to avoid use of unsynchronized thin_pool transaction_id */ - if (child->props.thin_pool_transaction_id && - !_check_thin_pool_transaction_id(child->name, child->info.major, - child->info.minor, - child->props.thin_pool_transaction_id)) { - stack; - if (!(dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len))) - log_error("Failed to deactivate %s", child->name); - r = 0; - continue; - } } handle = NULL;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-17 14:15:27 Modified files: libdm : libdm-deptree.c Log message: Add _thin_validate_device_id Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127 --- LVM2/libdm/libdm-deptree.c 2011/10/17 14:15:01 1.126 +++ LVM2/libdm/libdm-deptree.c 2011/10/17 14:15:26 1.127 @@ -2687,6 +2687,17 @@ return 1; } +static int _thin_validate_device_id(uint32_t device_id) +{ + if (device_id > DM_THIN_MAX_DEVICE_ID) { + log_error("Device id %u is higher then %u.", + device_id, DM_THIN_MAX_DEVICE_ID); + return 0; + } + + return 1; +} + int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, uint64_t size, uint64_t transaction_id, @@ -2744,11 +2755,8 @@ { struct load_segment *seg; - if (device_id > DM_THIN_MAX_DEVICE_ID) { - log_error("Device id %u is higher then %u.", - device_id, DM_THIN_MAX_DEVICE_ID); - return 0; - } + if (!_thin_validate_device_id(device_id)) + return_0; if (!(seg = _add_segment(node, SEG_THIN, size))) return_0;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-19 16:40:59 Modified files: libdm : libdm-deptree.c Log message: Use generic name for message sending function Drop _thin_pool prefix for _node_send_message so it could be extended later. Replace current_id with trans_id name. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131 --- LVM2/libdm/libdm-deptree.c 2011/10/19 16:36:40 1.130 +++ LVM2/libdm/libdm-deptree.c 2011/10/19 16:40:59 1.131 @@ -1328,17 +1328,17 @@ return r; } -static int _thin_pool_node_send_messages(struct dm_tree_node *dnode, - const char *uuid_prefix, - size_t uuid_prefix_len) +static int _node_send_messages(struct dm_tree_node *dnode, + const char *uuid_prefix, + size_t uuid_prefix_len) { struct load_segment *seg; struct thin_message *tmsg; - uint64_t current_id; + uint64_t trans_id; const char *uuid; - if ((dnode == &dnode->dtree->root) || /* root has rops.segs uninitialized */ - (dm_list_size(&dnode->props.segs) != 1)) + if ((dnode == &dnode->dtree->root) || /* root has props.segs uninitialized */ + !dnode->info.exists || (dm_list_size(&dnode->props.segs) != 1)) return 1; seg = dm_list_item(dm_list_last(&dnode->props.segs), struct load_segment); @@ -1353,16 +1353,15 @@ return 1; } - if (!_thin_pool_status_transaction_id(dnode, ¤t_id)) + if (!_thin_pool_status_transaction_id(dnode, &trans_id)) return_0; - log_debug("Expecting transaction_id: %" PRIu64, dnode->props.thin_pool_transaction_id); - if (current_id == dnode->props.thin_pool_transaction_id) + if (trans_id == dnode->props.thin_pool_transaction_id) return 1; /* In sync - skip messages */ - if (current_id != (dnode->props.thin_pool_transaction_id - 1)) { + if (trans_id != (dnode->props.thin_pool_transaction_id - 1)) { log_error("Thin pool transaction_id=%" PRIu64 ", while expected: %" PRIu64 ".", - current_id, dnode->props.thin_pool_transaction_id - 1); + trans_id, dnode->props.thin_pool_transaction_id - 1); return 0; /* Nothing to send */ } @@ -2323,7 +2322,7 @@ dm_tree_set_cookie(dnode, 0); } - if (r && !_thin_pool_node_send_messages(dnode, uuid_prefix, uuid_prefix_len)) { + if (r && !_node_send_messages(dnode, uuid_prefix, uuid_prefix_len)) { stack; if (!(dm_tree_deactivate_children(dnode, uuid_prefix, uuid_prefix_len))) log_error("Failed to deactivate %s", dnode->name);
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-19 16:45:03 Modified files: libdm : libdm-deptree.c Log message: Use structure copy Since the code evolved a bit with current structures we could use C to copy struct members. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133 --- LVM2/libdm/libdm-deptree.c 2011/10/19 16:42:14 1.132 +++ LVM2/libdm/libdm-deptree.c 2011/10/19 16:45:02 1.133 @@ -2906,26 +2906,24 @@ if (!_thin_validate_device_id(message->u.m_create_snap.device_id) || !_thin_validate_device_id(message->u.m_create_snap.origin_id)) return_0; - tm->message.u.m_create_snap.device_id = message->u.m_create_snap.device_id; - tm->message.u.m_create_snap.origin_id = message->u.m_create_snap.origin_id; + tm->message.u.m_create_snap = message->u.m_create_snap; break; case DM_THIN_MESSAGE_CREATE_THIN: if (!_thin_validate_device_id(message->u.m_create_thin.device_id)) return_0; - tm->message.u.m_create_thin.device_id = message->u.m_create_thin.device_id; + tm->message.u.m_create_thin = message->u.m_create_thin; tm->expected_errno = EEXIST; break; case DM_THIN_MESSAGE_DELETE: if (!_thin_validate_device_id(message->u.m_delete.device_id)) return_0; - tm->message.u.m_delete.device_id = message->u.m_delete.device_id; + tm->message.u.m_delete = message->u.m_delete; tm->expected_errno = ENODATA; break; case DM_THIN_MESSAGE_TRIM: if (!_thin_validate_device_id(message->u.m_trim.device_id)) return_0; - tm->message.u.m_trim.device_id = message->u.m_trim.device_id; - tm->message.u.m_trim.new_size = message->u.m_trim.new_size; + tm->message.u.m_trim = message->u.m_trim; break; case DM_THIN_MESSAGE_SET_TRANSACTION_ID: if (message->u.m_set_transaction_id.current_id != @@ -2933,10 +2931,7 @@ log_error("New transaction_id must be sequential."); return 0; /* FIXME: Maybe too strict here? */ } - tm->message.u.m_set_transaction_id.current_id = - message->u.m_set_transaction_id.current_id; - tm->message.u.m_set_transaction_id.new_id = - message->u.m_set_transaction_id.new_id; + tm->message.u.m_set_transaction_id = message->u.m_set_transaction_id; break; default: log_error("Unsupported message type %d.", (int) message->type);
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-20 10:35:55 Modified files: libdm : libdm-deptree.c Log message: Add last param 0 for thin-pool So now the table suppression works for thin-pool. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.136&r2=1.137 --- LVM2/libdm/libdm-deptree.c 2011/10/20 10:33:30 1.136 +++ LVM2/libdm/libdm-deptree.c 2011/10/20 10:35:55 1.137 @@ -2086,7 +2086,7 @@ return_0; EMIT_PARAMS(pos, "%s %s %d %" PRIu64 " %s", metadata, pool, seg->data_block_size, seg->low_water_mark, - seg->skip_block_zeroing ? "1 skip_block_zeroing" : ""); + seg->skip_block_zeroing ? "1 skip_block_zeroing" : "0"); break; case SEG_THIN: if (!_build_dev_string(pool, sizeof(pool), seg->pool))
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-20 10:39:07 Modified files: libdm : libdm-deptree.c Log message: Just replace stack, return 0 with return_0 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.137&r2=1.138 --- LVM2/libdm/libdm-deptree.c 2011/10/20 10:35:55 1.137 +++ LVM2/libdm/libdm-deptree.c 2011/10/20 10:39:07 1.138 @@ -2266,19 +2266,13 @@ return_0; /* FIXME Cope if name exists with no uuid? */ - if (!child->info.exists) { - if (!_create_node(child)) { - stack; - return 0; - } - } + if (!child->info.exists && !_create_node(child)) + return_0; - if (!child->info.inactive_table && child->props.segment_count) { - if (!_load_node(child)) { - stack; - return 0; - } - } + if (!child->info.inactive_table && + child->props.segment_count && + !_load_node(child)) + return_0; /* Propagate device size change change */ if (child->props.size_changed)
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-28 20:11:21 Modified files: libdm : libdm-deptree.c Log message: Trying to fix the retry logic There should be no need for retry for our internal devices - it would be hinding our own bug in the tree processing. Update error messages to show also also device name. No WHATS_NEW - in release fix. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.138&r2=1.139 --- LVM2/libdm/libdm-deptree.c 2011/10/20 10:39:07 1.138 +++ LVM2/libdm/libdm-deptree.c 2011/10/28 20:11:21 1.139 @@ -977,7 +977,7 @@ return r; } -static int _check_device_not_in_use(struct dm_info *info) +static int _check_device_not_in_use(const char *name, struct dm_info *info) { if (!info->exists) return 1; @@ -985,8 +985,8 @@ /* If sysfs is not used, use open_count information only. */ if (!*dm_sysfs_dir()) { if (info->open_count) { - log_error("Device %" PRIu32 ":%" PRIu32 " in use", - info->major, info->minor); + log_error("Device %s (%" PRIu32 ":%" PRIu32 ") in use", + name, info->major, info->minor); return 0; } @@ -994,14 +994,14 @@ } if (dm_device_has_holders(info->major, info->minor)) { - log_error("Device %" PRIu32 ":%" PRIu32 " is used " - "by another device.", info->major, info->minor); + log_error("Device %s (%" PRIu32 ":%" PRIu32 ") is used " + "by another device.", name, info->major, info->minor); return 0; } if (dm_device_has_mounted_fs(info->major, info->minor)) { - log_error("Device %" PRIu32 ":%" PRIu32 " contains " - "a filesystem in use.", info->major, info->minor); + log_error("Device %s (%" PRIu32 ":%" PRIu32 ") contains " + "a filesystem in use.", name, info->major, info->minor); return 0; } @@ -1413,8 +1413,27 @@ !info.exists) continue; - if (!_check_device_not_in_use(&info)) - continue; + if (info.open_count) { + /* Skip internal non-toplevel opened nodes */ + if (level) + continue; + + /* When retry is not allowed, error */ + if (!child->dtree->retry_remove) { + log_error("Unable to deactivate open %s (%" PRIu32 + ":%" PRIu32 ")", name, info.major, info.minor); + r = 0; + continue; + } + + /* Check toplevel node for holders/mounted fs */ + if (!_check_device_not_in_use(name, &info)) { + stack; + r = 0; + continue; + } + /* Go on with retry */ + } /* Also checking open_count in parent nodes of presuspend_node */ if ((child->presuspend_node && @@ -1437,7 +1456,7 @@ if (!_deactivate_node(name, info.major, info.minor, &child->dtree->cookie, child->udev_flags, - child->dtree->retry_remove)) { + (level == 0) ? child->dtree->retry_remove : 0)) { log_error("Unable to deactivate %s (%" PRIu32 ":%" PRIu32 ")", name, info.major, info.minor);
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-10-30 22:04:57 Modified files: libdm : libdm-deptree.c Log message: Thin segment transaction_id moved Add a new node flag send_messages that is used to simplify test when to call _node_send_messages(). Add call to _node_send_messages when pool is deeper in the tree. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.140&r2=1.141 --- LVM2/libdm/libdm-deptree.c 2011/10/28 20:19:26 1.140 +++ LVM2/libdm/libdm-deptree.c 2011/10/30 22:04:57 1.141 @@ -170,6 +170,7 @@ struct dm_tree_node *metadata; /* Thin_pool */ struct dm_tree_node *pool; /* Thin_pool, Thin */ struct dm_list thin_messages; /* Thin_pool */ + uint64_t transaction_id; /* Thin_pool */ uint64_t low_water_mark; /* Thin_pool */ uint32_t data_block_size; /* Thin_pool */ unsigned skip_block_zeroing; /* Thin_pool */ @@ -186,8 +187,6 @@ uint32_t read_ahead; uint32_t read_ahead_flags; - uint64_t thin_pool_transaction_id; /* Thin_pool */ - unsigned segment_count; unsigned size_changed; struct dm_list segs; @@ -209,6 +208,9 @@ * avoid starting the mirror resync operation too early. */ unsigned delay_resume_if_new; + + /* Send messages for this node in preload */ + unsigned send_messages; }; /* Two of these used to join two nodes with uses and used_by. */ @@ -1335,8 +1337,7 @@ uint64_t trans_id; const char *uuid; - if ((dnode == &dnode->dtree->root) || /* root has props.segs uninitialized */ - !dnode->info.exists || (dm_list_size(&dnode->props.segs) != 1)) + if (!dnode->info.exists || (dm_list_size(&dnode->props.segs) != 1)) return 1; seg = dm_list_item(dm_list_last(&dnode->props.segs), struct load_segment); @@ -1352,22 +1353,28 @@ } if (!_thin_pool_status_transaction_id(dnode, &trans_id)) - return_0; + goto_bad; - if (trans_id == dnode->props.thin_pool_transaction_id) + if (trans_id == seg->transaction_id) return 1; /* In sync - skip messages */ - if (trans_id != (dnode->props.thin_pool_transaction_id - 1)) { + if (trans_id != (seg->transaction_id - 1)) { log_error("Thin pool transaction_id=%" PRIu64 ", while expected: %" PRIu64 ".", - trans_id, dnode->props.thin_pool_transaction_id - 1); - return 0; /* Nothing to send */ + trans_id, seg->transaction_id - 1); + goto bad; /* Nothing to send */ } dm_list_iterate_items(tmsg, &seg->thin_messages) if (!(_thin_pool_node_message(dnode, tmsg))) - return_0; + goto_bad; return 1; +bad: + /* Try to deactivate */ + if (!(dm_tree_deactivate_children(dnode, uuid_prefix, uuid_prefix_len))) + log_error("Failed to deactivate %s", dnode->name); + + return 0; } /* @@ -2315,7 +2322,11 @@ /* Update cached info */ child->info = newinfo; - + if (child->props.send_messages && + !(r = _node_send_messages(child, uuid_prefix, uuid_prefix_len))) { + stack; + continue; + } /* * Prepare for immediate synchronization with udev and flush all stacked * dev node operations if requested by immediate_dev_node property. But @@ -2325,7 +2336,9 @@ update_devs_flag = 1; } - handle = NULL; + if (r && dnode->props.send_messages && + !(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len))) + stack; if (update_devs_flag) { if (!dm_udev_wait(dm_tree_get_cookie(dnode))) @@ -2875,7 +2888,8 @@ if (!_link_tree_nodes(node, seg->pool)) return_0; - node->props.thin_pool_transaction_id = transaction_id; // compare on resume + node->props.send_messages = 1; + seg->transaction_id = transaction_id; seg->low_water_mark = low_water_mark; seg->data_block_size = data_block_size; seg->skip_block_zeroing = skip_block_zeroing;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-11-04 12:39:45 Modified files: libdm : libdm-deptree.c Log message: Thin fix condition check for transation_id id2 must be checked. (missed in yesterday commit set). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.144&r2=1.145 --- LVM2/libdm/libdm-deptree.c 2011/11/03 14:45:01 1.144 +++ LVM2/libdm/libdm-deptree.c 2011/11/04 12:39:45 1.145 @@ -2980,11 +2980,11 @@ tm->message.u.m_trim.new_size = id2; break; case DM_THIN_MESSAGE_SET_TRANSACTION_ID: - if ((id1 + 1) != id2) { + if ((id1 + 1) != id2) { log_error("New transaction id must be sequential."); return 0; /* FIXME: Maybe too strict here? */ } - if (id1 != seg->transaction_id) { + if (id2 != seg->transaction_id) { log_error("Current transaction id is different from thin pool."); return 0; /* FIXME: Maybe too strict here? */ }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-01-19 15:22:32 Modified files: libdm : libdm-deptree.c Log message: Thin handle empty thin volume case Report both values as 0 in case the volume is unused. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.149&r2=1.150 --- LVM2/libdm/libdm-deptree.c 2012/01/19 15:21:23 1.149 +++ LVM2/libdm/libdm-deptree.c 2012/01/19 15:22:32 1.150 @@ -3143,7 +3143,10 @@ return 0; } - if (sscanf(params, "%" PRIu64 " %" PRIu64, + if (strchr(params, '-')) { + s->mapped_sectors = 0; + s->highest_mapped_sector = 0; + } else if (sscanf(params, "%" PRIu64 " %" PRIu64, &s->mapped_sectors, &s->highest_mapped_sector) != 2) { log_error("Failed to parse thin params: %s.", params);
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-01-25 08:46:22 Modified files: libdm : libdm-deptree.c Log message: Thin send messages on activation resume code path Using PRELOAD part would lead to problems when the problem would happen before vg_write and vg_commit. Also this change is necessary for snapshot creation sequence. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.151&r2=1.152 --- LVM2/libdm/libdm-deptree.c 2012/01/23 17:46:31 1.151 +++ LVM2/libdm/libdm-deptree.c 2012/01/25 08:46:21 1.152 @@ -1768,6 +1768,17 @@ } } + /* + * FIXME: Implement delayed error reporting + * activation should be stopped only in the case, + * the submission of transation_id message fails, + * resume should continue further, just whole command + * has to report failure. + */ + if (r && dnode->props.send_messages && + !(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len))) + stack; + handle = NULL; return r; @@ -2434,11 +2445,6 @@ /* Update cached info */ child->info = newinfo; - if (child->props.send_messages && - !(r = _node_send_messages(child, uuid_prefix, uuid_prefix_len))) { - stack; - continue; - } /* * Prepare for immediate synchronization with udev and flush all stacked * dev node operations if requested by immediate_dev_node property. But @@ -2448,23 +2454,12 @@ update_devs_flag = 1; } - if (r && dnode->props.send_messages && - !(r = _node_send_messages(dnode, uuid_prefix, uuid_prefix_len))) - stack; - if (update_devs_flag) { if (!dm_udev_wait(dm_tree_get_cookie(dnode))) stack; dm_tree_set_cookie(dnode, 0); } - if (r && !_node_send_messages(dnode, uuid_prefix, uuid_prefix_len)) { - stack; - if (!(dm_tree_deactivate_children(dnode, uuid_prefix, uuid_prefix_len))) - log_error("Failed to deactivate %s", dnode->name); - r = 0; - } - return r; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-03-02 21:53:17 Modified files: libdm : libdm-deptree.c Log message: Support 16GB for thin pool metadata Add some hack math to allow 16GB devices to be passed as thinpool metadata. Since kernel has put in limit to not allow which are just bigger then some predefined constant in kernel but not matching 16GB so any device bigger is rejected. FIXME: Current code still might need more tweaks to be more generic. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.160&r2=1.161 --- LVM2/libdm/libdm-deptree.c 2012/03/02 21:43:27 1.160 +++ LVM2/libdm/libdm-deptree.c 2012/03/02 21:53:17 1.161 @@ -2968,7 +2968,15 @@ uint64_t low_water_mark, unsigned skip_block_zeroing) { - struct load_segment *seg; + struct load_segment *seg, *mseg; + uint64_t devsize = 0; + /* + * Max supported size for thin pool metadata device + * Limitation is hardcoded into kernel and bigger + * device size is not accepted. (16978542592) + */ + const uint64_t max_metadata_size = + 255ULL * (1 << 14) * (4096 / (1 << 9)) - 256 * 1024; if (data_block_size < DM_THIN_MIN_DATA_BLOCK_SIZE) { log_error("Data block size %u is lower then %u sectors.", @@ -2993,6 +3001,18 @@ if (!_link_tree_nodes(node, seg->metadata)) return_0; + /* FIXME: more complex target may need more tweaks */ + dm_list_iterate_items(mseg, &seg->metadata->props.segs) { + devsize += mseg->size; + if (devsize > max_metadata_size) { + log_debug("Ignoring %" PRIu64 " of device.", + devsize - max_metadata_size); + mseg->size -= (devsize - max_metadata_size); + devsize = max_metadata_size; + /* FIXME: drop remaining segs */ + } + } + if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree, pool_uuid))) { log_error("Missing pool uuid %s.", pool_uuid); return 0;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-03-04 16:05:42 Modified files: libdm : libdm-deptree.c Log message: Remove part of FIXME (and reindent a code below) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.161&r2=1.162 --- LVM2/libdm/libdm-deptree.c 2012/03/02 21:53:17 1.161 +++ LVM2/libdm/libdm-deptree.c 2012/03/04 16:05:42 1.162 @@ -1590,16 +1590,12 @@ if (child->callback && !child->callback(child, DM_NODE_CALLBACK_DEACTIVATED, - child->callback_data)) { - r = 0; - // FIXME: break tree shutdown or continue? - // hmm what about _node_clear_table()? - } + child->callback_data)) + r = 0; // FIXME: _node_clear_table() without callback ? - if (dm_tree_node_num_children(child, 0)) { - if (!_dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len, level + 1)) - return_0; - } + if (dm_tree_node_num_children(child, 0) && + !_dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len, level + 1)) + return_0; } return r;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2012-05-15 14:10:54 Modified files: libdm : libdm-deptree.c Log message: indicate when deptree detects but ignores size change in debug msg Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.163&r2=1.164 --- LVM2/libdm/libdm-deptree.c 2012/03/04 17:36:24 1.163 +++ LVM2/libdm/libdm-deptree.c 2012/05/15 14:10:54 1.164 @@ -2364,9 +2364,6 @@ existing_table_size = dm_task_get_existing_table_size(dmt); if ((dnode->props.size_changed = (existing_table_size == seg_start) ? 0 : 1)) { - log_debug("Table size changed from %" PRIu64 " to %" - PRIu64 " for %s", existing_table_size, - seg_start, dnode->name); /* * Kernel usually skips size validation on zero-length devices * now so no need to preload them. @@ -2374,6 +2371,11 @@ /* FIXME In which kernel version did this begin? */ if (!existing_table_size && dnode->props.delay_resume_if_new) dnode->props.size_changed = 0; + + log_debug("Table size changed from %" PRIu64 " to %" + PRIu64 " for %s.%s", existing_table_size, + seg_start, dnode->name, + dnode->props.size_changed ? "" : " (Ignoring.)"); } }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2012-05-15 20:03:13 Modified files: libdm : libdm-deptree.c Log message: add major:minor to table size changed debug message Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165 --- LVM2/libdm/libdm-deptree.c 2012/05/15 14:10:54 1.164 +++ LVM2/libdm/libdm-deptree.c 2012/05/15 20:03:12 1.165 @@ -2373,8 +2373,9 @@ dnode->props.size_changed = 0; log_debug("Table size changed from %" PRIu64 " to %" - PRIu64 " for %s.%s", existing_table_size, - seg_start, dnode->name, + PRIu64 " for %s (%" PRIu32 ":%" PRIu32 ").%s", + existing_table_size, seg_start, dnode->name, + dnode->info.major, dnode->info.minor, dnode->props.size_changed ? "" : " (Ignoring.)"); } }