diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/obdclass/lu_object.c')
-rw-r--r-- | drivers/staging/lustre/lustre/obdclass/lu_object.c | 110 |
1 files changed, 52 insertions, 58 deletions
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index ce248f407..978568ada 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -86,13 +86,12 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o) */ fid = lu_object_fid(o); if (fid_is_zero(fid)) { - LASSERT(top->loh_hash.next == NULL - && top->loh_hash.pprev == NULL); + LASSERT(!top->loh_hash.next && !top->loh_hash.pprev); LASSERT(list_empty(&top->loh_lru)); if (!atomic_dec_and_test(&top->loh_ref)) return; list_for_each_entry_reverse(o, &top->loh_layers, lo_linkage) { - if (o->lo_ops->loo_object_release != NULL) + if (o->lo_ops->loo_object_release) o->lo_ops->loo_object_release(env, o); } lu_object_free(env, orig); @@ -119,7 +118,7 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o) * layers, and notify them that object is no longer busy. */ list_for_each_entry_reverse(o, &top->loh_layers, lo_linkage) { - if (o->lo_ops->loo_object_release != NULL) + if (o->lo_ops->loo_object_release) o->lo_ops->loo_object_release(env, o); } @@ -135,7 +134,7 @@ void lu_object_put(const struct lu_env *env, struct lu_object *o) } /* - * If object is dying (will not be cached), removed it + * If object is dying (will not be cached), then removed it * from hash table and LRU. * * This is done with hash table and LRU lists locked. As the only @@ -210,7 +209,7 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, * lu_object_header. */ top = dev->ld_ops->ldo_object_alloc(env, NULL, dev); - if (top == NULL) + if (!top) return ERR_PTR(-ENOMEM); if (IS_ERR(top)) return top; @@ -245,7 +244,7 @@ next: } while (!clean); list_for_each_entry_reverse(scan, layers, lo_linkage) { - if (scan->lo_ops->loo_object_start != NULL) { + if (scan->lo_ops->loo_object_start) { result = scan->lo_ops->loo_object_start(env, scan); if (result != 0) { lu_object_free(env, top); @@ -276,7 +275,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) * First call ->loo_object_delete() method to release all resources. */ list_for_each_entry_reverse(scan, layers, lo_linkage) { - if (scan->lo_ops->loo_object_delete != NULL) + if (scan->lo_ops->loo_object_delete) scan->lo_ops->loo_object_delete(env, scan); } @@ -296,7 +295,6 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o) */ o = container_of0(splice.prev, struct lu_object, lo_linkage); list_del_init(&o->lo_linkage); - LASSERT(o->lo_ops->loo_object_free != NULL); o->lo_ops->loo_object_free(env, o); } @@ -451,7 +449,6 @@ int lu_cdebug_printer(const struct lu_env *env, va_start(args, format); key = lu_context_key_get(&env->le_ctx, &lu_global_key); - LASSERT(key != NULL); used = strlen(key->lck_area); complete = format[strlen(format) - 1] == '\n'; @@ -462,7 +459,7 @@ int lu_cdebug_printer(const struct lu_env *env, ARRAY_SIZE(key->lck_area) - used, format, args); if (complete) { if (cfs_cdebug_show(msgdata->msg_mask, msgdata->msg_subsys)) - libcfs_debug_msg(msgdata, "%s", key->lck_area); + libcfs_debug_msg(msgdata, "%s\n", key->lck_area); key->lck_area[0] = 0; } va_end(args); @@ -508,7 +505,7 @@ void lu_object_print(const struct lu_env *env, void *cookie, (*printer)(env, cookie, "%*.*s%s@%p", depth, depth, ruler, o->lo_dev->ld_type->ldt_name, o); - if (o->lo_ops->loo_object_print != NULL) + if (o->lo_ops->loo_object_print) (*o->lo_ops->loo_object_print)(env, cookie, printer, o); (*printer)(env, cookie, "\n"); @@ -535,9 +532,10 @@ static struct lu_object *htable_lookup(struct lu_site *s, *version = ver; bkt = cfs_hash_bd_extra_get(s->ls_obj_hash, bd); /* cfs_hash_bd_peek_locked is a somehow "internal" function - * of cfs_hash, it doesn't add refcount on object. */ + * of cfs_hash, it doesn't add refcount on object. + */ hnode = cfs_hash_bd_peek_locked(s->ls_obj_hash, bd, (void *)f); - if (hnode == NULL) { + if (!hnode) { lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_MISS); return ERR_PTR(-ENOENT); } @@ -636,7 +634,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env, * If dying object is found during index search, add @waiter to the * site wait-queue and return ERR_PTR(-EAGAIN). */ - if (conf != NULL && conf->loc_flags & LOC_F_NEW) + if (conf && conf->loc_flags & LOC_F_NEW) return lu_object_new(env, dev, f, conf); s = dev->ld_site; @@ -715,7 +713,7 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env, top = lu_object_find(env, dev, f, conf); if (!IS_ERR(top)) { obj = lu_object_locate(top->lo_header, dev->ld_type); - if (obj == NULL) + if (!obj) lu_object_put(env, top); } else obj = top; @@ -842,8 +840,8 @@ static int lu_htable_order(void) #if BITS_PER_LONG == 32 /* limit hashtable size for lowmem systems to low RAM */ - if (cache_size > 1 << (30 - PAGE_CACHE_SHIFT)) - cache_size = 1 << (30 - PAGE_CACHE_SHIFT) * 3 / 4; + if (cache_size > 1 << (30 - PAGE_SHIFT)) + cache_size = 1 << (30 - PAGE_SHIFT) * 3 / 4; #endif /* clear off unreasonable cache setting. */ @@ -855,7 +853,7 @@ static int lu_htable_order(void) lu_cache_percent = LU_CACHE_PERCENT_DEFAULT; } cache_size = cache_size / 100 * lu_cache_percent * - (PAGE_CACHE_SIZE / 1024); + (PAGE_SIZE / 1024); for (bits = 1; (1 << bits) < cache_size; ++bits) { ; @@ -966,11 +964,11 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) CFS_HASH_NO_ITEMREF | CFS_HASH_DEPTH | CFS_HASH_ASSERT_EMPTY); - if (s->ls_obj_hash != NULL) + if (s->ls_obj_hash) break; } - if (s->ls_obj_hash == NULL) { + if (!s->ls_obj_hash) { CERROR("failed to create lu_site hash with bits: %d\n", bits); return -ENOMEM; } @@ -982,7 +980,7 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) } s->ls_stats = lprocfs_alloc_stats(LU_SS_LAST_STAT, 0); - if (s->ls_stats == NULL) { + if (!s->ls_stats) { cfs_hash_putref(s->ls_obj_hash); s->ls_obj_hash = NULL; return -ENOMEM; @@ -1031,19 +1029,19 @@ void lu_site_fini(struct lu_site *s) list_del_init(&s->ls_linkage); mutex_unlock(&lu_sites_guard); - if (s->ls_obj_hash != NULL) { + if (s->ls_obj_hash) { cfs_hash_putref(s->ls_obj_hash); s->ls_obj_hash = NULL; } - if (s->ls_top_dev != NULL) { + if (s->ls_top_dev) { s->ls_top_dev->ld_site = NULL; lu_ref_del(&s->ls_top_dev->ld_reference, "site-top", s); lu_device_put(s->ls_top_dev); s->ls_top_dev = NULL; } - if (s->ls_stats != NULL) + if (s->ls_stats) lprocfs_free_stats(&s->ls_stats); } EXPORT_SYMBOL(lu_site_fini); @@ -1088,7 +1086,7 @@ EXPORT_SYMBOL(lu_device_put); */ int lu_device_init(struct lu_device *d, struct lu_device_type *t) { - if (t->ldt_device_nr++ == 0 && t->ldt_ops->ldto_start != NULL) + if (t->ldt_device_nr++ == 0 && t->ldt_ops->ldto_start) t->ldt_ops->ldto_start(t); memset(d, 0, sizeof(*d)); atomic_set(&d->ld_ref, 0); @@ -1107,7 +1105,7 @@ void lu_device_fini(struct lu_device *d) struct lu_device_type *t; t = d->ld_type; - if (d->ld_obd != NULL) { + if (d->ld_obd) { d->ld_obd->obd_lu_dev = NULL; d->ld_obd = NULL; } @@ -1116,7 +1114,7 @@ void lu_device_fini(struct lu_device *d) LASSERTF(atomic_read(&d->ld_ref) == 0, "Refcount is %u\n", atomic_read(&d->ld_ref)); LASSERT(t->ldt_device_nr > 0); - if (--t->ldt_device_nr == 0 && t->ldt_ops->ldto_stop != NULL) + if (--t->ldt_device_nr == 0 && t->ldt_ops->ldto_stop) t->ldt_ops->ldto_stop(t); } EXPORT_SYMBOL(lu_device_fini); @@ -1148,7 +1146,7 @@ void lu_object_fini(struct lu_object *o) LASSERT(list_empty(&o->lo_linkage)); - if (dev != NULL) { + if (dev) { lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref, "lu_object", o); lu_device_put(dev); @@ -1239,7 +1237,7 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top) struct lu_device *next; lu_site_purge(env, site, ~0); - for (scan = top; scan != NULL; scan = next) { + for (scan = top; scan; scan = next) { next = scan->ld_type->ldt_ops->ldto_device_fini(env, scan); lu_ref_del(&scan->ld_reference, "lu-stack", &lu_site_init); lu_device_put(scan); @@ -1248,13 +1246,13 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top) /* purge again. */ lu_site_purge(env, site, ~0); - for (scan = top; scan != NULL; scan = next) { + for (scan = top; scan; scan = next) { const struct lu_device_type *ldt = scan->ld_type; struct obd_type *type; next = ldt->ldt_ops->ldto_device_free(env, scan); type = ldt->ldt_obd_type; - if (type != NULL) { + if (type) { type->typ_refcnt--; class_put_type(type); } @@ -1289,14 +1287,14 @@ int lu_context_key_register(struct lu_context_key *key) int result; int i; - LASSERT(key->lct_init != NULL); - LASSERT(key->lct_fini != NULL); + LASSERT(key->lct_init); + LASSERT(key->lct_fini); LASSERT(key->lct_tags != 0); result = -ENFILE; spin_lock(&lu_keys_guard); for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { - if (lu_keys[i] == NULL) { + if (!lu_keys[i]) { key->lct_index = i; atomic_set(&key->lct_used, 1); lu_keys[i] = key; @@ -1313,12 +1311,10 @@ EXPORT_SYMBOL(lu_context_key_register); static void key_fini(struct lu_context *ctx, int index) { - if (ctx->lc_value != NULL && ctx->lc_value[index] != NULL) { + if (ctx->lc_value && ctx->lc_value[index]) { struct lu_context_key *key; key = lu_keys[index]; - LASSERT(key != NULL); - LASSERT(key->lct_fini != NULL); LASSERT(atomic_read(&key->lct_used) > 1); key->lct_fini(ctx, key, ctx->lc_value[index]); @@ -1376,7 +1372,7 @@ int lu_context_key_register_many(struct lu_context_key *k, ...) if (result) break; key = va_arg(args, struct lu_context_key *); - } while (key != NULL); + } while (key); va_end(args); if (result != 0) { @@ -1404,7 +1400,7 @@ void lu_context_key_degister_many(struct lu_context_key *k, ...) do { lu_context_key_degister(k); k = va_arg(args, struct lu_context_key*); - } while (k != NULL); + } while (k); va_end(args); } EXPORT_SYMBOL(lu_context_key_degister_many); @@ -1420,7 +1416,7 @@ void lu_context_key_revive_many(struct lu_context_key *k, ...) do { lu_context_key_revive(k); k = va_arg(args, struct lu_context_key*); - } while (k != NULL); + } while (k); va_end(args); } EXPORT_SYMBOL(lu_context_key_revive_many); @@ -1436,7 +1432,7 @@ void lu_context_key_quiesce_many(struct lu_context_key *k, ...) do { lu_context_key_quiesce(k); k = va_arg(args, struct lu_context_key*); - } while (k != NULL); + } while (k); va_end(args); } EXPORT_SYMBOL(lu_context_key_quiesce_many); @@ -1477,8 +1473,7 @@ void lu_context_key_quiesce(struct lu_context_key *key) * XXX memory barrier has to go here. */ spin_lock(&lu_keys_guard); - list_for_each_entry(ctx, &lu_context_remembered, - lc_remember) + list_for_each_entry(ctx, &lu_context_remembered, lc_remember) key_fini(ctx, key->lct_index); spin_unlock(&lu_keys_guard); ++key_set_version; @@ -1497,7 +1492,7 @@ static void keys_fini(struct lu_context *ctx) { int i; - if (ctx->lc_value == NULL) + if (!ctx->lc_value) return; for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) @@ -1511,12 +1506,12 @@ static int keys_fill(struct lu_context *ctx) { int i; - LINVRNT(ctx->lc_value != NULL); + LINVRNT(ctx->lc_value); for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { struct lu_context_key *key; key = lu_keys[i]; - if (ctx->lc_value[i] == NULL && key != NULL && + if (!ctx->lc_value[i] && key && (key->lct_tags & ctx->lc_tags) && /* * Don't create values for a LCT_QUIESCENT key, as this @@ -1525,7 +1520,7 @@ static int keys_fill(struct lu_context *ctx) !(key->lct_tags & LCT_QUIESCENT)) { void *value; - LINVRNT(key->lct_init != NULL); + LINVRNT(key->lct_init); LINVRNT(key->lct_index == i); value = key->lct_init(ctx, key); @@ -1542,7 +1537,7 @@ static int keys_fill(struct lu_context *ctx) * value. */ ctx->lc_value[i] = value; - if (key->lct_exit != NULL) + if (key->lct_exit) ctx->lc_tags |= LCT_HAS_EXIT; } ctx->lc_version = key_set_version; @@ -1554,7 +1549,7 @@ static int keys_init(struct lu_context *ctx) { ctx->lc_value = kcalloc(ARRAY_SIZE(lu_keys), sizeof(ctx->lc_value[0]), GFP_NOFS); - if (likely(ctx->lc_value != NULL)) + if (likely(ctx->lc_value)) return keys_fill(ctx); return -ENOMEM; @@ -1626,14 +1621,13 @@ void lu_context_exit(struct lu_context *ctx) LINVRNT(ctx->lc_state == LCS_ENTERED); ctx->lc_state = LCS_LEFT; - if (ctx->lc_tags & LCT_HAS_EXIT && ctx->lc_value != NULL) { + if (ctx->lc_tags & LCT_HAS_EXIT && ctx->lc_value) { for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) { - if (ctx->lc_value[i] != NULL) { + if (ctx->lc_value[i]) { struct lu_context_key *key; key = lu_keys[i]; - LASSERT(key != NULL); - if (key->lct_exit != NULL) + if (key->lct_exit) key->lct_exit(ctx, key, ctx->lc_value[i]); } @@ -1688,7 +1682,7 @@ int lu_env_refill(struct lu_env *env) int result; result = lu_context_refill(&env->le_ctx); - if (result == 0 && env->le_ses != NULL) + if (result == 0 && env->le_ses) result = lu_context_refill(env->le_ses); return result; } @@ -1922,11 +1916,11 @@ int lu_kmem_init(struct lu_kmem_descr *caches) int result; struct lu_kmem_descr *iter = caches; - for (result = 0; iter->ckd_cache != NULL; ++iter) { + for (result = 0; iter->ckd_cache; ++iter) { *iter->ckd_cache = kmem_cache_create(iter->ckd_name, iter->ckd_size, 0, 0, NULL); - if (*iter->ckd_cache == NULL) { + if (!*iter->ckd_cache) { result = -ENOMEM; /* free all previously allocated caches */ lu_kmem_fini(caches); @@ -1943,7 +1937,7 @@ EXPORT_SYMBOL(lu_kmem_init); */ void lu_kmem_fini(struct lu_kmem_descr *caches) { - for (; caches->ckd_cache != NULL; ++caches) { + for (; caches->ckd_cache; ++caches) { kmem_cache_destroy(*caches->ckd_cache); *caches->ckd_cache = NULL; } |