linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
       [not found]   ` <20160425234946.GB26977@dastard>
@ 2016-04-26  8:14     ` Christoph Hellwig
  2016-04-26 15:07       ` Mike Marshall
       [not found]       ` <20160426081451.GA25616-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2016-04-26  8:14 UTC (permalink / raw)
  To: Dave Chinner, torvalds
  Cc: Dmitry Monakhov, Theodore Ts'o, Ext4 Developers List,
	linux-fsdevel, linux-api

On Tue, Apr 26, 2016 at 09:49:46AM +1000, Dave Chinner wrote:
> Why not just transparently fall back to buffered IO if direct IO
> cannot be done? Saves people from wondering why applications fail
> on one ext4 filesystem and not another....

I've been doing an audit of our direct I/O implementations, and most
of them does some form of transparent fallback, including some that
only pretend to support O_DIRECT, but do anything special for it at all,
while at the same time we go through greast efforts to check a file
system actualy supports direct I/O, leading to nasty no-op ->direct_IO
implementations as we even got that abstraction wrong.

At this point I wonder if we should simply treat O_DIRECT as a hint
and always allow it, and just let the file system optimize for it
(skip buffering, require alignment, relaxed Posix atomicy requirements)
if it is set.

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

* Re: O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
  2016-04-26  8:14     ` O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work Christoph Hellwig
@ 2016-04-26 15:07       ` Mike Marshall
       [not found]       ` <20160426081451.GA25616-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Mike Marshall @ 2016-04-26 15:07 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Dave Chinner, Linus Torvalds, Dmitry Monakhov, Theodore Ts'o,
	Ext4 Developers List, linux-fsdevel, linux-api

We have Orangefs users who have applications they
can't run because the applications open with
O_DIRECT. They are happy when I show them
how to "pretend" to support O_DIRECT - the
way they did it in NFS back in the 2.6 era...

I was thinking of adding it to the upstream version,
maybe as a mount option... so I like this "hint" idea...

-Mike

On Tue, Apr 26, 2016 at 4:14 AM, Christoph Hellwig <hch@infradead.org> wrote:
> On Tue, Apr 26, 2016 at 09:49:46AM +1000, Dave Chinner wrote:
>> Why not just transparently fall back to buffered IO if direct IO
>> cannot be done? Saves people from wondering why applications fail
>> on one ext4 filesystem and not another....
>
> I've been doing an audit of our direct I/O implementations, and most
> of them does some form of transparent fallback, including some that
> only pretend to support O_DIRECT, but do anything special for it at all,
> while at the same time we go through greast efforts to check a file
> system actualy supports direct I/O, leading to nasty no-op ->direct_IO
> implementations as we even got that abstraction wrong.
>
> At this point I wonder if we should simply treat O_DIRECT as a hint
> and always allow it, and just let the file system optimize for it
> (skip buffering, require alignment, relaxed Posix atomicy requirements)
> if it is set.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
       [not found]       ` <20160426081451.GA25616-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2016-04-27  2:16         ` Theodore Ts'o
       [not found]           ` <20160427021649.GA30021-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
  2016-04-27  2:25           ` Dave Chinner
  2016-04-27  2:27         ` Dave Chinner
  1 sibling, 2 replies; 8+ messages in thread
From: Theodore Ts'o @ 2016-04-27  2:16 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Dave Chinner, torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
	Dmitry Monakhov, Ext4 Developers List,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On Tue, Apr 26, 2016 at 01:14:51AM -0700, Christoph Hellwig wrote:
> I've been doing an audit of our direct I/O implementations, and most
> of them does some form of transparent fallback, including some that
> only pretend to support O_DIRECT, but do anything special for it at all,
> while at the same time we go through greast efforts to check a file
> system actualy supports direct I/O, leading to nasty no-op ->direct_IO
> implementations as we even got that abstraction wrong.
> 
> At this point I wonder if we should simply treat O_DIRECT as a hint
> and always allow it, and just let the file system optimize for it
> (skip buffering, require alignment, relaxed Posix atomicy requirements)
> if it is set.

That's fine with me, but there ought to be some way for a program to
query whether a particular file / file system is one where DIO is
supported, and if so, what the alignment requirements would be.  That
way applications who care can get the information they need (and we
can use it for xfstests's _require_odirect :-).

						- Ted

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

* Re: O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
       [not found]           ` <20160427021649.GA30021-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
@ 2016-04-27  2:22             ` Eric Sandeen
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Sandeen @ 2016-04-27  2:22 UTC (permalink / raw)
  To: Theodore Ts'o, Christoph Hellwig
  Cc: Dave Chinner, torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
	Dmitry Monakhov, Ext4 Developers List,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On 4/26/16 9:16 PM, Theodore Ts'o wrote:
> On Tue, Apr 26, 2016 at 01:14:51AM -0700, Christoph Hellwig wrote:
>> I've been doing an audit of our direct I/O implementations, and most
>> of them does some form of transparent fallback, including some that
>> only pretend to support O_DIRECT, but do anything special for it at all,
>> while at the same time we go through greast efforts to check a file
>> system actualy supports direct I/O, leading to nasty no-op ->direct_IO
>> implementations as we even got that abstraction wrong.
>>
>> At this point I wonder if we should simply treat O_DIRECT as a hint
>> and always allow it, and just let the file system optimize for it
>> (skip buffering, require alignment, relaxed Posix atomicy requirements)
>> if it is set.
> 
> That's fine with me, but there ought to be some way for a program to
> query whether a particular file / file system is one where DIO is
> supported, and if so, what the alignment requirements would be.  That
> way applications who care can get the information they need (and we
> can use it for xfstests's _require_odirect :-).
> 
> 						- Ted

Well, we have xfs's XFS_IOC_DIOINFO which gives memory alignment and
io size/alignment constraints.

That could pretty easily be "hoisted" to the vfs so that any fs 
could return the same info based on internal requirements, or EOPNOTSUPP
or something if dio is never possible.

We seemed to be talking about adding this to xstat, but I guess I
like the idea of a purpose-built interface, not an all-singing,
all-dancing file/filesystem query ...

-Eric

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

* Re: O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
  2016-04-27  2:16         ` Theodore Ts'o
       [not found]           ` <20160427021649.GA30021-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
@ 2016-04-27  2:25           ` Dave Chinner
  1 sibling, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2016-04-27  2:25 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Christoph Hellwig, torvalds, Dmitry Monakhov,
	Ext4 Developers List, linux-fsdevel, linux-api

On Tue, Apr 26, 2016 at 10:16:49PM -0400, Theodore Ts'o wrote:
> On Tue, Apr 26, 2016 at 01:14:51AM -0700, Christoph Hellwig wrote:
> > I've been doing an audit of our direct I/O implementations, and most
> > of them does some form of transparent fallback, including some that
> > only pretend to support O_DIRECT, but do anything special for it at all,
> > while at the same time we go through greast efforts to check a file
> > system actualy supports direct I/O, leading to nasty no-op ->direct_IO
> > implementations as we even got that abstraction wrong.
> > 
> > At this point I wonder if we should simply treat O_DIRECT as a hint
> > and always allow it, and just let the file system optimize for it
> > (skip buffering, require alignment, relaxed Posix atomicy requirements)
> > if it is set.
> 
> That's fine with me, but there ought to be some way for a program to
> query whether a particular file / file system is one where DIO is
> supported, and if so, what the alignment requirements would be.

Yes, that's called XFS_IOC_DIOINFO. We've been saying that this
should be promoted to the VFS for some time, though it might be
better to re-implement it with a different structure that includes
padding and a flags field....

> That
> way applications who care can get the information they need (and we
> can use it for xfstests's _require_odirect :-).

Just return EOPNOTSUPP to XFS_IOC_DIOINFO if direct io is not
supported?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
       [not found]       ` <20160426081451.GA25616-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  2016-04-27  2:16         ` Theodore Ts'o
@ 2016-04-27  2:27         ` Dave Chinner
  2016-04-27  3:25           ` Theodore Ts'o
  1 sibling, 1 reply; 8+ messages in thread
From: Dave Chinner @ 2016-04-27  2:27 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, Dmitry Monakhov,
	Theodore Ts'o, Ext4 Developers List,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On Tue, Apr 26, 2016 at 01:14:51AM -0700, Christoph Hellwig wrote:
> On Tue, Apr 26, 2016 at 09:49:46AM +1000, Dave Chinner wrote:
> > Why not just transparently fall back to buffered IO if direct IO
> > cannot be done? Saves people from wondering why applications fail
> > on one ext4 filesystem and not another....
> 
> I've been doing an audit of our direct I/O implementations, and most
> of them does some form of transparent fallback, including some that
> only pretend to support O_DIRECT, but do anything special for it at all,
> while at the same time we go through greast efforts to check a file
> system actualy supports direct I/O, leading to nasty no-op ->direct_IO
> implementations as we even got that abstraction wrong.
> 
> At this point I wonder if we should simply treat O_DIRECT as a hint
> and always allow it, and just let the file system optimize for it
> (skip buffering, require alignment, relaxed Posix atomicy requirements)
> if it is set.

I thought that's how most filesystems treated it, anyway. i.e.
anything they can't do via direct IO, they fell back to buffered IO
to complete (e.g. for allocation or append writes, etc). Hence why I
suggested the fallback rather than erroring out....

Cheers,

Dave.
-- 
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org

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

* Re: O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
  2016-04-27  2:27         ` Dave Chinner
@ 2016-04-27  3:25           ` Theodore Ts'o
       [not found]             ` <20160427032526.GC30021-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Theodore Ts'o @ 2016-04-27  3:25 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Christoph Hellwig, torvalds, Dmitry Monakhov,
	Ext4 Developers List, linux-fsdevel, linux-api

On Wed, Apr 27, 2016 at 12:27:46PM +1000, Dave Chinner wrote:
> > At this point I wonder if we should simply treat O_DIRECT as a hint
> > and always allow it, and just let the file system optimize for it
> > (skip buffering, require alignment, relaxed Posix atomicy requirements)
> > if it is set.
> 
> I thought that's how most filesystems treated it, anyway. i.e.
> anything they can't do via direct IO, they fell back to buffered IO
> to complete (e.g. for allocation or append writes, etc). Hence why I
> suggested the fallback rather than erroring out....

No, some file systems return EINVAL on the open.  In fact that's what
the _require_odirect test in xfstests relies upon....

    		     	     	      	     - Ted

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

* Re: O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
       [not found]             ` <20160427032526.GC30021-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
@ 2016-04-27  3:37               ` Dave Chinner
  0 siblings, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2016-04-27  3:37 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Christoph Hellwig, torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
	Dmitry Monakhov, Ext4 Developers List,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA

On Tue, Apr 26, 2016 at 11:25:26PM -0400, Theodore Ts'o wrote:
> On Wed, Apr 27, 2016 at 12:27:46PM +1000, Dave Chinner wrote:
> > > At this point I wonder if we should simply treat O_DIRECT as a hint
> > > and always allow it, and just let the file system optimize for it
> > > (skip buffering, require alignment, relaxed Posix atomicy requirements)
> > > if it is set.
> > 
> > I thought that's how most filesystems treated it, anyway. i.e.
> > anything they can't do via direct IO, they fell back to buffered IO
> > to complete (e.g. for allocation or append writes, etc). Hence why I
> > suggested the fallback rather than erroring out....
> 
> No, some file systems return EINVAL on the open.  In fact that's what
> the _require_odirect test in xfstests relies upon....

Sure, but that doesn't change the fact that many of the filesystems
that "support O_DIRECT" don't always do O_DIRECT - they
transparently do buffered IO instead and hence are treating O_DIRECT
as a hint once the file has been opened.

Cheers,

Dave.
-- 
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org

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

end of thread, other threads:[~2016-04-27  3:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1461472078-20104-1-git-send-email-tytso@mit.edu>
     [not found] ` <877ffmhvzt.fsf@openvz.org>
     [not found]   ` <20160425234946.GB26977@dastard>
2016-04-26  8:14     ` O_DIRECT as a hint, was: Re: [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work Christoph Hellwig
2016-04-26 15:07       ` Mike Marshall
     [not found]       ` <20160426081451.GA25616-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-04-27  2:16         ` Theodore Ts'o
     [not found]           ` <20160427021649.GA30021-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2016-04-27  2:22             ` Eric Sandeen
2016-04-27  2:25           ` Dave Chinner
2016-04-27  2:27         ` Dave Chinner
2016-04-27  3:25           ` Theodore Ts'o
     [not found]             ` <20160427032526.GC30021-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2016-04-27  3:37               ` Dave Chinner

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).