summaryrefslogtreecommitdiffstats
path: root/fs_mgr
diff options
context:
space:
mode:
authorSultan Qasim Khan <sultanqasim@gmail.com>2015-09-07 01:30:17 -0400
committerSteve Kondik <steve@cyngn.com>2015-10-16 06:39:09 -0700
commitdfe4df3928490dc9a56c97ffcdd8ea7e90b49358 (patch)
treeb315328b7667aaf62aba4c248639f4415a829d45 /fs_mgr
parent93a0c2a7c03224fc4b71689a7cc57f7b04ffd2a7 (diff)
downloadsystem_core-dfe4df3928490dc9a56c97ffcdd8ea7e90b49358.zip
system_core-dfe4df3928490dc9a56c97ffcdd8ea7e90b49358.tar.gz
system_core-dfe4df3928490dc9a56c97ffcdd8ea7e90b49358.tar.bz2
fs_mgr: zram: allow specifying stream count
This parameter allows specifying the number of parallel streams to be used in compression and decompression. This option was added in Linux 3.15, so it is not very common among devices currently on the market, but it has been backported to some kernels. This option must be set before zRAM is activated, as the kernel does not allow switching from single stream to multistream compression once zRAM is active. Change-Id: I3f5ad96a65b3b4a6915d2700c398a236ea8931b0
Diffstat (limited to 'fs_mgr')
-rw-r--r--fs_mgr/fs_mgr.c9
-rw-r--r--fs_mgr/fs_mgr_fstab.c6
-rw-r--r--fs_mgr/fs_mgr_priv.h1
-rw-r--r--fs_mgr/include/fs_mgr.h1
4 files changed, 17 insertions, 0 deletions
diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c
index d79932d..6e20560 100644
--- a/fs_mgr/fs_mgr.c
+++ b/fs_mgr/fs_mgr.c
@@ -61,6 +61,7 @@
#define FSCK_LOG_FILE "/dev/fscklogs/log"
#define ZRAM_CONF_DEV "/sys/block/zram0/disksize"
+#define ZRAM_STREAMS "/sys/block/zram0/max_comp_streams"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
@@ -871,6 +872,14 @@ int fs_mgr_swapon_all(struct fstab *fstab)
*/
FILE *zram_fp;
+ /* The stream count parameter is only available on new kernels.
+ * It must be set before the disk size. */
+ zram_fp = fopen(ZRAM_STREAMS, "r+");
+ if (zram_fp) {
+ fprintf(zram_fp, "%d\n", fstab->recs[i].zram_streams);
+ fclose(zram_fp);
+ }
+
zram_fp = fopen(ZRAM_CONF_DEV, "r+");
if (zram_fp == NULL) {
ERROR("Unable to open zram conf device %s\n", ZRAM_CONF_DEV);
diff --git a/fs_mgr/fs_mgr_fstab.c b/fs_mgr/fs_mgr_fstab.c
index f24af1f..b1b0325 100644
--- a/fs_mgr/fs_mgr_fstab.c
+++ b/fs_mgr/fs_mgr_fstab.c
@@ -32,6 +32,7 @@ struct fs_mgr_flag_values {
int partnum;
int swap_prio;
unsigned int zram_size;
+ unsigned int zram_streams;
};
struct flag_list {
@@ -74,6 +75,7 @@ static struct flag_list fs_mgr_flags[] = {
{ "noemulatedsd", MF_NOEMULATEDSD },
{ "notrim", MF_NOTRIM },
{ "formattable", MF_FORMATTABLE },
+ { "zramstreams=",MF_ZRAMSTREAMS },
{ "defaults", 0 },
{ 0, 0 },
};
@@ -106,6 +108,7 @@ static int parse_flags(char *flags, struct flag_list *fl,
memset(flag_vals, 0, sizeof(*flag_vals));
flag_vals->partnum = -1;
flag_vals->swap_prio = -1; /* negative means it wasn't specified. */
+ flag_vals->zram_streams = 1;
}
/* initialize fs_options to the null string */
@@ -178,6 +181,8 @@ static int parse_flags(char *flags, struct flag_list *fl,
flag_vals->zram_size = calculate_zram_size(val);
else
flag_vals->zram_size = val;
+ } else if ((fl[i].flag == MF_ZRAMSTREAMS) && flag_vals) {
+ flag_vals->zram_streams = strtoll(strchr(p, '=') + 1, NULL, 0);
}
break;
}
@@ -329,6 +334,7 @@ struct fstab *fs_mgr_read_fstab(const char *fstab_path)
fstab->recs[cnt].partnum = flag_vals.partnum;
fstab->recs[cnt].swap_prio = flag_vals.swap_prio;
fstab->recs[cnt].zram_size = flag_vals.zram_size;
+ fstab->recs[cnt].zram_streams = flag_vals.zram_streams;
cnt++;
}
fclose(fstab_file);
diff --git a/fs_mgr/fs_mgr_priv.h b/fs_mgr/fs_mgr_priv.h
index 682fd11..b72e200 100644
--- a/fs_mgr/fs_mgr_priv.h
+++ b/fs_mgr/fs_mgr_priv.h
@@ -79,6 +79,7 @@
#define MF_NOTRIM 0x1000
#define MF_FILEENCRYPTION 0x2000
#define MF_FORMATTABLE 0x4000
+#define MF_ZRAMSTREAMS 0x8000
#define DM_BUF_SIZE 4096
diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h
index 8097ed9..5e05d9a 100644
--- a/fs_mgr/include/fs_mgr.h
+++ b/fs_mgr/include/fs_mgr.h
@@ -65,6 +65,7 @@ struct fstab_rec {
int partnum;
int swap_prio;
unsigned int zram_size;
+ unsigned int zram_streams;
};
// Callback function for verity status