[PATCHv2 3/3] zsmalloc: add compaction callbacks

From: Vitaly Wool
Date: Sat Sep 26 2015 - 04:10:02 EST


Add compaction callbacks for zpool compaction API extension.

Signed-off-by: Vitaly Wool <vitalywool@xxxxxxxxx>
---
mm/zsmalloc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index f135b1b..8f2ddd1 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -365,6 +365,19 @@ static void zs_zpool_unmap(void *pool, unsigned long handle)
zs_unmap_object(pool, handle);
}

+static unsigned long zs_zpool_compact(void *pool)
+{
+ return zs_compact(pool);
+}
+
+static unsigned long zs_zpool_get_compacted(void *pool)
+{
+ struct zs_pool_stats stats;
+
+ zs_pool_stats(pool, &stats);
+ return stats.pages_compacted;
+}
+
static u64 zs_zpool_total_size(void *pool)
{
return zs_get_total_pages(pool) << PAGE_SHIFT;
@@ -380,6 +393,8 @@ static struct zpool_driver zs_zpool_driver = {
.shrink = zs_zpool_shrink,
.map = zs_zpool_map,
.unmap = zs_zpool_unmap,
+ .compact = zs_zpool_compact,
+ .get_num_compacted = zs_zpool_get_compacted,
.total_size = zs_zpool_total_size,
};

--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/