From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 14/27] check for O_DIRECT capability in open(), not write()
Date: Thu, 04 Jul 2002 16:54:33 -0700 [thread overview]
Message-ID: <3D24E039.D56C204@zip.com.au> (raw)
For O_DIRECT opens we're currently checking that the fs supports
O_DIRECT at write(2)-time.
This is a forward-port of Andrea's patch which moves the check to
open() time. Seems more sensible.
fs/fcntl.c | 5 +++++
fs/open.c | 8 ++++++++
mm/filemap.c | 2 --
3 files changed, 13 insertions(+), 2 deletions(-)
--- 2.5.24/fs/fcntl.c~o_direct-open-check Thu Jul 4 16:17:24 2002
+++ 2.5.24-akpm/fs/fcntl.c Thu Jul 4 16:17:24 2002
@@ -245,6 +245,11 @@ static int setfl(int fd, struct file * f
}
if (arg & O_DIRECT) {
+ if (inode->i_mapping && inode->i_mapping->a_ops) {
+ if (!inode->i_mapping->a_ops->direct_IO)
+ return -EINVAL;
+ }
+
/*
* alloc_kiovec() can sleep and we are only serialized by
* the big kernel lock here, so abuse the i_sem to serialize
--- 2.5.24/fs/open.c~o_direct-open-check Thu Jul 4 16:17:24 2002
+++ 2.5.24-akpm/fs/open.c Thu Jul 4 16:17:24 2002
@@ -665,6 +665,14 @@ struct file *dentry_open(struct dentry *
}
f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
+ /* NB: we're sure to have correct a_ops only after f_op->open */
+ if (f->f_flags & O_DIRECT) {
+ error = -EINVAL;
+ if (inode->i_mapping && inode->i_mapping->a_ops)
+ if (!inode->i_mapping->a_ops->direct_IO)
+ goto cleanup_all;
+ }
+
return f;
cleanup_all:
--- 2.5.24/mm/filemap.c~o_direct-open-check Thu Jul 4 16:17:24 2002
+++ 2.5.24-akpm/mm/filemap.c Thu Jul 4 16:22:09 2002
@@ -1121,8 +1121,6 @@ static ssize_t generic_file_direct_IO(in
retval = -EINVAL;
if ((offset & blocksize_mask) || (count & blocksize_mask))
goto out_free;
- if (!mapping->a_ops->direct_IO)
- goto out_free;
/*
* Flush to disk exclusively the _data_, metadata must remain
-
reply other threads:[~2002-07-04 23:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D24E039.D56C204@zip.com.au \
--to=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®