Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,742,869 Members 39,382 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][ANY][Mitsuyoshi EXT4 Mod][15/05/13]

Tip us?
 
jubei_mitsuyoshi
Old
(Last edited by jubei_mitsuyoshi; 17th May 2013 at 11:42 AM.) Reason: Addition
#1  
Member - OP
Thanks Meter 66
Posts: 50
Join Date: Mar 2013
Default [MOD][ANY][Mitsuyoshi EXT4 Mod][15/05/13]

Background..

With any linux system i build first thing i do is remove the journal from all my EXT4 partitions, to make a long story short ( i wont bore you with details of just how journal writes totally slow disk i/o , google it ) this gave me on average a 25% increase in system speed ( obviously due to the increased i/o rate )

I usually did it with

Code:
Select Code
mke2fs.ext4 -O ^has_journal ...device...
before installing the distro, now i thought hey maybe this would work on android?

Now mke2fs is not well supported on arm but tune2fs is! in fact its included in TWRP 2.5 so

Code:
Select Code
tune2fs -O ^has_journal /dev/block/platform/sdhci-tegra.3/by-name/APP
( for the system partition) should work right , and in fact yes it does !!!, tried it from TWRP command line and hey presto %^$%^$^%$ FAST system

This is the code for a recovery script version

Code:
Select Code
ui_print("test script");
ui_print("");
ui_print("");
ifelse(is_mounted("/system") == "/system", unmount("/system"));
ifelse(is_mounted("/cache") == "/cache", unmount("/cache"));
ifelse(is_mounted("/data") == "/data", unmount("/data"));
ui_print("converting partitions to ext4 minus journal");
ui_print(" ");
set_progress(1.000000);
ui_print("e2fsck system partition");
ui_print(" ");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/APP");
ui_print("e2fsck data partition");
ui_print(" ");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/UDA");
ui_print("e2fsck cache partition");
ui_print(" ");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/CAC");
ui_print("now lets rub out those nasty journals");
ui_print(" ");
run_program("/sbin/tune2fs", "-O", "^has_journal", "/dev/block/platform/sdhci-tegra.3/by-name/APP");
run_program("/sbin/tune2fs", "-O", "^has_journal", "/dev/block/platform/sdhci-tegra.3/by-name/UDA");
run_program("/sbin/tune2fs", "-O", "^has_journal", "/dev/block/platform/sdhci-tegra.3/by-name/CAC");
ui_print("and re-fsck to clean any set bits");
ui_print(" ");
ui_print("e2fsck system partition");
ui_print(" ");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/APP");
ui_print("e2fsck data partition");
ui_print(" ");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/UDA");
ui_print("e2fsck cache partition");
ui_print(" ");
run_program("/sbin/e2fsck", "-p", "/dev/block/platform/sdhci-tegra.3/by-name/CAC");
And i include a zip for those who like to test

Ps have not checked the function of this line

Code:
Select Code
run_program("/sbin/tune2fs", "-O", "^has_journal", "/dev/block/platform/sdhci-tegra.3/by-name/APP");
the bash equivalent is

Code:
Select Code
tune2fs -O ^has_journal /dev/block/platform/sdhci-tegra.3/by-name/APP
where ^has_journal is a parameter of -O not sure the recovery script is wrapping that correctly, if anyone flashes this script could you please check by typing

Code:
Select Code
tune2fs -l /dev/block/platform/sdhci-tegra.3/by-name/APP
in the TWRP terminal, scroll upward with an up finger swipe and check has_journal is not in the filesystem properties ( going to do it myself on next system wipe, but just enjoying the speed at the mo !! , am testing it on PRIME 04-20 mildly tweaked by me )
Thanks


Edit ... Since there has been more than passing interest in this obscure piece of code i have decided to tidy this post up

Hence now there are 2 scripts, one to remove the journal from your ext4 partitions, and one to re-instate the journal, this should allow people to test their setup with each without any wiping or reformatting

Instructions.......
( tested with TWRP 2.5+ only )
Flash the bugger
DO NOT WIPE ANYTHING, after flashing, doing so will only reformat the wiped partition with a journal
The Following 30 Users Say Thank You to jubei_mitsuyoshi For This Useful Post: [ Click to Expand ]
 
JetOhmNet
Old
#2  
JetOhmNet's Avatar
Member
Thanks Meter 13
Posts: 44
Join Date: Apr 2013
For us who have no background in Linux. What is this for? Does it just increase system speed? I'm running prime 4/20 as well and would definitely like to test it once I know exactly what it's supposed to do.
The Following User Says Thank You to JetOhmNet For This Useful Post: [ Click to Expand ]
 
N@th_OC
Old
#3  
N@th_OC's Avatar
Senior Member
Thanks Meter 115
Posts: 337
Join Date: Jul 2011
Location: Lyon
Quote:
Originally Posted by JetOhmNet View Post
For us who have no background in Linux. What is this for? Does it just increase system speed? I'm running prime 4/20 as well and would definitely like to test it once I know exactly what it's supposed to do.
No linux was just for explanation.
But it also work for Android.
So that's a good thing

The script he has posted is for twrp.
You can only find beauty in which can not be used for anything ; everything that is useful is ugly.
The Following User Says Thank You to N@th_OC For This Useful Post: [ Click to Expand ]
 
psyren
Old
#4  
Senior Member
Thanks Meter 72
Posts: 242
Join Date: Dec 2010
Location: Perth
Quote:
Originally Posted by JetOhmNet View Post
For us who have no background in Linux. What is this for? Does it just increase system speed? I'm running prime 4/20 as well and would definitely like to test it once I know exactly what it's supposed to do.
It forgoes recording disk writing (?) operations to a journal and instead writes things directly to disk (or a buffer, if you want to be pedantic).
Instead of going:
Write to journal (I'm doing this write) -> Write to journal (I'm currently doing this write) -> execute operation -> erase entry from journal
It goes:
Execute operation

The end result is greater write speeds, but greater risk of data loss if there is power loss.
If you were in the middle of a write operation when the power goes dead, the journal entry saying that you were doing something will still be there, so the OS can either resume/restart the operation (since it knows it was incomplete) or do some sort of error handling since it knows something went wrong.

For more/related info, see this thread.
The Following 7 Users Say Thank You to psyren For This Useful Post: [ Click to Expand ]
 
JetOhmNet
Old
#5  
JetOhmNet's Avatar
Member
Thanks Meter 13
Posts: 44
Join Date: Apr 2013
Quote:
Originally Posted by N@th_OC View Post
No linux was just for explanation.
But it also work for Android.
So that's a good thing

The script he has posted is for twrp.
I got that much, just wasn't convinced on what exactly this script does.

Quote:
Originally Posted by psyren View Post
It forgoes recording disk writing (?) operations to a journal and instead writes things directly to disk (or a buffer, if you want to be pedantic).
Instead of going:
Write to journal (I'm doing this write) -> Write to journal (I'm currently doing this write) -> execute operation -> erase entry from journal
It goes:
Execute operation

The end result is greater write speeds, but greater risk of data loss if there is power loss.
If you were in the middle of a write operation when the power goes dead, the journal entry saying that you were doing something will still be there, so the OS can either resume/restart the operation (since it knows it was incomplete) or do some sort of error handling since it knows something went wrong.

For more/related info, see this thread.
And thank you on the specifics and pros and cons. I'll definitely give it a try now and let you know what I think/if i notice any bugs!
 
Jack'O
Old
(Last edited by Jack'O; 16th May 2013 at 09:27 AM.)
#6  
Jack'O's Avatar
Senior Member
Thanks Meter 499
Posts: 1,439
Join Date: Aug 2011
Location: Toscana
Sorry, wrong post!
I was tring to send a message to a Razr owner but i bungled with the XDA app.

Thanks anyway for your reply.
 
jubei_mitsuyoshi
Old
#7  
Member - OP
Thanks Meter 66
Posts: 50
Join Date: Mar 2013
yes will work on any android/linux system using ext4 partitions, in the case of n7 thats only system,data and cache.
But the actual TWRP script needs checking for syntax for every device. ( obviously checked it on the n7 )

I can confirm a MASSIVE speed increase, everything in noticeably smoother and faster, which is to be expected since you have increased disk i/o by at least 25%, especially important in the data and cache partitions.

To really understand whats going on you really must google EXT4 and the journal folk's, a journaling filesystem is a legacy of the linux server heritage, its very useful in a server context, if you have a crash and are running 100+ TB of data, the journal allows you to reboot and instantly be back online ( which is massively important is the server world where seconds offline means millions of dollars ) rather than wait many hours for a fsck to complete. For android it is completely inappropriate! it should be obvious why

Psyren's post is a good simple explanation of the write structure and how removing the journal speeds things up.

If this code goes into anyone's rom please give me some love in the credits

Ps as mentioned in the post there is a line to double check, if your doing it by hand from the TWRP terminal then i can confirm it def works, i have not double checked the script ( except to prove it flashes etc ) and wont for about a week, i am getting ready my own rom that concentrates on improving the linux sub-structure, and that's taking my time
The Following User Says Thank You to jubei_mitsuyoshi For This Useful Post: [ Click to Expand ]
 
elfrosto
Old
(Last edited by elfrosto; 16th May 2013 at 09:57 AM.)
#8  
elfrosto's Avatar
Senior Member
Thanks Meter 116
Posts: 274
Join Date: May 2012
Location: Christchurch
Sorry if this is a stupid question, but does this wipe any partitions or will there be any data loss flashing the zip?

Or does it need to be flashed before flashing Rom?


Sent from my MB865 using xda app-developers app
Rocking New Zealand
 
JetOhmNet
Old
#9  
JetOhmNet's Avatar
Member
Thanks Meter 13
Posts: 44
Join Date: Apr 2013
Quote:
Originally Posted by elfrosto View Post
Sorry if this is a stupid question, but does this wipe any partitions or will there be any data loss flashing the zip?

Or does it need to be flashed before flashing Rom?


Sent from my MB865 using xda app-developers app
Flashing does not wipe anything, but I also haven't noticed any i/o improvements.
 
sotoskawasaki
Old
#10  
Senior Member
Thanks Meter 19
Posts: 172
Join Date: Feb 2012
Location: Limassol, Cyprus
Looks like a very interesting script.. Could we do that from CWM or even from a terminal? If yes what would be the procedure? Thanks for sharing!

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes