svn commit: r300339 - projects/zfsd/head/cddl/usr.sbin/zfsd
Alan Somers
asomers at FreeBSD.org
Sat May 21 00:43:11 UTC 2016
Author: asomers
Date: Sat May 21 00:43:10 2016
New Revision: 300339
URL: https://svnweb.freebsd.org/changeset/base/300339
Log:
Fix a crash bug in zfsd when destroying a pool with I/O errors
cddl/usr.sbin/zfsd/case_file.cc
CaseFile::ReEvaluateByGuid was calling std::for_each on a std::list
of CaseFiles. However, the functor would sometimes remove a
CaseFile from the list, which caused a segfault in std::for_each.
The solution is to remove the use of for_each. Instead, manually
iterate through the list, taking care not to access potentially
invalid iterators.
Sponsored by: Spectra Logic Corp
Modified:
projects/zfsd/head/cddl/usr.sbin/zfsd/case_file.cc
Modified: projects/zfsd/head/cddl/usr.sbin/zfsd/case_file.cc
==============================================================================
--- projects/zfsd/head/cddl/usr.sbin/zfsd/case_file.cc Sat May 21 00:34:54 2016 (r300338)
+++ projects/zfsd/head/cddl/usr.sbin/zfsd/case_file.cc Sat May 21 00:43:10 2016 (r300339)
@@ -89,36 +89,6 @@ using DevdCtl::EventList;
using DevdCtl::Guid;
using DevdCtl::ParseException;
-/*-------------------------- File-scoped classes ----------------------------*/
-/**
- * \brief Functor that operators on STL collections of CaseFiles
- *
- * Selectively calls ReEvaluate on the casefile, based on its pool GUID.
- */
-class CaseFileReEvaluator : public std::unary_function<CaseFile, bool>
-{
-public:
- CaseFileReEvaluator(Guid guid, const ZfsEvent &event);
-
- void operator() (CaseFile *casefile);
-
-private:
- Guid m_poolGUID;
- const ZfsEvent &m_event;
-};
-
-CaseFileReEvaluator::CaseFileReEvaluator(Guid guid, const ZfsEvent &event)
- : m_poolGUID(guid), m_event(event)
-{
-}
-
-void
-CaseFileReEvaluator::operator() (CaseFile *casefile)
-{
- if (m_poolGUID == casefile->PoolGUID())
- casefile->ReEvaluate(m_event);
-}
-
/*--------------------------------- CaseFile ---------------------------------*/
//- CaseFile Static Data -------------------------------------------------------
CaseFileList CaseFile::s_activeCases;
@@ -170,8 +140,13 @@ CaseFile::Find(const string &physPath)
void
CaseFile::ReEvaluateByGuid(Guid poolGUID, const ZfsEvent &event)
{
- CaseFileReEvaluator reevaluator(poolGUID, event);
- std::for_each(s_activeCases.begin(), s_activeCases.end(), reevaluator);
+ CaseFileList::iterator casefile;
+ for (casefile = s_activeCases.begin(); casefile != s_activeCases.end();){
+ CaseFileList::iterator next = std::next(casefile);
+ if (poolGUID == (*casefile)->PoolGUID())
+ (*casefile)->ReEvaluate(event);
+ casefile = next;
+ }
}
CaseFile &
More information about the svn-src-projects
mailing list