Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,732,619 Members 51,886 Now Online
XDA Developers Android and Mobile Development Forum

Some possible insight on the cause of the RFS lag and work-around

Tip us?
 
bilboa1
Old
(Last edited by bilboa1; 2nd October 2010 at 04:08 PM.)
#1  
Recognized Developer - OP
Thanks Meter 303
Posts: 1,158
Join Date: Aug 2010

 
DONATE TO ME
Default Some possible insight on the cause of the RFS lag and work-around

Since I installed JPK on a test phone after claims that the RFS related lag has been fixed.. well.. I'd like to share my impressions:

- I have installed approx 100 apps after the flash (flashed / wiped / factory reset btw)

A this point, the phone while slightly slower than one with Voodoo is pretty fast

A few days later, it's still good enough.

- 5 days later, lag starts to be felt, and it's stronger every next day until it becomes annoying to use


That's exactly the same experience as I had on various Eclair roms without any lag-fix. I also had this on JP3 (early Froyo).

So yeah. I looked into the /init binary from samsung and it's supposed to make some file system checks from time to time when you restart the phone, but it does not appear to really carry on with that.

So I ran the checks myself:

- you need a rooted phone, and adb or a terminal

- find all RFS partitions:
$ su
# mount|grep -i rfs

- kill all processes, go flight mode and remount them read-only
$ su (if you're not root.. not going to repeat it again for subsequent commands)
# kill -9 <pid> of anything that use the patrition
# mount -oremount,ro /dev/block/....

- check the RFS filesystem and correct errors
# /system/bin/fsck_msdos -p -f /dev/block/....

Surprise, a million of RFS errors fixed such as:

/path/to/file starts with free cluster FIXED
Cluster XXX continues with cluster XXX in FAT 0 but is marked free in FAT 1 FIXED
Detected cluster chain loop head XXXX for p XXXX FIXED
FSNext block XXX is correct NumClusters XXX FIXED (weird one)
No LOST.DIR FIXED
Lost cluster chain at cluster XXX YY clusters lost FIXED (prolly lost files/data here!)

Repeat for each partition

reboot the phone at the end

SURPRISE! It doesn't lag much anymore.

Use the phone an hour, do the check again and you will see it's already full of errors.

Conclusion:

RFS is bugged (we knew that didn't we) but it looks like it's fixable, if ever Samsung figures out what is corrupting the file system exactly (it's closed source so we can't really find out easily)

It might be possible to figure it out by looking at VFAT sources too.


I would be very interested to see if that fixes the lag for everyone or if i'm an isolated case and all my RFS partitions are on bad hardware or if it's really software corruption as I am guessing


Small disclaimer:
im not responsible for any data loss etc. no warranties etc. fixing file system even readonly might cause data loss due to the bugs in RFS. you've been warned lol.
 
ragin
Old
#2  
ragin's Avatar
Senior Member
Thanks Meter 151
Posts: 1,724
Join Date: Dec 2007
Location: Hubli
My God,

I think a lot of eyes will be on the BOUNTY
 
INeedYourHelp
Old
#3  
Senior Member
Thanks Meter 6
Posts: 553
Join Date: Mar 2010
Could someone just create an app that does this?
 
RyanZA
Old
#4  
Senior Member
Thanks Meter 731
Posts: 2,021
Join Date: Jan 2006
Location: JHB
Quote:
Originally Posted by bilboa1 View Post
Since I installed JPK on a test phone after claims that the RFS related lag has been fixed.. well.. I'd like to share my impressions:

- I have installed approx 100 apps after the flash (flashed / wiped / factory reset btw)

A this point, the phone while slightly slower than one with Voodoo is pretty fast

A few days later, it's still good enough.

- 5 days later, lag starts to be felt, and it's stronger every next day until it becomes annoying to use


That's exactly the same experience as I had on various Eclair roms without any lag-fix. I also had this on JP3 (early Froyo).

So yeah. I looked into the /init binary from samsung and it's supposed to make some file system checks from time to time when you restart the phone, but it does not appear to really carry on with that.

So I ran the checks myself:

- you need a rooted phone, and adb or a terminal

- find all RFS partitions:
$ su
# mount|grep -i rfs

- kill all processes, go flight mode and remount them read-only
$ su (if you're not root.. not going to repeat it again for subsequent commands)
# kill -9 <pid> of anything that use the patrition
# mount -oremount,ro /dev/block/....

- check the RFS filesystem and correct errors
# /system/bin/fsck_msdos -p -f /dev/block/....

Surprise, a million of RFS errors fixed such as:

/path/to/file starts with free cluster FIXED
Cluster XXX continues with cluster XXX in FAT 0 but is marked free in FAT 1 FIXED
Detected cluster chain loop head XXXX for p XXXX FIXED
FSNext block XXX is correct NumClusters XXX FIXED (weird one)
No LOST.DIR FIXED
Lost cluster chain at cluster XXX YY clusters lost FIXED (prolly lost files/data here!)

Repeat for each partition

reboot the phone at the end

SURPRISE! It doesn't lag much anymore.

Use the phone an hour, do the check again and you will see it's already full of errors.

Conclusion:

RFS is bugged (we knew that didn't we) but it looks like it's fixable, if ever Samsung figures out what is corrupting the file system exactly (it's closed source so we can't really find out easily)

It might be possible to figure it out by looking at VFAT sources too.


I would be very interested to see if that fixes the lag for everyone or if i'm an isolated case and all my RFS partitions are on bad hardware or if it's really software corruption as I am guessing


Small disclaimer:
im not responsible for any data loss etc. no warranties etc. fixing file system even readonly might cause data loss due to the bugs in RFS. you've been warned lol.
VOLD is what does the RFS check at boot. It seems to run, although maybe it fails? It definitely does run though, you can check it running using 'ps' on phone boot. Maybe it's only cleaning up /sdcard though.

At any rate, running the disk check does help with speed, but it doesn't help that much. It's still slow. I think if you want to stick with RFS, you need to do a defrag as well as the filesystem check. After some use, RFS must be very very fragemented on most people's phones.

Even in perfect condition though, RFS still has some very nasty properties such as locking the entire disk when a write occurs, not doing buffering, etc etc.
 
RyanZA
Old
#5  
Senior Member
Thanks Meter 731
Posts: 2,021
Join Date: Jan 2006
Location: JHB
Quote:
Originally Posted by INeedYourHelp View Post
Could someone just create an app that does this?
An app can't do this, since the app would have to be running off RFS and would crash/have to be killed to perform the FS checks. It could be done on boot using some trickery and the playlogos / replace binary trick. Or it can be done by replacing the init script with some kernel hackery. But at that point, you might as well just use a real filesystem.

I guess a PC .bat file could be made that uses adb to do this for you and then reboot the phone... Doesn't seem worth the trouble though!
 
andrewluecke
Old
#6  
Senior Member
Thanks Meter 18
Posts: 848
Join Date: Jul 2010
RFS is journelled. You sure the filesystem doesn't do the journaling properly?
 
dakine
Old
#7  
dakine's Avatar
Senior Member
Thanks Meter 36
Posts: 714
Join Date: Nov 2006
Nice job figuring this out. Is someone forwarding all these findings to that Samsung dev?
 
bilboa1
Old
#8  
Recognized Developer - OP
Thanks Meter 303
Posts: 1,158
Join Date: Aug 2010

 
DONATE TO ME
It's not about RFS vs the other filesystems. I'm well aware of the performance of RFS. But it's decent enough when it's working properly. It's not nearly as fast as ext but fast enough that you don't get annoyed.

Thus fixing RFS would make the life of many people who aren't technically inclined better. If the RFS do get all corrupted everywhere, and Samsung figure that out and fixes it, it means a good thing for most people.

The rest of us will end up on ext anyways

And yeah I think the fscheck at boot fails, it must fail actually, i don't see how else it would happen.
 
RyanZA
Old
#9  
Senior Member
Thanks Meter 731
Posts: 2,021
Join Date: Jan 2006
Location: JHB
Quote:
Originally Posted by bilboa1 View Post
It's not about RFS vs the other filesystems. I'm well aware of the performance of RFS. But it's decent enough when it's working properly. It's not nearly as fast as ext but fast enough that you don't get annoyed.

Thus fixing RFS would make the life of many people who aren't technically inclined better. If the RFS do get all corrupted everywhere, and Samsung figure that out and fixes it, it means a good thing for most people.

The rest of us will end up on ext anyways

And yeah I think the fscheck at boot fails, it must fail actually, i don't see how else it would happen.
What firmware did you test on, btw? I've noticed that JPK does seem to take longer on the FS checks, so maybe they have it fixed already (doubt it though)?
 
bilboa1
Old
#10  
Recognized Developer - OP
Thanks Meter 303
Posts: 1,158
Join Date: Aug 2010

 
DONATE TO ME
Quote:
Originally Posted by RyanZA View Post
What firmware did you test on, btw? I've noticed that JPK does seem to take longer on the FS checks, so maybe they have it fixed already (doubt it though)?
on JPK actually
im going to flash JM8 to see if its the same in fact, but i expect so

Tags
rfs lag
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Run, Jump, and Shoot in Tales of Ciaxia

There are certain types of games that have become paramount of the portable gaming world. As we have … more

Samsung Gear Live Stock Firmware Image Pulled, Temp Root

Just yesterday,XDA Recognized Developer and TV ProducerAdamOutlertore apart … more

Draw a Line and Let Your Device Do the Rest with LineitApp

Over the years, since evenbefore Android entered the scene, we have striven to … more