From c55b141005e4b0354267b77d9c52bde5d5a8d9cb Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Mon, 30 Jan 2006 23:36:04 +0000 Subject: [PATCH] Add dm_tree_skip_lockfs. --- WHATS_NEW_DM | 1 + libdm/.exported_symbols | 1 + libdm/libdevmapper.h | 7 +++++++ libdm/libdm-deptree.c | 18 +++++++++++++++--- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 7eb35d52d..f67c32481 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.03 - ============================ + Add dm_tree_skip_lockfs. Fix dm_strdup debug definition. Fix hash function to avoid using a negative array offset. Don't inline _find in hash.c and tidy signed/unsigned etc. diff --git a/libdm/.exported_symbols b/libdm/.exported_symbols index 0d798cd23..9dfc700fe 100644 --- a/libdm/.exported_symbols +++ b/libdm/.exported_symbols @@ -60,6 +60,7 @@ dm_tree_node_add_striped_target dm_tree_node_add_mirror_target dm_tree_node_add_mirror_target_log dm_tree_node_add_target_area +dm_tree_skip_lockfs dm_is_dm_major dm_mknodes dm_malloc_aux diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 535e4a098..fa9a26d6f 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -299,6 +299,13 @@ int dm_tree_suspend_children(struct dm_tree_node *dnode, const char *uuid_prefix, size_t uuid_prefix_len); +/* + * Skip the filesystem sync when suspending. + * Does nothing with other functions. + * Use this when no snapshots are involved. + */ +void dm_tree_skip_lockfs(struct dm_tree_node *dnode); + /* * Is the uuid prefix present in the tree? * Only returns 0 if every node was checked successfully. diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index e25205489..f497874b3 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -128,6 +128,7 @@ struct dm_tree { struct dm_hash_table *devs; struct dm_hash_table *uuids; struct dm_tree_node root; + int skip_lockfs; /* 1 skips lockfs (for non-snapshots) */ }; /* FIXME Consider exporting this */ @@ -159,6 +160,7 @@ struct dm_tree *dm_tree_create(void) dtree->root.dtree = dtree; list_init(&dtree->root.uses); list_init(&dtree->root.used_by); + dtree->skip_lockfs = 0; if (!(dtree->mem = dm_pool_create("dtree", 1024))) { log_error("dtree pool creation failed"); @@ -900,12 +902,13 @@ static int _resume_node(const char *name, uint32_t major, uint32_t minor, } static int _suspend_node(const char *name, uint32_t major, uint32_t minor, - struct dm_info *newinfo) + int skip_lockfs, struct dm_info *newinfo) { struct dm_task *dmt; int r; - log_verbose("Suspending %s (%" PRIu32 ":%" PRIu32 ")", name, major, minor); + log_verbose("Suspending %s (%" PRIu32 ":%" PRIu32 ")%s", name, major, + minor, skip_lockfs ? "" : " with filesystem sync."); if (!(dmt = dm_task_create(DM_DEVICE_SUSPEND))) { log_error("Suspend dm_task creation failed for %s", name); @@ -921,6 +924,9 @@ static int _suspend_node(const char *name, uint32_t major, uint32_t minor, if (!dm_task_no_open_count(dmt)) log_error("Failed to disable open_count"); + if (skip_lockfs && !dm_task_skip_lockfs(dmt)) + log_error("Failed to set skip_lockfs flag."); + if ((r = dm_task_run(dmt))) r = dm_task_get_info(dmt, newinfo); @@ -979,6 +985,11 @@ int dm_tree_deactivate_children(struct dm_tree_node *dnode, return 1; } +void dm_tree_skip_lockfs(struct dm_tree_node *dnode) +{ + dnode->dtree->skip_lockfs = 1; +} + int dm_tree_suspend_children(struct dm_tree_node *dnode, const char *uuid_prefix, size_t uuid_prefix_len) @@ -1019,7 +1030,8 @@ int dm_tree_suspend_children(struct dm_tree_node *dnode, !info.exists) continue; - if (!_suspend_node(name, info.major, info.minor, &newinfo)) { + if (!_suspend_node(name, info.major, info.minor, + child->dtree->skip_lockfs, &newinfo)) { log_error("Unable to suspend %s (%" PRIu32 ":%" PRIu32 ")", name, info.major, info.minor); -- 2.43.5