linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/6] vfs: create vfs helper vfs_tmpfile()
Date: Sun, 15 Jan 2017 15:57:27 +0200	[thread overview]
Message-ID: <1484488652-611-2-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1484488652-611-1-git-send-email-amir73il@gmail.com>

Factor out some common vfs bits from do_tmpfile()
to be used by overlayfs for concurrent copy up.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/namei.c         | 26 ++++++++++++++++----------
 include/linux/fs.h |  1 +
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index ad74877..4cbaf54 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3353,6 +3353,20 @@ static int do_last(struct nameidata *nd,
 	return error;
 }
 
+int vfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
+{
+	int error;
+
+	/* we want directory to be writable */
+	error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
+	if (error)
+		return error;
+	if (!dir->i_op->tmpfile)
+		return -EOPNOTSUPP;
+	return dir->i_op->tmpfile(dir, dentry, mode);
+}
+EXPORT_SYMBOL(vfs_tmpfile);
+
 static int do_tmpfile(struct nameidata *nd, unsigned flags,
 		const struct open_flags *op,
 		struct file *file, int *opened)
@@ -3368,14 +3382,6 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
 	if (unlikely(error))
 		goto out;
 	dir = path.dentry->d_inode;
-	/* we want directory to be writable */
-	error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
-	if (error)
-		goto out2;
-	if (!dir->i_op->tmpfile) {
-		error = -EOPNOTSUPP;
-		goto out2;
-	}
 	child = d_alloc(path.dentry, &name);
 	if (unlikely(!child)) {
 		error = -ENOMEM;
@@ -3383,8 +3389,8 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
 	}
 	dput(path.dentry);
 	path.dentry = child;
-	error = dir->i_op->tmpfile(dir, child, op->mode);
-	if (error)
+	error = vfs_tmpfile(dir, child, op->mode);
+	if (unlikely(error))
 		goto out2;
 	audit_inode(nd->name, child, 0);
 	/* Don't check for other permissions, the inode was just created */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2ba0743..13f56f1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1560,6 +1560,7 @@ extern int vfs_rmdir(struct inode *, struct dentry *);
 extern int vfs_unlink(struct inode *, struct dentry *, struct inode **);
 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int);
 extern int vfs_whiteout(struct inode *, struct dentry *);
+extern int vfs_tmpfile(struct inode *, struct dentry *, umode_t);
 
 /*
  * VFS file helper functions.
-- 
2.7.4


  reply	other threads:[~2017-01-15 13:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-15 13:57 [PATCH 0/6] ovl: concurrent copy up Amir Goldstein
2017-01-15 13:57 ` Amir Goldstein [this message]
2017-01-16 11:00   ` [PATCH 1/6] vfs: create vfs helper vfs_tmpfile() Miklos Szeredi
2017-01-16 11:19     ` Amir Goldstein
2017-01-16 13:22       ` Miklos Szeredi
2017-01-16 14:04         ` Amir Goldstein
2017-01-16 14:15           ` Miklos Szeredi
2017-01-15 13:57 ` [PATCH 2/6] ovl: check if upperdir fs supports O_TMPFILE Amir Goldstein
2017-01-16 14:02   ` Miklos Szeredi
2017-01-16 14:16     ` Amir Goldstein
2017-01-16 14:29       ` Miklos Szeredi
2017-01-15 13:57 ` [PATCH 3/6] ovl: rearrange code in ovl_copy_up_locked() Amir Goldstein
2017-01-15 13:57 ` [PATCH 4/6] ovl: copy up regular file using O_TMPFILE Amir Goldstein
2017-01-15 13:57 ` [PATCH 5/6] ovl: introduce copy up waitqueue Amir Goldstein
2017-01-15 13:57 ` [PATCH 6/6] ovl: concurrent copy up of regular files Amir Goldstein
2017-01-16 11:05   ` Miklos Szeredi
2017-01-16 11:31     ` Amir Goldstein
2017-01-16 11:58   ` [PATCH v2 " Amir Goldstein
2017-01-16 13:29     ` Miklos Szeredi

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=1484488652-611-2-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --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).