#define RECOMPRESS_IDLE (1 << 0)
#define RECOMPRESS_HUGE (1 << 1)
+static bool highest_priority_algorithm(struct zram *zram, u32 prio)
+{
+ u32 p;
+
+ for (p = prio + 1; p < ZRAM_MAX_COMPS; p++) {
+ if (zram->comp_algs[p])
+ return false;
+ }
+
+ return true;
+}
+
static int scan_slots_for_recompress(struct zram *zram, u32 mode, u32 prio_max,
struct zram_pp_ctl *ctl)
{
* Secondary algorithms failed to re-compress the page
* in a way that would save memory.
*
- * Mark the object incompressible if the max-priority
- * algorithm couldn't re-compress it.
+ * Mark the object incompressible if the max-priority (the
+ * last configured one) algorithm couldn't re-compress it.
*/
- if (prio < zram->num_active_comps)
- return 0;
- set_slot_flag(zram, index, ZRAM_INCOMPRESSIBLE);
+ if (highest_priority_algorithm(zram, prio))
+ set_slot_flag(zram, index, ZRAM_INCOMPRESSIBLE);
return 0;
}
}
}
- prio_max = min(prio_max, (u32)zram->num_active_comps);
- if (prio >= prio_max) {
- ret = -EINVAL;
- goto out;
- }
-
if (prio < ZRAM_SECONDARY_COMP || prio >= ZRAM_MAX_COMPS) {
ret = -EINVAL;
goto out;
if (!comp)
continue;
zcomp_destroy(comp);
- zram->num_active_comps--;
}
for (prio = ZRAM_PRIMARY_COMP; prio < ZRAM_MAX_COMPS; prio++)
}
zram->comps[prio] = comp;
- zram->num_active_comps++;
}
zram->disksize = disksize;
set_capacity_and_notify(zram->disk, zram->disksize >> SECTOR_SHIFT);