zfsd: listen for sysevent.fs.zfs instead of misc.fs.zfs

At some point the names of these devd events changed.  Probably it
happened when importing OpenZFS.  Before that, FreeBSD's sysevent_alloc
method didn't create a "class" nvpair in the event, which led to
log_sysevent using the event's ev_subclass field as its type.

Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D39437

(cherry picked from commit 92642bba4d)

Fix zfsd unittests after 92642bba4d

At the time we ensured that the more important functional tests were
working, but neglected to update the unit tests.

Sponsored by:	Axcient

(cherry picked from commit 2a0c0aea42)
This commit is contained in:
Alan Somers 2023-04-03 15:45:55 -06:00
parent 3961edfe13
commit b969a40cdf
4 changed files with 12 additions and 12 deletions

View file

@ -357,7 +357,7 @@ CaseFile::ReEvaluate(const ZfsEvent &event)
{
bool consumed(false);
if (event.Value("type") == "misc.fs.zfs.vdev_remove") {
if (event.Value("type") == "sysevent.fs.zfs.vdev_remove") {
/*
* The Vdev we represent has been removed from the
* configuration. This case is no longer of value.
@ -365,12 +365,12 @@ CaseFile::ReEvaluate(const ZfsEvent &event)
Close();
return (/*consumed*/true);
} else if (event.Value("type") == "misc.fs.zfs.pool_destroy") {
} else if (event.Value("type") == "sysevent.fs.zfs.pool_destroy") {
/* This Pool has been destroyed. Discard the case */
Close();
return (/*consumed*/true);
} else if (event.Value("type") == "misc.fs.zfs.config_sync") {
} else if (event.Value("type") == "sysevent.fs.zfs.config_sync") {
RefreshVdevState();
if (VdevState() < VDEV_STATE_HEALTHY)
consumed = ActivateSpare();

View file

@ -397,7 +397,7 @@ TEST_F(ZfsEventTest, ProcessPoolEventGetsCalled)
{
string evString("!system=ZFS "
"subsystem=ZFS "
"type=misc.fs.zfs.vdev_remove "
"type=sysevent.fs.zfs.vdev_remove "
"pool_name=foo "
"pool_guid=9756779504028057996 "
"vdev_guid=1631193447431603339 "
@ -512,7 +512,7 @@ TEST_F(CaseFileTest, PoolDestroy)
"pool_guid=456 "
"subsystem=ZFS "
"timestamp=1348867914 "
"type=misc.fs.zfs.pool_destroy ");
"type=sysevent.fs.zfs.pool_destroy ");
m_event = Event::CreateEvent(*m_eventFactory, evString);
ZfsEvent *zfs_event = static_cast<ZfsEvent*>(m_event);
EXPECT_CALL(*m_caseFile, Close());
@ -682,7 +682,7 @@ string ReEvaluateByGuidTest::s_evString(
"pool_name=foo "
"subsystem=ZFS "
"timestamp=1360620391 "
"type=misc.fs.zfs.config_sync");
"type=sysevent.fs.zfs.config_sync");
/*

View file

@ -245,7 +245,7 @@ ZfsDaemon::BuildCaseFiles()
snprintf(evString, 160, "!system=ZFS subsystem=ZFS "
"type=misc.fs.zfs.config_sync sub_type=synthesized "
"type=sysevent.fs.zfs.config_sync sub_type=synthesized "
"pool_name=%s pool_guid=%" PRIu64 "\n", poolname, poolGUID);
event = Event::CreateEvent(GetFactory(), string(evString));
if (event != NULL) {

View file

@ -279,7 +279,7 @@ ZfsEvent::Process() const
}
/* On config syncs, replay any queued events first. */
if (Value("type").find("misc.fs.zfs.config_sync") == 0) {
if (Value("type").find("sysevent.fs.zfs.config_sync") == 0) {
/*
* Even if saved events are unconsumed the second time
* around, drop them. Any events that still can't be
@ -290,7 +290,7 @@ ZfsEvent::Process() const
CaseFile::ReEvaluateByGuid(PoolGUID(), *this);
}
if (Value("type").find("misc.fs.zfs.") == 0) {
if (Value("type").find("sysevent.fs.zfs.") == 0) {
/* Configuration changes, resilver events, etc. */
ProcessPoolEvent();
return (false);
@ -403,7 +403,7 @@ ZfsEvent::ProcessPoolEvent() const
bool degradedDevice(false);
/* The pool is destroyed. Discard any open cases */
if (Value("type") == "misc.fs.zfs.pool_destroy") {
if (Value("type") == "sysevent.fs.zfs.pool_destroy") {
Log(LOG_INFO);
CaseFile::ReEvaluateByGuid(PoolGUID(), *this);
return;
@ -418,7 +418,7 @@ ZfsEvent::ProcessPoolEvent() const
Log(LOG_INFO);
caseFile->ReEvaluate(*this);
}
else if (Value("type") == "misc.fs.zfs.resilver_finish")
else if (Value("type") == "sysevent.fs.zfs.resilver_finish")
{
/*
* It's possible to get a resilver_finish event with no
@ -429,7 +429,7 @@ ZfsEvent::ProcessPoolEvent() const
CleanupSpares();
}
if (Value("type") == "misc.fs.zfs.vdev_remove"
if (Value("type") == "sysevent.fs.zfs.vdev_remove"
&& degradedDevice == false) {
/* See if any other cases can make use of this device. */