system/corennnnn
Revision | 2bf54d392864557c5fbe6ddd97e53e05cc08a283 (tree) |
---|---|
Zeit | 2016-09-04 08:46:00 |
Autor | Sultan Qasim Khan <sultanqasim@gmai...> |
Commiter | Steve Kondik |
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
@@ -61,6 +61,7 @@ | ||
61 | 61 | #define FSCK_LOG_FILE "/dev/fscklogs/log" |
62 | 62 | |
63 | 63 | #define ZRAM_CONF_DEV "/sys/block/zram0/disksize" |
64 | +#define ZRAM_STREAMS "/sys/block/zram0/max_comp_streams" | |
64 | 65 | |
65 | 66 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) |
66 | 67 |
@@ -882,6 +883,14 @@ int fs_mgr_swapon_all(struct fstab *fstab) | ||
882 | 883 | */ |
883 | 884 | FILE *zram_fp; |
884 | 885 | |
886 | + /* The stream count parameter is only available on new kernels. | |
887 | + * It must be set before the disk size. */ | |
888 | + zram_fp = fopen(ZRAM_STREAMS, "r+"); | |
889 | + if (zram_fp) { | |
890 | + fprintf(zram_fp, "%d\n", fstab->recs[i].zram_streams); | |
891 | + fclose(zram_fp); | |
892 | + } | |
893 | + | |
885 | 894 | zram_fp = fopen(ZRAM_CONF_DEV, "r+"); |
886 | 895 | if (zram_fp == NULL) { |
887 | 896 | ERROR("Unable to open zram conf device %s\n", ZRAM_CONF_DEV); |
@@ -32,6 +32,7 @@ struct fs_mgr_flag_values { | ||
32 | 32 | int partnum; |
33 | 33 | int swap_prio; |
34 | 34 | unsigned int zram_size; |
35 | + unsigned int zram_streams; | |
35 | 36 | }; |
36 | 37 | |
37 | 38 | struct flag_list { |
@@ -77,6 +78,7 @@ static struct flag_list fs_mgr_flags[] = { | ||
77 | 78 | { "formattable", MF_FORMATTABLE }, |
78 | 79 | { "slotselect", MF_SLOTSELECT }, |
79 | 80 | { "nofail", MF_NOFAIL }, |
81 | + { "zramstreams=",MF_ZRAMSTREAMS }, | |
80 | 82 | { "defaults", 0 }, |
81 | 83 | { 0, 0 }, |
82 | 84 | }; |
@@ -109,6 +111,7 @@ static int parse_flags(char *flags, struct flag_list *fl, | ||
109 | 111 | memset(flag_vals, 0, sizeof(*flag_vals)); |
110 | 112 | flag_vals->partnum = -1; |
111 | 113 | flag_vals->swap_prio = -1; /* negative means it wasn't specified. */ |
114 | + flag_vals->zram_streams = 1; | |
112 | 115 | } |
113 | 116 | |
114 | 117 | /* initialize fs_options to the null string */ |
@@ -186,6 +189,8 @@ static int parse_flags(char *flags, struct flag_list *fl, | ||
186 | 189 | flag_vals->zram_size = calculate_zram_size(val); |
187 | 190 | else |
188 | 191 | flag_vals->zram_size = val; |
192 | + } else if ((fl[i].flag == MF_ZRAMSTREAMS) && flag_vals) { | |
193 | + flag_vals->zram_streams = strtoll(strchr(p, '=') + 1, NULL, 0); | |
189 | 194 | } |
190 | 195 | break; |
191 | 196 | } |
@@ -337,6 +342,7 @@ struct fstab *fs_mgr_read_fstab(const char *fstab_path) | ||
337 | 342 | fstab->recs[cnt].partnum = flag_vals.partnum; |
338 | 343 | fstab->recs[cnt].swap_prio = flag_vals.swap_prio; |
339 | 344 | fstab->recs[cnt].zram_size = flag_vals.zram_size; |
345 | + fstab->recs[cnt].zram_streams = flag_vals.zram_streams; | |
340 | 346 | cnt++; |
341 | 347 | } |
342 | 348 | /* If an A/B partition, modify block device to be the real block device */ |
@@ -84,6 +84,7 @@ __BEGIN_DECLS | ||
84 | 84 | #define MF_SLOTSELECT 0x8000 |
85 | 85 | #define MF_FORCEFDEORFBE 0x10000 |
86 | 86 | #define MF_NOFAIL 0x40000 |
87 | +#define MF_ZRAMSTREAMS 0x80000 | |
87 | 88 | |
88 | 89 | #define DM_BUF_SIZE 4096 |
89 | 90 |
@@ -65,6 +65,7 @@ struct fstab_rec { | ||
65 | 65 | int partnum; |
66 | 66 | int swap_prio; |
67 | 67 | unsigned int zram_size; |
68 | + unsigned int zram_streams; | |
68 | 69 | }; |
69 | 70 | |
70 | 71 | // Callback function for verity status |