#include "tools.h"
+#include "lvmetad.h"
+#include "lvmcache.h"
+
int pv_max_name_len = 0;
int vg_max_name_len = 0;
static void _pvscan_display_single(struct cmd_context *cmd,
struct physical_volume *pv,
- void *handle __attribute((unused)))
+ void *handle __attribute__((unused)))
{
- char uuid[64] __attribute((aligned(8)));
+ char uuid[64] __attribute__((aligned(8)));
unsigned vg_name_len = 0;
char pv_tmp_name[NAME_LEN] = { 0, };
pv_pe_size(pv)));
}
-int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
- char **argv __attribute((unused)))
+static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
+{
+ int ret = ECMD_PROCESSED;
+
+ if (!argc) {
+ log_error("List of Physical Volumes to be cached by the lvmetad daemon required.");
+ return EINVALID_CMD_LINE;
+ }
+
+ if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ)) {
+ log_error("Unable to obtain global lock.");
+ return ECMD_FAILED;
+ }
+
+ log_verbose("Using physical volume(s) on command line");
+ while (argc--) {
+ if (!pvscan_lvmetad_single(cmd, *argv++)) {
+ ret = ECMD_FAILED;
+ break;
+ }
+ if (sigint_caught())
+ break;
+ }
+
+ unlock_vg(cmd, VG_GLOBAL);
+
+ return ret;
+}
+
+int pvscan(struct cmd_context *cmd, int argc, char **argv)
{
int new_pvs_found = 0;
int pvs_found = 0;
pv_max_name_len = 0;
vg_max_name_len = 0;
+ if (arg_count(cmd, cache_ARG))
+ return _pvscan_lvmetad(cmd, argc, argv);
+
if (arg_count(cmd, novolumegroup_ARG) && arg_count(cmd, exported_ARG)) {
log_error("Options -e and -n are incompatible");
return EINVALID_CMD_LINE;
pv_max_name_len += 2;
vg_max_name_len += 2;
- dm_list_iterate_items(pvl, pvslist)
- _pvscan_display_single(cmd, pvl->pv, NULL);
+ dm_list_iterate_items(pvl, pvslist) {
+ _pvscan_display_single(cmd, pvl->pv, NULL);
+ free_pv_fid(pvl->pv);
+ }
if (!pvs_found) {
log_print("No matching physical volumes found");