From 9cd3426d3aaed87562ae2766d84858e8fb8257c6 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Tue, 8 Aug 2006 21:20:00 +0000 Subject: [PATCH] Fix missing lockfs on first snapshot creation. --- WHATS_NEW | 1 + lib/activate/activate.c | 11 ++++++++--- lib/activate/dev_manager.c | 10 ++++++---- lib/activate/dev_manager.h | 3 ++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 2a50ddfd4..b49ead820 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.08 - ================================ + Fix missing lockfs on first snapshot creation. Add unreliable --trustcache option to reporting commands. Fix locking for mimage removal. Fix clvmd_init_rhel4 'status' exit code. diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 0ec914a48..c9a0c8f07 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -528,7 +528,7 @@ static int _lv_deactivate(struct logical_volume *lv) return r; } -static int _lv_suspend_lv(struct logical_volume *lv) +static int _lv_suspend_lv(struct logical_volume *lv, int lockfs) { int r; struct dev_manager *dm; @@ -536,7 +536,7 @@ static int _lv_suspend_lv(struct logical_volume *lv) if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) return_0; - if (!(r = dev_manager_suspend(dm, lv))) + if (!(r = dev_manager_suspend(dm, lv, lockfs))) stack; dev_manager_destroy(dm); @@ -637,6 +637,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, { struct logical_volume *lv, *lv_pre; struct lvinfo info; + int lockfs = 0; if (!activation()) return 1; @@ -672,7 +673,11 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, stack; memlock_inc(); - if (!_lv_suspend_lv(lv)) { + + if (lv_is_origin(lv_pre) || lv_is_cow(lv_pre)) + lockfs = 1; + + if (!_lv_suspend_lv(lv, lockfs)) { memlock_dec(); fs_unlock(); return 0; diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 9056f03ba..6d9407996 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -37,6 +37,7 @@ typedef enum { ACTIVATE, DEACTIVATE, SUSPEND, + SUSPEND_WITH_LOCKFS, CLEAN } action_t; @@ -984,8 +985,8 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv, actio goto_out; break; case SUSPEND: - if (!lv_is_origin(lv) && !lv_is_cow(lv)) - dm_tree_skip_lockfs(root); + dm_tree_skip_lockfs(root); + case SUSPEND_WITH_LOCKFS: if (!dm_tree_suspend_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1)) goto_out; break; @@ -1049,9 +1050,10 @@ int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv) return r; } -int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv) +int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv, + int lockfs) { - return _tree_action(dm, lv, SUSPEND); + return _tree_action(dm, lv, lockfs ? SUSPEND_WITH_LOCKFS : SUSPEND); } /* diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h index 6eb82788a..851561e15 100644 --- a/lib/activate/dev_manager.h +++ b/lib/activate/dev_manager.h @@ -47,7 +47,8 @@ int dev_manager_snapshot_percent(struct dev_manager *dm, int dev_manager_mirror_percent(struct dev_manager *dm, struct logical_volume *lv, int wait, float *percent, uint32_t *event_nr); -int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv); +int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv, + int lockfs); int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv); int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv); int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv);