ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
From: Mark Fasheh <mfasheh@suse.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH] Ocfs2: do not allow fallocate on dir file
Date: Thu, 10 Mar 2011 08:54:04 -0800	[thread overview]
Message-ID: <20110310165404.GH1703@wotan.suse.de> (raw)
In-Reply-To: <AANLkTimyFzy0yx_tYpAbxk7rMq3kZr5=+MJH-5=pJOaH@mail.gmail.com>

On Thu, Mar 10, 2011 at 02:00:33PM +0800, Jiaju Zhang wrote:
> On Thu, Mar 10, 2011 at 12:25 PM, Mark Fasheh <mfasheh@suse.com> wrote:
> > On Thu, Mar 10, 2011 at 10:46:33AM +0800, Tao Ma wrote:
> >> On 03/10/2011 10:27 AM, Sunil Mushran wrote:
> >> > On 03/09/2011 03:01 PM, Mark Fasheh wrote:
> >> >> On Fri, Mar 04, 2011 at 03:10:33PM +0800, Li Dongyang wrote:
> >> >>> @@ -1870,6 +1870,11 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
> >> >>> ? ? ? ? ? ? ? ? ? goto out_inode_unlock;
> >> >>> ? ? ? ? ? }
> >> >>>
> >> >>> + if (!S_ISREG(inode->i_mode)) {
> >> >>> + ? ? ? ? ret = -EINVAL;
> >> >>> + ? ? ? ? goto out_inode_unlock;
> >> >>> + }
> >> >> You might want to move the check into ocfs2_fallocate to mirror what
> >> >> ocfs2_change_file_space() does. Otherwise, looks like a good catch.
> >> >>
> >> >
> >> > Tristan pointed out that this check was already in ocfs2_change_file_space().
> >> > So this patch should not be required. Am I missing something?
> >> This patch is needed since the check is in ocfs2_change_file_space. But
> >> ocfs2_fallocate calls __ocfs2_change_file_space directly.
> >
> > Right.
> 
> It seems it is not right:-) If I read the code correctly, although
> ocfs2_fallocate calls __ocfs2_change_file_space directly, however,
> ocfs2_fallocate is a file operation but not an inode operation,
> ocfs2_fallocate can only be registered when that file is a regular
> file, so this patch is not needed.

Please review the code in fs/open.c:do_fallocate()

        /*
         * Let individual file system decide if it supports preallocation
         * for directories or not.
         */
        if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
                return -ENODEV;

So, sys_fallocate is leaving the decision up to the file system. Therefore I
think your patch is needed after all :)
	--Mark

--
Mark Fasheh

  reply	other threads:[~2011-03-10 16:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-04  7:10 [Ocfs2-devel] [PATCH] Ocfs2: do not allow fallocate on dir file Li Dongyang
2011-03-04  8:21 ` Tristan Ye
2011-03-09 23:01 ` Mark Fasheh
2011-03-10  2:27   ` Sunil Mushran
2011-03-10  2:46     ` Tao Ma
2011-03-10  4:25       ` Mark Fasheh
2011-03-10  6:00         ` Jiaju Zhang
2011-03-10 16:54           ` Mark Fasheh [this message]
2011-03-10 18:33             ` Jiaju Zhang
2011-03-10 21:21               ` Mark Fasheh

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=20110310165404.GH1703@wotan.suse.de \
    --to=mfasheh@suse.com \
    --cc=ocfs2-devel@oss.oracle.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).