Re: [RFC] VFS: File System Mount Wide O_DIRECT Support

From: Jan Kara
Date: Tue Sep 04 2012 - 08:27:41 EST


On Tue 04-09-12 18:17:47, Li Wang wrote:
> For file system created on file-backed loop device, there will be two-levels of
> page cache present, which typically doubles the memory consumption.
> In many cases, it is beneficial to turn on the O_DIRECT option while performing
> the upper file system file IO, to bypass the upper page cache, which not only reduces half
> of the memory consumption, but also improves the performance due to shorter copy path.
>
> For example, the following iozone REREAD test with O_DIRECT turned on over the one without
> enjoys 10x speedup due to redundant cache elimination, consequently, avoiding page cache thrashing
> on a 2GB memory machine running 3.2.9 kernel.
>
> losetup /dev/loop0 dummy // dummy is a ext4 file with a size of 1.1GB
> mkfs -t ext2 /dev/loop0
> mount /dev/loop0 /dsk
> cd /dsk
> iozone -t 1 -s 1G -r 4M -i 0 -+n -w // produce a 1GB test file
> iozone -t 1 -s 1G -r 4M -i 1 -w // REREAD test without O_DIRECT
> echo 1 > /proc/sys/vm/drop_caches // cleanup the page cache
> iozone -t 1 -s 1G -r 4M -i 1 -w -I // REREAD test with O_DIRECT
>
> This feature is also expected to be useful for virtualization situation, the file systems inside
> the guest operation system will use much less of guest memory, which, potencially results in less of
> host memory use. Especially, it may be more useful if multiple guests are running based
> on a same disk image file.
>
> The idea is simple, leave the desicion for the file system user to enable file system mount
> wide O_DIRECT support with a new mount option, for example,
I believe a better approach to your problem is actually to enable
loopback device driver to use direct IO. Someone was actually working on
this but I'm not sure where this ended up.

Honza
--
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/