linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work
@ 2016-04-24  4:27 Theodore Ts'o
  2016-04-25  9:35 ` Dmitry Monakhov
  0 siblings, 1 reply; 12+ messages in thread
From: Theodore Ts'o @ 2016-04-24  4:27 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

Certain ext4 modes (encryption, data=journal, inline data) cause
Direct I/O to be a no-op.  Instead of making DIO fail silently, make
the open with the O_DIRECT flag fail with EINVAL.

This will avoid surprises to application programs, and also signal to
xfstests not to try O_DIRECT tests for file system modes where it
doesn't work (and could result in test failures).

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 fs/ext4/file.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index fa2208b..4113676 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -372,7 +372,12 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
 			return -EACCES;
 		if (ext4_encryption_info(inode) == NULL)
 			return -ENOKEY;
+		if (filp->f_flags & O_DIRECT)
+			return -EINVAL;
 	}
+	if ((ext4_should_journal_data(inode) || ext4_has_inline_data(inode)) &&
+	    (filp->f_flags & O_DIRECT))
+		return -EINVAL;
 
 	dir = dget_parent(file_dentry(filp));
 	if (ext4_encrypted_inode(d_inode(dir)) &&
-- 
2.5.0


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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-24  4:27 [PATCH] ext4: refuse O_DIRECT opens for mode where DIO doesn't work Theodore Ts'o
2016-04-25  9:35 ` Dmitry Monakhov
2016-04-25 23:49   ` Dave Chinner
2016-04-26  0:20     ` Theodore Ts'o
2016-04-26  8:14     ` O_DIRECT as a hint, was: " 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).