stack;
}
+/*
+ * This is used when pvscan --cache sees a new PV, which
+ * means we should refresh hints. It could catch some case
+ * which the other methods of detecting stale hints may miss.
+ */
+void invalidate_hints(struct cmd_context *cmd)
+{
+ /* No commands are using hints. */
+ if (!cmd->enable_hints)
+ return;
+
+ if (!_touch_newhints())
+ stack;
+}
+
/*
* Currently, all the commands using hints (ALLOW_HINTS) take an optional or
* required first position arg of a VG name or LV name. If some other command
void clear_hint_file(struct cmd_context *cmd);
+void invalidate_hints(struct cmd_context *cmd);
+
int get_hints(struct cmd_context *cmd, struct dm_list *hints, int *newhints,
struct dm_list *devs_in, struct dm_list *devs_out);
#
# pvs (no change), pvscan (hints are new), pvs (no change)
+rm $HINTS $PREV
pvs
cp $HINTS $PREV
-diff $HINTS $PREV
-cp $HINTS $PREV
+# this next pvscan recreates the hints file
pvscan --cache
+# the only diff will be "Created by pvscan ..." vs "Created by pvs ..."
not diff $HINTS $PREV
cp $HINTS $PREV
pvs
grep 'Created by pvscan' $HINTS
# dev4 is a PV not used by a VG, dev5 is not a PV
# using dd to copy skirts hint tracking so dev5 won't be seen
+# (unless the dd triggers udev which triggers pvscan --cache $dev5,
+# but I've not seen that happen in tests so far.)
dd if="$dev4" of="$dev5" bs=1M
# this pvs won't see dev5
pvs > foo
grep "$dev4" $HINTS
not grep "$dev5" $HINTS
+#
+# Test pvscan --cache <dev> forces refresh
+#
+
+rm $HINTS $PREV
+pvs
+cp $HINTS $PREV
+# this next pvscan creates newhints to trigger a refresh
+pvscan --cache "$dev5"
+cat $NEWHINTS
+# this next pvs creates new hints
+pvs
+# the only diff will be "Created by..."
+not diff $HINTS $PREV
+
+
#
# Test incorrect dev-to-pvid info in hints is detected
#include "lib/cache/lvmcache.h"
#include "lib/metadata/metadata.h"
+#include "lib/label/hints.h"
#include <dirent.h>
int do_activate = arg_is_set(cmd, activate_ARG);
int all_vgs = 0;
int add_errors = 0;
+ int add_single_count = 0;
int ret = ECMD_PROCESSED;
dm_list_init(&single_devs);
if (dev->flags & DEV_FILTER_OUT_SCAN)
continue;
+ add_single_count++;
+
/*
* Devices that exist and pass the lvmetad filter
* are online.
if (dev->flags & DEV_FILTER_OUT_SCAN)
continue;
+ add_single_count++;
+
/*
* Devices that exist and pass the lvmetad filter
* are online.
}
activate:
+ /*
+ * When a new PV appears, the system runs pvscan --cache dev.
+ * This also means that existing hints are invalid, and
+ * we can force hints to be refreshed here. There may be
+ * cases where this detects a change that the other methods
+ * of detecting invalid hints doesn't catch.
+ */
+ if (add_single_count)
+ invalidate_hints(cmd);
+
/*
* Special case: pvscan --cache -aay dev
* where dev has no VG metadata, and it's the final device to