O_DIRECT support on a jffs2 Linux filesystem

你离开我真会死。 提交于 2019-12-11 07:03:03

问题


Im trying to use O_DIRECT to open a file and we're using jffs2

fd = open(filename, O_RDONLY|O_DIRECT|O_SYNC);

But i only get an "invalid argument" error. I have also tried the solutions in this SO link but to no avail. Ofcourse i have also put in "-D_GNU_SOURCE" in building the source.

I've read that O_DIRECT is not supported on tmpfs, but couldn't find support or un-support for jffs2. If someone could give me proof or un-proof for jffs2 support and/or any other thing i'm missing to make O_DIRECT work.

note: This all happened because Linux seem to cache memory data on its own when i use fread()/read(). And using system("echo 3 > /proc/sys/vm/drop_caches"); would be too late because I don't want the FS allocating cache memory in the first place.

Thanks, Naze


回答1:


jffs2 does not support O_DIRECT.

You can see in __dentry_open() that in order to support O_DIRECT, a filesystem must supply the direct_IO and/or get_xip_mem members of the address_space_operations struct. You can likewise see that jffs2 does not supply these members.

It is not clear why you are so keen to avoid the page cache. Pages in the page cache are effectively "free" - they will be reclaimed when more memory is required for other uses.



来源:https://stackoverflow.com/questions/6030002/o-direct-support-on-a-jffs2-linux-filesystem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!