Fix KMC_OFFSLAB type caches

Because spl_slab_size() was always returning -ENOSPC for caches of
type KMC_OFFSLAB the cache could never be created.  Additionally
the slab size is rounded up to a page which is what kv_alloc()
expects.  The kv_alloc() code will minimally allocate a page,
in the KMC_OFFSLAB case this could be reduced.

The basic regression tests kmem:slab_small, kmem:slab_large,
and kmem:slab_align regression were updated to test KMC_OFFSLAB.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ying Zhu <casualfisher@gmail.com>
Closes #266
This commit is contained in:
Brian Behlendorf 2013-07-19 14:39:35 -07:00
parent b9b3715346
commit ceb3872825
2 changed files with 45 additions and 3 deletions

View File

@ -1368,7 +1368,8 @@ spl_slab_size(spl_kmem_cache_t *skc, uint32_t *objs, uint32_t *size)
if (skc->skc_flags & KMC_OFFSLAB) {
*objs = SPL_KMEM_CACHE_OBJ_PER_SLAB;
*size = sizeof(spl_kmem_slab_t);
*size = P2ROUNDUP(sizeof(spl_kmem_slab_t), PAGE_SIZE);
SRETURN(0);
} else {
sks_size = spl_sks_size(skc);
obj_size = spl_obj_size(skc);

View File

@ -745,6 +745,7 @@ splat_kmem_test5(struct file *file, void *arg)
char *name = SPLAT_KMEM_TEST5_NAME;
int rc;
/* On slab (default + kmem + vmem) */
rc = splat_kmem_cache_test(file, arg, name, 128, 0, 0);
if (rc)
return rc;
@ -753,7 +754,24 @@ splat_kmem_test5(struct file *file, void *arg)
if (rc)
return rc;
return splat_kmem_cache_test(file, arg, name, 128, 0, KMC_VMEM);
rc = splat_kmem_cache_test(file, arg, name, 128, 0, KMC_VMEM);
if (rc)
return rc;
/* Off slab (default + kmem + vmem) */
rc = splat_kmem_cache_test(file, arg, name, 128, 0, KMC_OFFSLAB);
if (rc)
return rc;
rc = splat_kmem_cache_test(file, arg, name, 128, 0,
KMC_KMEM | KMC_OFFSLAB);
if (rc)
return rc;
rc = splat_kmem_cache_test(file, arg, name, 128, 0,
KMC_VMEM | KMC_OFFSLAB);
return rc;
}
/*
@ -765,6 +783,7 @@ splat_kmem_test6(struct file *file, void *arg)
char *name = SPLAT_KMEM_TEST6_NAME;
int rc;
/* On slab (default + kmem + vmem) */
rc = splat_kmem_cache_test(file, arg, name, 256*1024, 0, 0);
if (rc)
return rc;
@ -773,7 +792,24 @@ splat_kmem_test6(struct file *file, void *arg)
if (rc)
return rc;
return splat_kmem_cache_test(file, arg, name, 1024*1024, 0, KMC_VMEM);
rc = splat_kmem_cache_test(file, arg, name, 1024*1024, 0, KMC_VMEM);
if (rc)
return rc;
/* Off slab (default + kmem + vmem) */
rc = splat_kmem_cache_test(file, arg, name, 256*1024, 0, KMC_OFFSLAB);
if (rc)
return rc;
rc = splat_kmem_cache_test(file, arg, name, 64*1024, 0,
KMC_KMEM | KMC_OFFSLAB);
if (rc)
return rc;
rc = splat_kmem_cache_test(file, arg, name, 1024*1024, 0,
KMC_VMEM | KMC_OFFSLAB);
return rc;
}
/*
@ -789,6 +825,11 @@ splat_kmem_test7(struct file *file, void *arg)
rc = splat_kmem_cache_test(file, arg, name, 157, i, 0);
if (rc)
return rc;
rc = splat_kmem_cache_test(file, arg, name, 157, i,
KMC_OFFSLAB);
if (rc)
return rc;
}
return rc;