Changeset View
Changeset View
Standalone View
Standalone View
cddl/usr.sbin/zfsd/case_file.cc
Show All 33 Lines | |||||
* \file case_file.cc | * \file case_file.cc | ||||
* | * | ||||
* We keep case files for any leaf vdev that is not in the optimal state. | * We keep case files for any leaf vdev that is not in the optimal state. | ||||
* However, we only serialize to disk those events that need to be preserved | * However, we only serialize to disk those events that need to be preserved | ||||
* across reboots. For now, this is just a log of soft errors which we | * across reboots. For now, this is just a log of soft errors which we | ||||
* accumulate in order to mark a device as degraded. | * accumulate in order to mark a device as degraded. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
#include <sys/byteorder.h> | |||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <sys/fs/zfs.h> | #include <sys/fs/zfs.h> | ||||
#include <dirent.h> | #include <dirent.h> | ||||
#include <fcntl.h> | |||||
#include <iomanip> | #include <iomanip> | ||||
#include <fstream> | #include <fstream> | ||||
#include <functional> | #include <functional> | ||||
#include <sstream> | #include <sstream> | ||||
#include <syslog.h> | #include <syslog.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <libzfs.h> | #include <libzfs.h> | ||||
Show All 15 Lines | |||||
#include "vdev.h" | #include "vdev.h" | ||||
#include "zfsd.h" | #include "zfsd.h" | ||||
#include "zfsd_exception.h" | #include "zfsd_exception.h" | ||||
#include "zpool_list.h" | #include "zpool_list.h" | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
/*============================ Namespace Control =============================*/ | /*============================ Namespace Control =============================*/ | ||||
using std::auto_ptr; | |||||
using std::hex; | using std::hex; | ||||
using std::ifstream; | using std::ifstream; | ||||
using std::stringstream; | using std::stringstream; | ||||
using std::setfill; | using std::setfill; | ||||
using std::setw; | using std::setw; | ||||
using DevdCtl::Event; | using DevdCtl::Event; | ||||
using DevdCtl::EventFactory; | using DevdCtl::EventFactory; | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | CaseFile::RefreshVdevState() | ||||
return (true); | return (true); | ||||
} | } | ||||
bool | bool | ||||
CaseFile::ReEvaluate(const string &devPath, const string &physPath, Vdev *vdev) | CaseFile::ReEvaluate(const string &devPath, const string &physPath, Vdev *vdev) | ||||
{ | { | ||||
ZpoolList zpl(ZpoolList::ZpoolByGUID, &m_poolGUID); | ZpoolList zpl(ZpoolList::ZpoolByGUID, &m_poolGUID); | ||||
zpool_handle_t *pool(zpl.empty() ? NULL : zpl.front()); | zpool_handle_t *pool(zpl.empty() ? NULL : zpl.front()); | ||||
zpool_boot_label_t boot_type; | |||||
uint64_t boot_size; | |||||
if (pool == NULL || !RefreshVdevState()) { | if (pool == NULL || !RefreshVdevState()) { | ||||
/* | /* | ||||
* The pool or vdev for this case file is no longer | * The pool or vdev for this case file is no longer | ||||
* part of the configuration. This can happen | * part of the configuration. This can happen | ||||
* if we process a device arrival notification | * if we process a device arrival notification | ||||
* before seeing the ZFS configuration change | * before seeing the ZFS configuration change | ||||
* event. | * event. | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | syslog(LOG_INFO, | ||||
"Ignoring device insertion.\n", | "Ignoring device insertion.\n", | ||||
PoolGUIDString().c_str(), | PoolGUIDString().c_str(), | ||||
VdevGUIDString().c_str(), | VdevGUIDString().c_str(), | ||||
zpool_state_to_name(VdevState(), VDEV_AUX_NONE)); | zpool_state_to_name(VdevState(), VDEV_AUX_NONE)); | ||||
return (/*consumed*/false); | return (/*consumed*/false); | ||||
} | } | ||||
/* Write a label on the newly inserted disk. */ | /* Write a label on the newly inserted disk. */ | ||||
if (zpool_is_bootable(pool)) | if (zpool_label_disk(g_zfsHandle, pool, devPath.c_str()) != 0) { | ||||
boot_type = ZPOOL_COPY_BOOT_LABEL; | |||||
else | |||||
boot_type = ZPOOL_NO_BOOT_LABEL; | |||||
boot_size = zpool_get_prop_int(pool, ZPOOL_PROP_BOOTSIZE, NULL); | |||||
if (zpool_label_disk(g_zfsHandle, pool, devPath.c_str(), | |||||
boot_type, boot_size, NULL) != 0) { | |||||
syslog(LOG_ERR, | syslog(LOG_ERR, | ||||
"Replace vdev(%s/%s) by physical path (label): %s: %s\n", | "Replace vdev(%s/%s) by physical path (label): %s: %s\n", | ||||
zpool_get_name(pool), VdevGUIDString().c_str(), | zpool_get_name(pool), VdevGUIDString().c_str(), | ||||
libzfs_error_action(g_zfsHandle), | libzfs_error_action(g_zfsHandle), | ||||
libzfs_error_description(g_zfsHandle)); | libzfs_error_description(g_zfsHandle)); | ||||
return (/*consumed*/false); | return (/*consumed*/false); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 762 Lines • ▼ Show 20 Lines | || nvlist_add_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, | ||||
nvlist_free(nvroot); | nvlist_free(nvroot); | ||||
return (true); | return (true); | ||||
} | } | ||||
/* Data was copied when added to the root vdev. */ | /* Data was copied when added to the root vdev. */ | ||||
nvlist_free(newvd); | nvlist_free(newvd); | ||||
retval = (zpool_vdev_attach(zhp, oldstr.c_str(), path, nvroot, | retval = (zpool_vdev_attach(zhp, oldstr.c_str(), path, nvroot, | ||||
/*replace*/B_TRUE) == 0); | /*replace*/B_TRUE, /*rebuild*/ B_FALSE) == 0); | ||||
if (retval) | if (retval) | ||||
syslog(LOG_INFO, "Replacing vdev(%s/%s) with %s\n", | syslog(LOG_INFO, "Replacing vdev(%s/%s) with %s\n", | ||||
poolname, oldstr.c_str(), path); | poolname, oldstr.c_str(), path); | ||||
else | else | ||||
syslog(LOG_ERR, "Replace vdev(%s/%s): %s: %s\n", | syslog(LOG_ERR, "Replace vdev(%s/%s): %s: %s\n", | ||||
poolname, oldstr.c_str(), libzfs_error_action(g_zfsHandle), | poolname, oldstr.c_str(), libzfs_error_action(g_zfsHandle), | ||||
libzfs_error_description(g_zfsHandle)); | libzfs_error_description(g_zfsHandle)); | ||||
nvlist_free(nvroot); | nvlist_free(nvroot); | ||||
Show All 37 Lines |