* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
}
return obd;
}
-EXPORT_SYMBOL(obd_device_alloc);
static void obd_device_free(struct obd_device *obd)
{
struct obd_device *obd = exp->exp_obd;
ENTRY;
- LASSERT (cfs_atomic_read(&exp->exp_refcount) == 0);
+ LASSERT_ATOMIC_ZERO(&exp->exp_refcount);
CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp,
exp->exp_client_uuid.uuid, obd->obd_name);
void class_export_put(struct obd_export *exp)
{
LASSERT(exp != NULL);
+ LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, 0x5a5a5a);
CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp,
cfs_atomic_read(&exp->exp_refcount) - 1);
- LASSERT(cfs_atomic_read(&exp->exp_refcount) > 0);
- LASSERT(cfs_atomic_read(&exp->exp_refcount) < 0x5a5a5a);
if (cfs_atomic_dec_and_test(&exp->exp_refcount)) {
LASSERT(!cfs_list_empty(&exp->exp_obd_chain));
CDEBUG(D_IOCTL, "final put %p/%s\n",
exp, exp->exp_client_uuid.uuid);
+
+ /* release nid stat refererence */
+ lprocfs_exp_cleanup(exp);
+
obd_zombie_export_add(exp);
}
}
struct obd_uuid *cluuid)
{
struct obd_export *export;
+ cfs_hash_t *hash = NULL;
int rc = 0;
ENTRY;
class_handle_hash(&export->exp_handle, export_handle_addref);
export->exp_last_request_time = cfs_time_current_sec();
cfs_spin_lock_init(&export->exp_lock);
+ cfs_spin_lock_init(&export->exp_rpc_lock);
CFS_INIT_HLIST_NODE(&export->exp_uuid_hash);
CFS_INIT_HLIST_NODE(&export->exp_nid_hash);
cfs_spin_lock(&obd->obd_dev_lock);
/* shouldn't happen, but might race */
if (obd->obd_stopping)
- GOTO(exit_err, rc = -ENODEV);
+ GOTO(exit_unlock, rc = -ENODEV);
+
+ hash = cfs_hash_getref(obd->obd_uuid_hash);
+ if (hash == NULL)
+ GOTO(exit_unlock, rc = -ENODEV);
+ cfs_spin_unlock(&obd->obd_dev_lock);
if (!obd_uuid_equals(cluuid, &obd->obd_uuid)) {
- rc = cfs_hash_add_unique(obd->obd_uuid_hash, cluuid,
- &export->exp_uuid_hash);
+ rc = cfs_hash_add_unique(hash, cluuid, &export->exp_uuid_hash);
if (rc != 0) {
LCONSOLE_WARN("%s: denying duplicate export for %s, %d\n",
obd->obd_name, cluuid->uuid, rc);
}
}
+ cfs_spin_lock(&obd->obd_dev_lock);
+ if (obd->obd_stopping) {
+ cfs_hash_del(hash, cluuid, &export->exp_uuid_hash);
+ GOTO(exit_unlock, rc = -ENODEV);
+ }
+
class_incref(obd, "export", export);
cfs_list_add(&export->exp_obd_chain, &export->exp_obd->obd_exports);
cfs_list_add_tail(&export->exp_obd_chain_timed,
&export->exp_obd->obd_exports_timed);
export->exp_obd->obd_num_exports++;
cfs_spin_unlock(&obd->obd_dev_lock);
+ cfs_hash_putref(hash);
RETURN(export);
-exit_err:
+exit_unlock:
cfs_spin_unlock(&obd->obd_dev_lock);
+exit_err:
+ if (hash)
+ cfs_hash_putref(hash);
class_handle_unhash(&export->exp_handle);
LASSERT(cfs_hlist_unhashed(&export->exp_uuid_hash));
obd_destroy_export(export);
CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp,
imp->imp_obd->obd_name);
- LASSERT(cfs_atomic_read(&imp->imp_refcount) == 0);
+ LASSERT_ATOMIC_ZERO(&imp->imp_refcount);
ptlrpc_put_connection_superhack(imp->imp_connection);
struct obd_import *class_import_get(struct obd_import *import)
{
- LASSERT(cfs_atomic_read(&import->imp_refcount) >= 0);
- LASSERT(cfs_atomic_read(&import->imp_refcount) < 0x5a5a5a);
cfs_atomic_inc(&import->imp_refcount);
CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", import,
cfs_atomic_read(&import->imp_refcount),
{
ENTRY;
- LASSERT(cfs_atomic_read(&imp->imp_refcount) > 0);
- LASSERT(cfs_atomic_read(&imp->imp_refcount) < 0x5a5a5a);
LASSERT(cfs_list_empty(&imp->imp_zombie_chain));
+ LASSERT_ATOMIC_GE_LT(&imp->imp_refcount, 0, 0x5a5a5a);
CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", imp,
cfs_atomic_read(&imp->imp_refcount) - 1,
{
struct obd_device *obd = exp->exp_obd;
- cfs_spin_lock_bh(&obd->obd_processing_task_lock);
+ cfs_spin_lock(&obd->obd_recovery_task_lock);
if (exp->exp_delayed)
obd->obd_delayed_clients--;
if (obd->obd_recovering && exp->exp_in_recovery) {
LASSERT(obd->obd_connected_clients);
obd->obd_connected_clients--;
}
+ cfs_spin_unlock(&obd->obd_recovery_task_lock);
/** Cleanup req replay fields */
if (exp->exp_req_replay_needed) {
cfs_spin_lock(&exp->exp_lock);
LASSERT(cfs_atomic_read(&obd->obd_lock_replay_clients));
cfs_atomic_dec(&obd->obd_lock_replay_clients);
}
- cfs_spin_unlock_bh(&obd->obd_processing_task_lock);
}
/* This function removes 1-3 references from the export:
"The obd refcount = %d. Is it stuck?\n",
obd->obd_name, waited,
cfs_atomic_read(&obd->obd_refcount));
- dump_exports(obd, 0);
+ dump_exports(obd, 1);
}
waited *= 2;
cfs_spin_lock(&obd->obd_dev_lock);
#endif
}
+/***** Kernel-userspace comm helpers *******/
+
+/* Get length of entire message, including header */
+int kuc_len(int payload_len)
+{
+ return sizeof(struct kuc_hdr) + payload_len;
+}
+EXPORT_SYMBOL(kuc_len);
+
+/* Get a pointer to kuc header, given a ptr to the payload
+ * @param p Pointer to payload area
+ * @returns Pointer to kuc header
+ */
+struct kuc_hdr * kuc_ptr(void *p)
+{
+ struct kuc_hdr *lh = ((struct kuc_hdr *)p) - 1;
+ LASSERT(lh->kuc_magic == KUC_MAGIC);
+ return lh;
+}
+EXPORT_SYMBOL(kuc_ptr);
+
+/* Test if payload is part of kuc message
+ * @param p Pointer to payload area
+ * @returns boolean
+ */
+int kuc_ispayload(void *p)
+{
+ struct kuc_hdr *kh = ((struct kuc_hdr *)p) - 1;
+
+ if (kh->kuc_magic == KUC_MAGIC)
+ return 1;
+ else
+ return 0;
+}
+EXPORT_SYMBOL(kuc_ispayload);
+
+/* Alloc space for a message, and fill in header
+ * @return Pointer to payload area
+ */
+void *kuc_alloc(int payload_len, int transport, int type)
+{
+ struct kuc_hdr *lh;
+ int len = kuc_len(payload_len);
+
+ OBD_ALLOC(lh, len);
+ if (lh == NULL)
+ return ERR_PTR(-ENOMEM);
+
+ lh->kuc_magic = KUC_MAGIC;
+ lh->kuc_transport = transport;
+ lh->kuc_msgtype = type;
+ lh->kuc_msglen = len;
+
+ return (void *)(lh + 1);
+}
+EXPORT_SYMBOL(kuc_alloc);
+
+/* Takes pointer to payload area */
+inline void kuc_free(void *p, int payload_len)
+{
+ struct kuc_hdr *lh = kuc_ptr(p);
+ OBD_FREE(lh, kuc_len(payload_len));
+}
+EXPORT_SYMBOL(kuc_free);
+
+
+