Merge tag 'for-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power...
[linux-block.git] / mm / zpool.c
index 68facc193496523c6a51394483c9f0b70cc839aa..571f5c5031dda4c5fc4c64e2a3118a63430b78db 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);
@@ -177,9 +174,6 @@ 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;
 
        if (!zpool->pool) {
                pr_err("couldn't create %s pool\n", type);
@@ -380,18 +374,25 @@ u64 zpool_get_total_size(struct zpool *zpool)
  */
 bool zpool_evictable(struct zpool *zpool)
 {
-       return zpool->evictable;
+       return zpool->driver->shrink;
 }
 
 /**
  * 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");