2 * Copyright (c) 2011, 2012, 2013, 2014, 2016 Spectra Logic Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * substantially similar to the "NO WARRANTY" disclaimer below
13 * ("Disclaimer") and any redistribution must be conditioned upon
14 * including a substantially similar Disclaimer requirement for further
15 * binary redistribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGES.
30 * Authors: Justin T. Gibbs (Spectra Logic Corporation)
36 * \file dev_ctl_event.h
38 * \brief Class hierarchy used to express events received via
41 * Header requirements:
46 * #include <devdctl/guid.h>
47 * #include <devdctl/event.h>
50 #ifndef _ZFSD_EVENT_H_
51 #define _ZFSD_EVENT_H_
53 /*============================ Namespace Control =============================*/
56 /*=========================== Forward Declarations ===========================*/
58 typedef struct zpool_handle zpool_handle_t;
61 typedef struct nvlist nvlist_t;
63 /*--------------------------------- ZfsEvent ---------------------------------*/
64 class ZfsEvent : public DevdCtl::ZfsEvent
67 /** Specialized DevdCtlEvent object factory for ZFS events. */
68 static BuildMethod Builder;
70 virtual DevdCtl::Event *DeepCopy() const;
73 * Interpret and perform any actions necessary to
75 * \return True if this event should be queued for later reevaluation
77 virtual bool Process() const;
80 /** DeepCopy Constructor. */
81 ZfsEvent(const ZfsEvent &src);
84 ZfsEvent(Type, DevdCtl::NVPairMap &, const string &);
87 * Detach any spares that are no longer needed, but were not
88 * automatically detached by the kernel
90 virtual void CleanupSpares() const;
91 virtual void ProcessPoolEvent() const;
92 static VdevCallback_t TryDetach;
95 class GeomEvent : public DevdCtl::GeomEvent
98 static BuildMethod Builder;
100 virtual DevdCtl::Event *DeepCopy() const;
102 virtual bool Process() const;
105 /** DeepCopy Constructor. */
106 GeomEvent(const GeomEvent &src);
109 GeomEvent(Type, DevdCtl::NVPairMap &, const string &);
112 * Attempt to match the ZFS labeled device at devPath with an active
113 * CaseFile for a missing vdev. If a CaseFile is found, attempt
114 * to re-integrate the device with its pool.
116 * \param devPath The devfs path to the potential leaf vdev.
117 * \param physPath The physical path string reported by the device
119 * \param devConfig The ZFS label information found on the device
122 * \return true if the event that caused the online action can
123 * be considered consumed.
125 static bool OnlineByLabel(const string &devPath,
126 const string& physPath,
127 nvlist_t *devConfig);
130 * \brief Read and return label information for a device.
132 * \param devFd The device from which to read ZFS label information.
133 * \param inUse The device is part of an active or potentially
134 * active configuration.
135 * \param degraded The device label indicates the vdev is not healthy.
137 * \return If label information is available, an nvlist describing
138 * the vdev configuraiton found on the device specified by
139 * devFd. Otherwise NULL.
141 static nvlist_t *ReadLabel(int devFd, bool &inUse, bool °raded);
144 #endif /*_ZFSD_EVENT_H_ */