对jffs2 Linux文件系统的O_DIRECT支持 [英] O_DIRECT support on a jffs2 Linux filesystem

查看:207
本文介绍了对jffs2 Linux文件系统的O_DIRECT支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用O_DIRECT打开一个文件,我们使用的是jffs2

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

但是我只得到一个无效的参数错误。
我也试过解决方案
中,但是无济于事。
Ofcourse我也已经把-D_GNU_SOURCE放在源代码中。

我读过tmpfs不支持O_DIRECT,但是不能找到支持或不支持jffs2。
如果有人可以给我证明或不支持jffs2的支持和/或任何其他的东西,我错过了使O_DIRECT工作。



注意:
这一切都是因为当我使用fread()/ read()时,Linux似乎自行缓存内存数据。
使用 system(echo 3> / proc / sys / vm / drop_caches); 太晚了,因为我不希望FS分配缓存内存。



感谢,
Naze

解决方案

jffs2不支持 O_DIRECT



linux.no/#linux+v2.6.38/fs/open.c#L711rel =nofollow>可以在 __ dentry_open() 中看到,为了支持 O_DIRECT ,文件系统必须提供 direct_IO 和/或 get_xip_mem address_space_operations 结构的成员。你也可以看到 jffs2不提供这些成员。

目前还不清楚为什么你如此热衷于避免页面缓存。页面缓存中的页面实际上是免费的 - 当需要更多内存用于其他用途时,它们将被回收。


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

解决方案

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.

这篇关于对jffs2 Linux文件系统的O_DIRECT支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆