From 3b604e5c8e505138fc86e009375fd33160ab84ff Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 19 Sep 2013 14:05:55 +0200 Subject: [PATCH] lvinfo: allow to use lv_info with NULL info When NULL info struct is passed in - function is usable as a quick query for lv_is_active_locally() - with a bonus we may query for layered device. So it could be seen as a more efficient lv_is_active_locally(). --- WHATS_NEW | 4 ++++ lib/activate/activate.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index e9696202f..cca4c0e99 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,3 +1,7 @@ +Version 2.02.102 +====================================== + Extend lv_info() for more efficient lv_is_active_locally() check. + Version 2.02.101 - 20th September 2013 ====================================== Fix 3-thread clvmd deadlock triggered by cleanup on EOF from client. diff --git a/lib/activate/activate.c b/lib/activate/activate.c index ecd35b22f..e4d9b49d8 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -616,6 +616,7 @@ int target_present(struct cmd_context *cmd, const char *target_name, /* * Returns 1 if info structure populated, else 0 on failure. + * When lvinfo* is NULL, it returns 1 if the device is locally active, 0 otherwise. */ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_layer, struct lvinfo *info, int with_open_count, int with_read_ahead) @@ -640,9 +641,12 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la if (!dev_manager_info(lv->vg->cmd->mem, lv, (use_layer) ? lv_layer(lv) : NULL, with_open_count, with_read_ahead, - &dminfo, &info->read_ahead)) + &dminfo, (info) ? &info->read_ahead : NULL)) return_0; + if (!info) + return dminfo.exists; + info->exists = dminfo.exists; info->suspended = dminfo.suspended; info->open_count = dminfo.open_count;