From 4d217f02d3327cc06a3266c3e1022cef7dd753ff Mon Sep 17 00:00:00 2001 From: Peter Enderborg Date: Fri, 26 Aug 2016 15:09:35 +0200 Subject: [PATCH] Add support for max_comp_streams option for zram With this option the fstab can include a parameter for zram the enables more streams for kernels that does not have dynamic stream task handling. Test: Made sure max_comp_streams is set according to fstab. Change-Id: I22e158a075a8a86b4e80d3b13989896929c0d223 --- fs_mgr/fs_mgr.c | 13 +++++++++++++ fs_mgr/fs_mgr_fstab.c | 5 +++++ fs_mgr/fs_mgr_priv.h | 1 + fs_mgr/include/fs_mgr.h | 1 + 4 files changed, 20 insertions(+) diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c index b1511fed8..e0d46d3ac 100644 --- a/fs_mgr/fs_mgr.c +++ b/fs_mgr/fs_mgr.c @@ -56,6 +56,7 @@ #define FSCK_LOG_FILE "/dev/fscklogs/log" #define ZRAM_CONF_DEV "/sys/block/zram0/disksize" +#define ZRAM_CONF_MCS "/sys/block/zram0/max_comp_streams" #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) @@ -802,6 +803,18 @@ int fs_mgr_swapon_all(struct fstab *fstab) * we can assume the device number is 0. */ FILE *zram_fp; + FILE *zram_mcs_fp; + + if (fstab->recs[i].max_comp_streams >= 0) { + zram_mcs_fp = fopen(ZRAM_CONF_MCS, "r+"); + if (zram_mcs_fp == NULL) { + ERROR("Unable to open zram conf comp device %s\n", ZRAM_CONF_MCS); + ret = -1; + continue; + } + fprintf(zram_mcs_fp, "%d\n", fstab->recs[i].max_comp_streams); + fclose(zram_mcs_fp); + } zram_fp = fopen(ZRAM_CONF_DEV, "r+"); if (zram_fp == NULL) { diff --git a/fs_mgr/fs_mgr_fstab.c b/fs_mgr/fs_mgr_fstab.c index 313bc5abb..b219b38a8 100644 --- a/fs_mgr/fs_mgr_fstab.c +++ b/fs_mgr/fs_mgr_fstab.c @@ -31,6 +31,7 @@ struct fs_mgr_flag_values { char *label; int partnum; int swap_prio; + int max_comp_streams; unsigned int zram_size; }; @@ -71,6 +72,7 @@ static struct flag_list fs_mgr_flags[] = { { "recoveryonly",MF_RECOVERYONLY }, { "swapprio=", MF_SWAPPRIO }, { "zramsize=", MF_ZRAMSIZE }, + { "max_comp_streams=", MF_MAX_COMP_STREAMS }, { "verify", MF_VERIFY }, { "noemulatedsd", MF_NOEMULATEDSD }, { "notrim", MF_NOTRIM }, @@ -180,6 +182,8 @@ static int parse_flags(char *flags, struct flag_list *fl, } } else if ((fl[i].flag == MF_SWAPPRIO) && flag_vals) { flag_vals->swap_prio = strtoll(strchr(p, '=') + 1, NULL, 0); + } else if ((fl[i].flag == MF_MAX_COMP_STREAMS) && flag_vals) { + flag_vals->max_comp_streams = strtoll(strchr(p, '=') + 1, NULL, 0); } else if ((fl[i].flag == MF_ZRAMSIZE) && flag_vals) { int is_percent = !!strrchr(p, '%'); unsigned int val = strtoll(strchr(p, '=') + 1, NULL, 0); @@ -329,6 +333,7 @@ struct fstab *fs_mgr_read_fstab_file(FILE *fstab_file) fstab->recs[cnt].label = flag_vals.label; fstab->recs[cnt].partnum = flag_vals.partnum; fstab->recs[cnt].swap_prio = flag_vals.swap_prio; + fstab->recs[cnt].max_comp_streams = flag_vals.max_comp_streams; fstab->recs[cnt].zram_size = flag_vals.zram_size; cnt++; } diff --git a/fs_mgr/fs_mgr_priv.h b/fs_mgr/fs_mgr_priv.h index 6d9492bef..6f6926c14 100644 --- a/fs_mgr/fs_mgr_priv.h +++ b/fs_mgr/fs_mgr_priv.h @@ -85,6 +85,7 @@ __BEGIN_DECLS #define MF_FORCEFDEORFBE 0x10000 #define MF_LATEMOUNT 0x20000 #define MF_NOFAIL 0x40000 +#define MF_MAX_COMP_STREAMS 0x80000 #define DM_BUF_SIZE 4096 diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h index b120f7c35..37df8f867 100644 --- a/fs_mgr/include/fs_mgr.h +++ b/fs_mgr/include/fs_mgr.h @@ -73,6 +73,7 @@ struct fstab_rec { char *label; int partnum; int swap_prio; + int max_comp_streams; unsigned int zram_size; };