BAD: list_add(&list_item, list_head.prev); Overwrites the adjacent field.
GOOD: list_add_tail(&list_item, list_head);
While the following usage is technically correct, it does encourage people
to use the above (incorrect) usage pattern, so it should be avoided:
BAD: list_add(&list_item, list_head.next);
GOOD: list_add_tail(&list_item, &list_head);
Just FYI - list_add() is like a queue, while list_add_tail() is like a stack,
when iterating over items via list_for_each().
lock->l_completion_ast(lock, 0);
}
} else
- list_add(&lock->l_res_link, res->lr_converting.prev);
+ list_add_tail(&lock->l_res_link, &res->lr_converting);
l_unlock(&ns->ns_lock);
LBUG();
GOTO(out, ns);
}
+ obd_memory += sizeof(*ns->ns_hash) * RES_HASH_SIZE;
OBD_ALLOC(ns->ns_name, strlen(name) + 1);
if (!ns->ns_name) {
RETURN(ns);
out:
- if (ns && ns->ns_hash)
+ if (ns && ns->ns_hash) {
vfree(ns->ns_hash);
+ obd_memory -= sizeof(*ns->ns_hash) * RES_HASH_SIZE;
+ }
if (ns && ns->ns_name)
OBD_FREE(ns->ns_name, strlen(name) + 1);
if (ns)
}
}
- vfree(ns->ns_hash /* , sizeof(struct list_head) * RES_HASH_SIZE */);
+ vfree(ns->ns_hash /* , sizeof(*ns->ns_hash) * RES_HASH_SIZE */);
+ obd_memory -= sizeof(*ns->ns_hash) * RES_HASH_SIZE;
ptlrpc_cleanup_client(&ns->ns_rpc_client);
OBD_FREE(ns->ns_name, strlen(ns->ns_name) + 1);
OBD_FREE(ns, sizeof(*ns));
INIT_LIST_HEAD(&obd->obd_exports);
/* do the attach */
- if (OBT(obd) && OBP(obd, attach))
+ if (OBP(obd, attach))
err = OBP(obd,attach)(obd, sizeof(*data), data);
if (err) {
obd->obd_type = NULL;
RETURN(-ENOMEM);
INIT_LIST_HEAD(&type->typ_chain);
MOD_INC_USE_COUNT;
- list_add(&type->typ_chain, obd_types.next);
+ list_add(&type->typ_chain, &obd_types);
type->typ_ops = ops;
type->typ_name = nm;
RETURN(0);
ENTRY;
- if ( !type ) {
+ if (!type) {
CERROR("unknown obd type\n");
RETURN(-EINVAL);
}
- if ( type->typ_refcnt ) {
+ if (type->typ_refcnt) {
CERROR("type %s has refcount (%d)\n", nm, type->typ_refcnt);
RETURN(-EBUSY);
}
get_random_bytes(&export->exp_cookie, sizeof(__u64));
export->exp_obd = obddev;
INIT_LIST_HEAD(&export->exp_mds_data.med_open_head);
- list_add(&(export->exp_chain), export->exp_obd->obd_exports.prev);
+ list_add(&(export->exp_chain), &export->exp_obd->obd_exports);
return export;
}
struct inode *inode;
int j;
- dentry = filter_fid2dentry(obd,
- filter_parent(obd, S_IFREG),
+ dentry = filter_fid2dentry(obd, filter_parent(obd, S_IFREG),
o->ioo_id, S_IFREG);
if (IS_ERR(dentry))
GOTO(out_clean, rc = PTR_ERR(dentry));