From: Al Viro <viro@ZenIV.linux.org.uk>
To: weiping zhang <zhangweiping@didichuxing.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] fs: disable create file with O_DIRECT for tmpfs
Date: Thu, 20 Jul 2017 04:19:31 +0100 [thread overview]
Message-ID: <20170720031931.GD2063@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20170719174120.GA16327@bogon.didichuxing.com>
On Thu, Jul 20, 2017 at 01:41:26AM +0800, weiping zhang wrote:
> tmpfs not support O_DIRECT, when user open with O_DIRECT , the errno
> -EINVAL return to userspace by open_check_o_direct, but the file has
> been created, it's a strange thing. Add a checking for tmpfs that can
> avoid creating that file.
>
> Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
> ---
> fs/namei.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/namei.c b/fs/namei.c
> index ddb6a7c..a2a8cb9 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -3106,6 +3106,10 @@ static int lookup_open(struct nameidata *nd, struct path *path,
> if (unlikely(IS_DEADDIR(dir_inode)))
> return -ENOENT;
>
> + if (unlikely(open_flag & (O_CREAT | O_DIRECT) &&
> + strcmp(dir->d_sb->s_type->name, "tmpfs") == 0))
> + return -EINVAL;
Hell, _no_. Kludges of that sort are flat-out wrong - string comparisons on the
fs type name, no less... For one thing, tmpfs is not the only such filesystem.
Should we turn that into a long list of "forbidden" types, patching it every time
somebody comes up with a filesystem that fails O_DIRECT open? Not to mention the
modules, or filesystems where that depends upon e.g. mount flags...
next prev parent reply other threads:[~2017-07-20 3:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-19 17:41 [RFC] fs: disable create file with O_DIRECT for tmpfs weiping zhang
2017-07-20 3:19 ` Al Viro [this message]
2017-07-22 10:06 ` weiping zhang
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=20170720031931.GD2063@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=zhangweiping@didichuxing.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;
as well as URLs for NNTP newsgroup(s).