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 /*============================= Class Definitions ============================*/
64 /*-------------------------------- DevfsEvent --------------------------------*/
65 class DevfsEvent : public DevdCtl::DevfsEvent
68 /** Specialized DevdCtlEvent object factory for Devfs events. */
69 static BuildMethod Builder;
71 virtual DevdCtl::Event *DeepCopy() const;
74 * Interpret and perform any actions necessary to
76 * \return True if this event should be queued for later reevaluation
78 virtual bool Process() const;
82 * \brief Read and return label information for a device.
84 * \param devFd The device from which to read ZFS label information.
85 * \param inUse The device is part of an active or potentially
86 * active configuration.
87 * \param degraded The device label indicates the vdev is not healthy.
89 * \return If label information is available, an nvlist describing
90 * the vdev configuraiton found on the device specified by
91 * devFd. Otherwise NULL.
93 static nvlist_t *ReadLabel(int devFd, bool &inUse, bool °raded);
96 * Attempt to match the ZFS labeled device at devPath with an active
97 * CaseFile for a missing vdev. If a CaseFile is found, attempt
98 * to re-integrate the device with its pool.
100 * \param devPath The devfs path to the potential leaf vdev.
101 * \param physPath The physical path string reported by the device
103 * \param devConfig The ZFS label information found on the device
106 * \return true if the event that caused the online action can
107 * be considered consumed.
109 static bool OnlineByLabel(const string &devPath,
110 const string& physPath,
111 nvlist_t *devConfig);
113 /** DeepCopy Constructor. */
114 DevfsEvent(const DevfsEvent &src);
117 DevfsEvent(Type, DevdCtl::NVPairMap &, const string &);
120 /*--------------------------------- ZfsEvent ---------------------------------*/
121 class ZfsEvent : public DevdCtl::ZfsEvent
124 /** Specialized DevdCtlEvent object factory for ZFS events. */
125 static BuildMethod Builder;
127 virtual DevdCtl::Event *DeepCopy() const;
130 * Interpret and perform any actions necessary to
132 * \return True if this event should be queued for later reevaluation
134 virtual bool Process() const;
137 /** DeepCopy Constructor. */
138 ZfsEvent(const ZfsEvent &src);
141 ZfsEvent(Type, DevdCtl::NVPairMap &, const string &);
144 * Detach any spares that are no longer needed, but were not
145 * automatically detached by the kernel
147 virtual void CleanupSpares() const;
148 virtual void ProcessPoolEvent() const;
149 static VdevCallback_t TryDetach;
152 class GeomEvent : public DevdCtl::GeomEvent
155 static BuildMethod Builder;
157 virtual DevdCtl::Event *DeepCopy() const;
159 virtual bool Process() const;
162 /** DeepCopy Constructor. */
163 GeomEvent(const GeomEvent &src);
166 GeomEvent(Type, DevdCtl::NVPairMap &, const string &);
168 #endif /*_ZFSD_EVENT_H_ */