[PATCH 21/25] gfs2: use i_op->atomic_create()

From: Miklos Szeredi
Date: Wed Mar 07 2012 - 16:25:11 EST


From: Miklos Szeredi <mszeredi@xxxxxxx>

GFS2 doesn't open the file in ->create, but it does check the LOOKUP_EXCL flag
in it's create function. Convert to using ->atomic_create and checking O_EXCL
so that the nameidata argument is no longer necessary.

Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx>
---
fs/gfs2/inode.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 5698746..203ec3c 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -754,13 +754,21 @@ fail:
* Returns: errno
*/

-static int gfs2_create(struct inode *dir, struct dentry *dentry,
- umode_t mode, struct nameidata *nd)
+static struct file *gfs2_create(struct inode *dir, struct dentry *dentry,
+ struct opendata *od, unsigned open_flag,
+ umode_t mode)
{
- int excl = 0;
- if (nd && (nd->flags & LOOKUP_EXCL))
+ int err;
+ int excl = 0; /* Why is excl not the default? */
+
+ if (od && (open_flag & O_EXCL))
excl = 1;
- return gfs2_create_inode(dir, dentry, S_IFREG | mode, 0, NULL, 0, excl);
+
+ err = gfs2_create_inode(dir, dentry, S_IFREG | mode, 0, NULL, 0, excl);
+ if (err)
+ return ERR_PTR(err);
+
+ return NULL;
}

/**
@@ -1809,7 +1817,7 @@ const struct inode_operations gfs2_file_iops = {
};

const struct inode_operations gfs2_dir_iops = {
- .create = gfs2_create,
+ .atomic_create = gfs2_create,
.lookup = gfs2_lookup,
.link = gfs2_link,
.unlink = gfs2_unlink,
--
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/