From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailsec113.isp.belgacom.be ([195.238.20.109]:49760 "EHLO mailsec113.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966571AbcKXVn0 (ORCPT ); Thu, 24 Nov 2016 16:43:26 -0500 Date: Thu, 24 Nov 2016 22:43:19 +0100 (CET) From: Fabian Frederick Reply-To: Fabian Frederick To: Al Viro Cc: linux-kernel@vger.kernel.org, Jan Kara , tytso@mit.edu, linux-fsdevel@vger.kernel.org Message-ID: <1954692245.364386.1480023799768.open-xchange@webmail.nmp.proximus.be> In-Reply-To: <20161124203900.GS1555@ZenIV.linux.org.uk> References: <1480016861-24432-1-git-send-email-fabf@skynet.be> <20161124203900.GS1555@ZenIV.linux.org.uk> Subject: Re: [PATCH 1/1 linux-next] ext4: add compatibility flag check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-fsdevel-owner@vger.kernel.org List-ID: > On 24 November 2016 at 21:39 Al Viro 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;