Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
- make HEAD from b_post_cmd3
[fs/lustre-release.git]
/
lustre
/
obdclass
/
genops.c
diff --git
a/lustre/obdclass/genops.c
b/lustre/obdclass/genops.c
index
34b137c
..
c005804
100644
(file)
--- a/
lustre/obdclass/genops.c
+++ b/
lustre/obdclass/genops.c
@@
-58,7
+58,7
@@
static struct obd_device *obd_device_alloc(void)
{
struct obd_device *obd;
- OBD_SLAB_ALLOC(obd, obd_device_cachep,
SLAB
_KERNEL, sizeof(*obd));
+ OBD_SLAB_ALLOC(obd, obd_device_cachep,
GFP
_KERNEL, sizeof(*obd));
if (obd != NULL) {
obd->obd_magic = OBD_DEVICE_MAGIC;
}
@@
-99,20
+99,19
@@
struct obd_type *class_get_type(const char *name)
#ifdef CONFIG_KMOD
if (!type) {
const char *modname = name;
- if (strcmp(modname, LUSTRE_MDT_NAME) == 0)
- modname = LUSTRE_MDS_NAME;
if (!request_module(modname)) {
CDEBUG(D_INFO, "Loaded module '%s'\n", modname);
type = class_search_type(name);
} else {
- LCONSOLE_ERROR("Can't load module '%s'\n", modname);
+ LCONSOLE_ERROR_MSG(0x158, "Can't load module '%s'\n",
+ modname);
}
}
#endif
if (type) {
spin_lock(&type->obd_type_lock);
type->typ_refcnt++;
- try_module_get(type->typ_ops->o_owner);
+ try_module_get(type->typ_
dt_
ops->o_owner);
spin_unlock(&type->obd_type_lock);
}
return type;
@@
-123,18
+122,22
@@
void class_put_type(struct obd_type *type)
LASSERT(type);
spin_lock(&type->obd_type_lock);
type->typ_refcnt--;
- module_put(type->typ_ops->o_owner);
+ module_put(type->typ_
dt_
ops->o_owner);
spin_unlock(&type->obd_type_lock);
}
-int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars,
- const char *name)
+#define CLASS_MAX_NAME 1024
+
+int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
+ struct lprocfs_vars *vars, const char *name,
+ struct lu_device_type *ldt)
{
struct obd_type *type;
int rc = 0;
ENTRY;
- LASSERT(strnlen(name, 1024) < 1024); /* sanity check */
+ /* sanity check */
+ LASSERT(strnlen(name, CLASS_MAX_NAME) < CLASS_MAX_NAME);
if (class_search_type(name)) {
CDEBUG(D_IOCTL, "Type %s already registered\n", name);
@@
-146,12
+149,19
@@
int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars,
if (type == NULL)
RETURN(rc);
- OBD_ALLOC(type->typ_ops, sizeof(*type->typ_ops));
+ OBD_ALLOC_PTR(type->typ_dt_ops);
+ OBD_ALLOC_PTR(type->typ_md_ops);
OBD_ALLOC(type->typ_name, strlen(name) + 1);
- if (type->typ_ops == NULL || type->typ_name == NULL)
+
+ if (type->typ_dt_ops == NULL ||
+ type->typ_md_ops == NULL ||
+ type->typ_name == NULL)
GOTO (failed, rc);
- *(type->typ_ops) = *ops;
+ *(type->typ_dt_ops) = *dt_ops;
+ /* md_ops is optional */
+ if (md_ops)
+ *(type->typ_md_ops) = *md_ops;
strcpy(type->typ_name, name);
spin_lock_init(&type->obd_type_lock);
@@
-164,6
+174,12
@@
int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars,
GOTO (failed, rc);
}
#endif
+ if (ldt != NULL) {
+ type->typ_lu = ldt;
+ rc = ldt->ldt_ops->ldto_init(ldt);
+ if (rc != 0)
+ GOTO (failed, rc);
+ }
spin_lock(&obd_types_lock);
list_add(&type->typ_chain, &obd_types);
@@
-174,8
+190,10
@@
int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars,
failed:
if (type->typ_name != NULL)
OBD_FREE(type->typ_name, strlen(name) + 1);
- if (type->typ_ops != NULL)
- OBD_FREE (type->typ_ops, sizeof (*type->typ_ops));
+ if (type->typ_md_ops != NULL)
+ OBD_FREE_PTR(type->typ_md_ops);
+ if (type->typ_dt_ops != NULL)
+ OBD_FREE_PTR(type->typ_dt_ops);
OBD_FREE(type, sizeof(*type));
RETURN(rc);
}
@@
-194,19
+212,26
@@
int class_unregister_type(const char *name)
CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt);
/* This is a bad situation, let's make the best of it */
/* Remove ops, but leave the name for debugging */
- OBD_FREE(type->typ_ops, sizeof(*type->typ_ops));
+ OBD_FREE_PTR(type->typ_dt_ops);
+ OBD_FREE_PTR(type->typ_md_ops);
RETURN(-EBUSY);
}
- if (type->typ_procroot)
+ if (type->typ_procroot)
{
lprocfs_remove(&type->typ_procroot);
+ }
+
+ if (type->typ_lu)
+ type->typ_lu->ldt_ops->ldto_fini(type->typ_lu);
spin_lock(&obd_types_lock);
list_del(&type->typ_chain);
spin_unlock(&obd_types_lock);
OBD_FREE(type->typ_name, strlen(name) + 1);
- if (type->typ_ops != NULL)
- OBD_FREE(type->typ_ops, sizeof(*type->typ_ops));
+ if (type->typ_dt_ops != NULL)
+ OBD_FREE_PTR(type->typ_dt_ops);
+ if (type->typ_md_ops != NULL)
+ OBD_FREE_PTR(type->typ_md_ops);
OBD_FREE(type, sizeof(*type));
RETURN(0);
} /* class_unregister_type */
@@
-224,7
+249,7
@@
struct obd_device *class_newdev(const char *type_name, const char *name)
RETURN(ERR_PTR(-EINVAL));
}
- type = class_get_type(type_name);
+ type = class_get_type(type_name);
if (type == NULL){
CERROR("OBD: unknown type: %s\n", type_name);
RETURN(ERR_PTR(-ENODEV));
@@
-240,7
+265,8
@@
struct obd_device *class_newdev(const char *type_name, const char *name)
spin_lock(&obd_dev_lock);
for (i = 0; i < class_devno_max(); i++) {
struct obd_device *obd = class_num2obd(i);
- if (obd && obd->obd_name && (strcmp(name, obd->obd_name) == 0)){
+ if (obd && obd->obd_name &&
+ (strcmp(name, obd->obd_name) == 0)) {
CERROR("Device %s already exists, won't add\n", name);
if (result) {
LASSERTF(result->obd_magic == OBD_DEVICE_MAGIC,
@@
-252,7
+278,7
@@
struct obd_device *class_newdev(const char *type_name, const char *name)
obd_devs[result->obd_minor] = NULL;
result->obd_name[0]='\0';
- }
+
}
result = ERR_PTR(-EEXIST);
break;
}
@@
-508,6
+534,11
@@
void obd_cleanup_caches(void)
LASSERTF(rc == 0, "Cannot destory ll_import_cache\n");
import_cachep = NULL;
}
+ if (capa_cachep) {
+ rc = cfs_mem_cache_destroy(capa_cachep);
+ LASSERTF(rc == 0, "Cannot destory capa_cache\n");
+ capa_cachep = NULL;
+ }
EXIT;
}
@@
-534,6
+565,12
@@
int obd_init_caches(void)
if (!import_cachep)
GOTO(out, -ENOMEM);
+ LASSERT(capa_cachep == NULL);
+ capa_cachep = cfs_mem_cache_create("capa_cache",
+ sizeof(struct obd_capa), 0, 0);
+ if (!capa_cachep)
+ GOTO(out, -ENOMEM);
+
RETURN(0);
out:
obd_cleanup_caches();
@@
-624,11
+661,12
@@
EXPORT_SYMBOL(__class_export_put);
void class_export_destroy(struct obd_export *exp)
{
struct obd_device *obd = exp->exp_obd;
+ ENTRY;
LASSERT (atomic_read(&exp->exp_refcount) == 0);
- CDEBUG(D_IOCTL, "destroying export %p/%s\n", exp,
- exp->exp_client_uuid.uuid);
+ CDEBUG(D_IOCTL, "destroying export %p/%s
for %s
\n", exp,
+ exp->exp_client_uuid.uuid
, obd->obd_name
);
LASSERT(obd != NULL);
@@
-637,11
+675,11
@@
void class_export_destroy(struct obd_export *exp)
ptlrpc_put_connection_superhack(exp->exp_connection);
LASSERT(list_empty(&exp->exp_outstanding_replies));
- LASSERT(list_empty(&exp->exp_handle.h_link));
obd_destroy_export(exp);
-
- OBD_FREE
(exp, sizeof(*exp)
);
+
+ OBD_FREE
_RCU(exp, sizeof(*exp), &exp->exp_handle
);
class_decref(obd);
+ EXIT;
}
/* Creates a new export, adds it to the hash table, and returns a
@@
-759,7
+797,8
@@
void class_import_destroy(struct obd_import *import)
{
ENTRY;
- CDEBUG(D_IOCTL, "destroying import %p\n", import);
+ CDEBUG(D_IOCTL, "destroying import %p for %s\n", import,
+ import->imp_obd->obd_name);
LASSERT(atomic_read(&import->imp_refcount) == 0);
@@
-775,10
+814,9
@@
void class_import_destroy(struct obd_import *import)
OBD_FREE(imp_conn, sizeof(*imp_conn));
}
- LASSERT(
list_empty(&import->imp_handle.h_link)
);
+ LASSERT(
import->imp_sec == NULL
);
class_decref(import->imp_obd);
- OBD_FREE(import, sizeof(*import));
-
+ OBD_FREE_RCU(import, sizeof(*import), &import->imp_handle);
EXIT;
}
EXPORT_SYMBOL(class_import_put);
@@
-826,7
+864,6
@@
void class_destroy_import(struct obd_import *import)
spin_lock(&import->imp_lock);
import->imp_generation++;
spin_unlock(&import->imp_lock);
-
class_import_put(import);
}
EXPORT_SYMBOL(class_destroy_import);
@@
-857,6
+894,37
@@
int class_connect(struct lustre_handle *conn, struct obd_device *obd,
}
EXPORT_SYMBOL(class_connect);
+/* if export is involved in recovery then clean up related things */
+void class_export_recovery_cleanup(struct obd_export *exp)
+{
+ struct obd_device *obd = exp->exp_obd;
+
+ spin_lock_bh(&obd->obd_processing_task_lock);
+ if (obd->obd_recovering && exp->exp_in_recovery) {
+ spin_lock(&exp->exp_lock);
+ exp->exp_in_recovery = 0;
+ spin_unlock(&exp->exp_lock);
+ obd->obd_connected_clients--;
+ /* each connected client is counted as recoverable */
+ obd->obd_recoverable_clients--;
+ if (exp->exp_req_replay_needed) {
+ spin_lock(&exp->exp_lock);
+ exp->exp_req_replay_needed = 0;
+ spin_unlock(&exp->exp_lock);
+ LASSERT(atomic_read(&obd->obd_req_replay_clients));
+ atomic_dec(&obd->obd_req_replay_clients);
+ }
+ if (exp->exp_lock_replay_needed) {
+ spin_lock(&exp->exp_lock);
+ exp->exp_lock_replay_needed = 0;
+ spin_unlock(&exp->exp_lock);
+ LASSERT(atomic_read(&obd->obd_lock_replay_clients));
+ atomic_dec(&obd->obd_lock_replay_clients);
+ }
+ }
+ spin_unlock_bh(&obd->obd_processing_task_lock);
+}
+
/* This function removes two references from the export: one for the
* hash entry and one for the export pointer passed in. The export
* pointer passed to this function is destroyed should not be used
@@
-886,6
+954,7
@@
int class_disconnect(struct obd_export *export)
CDEBUG(D_IOCTL, "disconnect: cookie "LPX64"\n",
export->exp_handle.h_cookie);
+ class_export_recovery_cleanup(export);
class_unlink_export(export);
class_export_put(export);
RETURN(0);
@@
-959,17
+1028,23
@@
void class_disconnect_exports(struct obd_device *obd)
list_add(&work_list, &obd->obd_exports);
list_del_init(&obd->obd_exports);
spin_unlock(&obd->obd_dev_lock);
-
- CDEBUG(D_HA, "OBD device %d (%p) has exports, "
- "disconnecting them\n", obd->obd_minor, obd);
- class_disconnect_export_list(&work_list, get_exp_flags_from_obd(obd));
+
+ if (!list_empty(&work_list)) {
+ CDEBUG(D_HA, "OBD device %d (%p) has exports, "
+ "disconnecting them\n", obd->obd_minor, obd);
+ class_disconnect_export_list(&work_list,
+ get_exp_flags_from_obd(obd));
+ } else
+ CDEBUG(D_HA, "OBD device %d (%p) has no exports\n",
+ obd->obd_minor, obd);
EXIT;
}
EXPORT_SYMBOL(class_disconnect_exports);
/* Remove exports that have not completed recovery.
*/
-void class_disconnect_stale_exports(struct obd_device *obd)
+int class_disconnect_stale_exports(struct obd_device *obd,
+ int (*test_export)(struct obd_export *))
{
struct list_head work_list;
struct list_head *pos, *n;
@@
-981,18
+1056,28
@@
void class_disconnect_stale_exports(struct obd_device *obd)
spin_lock(&obd->obd_dev_lock);
list_for_each_safe(pos, n, &obd->obd_exports) {
exp = list_entry(pos, struct obd_export, exp_obd_chain);
- if (exp->exp_replay_needed) {
- list_del(&exp->exp_obd_chain);
- list_add(&exp->exp_obd_chain, &work_list);
- cnt++;
- }
+ if (test_export(exp))
+ continue;
+
+ list_del(&exp->exp_obd_chain);
+ list_add(&exp->exp_obd_chain, &work_list);
+ /* don't count self-export as client */
+ if (obd_uuid_equals(&exp->exp_client_uuid,
+ &exp->exp_obd->obd_uuid))
+ continue;
+
+ cnt++;
+ CDEBUG(D_ERROR, "%s: disconnect stale client %s@%s\n",
+ obd->obd_name, exp->exp_client_uuid.uuid,
+ exp->exp_connection == NULL ? "<unknown>" :
+ libcfs_nid2str(exp->exp_connection->c_peer.nid));
}
spin_unlock(&obd->obd_dev_lock);
CDEBUG(D_ERROR, "%s: disconnecting %d stale clients\n",
obd->obd_name, cnt);
class_disconnect_export_list(&work_list, get_exp_flags_from_obd(obd));
-
EXIT
;
+
RETURN(cnt)
;
}
EXPORT_SYMBOL(class_disconnect_stale_exports);
@@
-1174,13
+1259,13
@@
char *obd_export_nid2str(struct obd_export *exp)
{
if (exp->exp_connection != NULL)
return libcfs_nid2str(exp->exp_connection->c_peer.nid);
-
+
return "(no nid)";
}
EXPORT_SYMBOL(obd_export_nid2str);
#define EVICT_BATCH 32
-int obd_export_evict_by_nid(struct obd_device *obd, char *nid)
+int obd_export_evict_by_nid(struct obd_device *obd, c
onst c
har *nid)
{
struct obd_export *doomed_exp[EVICT_BATCH] = { NULL };
struct list_head *p;
@@
-1220,7
+1305,7
@@
search_again:
}
EXPORT_SYMBOL(obd_export_evict_by_nid);
-int obd_export_evict_by_uuid(struct obd_device *obd, char *uuid)
+int obd_export_evict_by_uuid(struct obd_device *obd, c
onst c
har *uuid)
{
struct obd_export *doomed_exp = NULL;
struct list_head *p;
@@
-1260,6
+1345,7
@@
void obd_zombie_impexp_cull(void)
{
struct obd_import *import;
struct obd_export *export;
+ ENTRY;
do {
spin_lock (&obd_zombie_impexp_lock);
@@
-1289,6
+1375,7
@@
void obd_zombie_impexp_cull(void)
class_export_destroy(export);
} while (import != NULL || export != NULL);
+ EXIT;
}
EXPORT_SYMBOL(obd_zombie_impexp_cull);
@@
-1298,3
+1385,4
@@
void obd_zombie_impexp_init(void)
INIT_LIST_HEAD(&obd_zombie_exports);
spin_lock_init(&obd_zombie_impexp_lock);
}
+