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
This commit is contained in:
Peter Enderborg 2016-08-26 15:09:35 +02:00 committed by Jin Qian
parent 16300f192b
commit 4d217f02d3
4 changed files with 20 additions and 0 deletions

View File

@ -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) {

View File

@ -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++;
}

View File

@ -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

View File

@ -73,6 +73,7 @@ struct fstab_rec {
char *label;
int partnum;
int swap_prio;
int max_comp_streams;
unsigned int zram_size;
};