linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* invalidate the buffer heads of a block device
@ 2014-09-29 16:24 Thanos Makatos
  2014-09-29 18:11 ` Jan Kara
  0 siblings, 1 reply; 15+ messages in thread
From: Thanos Makatos @ 2014-09-29 16:24 UTC (permalink / raw)
  To: linux-fsdevel@vger.kernel.org; +Cc: Ross Lagerwall, Felipe Franciosi

I'm looking for ways to achieve _read_ caching of a block device (usually
iSCSI) that is attached to multiple hosts. The problem is that sometimes there
will be some writes on that block device in a particular, known host using
O_DIRECT, and that requires all other hosts to invalidate their buffer caches
for that block device. I'd prefer to use standard tools/procedures rather than
hacking things, but if I do have to implement something to solve this problem
I'd prefer it to be something that can be accepted upstream.

It looks like that closing the block device guarantees that the buffer cache is
invalidated, and I can guarantee that all _my_ processes close the block device
to achieve this. However, if there is at least one other process I don't know
of that is keeping an open file handle against that block device, the buffer
cache won't be invalidated, and that will result in corruption. So this
solution doesn't seem to work.

I had a look at the BLKFLSBUF ioctl, which seems to be designed to do the job,
except that it doesn't work if a process has memory mapped the block device,
and AFAIK there's no way to disallow memory mapping of a block device. Again,
that looks like a deal-breaker.

If the above observations are correct, it seems that I have to either extend
BLKFLSBUF to some invalidate such memory maps (I'm completely ignorant in that
field, is it even possible?), or look for other solutions.

Could some configuration of dm-cache, bcache, or some other component solve my
problem? posix_fadvise with POSIX_FADV_DONTNEED seems to be just a hint to the
kernel, there are no guarantees that cached data will be discarded.  I've also
though of using a virtual block device driver that exclusively opens the
actual network block device and lets user-space applications use the
virtualised one so that I have more control and enforce things.

Are there any other documents/resources I could read?




^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-10-01 15:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-29 16:24 invalidate the buffer heads of a block device Thanos Makatos
2014-09-29 18:11 ` Jan Kara
2014-09-30  8:58   ` Thanos Makatos
2014-09-30  9:19     ` Jan Kara
2014-09-30  9:39       ` Thanos Makatos
2014-09-30  9:55         ` Jan Kara
2014-09-30 10:11           ` Thanos Makatos
2014-09-30 10:48             ` Jan Kara
2014-09-30 20:53               ` Zach Brown
2014-09-30 21:13                 ` Trond Myklebust
2014-10-01  9:05                   ` Jan Kara
2014-10-01 11:50                     ` Trond Myklebust
2014-10-01 14:07                       ` Jan Kara
2014-10-01 14:47                         ` Trond Myklebust
2014-10-01 15:15                           ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).