linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabian Frederick <fabf@skynet.be>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, Jan Kara <jack@suse.com>,
	tytso@mit.edu, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/1 linux-next] ext4: add compatibility flag check
Date: Thu, 24 Nov 2016 22:43:19 +0100 (CET)	[thread overview]
Message-ID: <1954692245.364386.1480023799768.open-xchange@webmail.nmp.proximus.be> (raw)
In-Reply-To: <20161124203900.GS1555@ZenIV.linux.org.uk>



> On 24 November 2016 at 21:39 Al Viro <viro@ZenIV.linux.org.uk> wrote:
>
>
> On Thu, Nov 24, 2016 at 08:47:41PM +0100, Fabian Frederick wrote:
> > data=journal mount option should disable O_DIRECT access
> > (See Documentation/filesystems/ext4.txt) but open operations
> > using O_CREAT|O_RDWR|O_DIRECT|O_SYNC have no warning in return and file is
> > being
> > created. This patch adds vfs super_operations compatibility flag function
> > returning -EPERM in such a case.
>
> Why not simply check it in ->open()?  Occam's Razor and all such...
Thanks for the advice Al but I already tried that solution (see below) and had
an empty file created
(write operation is of course avoided).

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 2a822d3..ec414b5 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -323,6 +323,10 @@ static int ext4_file_open(struct inode * inode, struct file
* filp)
        char buf[64], *cp;
        int ret;
 
+       if ((test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) &&
+          (filp->f_flags & O_DIRECT ))
+               return -EPERM;
+
        if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) &&
                     !(sb->s_flags & MS_RDONLY))) {
                sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED;

  reply	other threads:[~2016-11-24 21:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24 19:47 [PATCH 1/1 linux-next] ext4: add compatibility flag check Fabian Frederick
2016-11-24 20:39 ` Al Viro
2016-11-24 21:43   ` Fabian Frederick [this message]
2016-11-25  5:26 ` Theodore Ts'o
2016-11-25  6:14   ` Fabian Frederick

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=1954692245.364386.1480023799768.open-xchange@webmail.nmp.proximus.be \
    --to=fabf@skynet.be \
    --cc=jack@suse.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@ZenIV.linux.org.uk \
    /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).