From 56cab8cc037fc4d31085705987b3a4c04d5e5938 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 3 Feb 2011 01:16:35 +0000 Subject: [PATCH] Synchronize with udev for lv_info In case the open_count is requested via lv_info - check if there are any udev operations in-progress - and wait for them before checking for lv_info --- lib/activate/activate.c | 12 ++++++++++++ lib/activate/fs.c | 5 +++++ lib/activate/fs.h | 1 + 3 files changed, 18 insertions(+) diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 3670ea4a5..dd40acc06 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -460,6 +460,18 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, unsigned o if (!activation()) return 0; + /* + * If open_count info is requested and we have to be sure our own udev + * transactions are finished + * For non-clustered locking type we are only interested for non-delete operation + * in progress - as only those could lead to opened files + */ + if (with_open_count) { + if (locking_is_clustered()) + sync_local_dev_names(cmd); /* Wait to have udev in sync */ + else if (fs_has_non_delete_ops()) + fs_unlock(); /* For non clustered - wait if there are non-delete ops */ + } if (!dev_manager_info(lv->vg->cmd->mem, lv, origin_only ? "real" : NULL, with_open_count, with_read_ahead, &dminfo, &info->read_ahead)) diff --git a/lib/activate/fs.c b/lib/activate/fs.c index ae94763ea..373d1599d 100644 --- a/lib/activate/fs.c +++ b/lib/activate/fs.c @@ -422,3 +422,8 @@ void fs_set_cookie(uint32_t cookie) { _fs_cookie = cookie; } + +int fs_has_non_delete_ops(void) +{ + return _other_fs_ops(FS_DEL); +} diff --git a/lib/activate/fs.h b/lib/activate/fs.h index 17ecedf5f..43e2846a8 100644 --- a/lib/activate/fs.h +++ b/lib/activate/fs.h @@ -32,5 +32,6 @@ int fs_rename_lv(struct logical_volume *lv, const char *dev, /* void fs_unlock(void); moved to activate.h */ uint32_t fs_get_cookie(void); void fs_set_cookie(uint32_t cookie); +int fs_has_non_delete_ops(void); #endif -- 2.43.5