1 // 2 // CDDL HEADER START 3 // 4 // The contents of this file are subject to the terms of the 5 // Common Development and Distribution License (the License). 6 // You may not use this file except in compliance with the License. 7 // 8 // You can obtain a copy of the license at usr/src/CDDL.txt 9 // or http://www.opensolaris.org/os/licensing. 10 // See the License for the specific language governing permissions 11 // and limitations under the License. 12 // 13 // When distributing Covered Code, include this CDDL HEADER in each 14 // file and include the License file at usr/src/CDDL.txt. 15 // If applicable, add the following below this CDDL HEADER, with the 16 // fields enclosed by brackets [] replaced with your own identifying 17 // information: Portions Copyright [yyyy] [name of copyright owner] 18 // 19 // CDDL HEADER END 20 // 21 22 // 23 // Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 // Use is subject to license terms. 25 // 26 27 #ifndef _MOUNT_CLIENT_IMPL_H 28 #define _MOUNT_CLIENT_IMPL_H 29 30 #pragma ident "@(#)mount_client_impl.h 1.34 08/05/20 SMI" 31 32 #include <h/pxfs.h> 33 #include <h/pxfs_v1.h> 34 #include <h/solobj.h> 35 #include <orb/object/adapter.h> 36 37 #include <pxfs/client/pxvfs.h> 38 39 // 40 // mount_client_impl - one object exists on every node in the cluster. 41 // This object supports starting and stopping the pxfs client software 42 // for each mounted file system. This includes mounting and umounting 43 // the proxy file system. 44 // 45 class mount_client_impl : public McServerof<fs::mount_client> { 46 public: 47 void _unreferenced(unref_t arg); 48 49 // 50 // Activate() registers this node's mount_client with the 51 // mount_server and thereby imports all extant globally mounted 52 // file systems. 53 // 54 // It is distinct from startup because module load time occurs before 55 // the prerequisites for the global name space have been established. 56 // 57 static int activate(); 58 59 // 60 // Return true if activate() has been called. 61 // 62 static bool is_activated(); 63 64 // 65 // Notify intent to mount a device. 66 // Device is "locked" until it is either mounted or the requesting 67 // node dies. 68 // 69 static int devlock(int cmd, struct pathname *devpnp); 70 71 // 72 // Return a pointer to the mount server. 73 // Note that the returned pointer is not duplicated and therefore 74 // should not be released. 75 // 76 static fs::mount_server_ptr get_server(); 77 78 // 79 // Return a reference to the local mount client. 80 // Note that the returned pointer is duplicated and therefore 81 // should be released. 82 // 83 static fs::mount_client_ptr get_client_ref(); 84 85 void _generic_method(CORBA::octet_seq_t &, 86 CORBA::object_seq_t &, Environment &); 87 88 // For rolling upgrade support 89 static void update_mount_server_ref(); 90 91 // 92 // Return a pointer to the local mount client. 93 // 94 static mount_client_impl *get_client(); 95 96 // + fs::mount_client::* 97 /* mount_client */ 98 void lock_mountpoint(const char *mountpoint, int32_t mntflags, 99 Environment &_environment); 100 101 void unlock_mountpoint(const char *mountpoint, 102 Environment &_environment); 103 104 void instantiate(const sol::mounta &ma, sol::uintptr_t mvp, 105 solobj::cred_ptr credobj, fs::filesystem_out fs, 106 fs::fs_info &fsinfo, CORBA::String_out mntoptions, 107 Environment &_environment); 108 109 void instantiate_v1(const sol::mounta &ma, sol::uintptr_t mvp, 110 solobj::cred_ptr credobj, pxfs_v1::filesystem_out fs, 111 pxfs_v1::fs_info &fsinfo, CORBA::String_out mntoptions, 112 Environment &_environment); 113 114 void instantiate_ha(const sol::mounta &ma, sol::uintptr_t mvp, 115 solobj::cred_ptr credobj, const char *dev_name, 116 Environment &_environment); 117 118 void instantiate_ha_v1(const sol::mounta &ma, sol::uintptr_t mvp, 119 solobj::cred_ptr credobj, const char *dev_name, 120 Environment &_environment); 121 122 void reinstantiate_ha(const sol::mounta &ma, 123 fs::filesystem_ptr fs, 124 solobj::cred_ptr credobj, const char *dev_name, 125 Environment &_environment); 126 127 void reinstantiate_ha_v1(const sol::mounta &ma, 128 pxfs_v1::filesystem_ptr fs, 129 solobj::cred_ptr credobj, const char *dev_name, 130 Environment &_environment); 131 132 void prepare_unmount(fs::filesystem_ptr fs, solobj::cred_ptr credobj, 133 Environment &_environment); 134 135 void prepare_unmount_1(fs::filesystem_ptr fs, int32_t flags, 136 solobj::cred_ptr credobj, bool skip_purge, 137 Environment &_environment); 138 139 void prepare_unmount_v1(pxfs_v1::filesystem_ptr fs, int32_t flags, 140 solobj::cred_ptr credobj, bool skip_purge, 141 Environment &_environment); 142 143 void unmount_failed(Environment &_environment); 144 145 void unmount_failed_1(bool skip, Environment &_environment); 146 147 void add_notify_locked(const sol::mounta &ma, const char *mntoptions, 148 fs::filesystem_ptr fs, const fs::fs_info &fsinfo, 149 Environment &_environment); 150 151 void add_notify_locked_v1(const sol::mounta &ma, 152 const char *mntoptions, 153 pxfs_v1::filesystem_ptr fs, const pxfs_v1::fs_info &fsinfo, 154 Environment &_environment); 155 156 void add_notify(const sol::mounta &ma, const char *mntoptions, 157 bool is_ha_repl, const char *dev_name, fs::filesystem_ptr fs, 158 const fs::fs_info &fsinfo, Environment &_environment); 159 160 void add_notify_v1(const sol::mounta &ma, const char *mntoptions, 161 bool is_ha_repl, const char *dev_name, pxfs_v1::filesystem_ptr fs, 162 const pxfs_v1::fs_info &fsinfo, Environment &_environment); 163 164 void remove_notify(const char *mountpoint, const char *special, 165 bool updatemtab, Environment &_environment); 166 167 void remove_notify_1(const char *mountpoint, bool unlink_vfs, 168 Environment &_environment); 169 170 void remove_client(const char *mountpoint, const char *special, 171 bool is_ha_repl, const char *dev_name, fs::filesystem_ptr fs, 172 solobj::cred_ptr credobj, Environment &_environment); 173 174 void remove_client_v1(const char *mountpoint, const char *special, 175 bool is_ha_repl, const char *dev_name, pxfs_v1::filesystem_ptr fs, 176 solobj::cred_ptr credobj, Environment &_environment); 177 178 void set_flags(const sol::mounta &ma, const char *mntoptions, 179 fs::filesystem_ptr fs, uint32_t vfsflags, 180 Environment &_environment); 181 182 void set_flags_v1(const sol::mounta &ma, const char *mntoptions, 183 pxfs_v1::filesystem_ptr fs, uint32_t vfsflags, 184 Environment &_environment); 185 186 void upgrade_mount_client(fs::mount_server_ptr mountserver_p, 187 Environment &_environment); 188 // + 189 190 private: 191 enum mount_ver_t {VERSION_0, VERSION_1}; 192 193 // Private so we can ensure one per node. 194 mount_client_impl(); 195 ~mount_client_impl(); 196 197 // 198 // Common code for add_notify() and add_notify_local(). 199 // 200 void add_notify_common_v1(const sol::mounta &ma, 201 const char *mntoptions, 202 pxfs_v1::filesystem_ptr fs, const pxfs_v1::fs_info &fsinfo, 203 vnode_t *coveredvp); 204 205 // 206 // Common code for instantiate_ha() and reinstantiate_ha(). 207 // 208 void instantiate_ha_common(const sol::mounta &ma, vnode_t *vp, 209 solobj::cred_ptr credobj, const char *dev_name, 210 mount_ver_t mount_ver, Environment &_environment); 211 212 void unmount_failed_v1(bool skip); 213 214 void remove_notify_v1(const char *mountpoint, bool unlink_vfs); 215 216 // 217 // Reference to the mount server. 218 // 219 fs::mount_server_var server; 220 221 // Reference to server object for detecting if this client crashes. 222 fs::mount_client_died_var keepalive; 223 224 // Locked mount point vnode or NULL if no lock. 225 vnode_t *mntvp; 226 227 // Protects 'mntvp'. 228 os::mutex_t mount_lock; 229 230 // Serialize mount server retry attempts to add_notify 231 os::mutex_t add_notify_lock; 232 233 // 234 // Record the pxvfs when an unmount is in progress. 235 // Only one unmount can occur at a time. 236 // 237 pxvfs *unmount_pxvfs_v1_p; 238 239 // Protects 'unmount_pxvfsp'. 240 os::mutex_t unmount_lock; 241 242 // 243 // Pointer to the mount client for this node (see activate()). 244 // 245 static mount_client_impl *this_mount_client; 246 static os::mutex_t mount_client_lock; // protects above 247 }; 248 249 int pxfs_mount_client_startup(); 250 int pxfs_mount_client_shutdown(); 251 252 #endif // _MOUNT_CLIENT_IMPL_H 253