public inbox for lvm2-cvs@sourceware.org help / color / mirror / Atom feed
From: agk@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ... Date: Thu, 30 Jun 2011 18:25:00 -0000 [thread overview] Message-ID: <20110630182519.16653.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-30 18:25:19 Modified files: . : WHATS_NEW lib/activate : activate.c dev_manager.c lib/metadata : lv_manip.c metadata.h Log message: When suspending, automatically preload newly-visible existing LVs Let's find out if this makes things better or worse overall... Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2033&r2=1.2034 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.203&r2=1.204 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.220&r2=1.221 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.265&r2=1.266 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.246&r2=1.247 --- LVM2/WHATS_NEW 2011/06/30 09:24:58 1.2033 +++ LVM2/WHATS_NEW 2011/06/30 18:25:18 1.2034 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + When suspending, automatically preload newly-visible existing LVs. Report internal error when parameters are missing on table load. Teardown any stray devices with $COMMON_PREFIX during test runs. Reinstate correct permissions when creating mirrors. [2.02.85] --- LVM2/lib/activate/activate.c 2011/06/22 21:31:21 1.203 +++ LVM2/lib/activate/activate.c 2011/06/30 18:25:18 1.204 @@ -1097,6 +1097,26 @@ #endif } +struct detached_lv_data { + struct logical_volume *lv_pre; + struct lv_activate_opts *laopts; + int *flush_required; +}; + +static int _preload_detached_lv(struct cmd_context *cmd, struct logical_volume *lv, void *data) +{ + struct detached_lv_data *detached = data; + struct lv_list *lvl_pre; + + if ((lvl_pre = find_lv_in_vg(detached->lv_pre->vg, lv->name))) { + if (lv_is_visible(lvl_pre->lv) && lv_is_active(lv) && + !_lv_preload(lvl_pre->lv, detached->laopts, detached->flush_required)) + return_0; + } + + return 1; +} + static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, struct lv_activate_opts *laopts, int error_if_not_suspended) { @@ -1105,6 +1125,7 @@ struct seg_list *sl; struct lvinfo info; int r = 0, lockfs = 0, flush_required = 0; + struct detached_lv_data detached; if (!activation()) return 1; @@ -1172,9 +1193,21 @@ } if (!_lv_preload(lvl_pre->lv, laopts, &flush_required)) goto_out; - } else if (!_lv_preload(lv_pre, laopts, &flush_required)) - /* FIXME Revert preloading */ - goto_out; + } else { + if (!_lv_preload(lv_pre, laopts, &flush_required)) + /* FIXME Revert preloading */ + goto_out; + + /* + * Search for existing LVs that have become detached and preload them. + */ + detached.lv_pre = lv_pre; + detached.laopts = laopts; + detached.flush_required = &flush_required; + + if (!for_each_sub_lv(cmd, lv, &_preload_detached_lv, &detached)) + goto_out; + } } if (!monitor_dev_for_events(cmd, lv, laopts, 0)) --- LVM2/lib/activate/dev_manager.c 2011/06/17 14:50:53 1.220 +++ LVM2/lib/activate/dev_manager.c 2011/06/30 18:25:18 1.221 @@ -1096,11 +1096,11 @@ return NULL; } - if (!_add_lv_to_dtree(dm, dtree, lv, origin_only)) + if (!_add_lv_to_dtree(dm, dtree, lv, lv_is_origin(lv) ? origin_only : 0)) goto_bad; /* Add any snapshots of this LV */ - if (!origin_only) + if (!origin_only && lv_is_origin(lv)) dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) if (!_add_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow, 0)) goto_bad; @@ -1714,7 +1714,7 @@ /* Restore fs cookie */ dm_tree_set_cookie(root, fs_get_cookie()); - if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, laopts->origin_only ? "real" : NULL))) + if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, (lv_is_origin(lv) && laopts->origin_only) ? "real" : NULL))) goto_out; /* Only process nodes with uuid of "LVM-" plus VG id. */ @@ -1744,7 +1744,7 @@ case PRELOAD: case ACTIVATE: /* Add all required new devices to tree */ - if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, laopts->origin_only ? "real" : NULL)) + if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, (lv_is_origin(lv) && laopts->origin_only) ? "real" : NULL)) goto_out; /* Preload any devices required before any suspensions */ --- LVM2/lib/metadata/lv_manip.c 2011/06/29 17:05:53 1.265 +++ LVM2/lib/metadata/lv_manip.c 2011/06/30 18:25:18 1.266 @@ -2317,7 +2317,7 @@ return _rename_single_lv(lv, new_name); } -/* Callback for _for_each_sub_lv */ +/* Callback for for_each_sub_lv */ static int _rename_cb(struct cmd_context *cmd, struct logical_volume *lv, void *data) { @@ -2327,32 +2327,31 @@ } /* - * Loop down sub LVs and call "func" for each. - * "func" is responsible to log necessary information on failure. + * Loop down sub LVs and call fn for each. + * fn is responsible to log necessary information on failure. */ -static int _for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv, - int (*func)(struct cmd_context *cmd, - struct logical_volume *lv, - void *data), - void *data) +int for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv, + int (*fn)(struct cmd_context *cmd, + struct logical_volume *lv, void *data), + void *data) { struct logical_volume *org; struct lv_segment *seg; uint32_t s; if (lv_is_cow(lv) && lv_is_virtual_origin(org = origin_from_cow(lv))) - if (!func(cmd, org, data)) + if (!fn(cmd, org, data)) return_0; dm_list_iterate_items(seg, &lv->segments) { - if (seg->log_lv && !func(cmd, seg->log_lv, data)) + if (seg->log_lv && !fn(cmd, seg->log_lv, data)) return_0; for (s = 0; s < seg->area_count; s++) { if (seg_type(seg, s) != AREA_LV) continue; - if (!func(cmd, seg_lv(seg, s), data)) + if (!fn(cmd, seg_lv(seg, s), data)) return_0; - if (!_for_each_sub_lv(cmd, seg_lv(seg, s), func, data)) + if (!for_each_sub_lv(cmd, seg_lv(seg, s), fn, data)) return_0; } } @@ -2397,7 +2396,7 @@ /* rename sub LVs */ lv_names.old = lv->name; lv_names.new = new_name; - if (!_for_each_sub_lv(cmd, lv, _rename_cb, (void *) &lv_names)) + if (!for_each_sub_lv(cmd, lv, _rename_cb, (void *) &lv_names)) return 0; /* rename main LV */ --- LVM2/lib/metadata/metadata.h 2011/06/17 14:30:58 1.246 +++ LVM2/lib/metadata/metadata.h 2011/06/30 18:25:18 1.247 @@ -441,6 +441,11 @@ int remove_seg_from_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg); struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv); +int for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv, + int (*fn)(struct cmd_context *cmd, + struct logical_volume *lv, void *data), + void *data); + /* * Calculate readahead from underlying PV devices */
next reply other threads:[~2011-06-30 18:25 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-06-30 18:25 agk [this message] -- strict thread matches above, loose matches on Subject: below -- 2012-03-23 9:58 zkabelac 2012-02-23 22:42 zkabelac 2012-01-25 13:10 zkabelac 2012-01-25 8:48 zkabelac 2011-11-18 19:31 zkabelac 2011-10-06 14:55 jbrassow 2011-10-03 18:37 zkabelac 2011-09-22 17:33 prajnoha 2011-06-22 21:31 jbrassow 2011-06-17 14:22 zkabelac 2011-06-17 14:14 zkabelac 2011-02-04 19:14 zkabelac 2011-02-03 1:24 zkabelac 2010-08-17 1:16 agk 2010-02-24 20:01 mbroz 2010-02-24 20:00 mbroz 2009-10-01 0:35 agk 2009-06-01 12:43 mbroz 2009-05-20 11:09 mbroz 2009-05-20 9:52 mbroz 2009-02-28 0:54 agk 2008-12-19 14:22 prajnoha 2008-04-07 10:23 mbroz 2008-01-30 14:00 agk 2007-11-12 20:51 agk 2007-07-02 11:17 wysochanski 2007-03-08 21:08 agk 2006-10-03 17:55 agk 2006-08-21 12:55 agk 2006-08-08 21:20 agk 2005-12-19 21:01 agk 2005-10-25 19:08 agk 2005-10-19 13:59 agk 2005-06-01 16:51 agk 2005-01-12 22:58 agk
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20110630182519.16653.qmail@sourceware.org \ --to=agk@sourceware.org \ --cc=lvm-devel@redhat.com \ --cc=lvm2-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).