From: Joel Becker <joel.becker@ORACLE.COM>
To: ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
hch@infradead.org, torvalds@linux-foundation.org
Subject: [PATCH 1/2] vfs: Add MAY_CREATE to the permission() flags.
Date: Wed, 14 Oct 2009 02:57:40 -0700 [thread overview]
Message-ID: <1255514261-25823-2-git-send-email-joel.becker@oracle.com> (raw)
In-Reply-To: <1255514261-25823-1-git-send-email-joel.becker@oracle.com>
A simple rule of system calls is that you cannot return -ERESTARTSYS
after you've made non-idempotent changes. ocfs2 has run into this with
open(O_CREAT|O_EXCL). Once you've created the file, you can't restart
the open(), because O_CREAT|O_EXCL will trigger -EEXIST.
The problem is that ocfs2 is catching the signal ->permission(), called
by may_open(). This happens after ->create() has successfully created
the file. ocfs2_permission() has to get a cluster lock, and this is
what can be interrupted by a signal. Now, obviously we want to block
signals in the O_CREAT|O_EXCL case, but ocfs2_permission() has no way of
knowing it just got called from open_namei_create().
So we add the MAY_CREATE flag to permission(). open_namei_create() will
pass it to may_open(), and then ocfs2 can block signals in
ocfs2_permission() as appropriate. The same is true of any other
filesystem that has to do work in may_open().
Signed-off-by: Joel Becker <joel.becker@oracle.com>
---
fs/namei.c | 2 +-
include/linux/fs.h | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index d11f404..d54cb98 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1623,7 +1623,7 @@ out_unlock:
if (error)
return error;
/* Don't check for write permission, don't truncate */
- return may_open(&nd->path, 0, flag & ~O_TRUNC);
+ return may_open(&nd->path, MAY_CREATE, flag & ~O_TRUNC);
}
/*
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2620a8c..b1a454c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -53,6 +53,7 @@ struct inodes_stat_t {
#define MAY_APPEND 8
#define MAY_ACCESS 16
#define MAY_OPEN 32
+#define MAY_CREATE 64
/*
* flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
--
1.6.3.3
next prev parent reply other threads:[~2009-10-14 9:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-14 9:57 [PATCH 0/2] [RFC] Adding the MAY_CREATE flag to ->permission() Joel Becker
2009-10-14 9:57 ` Joel Becker [this message]
2009-10-14 9:57 ` [PATCH 2/2] ocfs2: Use MAY_CREATE in ocfs2_permission() Joel Becker
-- strict thread matches above, loose matches on Subject: below --
2009-09-03 1:06 [PATCH 0/2] [RFC] Adding the MAY_CREATE flag to ->permission() Joel Becker
2009-09-03 1:06 ` [PATCH 1/2] vfs: Add MAY_CREATE to the permission() flags Joel Becker
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=1255514261-25823-2-git-send-email-joel.becker@oracle.com \
--to=joel.becker@oracle.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ocfs2-devel@oss.oracle.com \
--cc=torvalds@linux-foundation.org \
--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).