• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revision2bf54d392864557c5fbe6ddd97e53e05cc08a283 (tree)
Zeit2016-09-04 08:46:00
AutorSultan Qasim Khan <sultanqasim@gmai...>
CommiterSteve Kondik

Log Message

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

Ändern Zusammenfassung

Diff

--- a/fs_mgr/fs_mgr.c
+++ b/fs_mgr/fs_mgr.c
@@ -61,6 +61,7 @@
6161 #define FSCK_LOG_FILE "/dev/fscklogs/log"
6262
6363 #define ZRAM_CONF_DEV "/sys/block/zram0/disksize"
64+#define ZRAM_STREAMS "/sys/block/zram0/max_comp_streams"
6465
6566 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
6667
@@ -882,6 +883,14 @@ int fs_mgr_swapon_all(struct fstab *fstab)
882883 */
883884 FILE *zram_fp;
884885
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+
885894 zram_fp = fopen(ZRAM_CONF_DEV, "r+");
886895 if (zram_fp == NULL) {
887896 ERROR("Unable to open zram conf device %s\n", ZRAM_CONF_DEV);
--- a/fs_mgr/fs_mgr_fstab.c
+++ b/fs_mgr/fs_mgr_fstab.c
@@ -32,6 +32,7 @@ struct fs_mgr_flag_values {
3232 int partnum;
3333 int swap_prio;
3434 unsigned int zram_size;
35+ unsigned int zram_streams;
3536 };
3637
3738 struct flag_list {
@@ -77,6 +78,7 @@ static struct flag_list fs_mgr_flags[] = {
7778 { "formattable", MF_FORMATTABLE },
7879 { "slotselect", MF_SLOTSELECT },
7980 { "nofail", MF_NOFAIL },
81+ { "zramstreams=",MF_ZRAMSTREAMS },
8082 { "defaults", 0 },
8183 { 0, 0 },
8284 };
@@ -109,6 +111,7 @@ static int parse_flags(char *flags, struct flag_list *fl,
109111 memset(flag_vals, 0, sizeof(*flag_vals));
110112 flag_vals->partnum = -1;
111113 flag_vals->swap_prio = -1; /* negative means it wasn't specified. */
114+ flag_vals->zram_streams = 1;
112115 }
113116
114117 /* initialize fs_options to the null string */
@@ -186,6 +189,8 @@ static int parse_flags(char *flags, struct flag_list *fl,
186189 flag_vals->zram_size = calculate_zram_size(val);
187190 else
188191 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);
189194 }
190195 break;
191196 }
@@ -337,6 +342,7 @@ struct fstab *fs_mgr_read_fstab(const char *fstab_path)
337342 fstab->recs[cnt].partnum = flag_vals.partnum;
338343 fstab->recs[cnt].swap_prio = flag_vals.swap_prio;
339344 fstab->recs[cnt].zram_size = flag_vals.zram_size;
345+ fstab->recs[cnt].zram_streams = flag_vals.zram_streams;
340346 cnt++;
341347 }
342348 /* If an A/B partition, modify block device to be the real block device */
--- a/fs_mgr/fs_mgr_priv.h
+++ b/fs_mgr/fs_mgr_priv.h
@@ -84,6 +84,7 @@ __BEGIN_DECLS
8484 #define MF_SLOTSELECT 0x8000
8585 #define MF_FORCEFDEORFBE 0x10000
8686 #define MF_NOFAIL 0x40000
87+#define MF_ZRAMSTREAMS 0x80000
8788
8889 #define DM_BUF_SIZE 4096
8990
--- a/fs_mgr/include/fs_mgr.h
+++ b/fs_mgr/include/fs_mgr.h
@@ -65,6 +65,7 @@ struct fstab_rec {
6565 int partnum;
6666 int swap_prio;
6767 unsigned int zram_size;
68+ unsigned int zram_streams;
6869 };
6970
7071 // Callback function for verity status