staging: lustre: remove RETURN macro
[deliverable/linux.git] / drivers / staging / lustre / lustre / obdclass / lu_object.c
index fdf0ed3676939bc1fbc8755704c7eccf37047909..c29ac1c2defd1850fabfd2186dc80ee0920af7eb 100644 (file)
@@ -202,7 +202,6 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env,
        struct list_head *layers;
        int clean;
        int result;
-       ENTRY;
 
        /*
         * Create top-level object slice. This will also create
@@ -210,9 +209,9 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env,
         */
        top = dev->ld_ops->ldo_object_alloc(env, NULL, dev);
        if (top == NULL)
-               RETURN(ERR_PTR(-ENOMEM));
+               return ERR_PTR(-ENOMEM);
        if (IS_ERR(top))
-               RETURN(top);
+               return top;
        /*
         * This is the only place where object fid is assigned. It's constant
         * after this point.
@@ -233,7 +232,7 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env,
                        result = scan->lo_ops->loo_object_init(env, scan, conf);
                        if (result != 0) {
                                lu_object_free(env, top);
-                               RETURN(ERR_PTR(result));
+                               return ERR_PTR(result);
                        }
                        scan->lo_flags |= LU_OBJECT_ALLOCATED;
                }
@@ -244,13 +243,13 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env,
                        result = scan->lo_ops->loo_object_start(env, scan);
                        if (result != 0) {
                                lu_object_free(env, top);
-                               RETURN(ERR_PTR(result));
+                               return ERR_PTR(result);
                        }
                }
        }
 
        lprocfs_counter_incr(dev->ld_site->ls_stats, LU_SS_CREATED);
-       RETURN(top);
+       return top;
 }
 
 /**
@@ -317,7 +316,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr)
        int                   i;
 
        if (OBD_FAIL_CHECK(OBD_FAIL_OBD_NO_LRU))
-               RETURN(0);
+               return 0;
 
        INIT_LIST_HEAD(&dispose);
        /*
@@ -538,7 +537,7 @@ static struct lu_object *htable_lookup(struct lu_site *s,
        __u64  ver = cfs_hash_bd_version_get(bd);
 
        if (*version == ver)
-               return NULL;
+               return ERR_PTR(-ENOENT);
 
        *version = ver;
        bkt = cfs_hash_bd_extra_get(s->ls_obj_hash, bd);
@@ -547,7 +546,7 @@ static struct lu_object *htable_lookup(struct lu_site *s,
        hnode = cfs_hash_bd_peek_locked(s->ls_obj_hash, bd, (void *)f);
        if (hnode == NULL) {
                lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_MISS);
-               return NULL;
+               return ERR_PTR(-ENOENT);
        }
 
        h = container_of0(hnode, struct lu_object_header, loh_hash);
@@ -651,7 +650,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
        cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1);
        o = htable_lookup(s, &bd, f, waiter, &version);
        cfs_hash_bd_unlock(hs, &bd, 1);
-       if (o != NULL)
+       if (!IS_ERR(o) || PTR_ERR(o) != -ENOENT)
                return o;
 
        /*
@@ -667,7 +666,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env,
        cfs_hash_bd_lock(hs, &bd, 1);
 
        shadow = htable_lookup(s, &bd, f, waiter, &version);
-       if (likely(shadow == NULL)) {
+       if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) {
                struct lu_site_bkt_data *bkt;
 
                bkt = cfs_hash_bd_extra_get(hs, &bd);
@@ -849,7 +848,7 @@ static int lu_htable_order(void)
         *
         * Size of lu_object is (arbitrary) taken as 1K (together with inode).
         */
-       cache_size = num_physpages;
+       cache_size = totalram_pages;
 
 #if BITS_PER_LONG == 32
        /* limit hashtable size for lowmem systems to low RAM */
@@ -980,7 +979,6 @@ int lu_site_init(struct lu_site *s, struct lu_device *top)
        char name[16];
        int bits;
        int i;
-       ENTRY;
 
        memset(s, 0, sizeof *s);
        bits = lu_htable_order();
@@ -1041,7 +1039,7 @@ int lu_site_init(struct lu_site *s, struct lu_device *top)
 
        lu_dev_add_linkage(s, top);
 
-       RETURN(0);
+       return 0;
 }
 EXPORT_SYMBOL(lu_site_init);
 
@@ -1147,15 +1145,16 @@ EXPORT_SYMBOL(lu_device_fini);
  * Initialize object \a o that is part of compound object \a h and was created
  * by device \a d.
  */
-int lu_object_init(struct lu_object *o,
-                  struct lu_object_header *h, struct lu_device *d)
+int lu_object_init(struct lu_object *o, struct lu_object_header *h,
+                  struct lu_device *d)
 {
-       memset(o, 0, sizeof *o);
+       memset(o, 0, sizeof(*o));
        o->lo_header = h;
-       o->lo_dev    = d;
+       o->lo_dev = d;
        lu_device_get(d);
-       o->lo_dev_ref = lu_ref_add(&d->ld_reference, "lu_object", o);
+       lu_ref_add_at(&d->ld_reference, &o->lo_dev_ref, "lu_object", o);
        INIT_LIST_HEAD(&o->lo_linkage);
+
        return 0;
 }
 EXPORT_SYMBOL(lu_object_init);
@@ -1170,8 +1169,8 @@ void lu_object_fini(struct lu_object *o)
        LASSERT(list_empty(&o->lo_linkage));
 
        if (dev != NULL) {
-               lu_ref_del_at(&dev->ld_reference,
-                             o->lo_dev_ref , "lu_object", o);
+               lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref,
+                             "lu_object", o);
                lu_device_put(dev);
                o->lo_dev = NULL;
        }
@@ -1315,7 +1314,6 @@ int lu_context_key_register(struct lu_context_key *key)
        LASSERT(key->lct_init != NULL);
        LASSERT(key->lct_fini != NULL);
        LASSERT(key->lct_tags != 0);
-       LASSERT(key->lct_owner != NULL);
 
        result = -ENFILE;
        spin_lock(&lu_keys_guard);
@@ -1349,7 +1347,6 @@ static void key_fini(struct lu_context *ctx, int index)
                lu_ref_del(&key->lct_reference, "ctx", ctx);
                atomic_dec(&key->lct_used);
 
-               LASSERT(key->lct_owner != NULL);
                if ((ctx->lc_tags & LCT_NOREF) == 0) {
 #ifdef CONFIG_MODULE_UNLOAD
                        LINVRNT(module_refcount(key->lct_owner) > 0);
@@ -1557,7 +1554,6 @@ static int keys_fill(struct lu_context *ctx)
                        if (unlikely(IS_ERR(value)))
                                return PTR_ERR(value);
 
-                       LASSERT(key->lct_owner != NULL);
                        if (!(ctx->lc_tags & LCT_NOREF))
                                try_module_get(key->lct_owner);
                        lu_ref_add_atomic(&key->lct_reference, "ctx", ctx);
@@ -2079,7 +2075,7 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o,
        cfs_hash_bd_get_and_lock(hs, (void *)fid, &bd, 1);
        shadow = htable_lookup(s, &bd, fid, &waiter, &version);
        /* supposed to be unique */
-       LASSERT(shadow == NULL);
+       LASSERT(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT);
        *old = *fid;
        bkt = cfs_hash_bd_extra_get(hs, &bd);
        cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash);
This page took 0.028162 seconds and 5 git commands to generate.