[Lustre-devel] OSD object questions

Bobi Jam bobijam at whamcloud.com
Fri Oct 19 10:38:04 PDT 2012


My understanding is that when we allocate top slice object by calling lu_object_alloc(), first it calls its corresponding device's ldo_object_alloc() to create the top slice object, then it go into following code

do {
        /*
         * Call ->loo_object_init() repeatedly, until no more new
         * object slices are created.
         */
        clean = 1;
        cfs_list_for_each_entry(scan, layers, lo_linkage) {
                if (scan->lo_flags & LU_OBJECT_ALLOCATED)
                        continue;
                clean = 0;
                scan->lo_header = top->lo_header;
                result = scan->lo_ops->loo_object_init(env, scan, conf);
                if (result != 0) {
                        lu_object_free(env, top);
                        RETURN(ERR_PTR(result));
                }
                scan->lo_flags |= LU_OBJECT_ALLOCATED;
        }
} while (!clean);

In the first round, the layers list only contains the upper slice it self (scan be the top object), scan->lo_ops->loo_object_init() will go into the <top>_object_init() as you described earlier, it allocate lower slice object and add it into the layers list (by calling lu_object_add()), and scan->lo_flags is set to indicate that the top object has been allocated, this time clean is 0, we will go into the 2nd round of do_while loop.

In the 2nd round, layers list contains top object(flags is set as allocated) and 2nd slice object (flags hasn't be set allocated), clean <- 0 and scan <- 2nd_slice_obj, its loo_object_init() will alloc possible 3rd slice obj, and continue the loop.

If there's no 3rd slice, 2nd_obj->loo_object_init() will just initialise 2nd object itself and not 3rd object be allocated and linked into the layers list (as osc_object_init() shows), and 2nd_obj's flag set to be allocated. And the loop will bail out.

-- 
Best regards,

Bobi Jam     bobijam at whamcloud.com

On Oct 19, 2012, at 3:15 AM, James A Simmons <uja at ornl.gov> wrote:

> The part I had a hard time making out was the 
> lu_object_alloc() function in lu_object.c. You appear to allocate a
> top level lu_object with the low level ldo_object_alloc hook but its a
> freshly created object so I assume because you did add the top object to
> its own list, loh_layer, that the loop you do only contains one object
> but you loop as if alot of lu_objects will be in the loh_layers list
> with some even allocated. Where is that list being set from so the
> properly related objects are initialized? Which objects are being
> initialized? The one's higher in the slice? 




More information about the lustre-devel mailing list