[PATCH] Add fstrim support to restore NAND/eMMC write performance.
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Sat Feb 23 09:46:51 UTC 2013
On Fri, Feb 22, 2013 at 02:43:36PM +0200, eugenesan at gmail.com wrote:
>From: Malek Degachi <malek-degachi at laposte.net>
>
>fstrim applet is a port from util-linux.
>
>"Trimming" your NAND/eMMC storage will restore the write performance back to normal
>after having slow down issues on sequential write and random write due to usage over time.
>
>Good reading on subject: http://forum.xda-developers.com/showthread.php?t=1971852
>
>Signed-off-by: Eugene San (eugenesan) <eugenesan at gmail.com>
>---
> include/applets.src.h | 1 +
> util-linux/Config.src | 7 ++++
> util-linux/Kbuild.src | 1 +
> util-linux/fstrim.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 123 insertions(+)
> create mode 100644 util-linux/fstrim.c
>
>diff --git a/include/applets.src.h b/include/applets.src.h
>index 29ab167..c9244fb 100644
>--- a/include/applets.src.h
>+++ b/include/applets.src.h
>@@ -161,6 +161,7 @@ IF_FSCK(APPLET(fsck, BB_DIR_SBIN, BB_SUID_DROP))
> //IF_E2FSCK(APPLET_ODDNAME(fsck.ext2, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext2))
> //IF_E2FSCK(APPLET_ODDNAME(fsck.ext3, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext3))
> IF_FSCK_MINIX(APPLET_ODDNAME(fsck.minix, fsck_minix, BB_DIR_SBIN, BB_SUID_DROP, fsck_minix))
>+IF_FSTRIM(APPLET(fstrim, BB_DIR_SBIN, BB_SUID_DROP))
> IF_FSYNC(APPLET_NOFORK(fsync, fsync, BB_DIR_BIN, BB_SUID_DROP, fsync))
> IF_FTPD(APPLET(ftpd, BB_DIR_USR_SBIN, BB_SUID_DROP))
> IF_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpget))
>diff --git a/util-linux/Config.src b/util-linux/Config.src
>index 6c1b928..a82817c 100644
>--- a/util-linux/Config.src
>+++ b/util-linux/Config.src
>@@ -246,6 +246,13 @@ config FSCK_MINIX
> check for and attempt to repair any corruption that occurs to a minix
> filesystem.
>
>+config FSTRIM
>+ bool "fstrim"
>+ default y
>+ select PLATFORM_LINUX
Doesn't that work on android, too?
>diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c
>new file mode 100644
>index 0000000..915de06
>--- /dev/null
>+++ b/util-linux/fstrim.c
>+static const struct suffix_mult fstrim_sfx[] = {
>+ { "KiB", 1024 },
>+ { "kiB", 1024 },
>+ { "K", 1024 },
>+ { "k", 1024 },
>+ { "MiB", 1048576 },
>+ { "miB", 1048576 },
>+ { "M", 1048576 },
>+ { "m", 1048576 },
>+ { "GiB", 1073741824 },
>+ { "giB", 1073741824 },
>+ { "G", 1073741824 },
>+ { "g", 1073741824 },
>+ { "KB", 1000 },
>+ { "MB", 1000000 },
>+ { "GB", 1000000000 },
>+ { "", 0 }
>+};
>+ if (opts & OPT_v)
>+ printf("%s: %llu bytes was trimmed\n", argv[optind], range.len);
Please use make_human_readable_str()
See
$ scripts/bloat-o-meter bb_un.master busybox_unstripped
$ scripts/bloat-o-meter bb_un.old busybox_unstripped
before and after using make_human_readable_str() against pristine master
and your manual version above.
TIA,
More information about the busybox
mailing list