Linux 6.9-rc1
[linux-2.6-microblaze.git] / mm / zpool.c
index 68facc1..8464104 100644 (file)
@@ -21,9 +21,6 @@
 struct zpool {
        struct zpool_driver *driver;
        void *pool;
-       const struct zpool_ops *ops;
-       bool evictable;
-       bool can_sleep_mapped;
 };
 
 static LIST_HEAD(drivers_head);
@@ -136,7 +133,6 @@ EXPORT_SYMBOL(zpool_has_pool);
  * @type:      The type of the zpool to create (e.g. zbud, zsmalloc)
  * @name:      The name of the zpool (e.g. zram0, zswap)
  * @gfp:       The GFP flags to use when allocating the pool.
- * @ops:       The optional ops callback.
  *
  * This creates a new zpool of the specified type.  The gfp flags will be
  * used when allocating memory, if the implementation supports it.  If the
@@ -148,8 +144,7 @@ EXPORT_SYMBOL(zpool_has_pool);
  *
  * Returns: New zpool on success, NULL on failure.
  */
-struct zpool *zpool_create_pool(const char *type, const char *name, gfp_t gfp,
-               const struct zpool_ops *ops)
+struct zpool *zpool_create_pool(const char *type, const char *name, gfp_t gfp)
 {
        struct zpool_driver *driver;
        struct zpool *zpool;
@@ -176,10 +171,7 @@ struct zpool *zpool_create_pool(const char *type, const char *name, gfp_t gfp,
        }
 
        zpool->driver = driver;
-       zpool->pool = driver->create(name, gfp, ops, zpool);
-       zpool->ops = ops;
-       zpool->evictable = driver->shrink && ops && ops->evict;
-       zpool->can_sleep_mapped = driver->sleep_mapped;
+       zpool->pool = driver->create(name, gfp);
 
        if (!zpool->pool) {
                pr_err("couldn't create %s pool\n", type);
@@ -285,30 +277,6 @@ void zpool_free(struct zpool *zpool, unsigned long handle)
        zpool->driver->free(zpool->pool, handle);
 }
 
-/**
- * zpool_shrink() - Shrink the pool size
- * @zpool:     The zpool to shrink.
- * @pages:     The number of pages to shrink the pool.
- * @reclaimed: The number of pages successfully evicted.
- *
- * This attempts to shrink the actual memory size of the pool
- * by evicting currently used handle(s).  If the pool was
- * created with no zpool_ops, or the evict call fails for any
- * of the handles, this will fail.  If non-NULL, the @reclaimed
- * parameter will be set to the number of pages reclaimed,
- * which may be more than the number of pages requested.
- *
- * Implementations must guarantee this to be thread-safe.
- *
- * Returns: 0 on success, negative value on error/failure.
- */
-int zpool_shrink(struct zpool *zpool, unsigned int pages,
-                       unsigned int *reclaimed)
-{
-       return zpool->driver->shrink ?
-              zpool->driver->shrink(zpool->pool, pages, reclaimed) : -EINVAL;
-}
-
 /**
  * zpool_map_handle() - Map a previously allocated handle into memory
  * @zpool:     The zpool that the handle was allocated from
@@ -365,35 +333,23 @@ u64 zpool_get_total_size(struct zpool *zpool)
        return zpool->driver->total_size(zpool->pool);
 }
 
-/**
- * zpool_evictable() - Test if zpool is potentially evictable
- * @zpool:     The zpool to test
- *
- * Zpool is only potentially evictable when it's created with struct
- * zpool_ops.evict and its driver implements struct zpool_driver.shrink.
- *
- * However, it doesn't necessarily mean driver will use zpool_ops.evict
- * in its implementation of zpool_driver.shrink. It could do internal
- * defragmentation instead.
- *
- * Returns: true if potentially evictable; false otherwise.
- */
-bool zpool_evictable(struct zpool *zpool)
-{
-       return zpool->evictable;
-}
-
 /**
  * zpool_can_sleep_mapped - Test if zpool can sleep when do mapped.
  * @zpool:     The zpool to test
  *
+ * Some allocators enter non-preemptible context in ->map() callback (e.g.
+ * disable pagefaults) and exit that context in ->unmap(), which limits what
+ * we can do with the mapped object. For instance, we cannot wait for
+ * asynchronous crypto API to decompress such an object or take mutexes
+ * since those will call into the scheduler. This function tells us whether
+ * we use such an allocator.
+ *
  * Returns: true if zpool can sleep; false otherwise.
  */
 bool zpool_can_sleep_mapped(struct zpool *zpool)
 {
-       return zpool->can_sleep_mapped;
+       return zpool->driver->sleep_mapped;
 }
 
-MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>");
 MODULE_DESCRIPTION("Common API for compressed memory storage");