lkml.org 
[lkml]   [2018]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] zswap: only save zswap header if zpool is shrinkable
On (01/08/18 14:51), Yu Zhao wrote:
[..]
> int zpool_shrink(struct zpool *zpool, unsigned int pages,
> unsigned int *reclaimed)
> {
> - return zpool->driver->shrink(zpool->pool, pages, reclaimed);
> + return zpool_shrinkable(zpool) ?
> + zpool->driver->shrink(zpool->pool, pages, reclaimed) : -EINVAL;
> }
>
> /**
> @@ -355,6 +356,20 @@ u64 zpool_get_total_size(struct zpool *zpool)
> return zpool->driver->total_size(zpool->pool);
> }
>
> +/**
> + * zpool_shrinkable() - Test if zpool is shrinkable
> + * @pool The zpool to test
> + *
> + * Zpool is only shrinkable when it's created with struct
> + * zpool_ops.evict and its driver implements struct zpool_driver.shrink.
> + *
> + * Returns: true if shrinkable; false otherwise.
> + */
> +bool zpool_shrinkable(struct zpool *zpool)
> +{
> + return zpool->ops && zpool->ops->evict && zpool->driver->shrink;
> +}

just a side note,
it might be a bit confusing and maybe there is a better
name for it. zsmalloc is shrinkable (we register a shrinker
callback), but not in the way zpool defines it.

-ss

\
 
 \ /
  Last update: 2018-01-14 23:18    [W:0.106 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site