LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-16-2016, 01:39 AM   #1
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Rep: Reputation: 4
How to force disk caching even if software uses O_DIRECT?


Hi.
Some programs disable OS caching by using O_SYNC or O_DIRECT flags, because they think they can do better caching than OS. Sometimes they're wrong and become very slow.

Is it possible to create a stack of virtual block devices that silently ignores O_DIRECT at some level? Or maybe some filesystems can be tuned to ignore it? I don't care about crashes or power failures, it's not a production environment.
 
Old 04-16-2016, 04:12 AM   #2
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,669

Rep: Reputation: 498Reputation: 498Reputation: 498Reputation: 498Reputation: 498
Before opting for a stack of virtual block here is something that may improve the needed performance.
 
Old 04-16-2016, 05:11 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
I would guess the OP is attacking the symptom rather than the problem.
Let's see some evidence.
 
Old 04-16-2016, 05:35 AM   #4
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by malekmustaq View Post
Before opting for a stack of virtual block here is something that may improve the needed performance.
just read that article. I can't change i/o scheduler, because the only available value is "none" (and it's correct, because it's a virtual machine with virtio storage)
Code:
/sys/block/vda/queue/scheduler:none
/sys/block/vdb/queue/scheduler:none

Other advices are for those who write software; mine is already written.
 
Old 04-16-2016, 06:12 AM   #5
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,148

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
If you have plenty of memory you can mount a tmpfs, write there and copy to disk manually or with a background rsync process.
 
Old 04-16-2016, 11:14 AM   #6
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by smallpond View Post
If you have plenty of memory you can mount a tmpfs, write there and copy to disk manually or with a background rsync process.
Attempt to open a file in tmpfs with O_DIRECT fails.
 
Old 04-17-2016, 06:32 AM   #7
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,148

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
I found a thread on LKML where everyone agrees that tmpfs should support O_DIRECT but no change gets made. It points out that the workaround is a loop device.

https://lkml.org/lkml/2007/1/4/55
 
Old 04-18-2016, 01:14 AM   #8
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by smallpond View Post
It points out that the workaround is a loop device.
This seems ugly, but it works. It's actually possible to create loop devices not only for regular files, but for other block devices too:
Code:
# mounting /home/db2inst1 with -oloop to ignore O_DIRECT
/dev/mapper/vg_unsafe-db2inst1 /home/db2inst1 auto loop
 
  


Reply

Tags
cache, devicemapper, lvm2



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is Btrfs's disk space caching? Geremia Linux - Hardware 4 12-23-2014 11:22 PM
Polipo cache to disk, cannot activate disk caching, different browsers redownload con Trauma Linux - Software 8 12-07-2013 11:13 AM
RHEL6, VMware, shared disk - how to mount to avoid caching? cadet_concept Linux - Server 2 02-06-2013 11:10 AM
Disk caching utility for power saving Changes Linux - Software 1 11-28-2010 04:06 PM
SuSe 10.0 - Memory disk caching leading to unstability EventingCameron Linux - Newbie 1 03-13-2006 06:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration